|
|
|
|
@@ -1,6 +1,6 @@
|
|
|
|
|
class ReceiptBillPdf < Prawn::Document
|
|
|
|
|
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
|
|
|
|
|
def initialize(printer_settings, sale_items, sale_data, customer_name, food_total, beverage_total, member_info = nil,rebate_amount = nil)
|
|
|
|
|
def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, member_info = nil,rebate_amount = nil)
|
|
|
|
|
self.page_width = 210
|
|
|
|
|
self.page_height = 2500
|
|
|
|
|
self.margin = 5
|
|
|
|
|
@@ -29,7 +29,8 @@ class ReceiptBillPdf < Prawn::Document
|
|
|
|
|
stroke_horizontal_rule
|
|
|
|
|
|
|
|
|
|
cashier_info(sale_data, customer_name)
|
|
|
|
|
line_items(sale_items, food_total, beverage_total)
|
|
|
|
|
line_items(sale_items)
|
|
|
|
|
items_account(item_price_by_accounts)
|
|
|
|
|
all_total(sale_data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -103,26 +104,24 @@ class ReceiptBillPdf < Prawn::Document
|
|
|
|
|
move_down 5
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def line_items(sale_items, food_total, beverage_total)
|
|
|
|
|
def line_items(sale_items)
|
|
|
|
|
y_position = cursor
|
|
|
|
|
|
|
|
|
|
pad_top(15) {
|
|
|
|
|
# @item_width.to_i + @half_qty.to_i
|
|
|
|
|
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 =>[(self.item_width+self.price_width),y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
|
|
|
|
text_box "Total", :at =>[(self.item_width+self.price_width+4),y_position], :width => self.total_width+3, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
# @item_width.to_i + @half_qty.to_i
|
|
|
|
|
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 =>[(self.item_width+self.price_width),y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
|
|
|
|
text_box "Total", :at =>[(self.item_width+self.price_width+4),y_position], :width => self.total_width+3, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
move_down 5
|
|
|
|
|
stroke_horizontal_rule
|
|
|
|
|
|
|
|
|
|
add_line_item_row(sale_items, food_total, beverage_total)
|
|
|
|
|
|
|
|
|
|
add_line_item_row(sale_items)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def add_line_item_row(sale_items, food_total, beverage_total)
|
|
|
|
|
def add_line_item_row(sale_items)
|
|
|
|
|
item_name_width = (self.item_width+self.price_width)
|
|
|
|
|
y_position = cursor
|
|
|
|
|
move_down 5
|
|
|
|
|
@@ -155,25 +154,26 @@ class ReceiptBillPdf < Prawn::Document
|
|
|
|
|
end
|
|
|
|
|
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
|
|
|
|
text "#{ sub_total }" , :size => self.item_font_size,:align => :right
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# Food and Beverage
|
|
|
|
|
food_beverage_total = food_total.to_s + "/" + beverage_total.to_s
|
|
|
|
|
|
|
|
|
|
move_down 5
|
|
|
|
|
end
|
|
|
|
|
move_down 5
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def items_account(item_price_by_accounts)
|
|
|
|
|
y_position = cursor
|
|
|
|
|
bounding_box([0,y_position], :width => self.item_description_width, :height => self.item_height) do
|
|
|
|
|
text "Food/Beverage Total", :size => self.item_font_size,:align => :left
|
|
|
|
|
end
|
|
|
|
|
bounding_box([self.item_description_width,y_position], :width => self.label_width) do
|
|
|
|
|
text "#{ food_beverage_total }" , :size => self.item_font_size,:align => :right
|
|
|
|
|
item_price_by_accounts.each do |ipa|
|
|
|
|
|
y_position = cursor
|
|
|
|
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
|
|
|
|
text "#{ ipa[:name] }", :size => self.item_font_size,:align => :left
|
|
|
|
|
end
|
|
|
|
|
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
|
|
|
|
text "#{ ipa[:price] }" , :size => self.item_font_size,:align => :right
|
|
|
|
|
end
|
|
|
|
|
move_down 5
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def all_total(sale_data)
|
|
|
|
|
item_name_width = self.item_width
|
|
|
|
|
move_down 5
|
|
|
|
|
y_position = cursor
|
|
|
|
|
|
|
|
|
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
|
|
|
|
|