shift sale item pdf
This commit is contained in:
@@ -516,93 +516,94 @@ class CloseCashierPdf < Prawn::Document
|
||||
bounding_box([0,y_position], :width =>self.page_width - 10, :height => 20) do
|
||||
text "Sale Items Summary", :size => self.header_font_size, :align => :center
|
||||
end
|
||||
move_down 5
|
||||
|
||||
total_items = 0
|
||||
total_amount = 0
|
||||
total_qty = 0
|
||||
sub_total = 0
|
||||
|
||||
if !menu_cate_count.nil?
|
||||
menu_cate_count.each do |key, value|
|
||||
arr = Array.new
|
||||
|
||||
# account = Account.find(key)
|
||||
menu_category = MenuCategory.where('code=?', key).last
|
||||
unless sale_items.nil?
|
||||
sale_items.each do |item|
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.page_width - 10, :height => 20) do
|
||||
text "#{menu_category.name}", :size => self.header_font_size, :align => :left
|
||||
end
|
||||
move_down 5
|
||||
if !arr.include?(item['menu_category_id'])
|
||||
|
||||
unless total_qty == 0 and sub_total == 0
|
||||
total_details('Sub Total', total_qty, sub_total)
|
||||
end
|
||||
|
||||
stroke_horizontal_rule
|
||||
move_down 2
|
||||
y_position = cursor
|
||||
pad_top(15) {
|
||||
# @item_width.to_i + @half_qty.to_i
|
||||
total_qty = 0
|
||||
sub_total = 0
|
||||
|
||||
move_down 10
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.page_width - 10, :height => 20) do
|
||||
text "#{item['menu_category_name']}", :size => self.header_font_size, :align => :left
|
||||
end
|
||||
|
||||
# write_stroke_dash
|
||||
# dash(1, :space => 1, :phase => 1)
|
||||
# stroke_horizontal_rule
|
||||
# move_down 2
|
||||
y_position = cursor
|
||||
pad_top(15) {
|
||||
text_box "Items", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
|
||||
text_box "Price", :at =>[(self.item_width),y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
text_box "Qty", :at =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||
text_box "Total", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
}
|
||||
move_down 2
|
||||
stroke_horizontal_rule
|
||||
|
||||
total_qty = 0
|
||||
sub_total = 0
|
||||
|
||||
sale_items.each do |item|
|
||||
|
||||
if item.menu_category_id == key
|
||||
total_qty += item.total_item.to_i
|
||||
sub_total += item.grand_total.to_i
|
||||
|
||||
|
||||
move_down 5
|
||||
|
||||
y_position = cursor
|
||||
pad_top(15) {
|
||||
# @item_width.to_i + @half_qty.to_i
|
||||
text_box "#{item.product_name}", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
|
||||
text_box "#{item.unit_price.to_i}", :at =>[(self.item_width),y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
text_box "#{item.total_item.to_i}", :at =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||
text_box "#{item.grand_total.to_i}", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
}
|
||||
# move_down 3
|
||||
end
|
||||
}
|
||||
move_down 2
|
||||
stroke_horizontal_rule
|
||||
end
|
||||
stroke_horizontal_rule
|
||||
move_down 5
|
||||
|
||||
# item_label_qty_front_width = (self.item_width+self.price_width) + 2
|
||||
# item_label_qty_end_width = 32
|
||||
# item_label_total_front_width = (self.item_width+self.price_width) + 2
|
||||
# item_label_total_end_width = 64
|
||||
total_items += total_qty
|
||||
total_amount += sub_total
|
||||
|
||||
move_down 3
|
||||
|
||||
y_position = cursor
|
||||
pad_top(15) {
|
||||
# @item_width.to_i + @half_qty.to_i
|
||||
text_box "Sub Total", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
|
||||
# text_box "#{item.unit_price.to_i}", :at =>[(self.item_width),y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
text_box "#{total_qty}", :at =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||
text_box "#{sub_total}", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
bounding_box([0,y_position], :width =>self.item_width) do
|
||||
text "#{item['product_name']}", :size => self.item_font_size, :align => :left#, :overflow => :shrink_to_fix
|
||||
end
|
||||
text_box "#{item['unit_price'].to_i}", :at =>[(self.item_width),y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
text_box "#{item['total_item'].to_i}", :at =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||
text_box "#{item['grand_total'].to_i}", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
}
|
||||
move_down 10
|
||||
|
||||
if item['total_item'].to_i > 0
|
||||
total_qty += item['total_item'].to_i
|
||||
total_items += item['total_item'].to_i
|
||||
end
|
||||
|
||||
sub_total += item['grand_total'].to_i
|
||||
total_amount += item['grand_total'].to_i
|
||||
arr.push(item['menu_category_id'])
|
||||
end
|
||||
|
||||
stroke_horizontal_rule
|
||||
# stroke_horizontal_rule
|
||||
total_details('Sub Total', total_qty, sub_total)
|
||||
move_down 5
|
||||
|
||||
y_position = cursor
|
||||
pad_top(15) {
|
||||
# @item_width.to_i + @half_qty.to_i
|
||||
text_box "Total Amount", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
|
||||
# text_box "#{item.unit_price.to_i}", :at =>[(self.item_width),y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
text_box "#{total_items}", :at =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||
text_box "#{total_amount}", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
}
|
||||
|
||||
total_details('Total Amount', total_items, total_amount)
|
||||
move_down 10
|
||||
end
|
||||
end
|
||||
|
||||
def total_details(col_name, total_qty, sub_total)
|
||||
self.item_width = 73
|
||||
self.price_width = 60
|
||||
item_label_qty_front_width = (self.item_width+self.price_width) + 2
|
||||
item_label_qty_end_width = 32
|
||||
item_label_total_front_width = (self.item_width+self.price_width) + 2
|
||||
item_label_total_end_width = 64
|
||||
|
||||
move_down 5
|
||||
stroke_horizontal_rule
|
||||
y_position = cursor
|
||||
pad_top(15) {
|
||||
text_box "#{col_name}", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
|
||||
text_box "#{total_qty.to_i}", :at =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||
text_box "#{sub_total.to_i}", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
||||
}
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user