diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 107e3163..14f05a00 100755 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -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 diff --git a/app/views/api/restaurant/menu/_menu.json.jbuilder b/app/views/api/restaurant/menu/_menu.json.jbuilder index 9441daf9..cf046939 100755 --- a/app/views/api/restaurant/menu/_menu.json.jbuilder +++ b/app/views/api/restaurant/menu/_menu.json.jbuilder @@ -7,6 +7,8 @@ json.valid_time_to menu.valid_time_to.strftime("%H:%M") if (menu.menu_categories) json.categories menu.menu_categories do |category| json.id category.id + json.code category.code + json.order_by category.order_by json.name category.name json.alt_name category.alt_name json.parent_id category.menu_category_id diff --git a/app/views/print_settings/_form.html.erb b/app/views/print_settings/_form.html.erb index 51ee0eaa..201d1411 100755 --- a/app/views/print_settings/_form.html.erb +++ b/app/views/print_settings/_form.html.erb @@ -15,8 +15,8 @@ <%= f.input :api_settings %> <%= f.input :page_width %> <%= f.input :page_height %> - <%= f.input :print_copies, input_html: { min: '1', step: '1', :onkeypress => "return isNumberKey(event);", :onkeyup => "greaterThanOne(this.value);" } %> - <%= f.input :precision %> + <%= f.input :print_copies, input_html: { min: 1, step: '1', :onkeypress => "return isNumberKey(event);", :onkeyup => "greaterThanOne(this.value);" } %> + <%= f.input :precision, input_html: { min: 0, max: 2, :onkeypress => "return isNumberKey(event);", :onkeyup => "greaterThanThree(this.value);" } %> <%= f.input :delimiter %> <%= f.input :heading_space %> @@ -73,4 +73,8 @@ function greaterThanOne(val){ if(parseInt(val)==0) $("#print_setting_print_copies").val(1); } + + function greaterThanThree(val){ + if(parseInt(val)>2) $("#print_setting_precision").val(2); + } \ No newline at end of file