print format

This commit is contained in:
Yan
2017-06-15 13:24:37 +06:30
parent 061c06b3c3
commit bd94e808d4
4 changed files with 31 additions and 31 deletions

View File

@@ -1,16 +1,16 @@
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)
self.page_width = 250
self.page_height = 1450
self.margin = 10
self.price_width = 40
self.page_width = 210
self.page_height = 2500
self.margin = 5
self.price_width = 35
self.qty_width = 20
self.total_width = 40
self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width)+(self.margin*4))
self.total_width = 35
self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width))
self.item_height = 15
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
self.label_width=80
self.item_description_width = (self.page_width-20) / 2
self.label_width = 100
# @item_width = self.page_width.to_i / 2
# @qty_width = @item_width.to_i / 3
@@ -22,10 +22,10 @@ class ReceiptBillPdf < Prawn::Document
# font "public/fonts/#{font_name}".to_s + ".ttf".to_s
# font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf"
self.header_font_size = 11
self.item_font_size = 9
self.header_font_size = 10
self.item_font_size = 8
header( printer_settings.printer_name, printer_settings.name)
header( "Beauty In the Pot", printer_settings.name)
stroke_horizontal_rule
@@ -92,8 +92,8 @@ class ReceiptBillPdf < Prawn::Document
# @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 => :right, :overflow => :shrink_to_fix
text_box "Total", :at =>[(self.item_width+self.price_width+2),y_position], :width => self.total_width+2, :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),y_position], :width => self.total_width+5, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
}
@@ -121,9 +121,9 @@ class ReceiptBillPdf < Prawn::Document
pad_top(15) {
text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :overflow => :shrink_to_fix, :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.to_i}", :at =>[item_name_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
text_box "#{total_price}", :at =>[(item_name_width+2),y_position], :width =>self.total_width+2, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
text_box "#{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 "#{qty.to_i}", :at =>[item_name_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_price.to_i}", :at =>[(item_name_width),y_position], :width =>self.total_width+5, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
}
move_down 3
end
@@ -132,10 +132,10 @@ class ReceiptBillPdf < Prawn::Document
move_down 5
y_position = cursor
bounding_box([0,y_position], :width =>item_name_width, :height => self.item_height) do
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Sub Total", :size => self.item_font_size,:align => :left
end
bounding_box([item_name_width,y_position], :width =>self.total_width) do
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{ sub_total }" , :size => self.item_font_size,:align => :right
end
@@ -145,10 +145,10 @@ class ReceiptBillPdf < Prawn::Document
move_down 5
y_position = cursor
bounding_box([0,y_position], :width =>(item_name_width), :height => self.item_height) do
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([item_name_width,y_position], :width =>self.total_width) do
bounding_box([self.item_description_width,y_position], :width => self.label_width) do
text "#{ food_beverage_total }" , :size => self.item_font_size,:align => :right
end
end
@@ -158,30 +158,30 @@ class ReceiptBillPdf < Prawn::Document
move_down 5
y_position = cursor
bounding_box([0,y_position], :width =>(item_name_width+self.price_width), :height => self.item_height) do
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Discount", :size => self.item_font_size,:align => :left
end
bounding_box([(item_name_width+self.price_width),y_position], :width =>self.total_width) do
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "( " +"#{sale_data.total_discount}" +" )" , :size => self.item_font_size,:align => :right
end
move_down 5
y_position = cursor
bounding_box([0,y_position], :width =>(item_name_width+self.price_width), :height => self.item_height) do
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Total Tax", :size => self.item_font_size,:align => :left
end
bounding_box([(item_name_width+self.price_width),y_position], :width =>self.total_width) do
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "( " +"#{sale_data.total_tax}" +" )" , :size => self.item_font_size,:align => :right
end
move_down 5
y_position = cursor
move_down 5
bounding_box([0,y_position], :width =>(item_name_width+self.price_width), :height => self.item_height) do
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Grand Total", :size => self.item_font_size,:align => :left
end
bounding_box([(item_name_width+self.price_width),y_position], :width =>self.total_width) do
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{sale_data.grand_total}" , :size => self.item_font_size,:align => :right
end
move_down 5