check order by and code for menu cats:

This commit is contained in:
phyusin
2017-12-22 14:43:59 +06:30
parent 9094d46209
commit 7d8fddbdeb
3 changed files with 23 additions and 8 deletions

View File

@@ -5,12 +5,12 @@ class ReceiptBillPdf < Prawn::Document
self.page_width = printer_settings.page_width
self.page_height = printer_settings.page_height
self.margin = 0
self.price_width = 40
self.qty_width = 20
self.total_width = 40
self.price_width = 50
self.qty_width = 35
self.total_width = 50
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-20) / 2
self.item_description_width = (self.page_width-5) / 2
self.label_width = 100
self.description_width = 150
@@ -22,6 +22,11 @@ class ReceiptBillPdf < Prawn::Document
#setting page margin and width
super(:margin => [printer_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
#precision checked
if printer_settings.precision.to_i > 2
printer_settings.precision = 2
end
# db font setup
if printer_settings.font != ""
font_families.update("#{printer_settings.font}" => {
@@ -124,6 +129,8 @@ class ReceiptBillPdf < Prawn::Document
end
def line_items(sale_items,precision,delimiter)
item_label_total_front_width = (self.item_width+self.price_width) + 15
item_label_total_end_width = self.total_width + 14
move_down 5
y_position = cursor
move_down 5
@@ -132,7 +139,7 @@ class ReceiptBillPdf < Prawn::Document
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
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 -5
stroke_horizontal_rule
@@ -141,6 +148,8 @@ class ReceiptBillPdf < Prawn::Document
def add_line_item_row(sale_items,precision,delimiter)
item_name_width = (self.item_width+self.price_width)
item_total_front_width = item_name_width + 15
item_total_end_width = self.total_width + 14
y_position = cursor
move_down 5
sub_total = 0.0
@@ -163,7 +172,7 @@ class ReceiptBillPdf < Prawn::Document
# text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size
text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_name_width,y_position], :width => self.qty_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[(item_name_width+4),y_position], :width =>self.total_width+3, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
}
move_down 5
end