From 49917c352c244ba49fd3b32833f2b81ff7498cc2 Mon Sep 17 00:00:00 2001 From: NyanLinHtut Date: Thu, 27 Jun 2019 13:51:02 +0630 Subject: [PATCH 1/4] add show subtotal+service charges in receipt bill --- README.md | 6 + .../channels/second_display_view.js | 4 +- app/pdf/receipt_bill_pdf.rb | 166 ++++++++++++------ 3 files changed, 117 insertions(+), 59 deletions(-) diff --git a/README.md b/README.md index d3f2199f..4d7f8a11 100755 --- a/README.md +++ b/README.md @@ -287,6 +287,12 @@ For Online Order Receipt Setting For Close Cashier Print Settings settings/lookups => {type:close_cashier_print, name:CloseCashierPrint, value: {0 or 1} } +For Second Display View Setting +settings/lookups => {type:display_type, name: Display Type, value: 2} + +For show total and service charges in receipt bill +settings/lookups => {type:show_sub_total_and_service_charges, name:Show Sub Total and Service charges, value: {0 or 1}} + * ToDo list 1. Migration diff --git a/app/assets/javascripts/channels/second_display_view.js b/app/assets/javascripts/channels/second_display_view.js index 721b098f..2e32201e 100644 --- a/app/assets/javascripts/channels/second_display_view.js +++ b/app/assets/javascripts/channels/second_display_view.js @@ -40,6 +40,7 @@ App.checkin = App.cable.subscriptions.create('SecondDisplayViewChannel', { // } d_option = items[i].opt; + console.log(d_option) if (items[i].click_type != "add_icon"){ option_name = "-"+items[i].options; data_option = items[i].options ; @@ -54,7 +55,8 @@ App.checkin = App.cable.subscriptions.create('SecondDisplayViewChannel', { $(item_row).each(function(j){ var item_code = $(item_row[j]).attr('data-code'); var instance_code = $(item_row[j]).attr('data-instance-code'); - var r_option = $(item_row[j]).attr('data-options'); + var r_option = $(item_row[j]).attr('data-opt'); + console.log(r_option) if (item_code == items[i].item_code && instance_code == items[i].instance_code && r_option==d_option) { if (qty > 1) { qty = parseInt($(item_row[j]).children('#item_qty').text()) + qty; diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 97f6dfc2..aef43ce9 100755 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -2,7 +2,7 @@ class ReceiptBillPdf < Prawn::Document include ActionView::Helpers::NumberHelper 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, :description_width, :price_num_width, :line_move - + def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no,card_balance_amount) self.page_width = printer_settings.page_width self.page_height = printer_settings.page_height @@ -101,7 +101,7 @@ class ReceiptBillPdf < Prawn::Document if shop_details.note && !shop_details.note.nil? shop_note(shop_details) end - + footer(printed_status) end @@ -129,7 +129,7 @@ class ReceiptBillPdf < Prawn::Document text "OrderNo : #{ latest_order_no }", :size => self.header_font_size,:align => :left end move_down line_move - + # move_down 2 y_position = cursor bounding_box([0,y_position], :width =>self.description_width + self.price_num_width, :height => self.item_height) do @@ -146,7 +146,7 @@ class ReceiptBillPdf < Prawn::Document y_position = cursor bounding_box([0, y_position], :width =>self.label_width, :height => self.item_height) do text "W: #{sale_data.requested_by}" , :size => self.item_font_size, :align => :left - end + end bounding_box([self.label_width - 2,y_position], :width =>self.label_width, :height => self.item_height) do text "C: #{sale_data.cashier_name}", :size => self.item_font_size,:align => :right end @@ -164,7 +164,7 @@ class ReceiptBillPdf < Prawn::Document end # bounding_box([self.item_description_width,y_position], :width =>self.label_width+5) do - # text "(#{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') } + # text "(#{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') } # - #{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') })" , # :size => self.item_font_size,:align => :right # end @@ -201,7 +201,7 @@ class ReceiptBillPdf < Prawn::Document end def add_line_item_row(sale_items,precision,delimiter) - + if precision.to_i > 0 item_name_width = (self.item_width+self.price_width) item_qty_front_width = (self.item_width+self.price_width) + 5 @@ -218,18 +218,18 @@ class ReceiptBillPdf < Prawn::Document y_position = cursor move_down line_move - sub_total = 0.0 + @sub_total = 0.0 total_qty = 0.0 show_price = Lookup.find_by_lookup_type("show_price") sale_items.each do |item| - # check for item not to show - + # check for item not to show + if item.status != 'Discount' && item.qty > 0 if !show_price.nil? && show_price.value.to_i > 0 && item.price == 0 - total_qty += item.qty + total_qty += item.qty else if item.price != 0 - total_qty += item.qty + total_qty += item.qty end end end @@ -242,13 +242,13 @@ class ReceiptBillPdf < Prawn::Document # total_price = -item.price #item.qty*item.unit_price - comment for room charges # price = -item.unit_price # else - sub_total += item.price #(item.qty*item.unit_price) - comment for room charges + @sub_total += item.price #(item.qty*item.unit_price) - comment for room charges qty = item.qty total_price = item.price #item.qty*item.unit_price - comment for room charges price = item.unit_price - + # end - + if !show_price.nil? && show_price.value.to_i>0 item_row(item,precision,delimiter,product_name,price,qty ,total_price) @@ -257,7 +257,7 @@ class ReceiptBillPdf < Prawn::Document item_row(item,precision,delimiter,product_name,price,qty ,total_price) end end - + end stroke_horizontal_rule @@ -268,7 +268,7 @@ class ReceiptBillPdf < Prawn::Document text "Sub Total", :size => self.item_font_size,:align => :left end text_box "#{number_with_precision(total_qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix - text_box "#{number_with_precision(sub_total, :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 + text_box "#{number_with_precision(@sub_total, :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 end def item_row(item,precision,delimiter,product_name,price,qty ,total_price) @@ -291,10 +291,10 @@ class ReceiptBillPdf < Prawn::Document bounding_box([0,y_position], :width =>self.item_width) do text "#{product_name}", :size => self.item_font_size,:align => :left end - # 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_qty_front_width,y_position], :width => item_qty_end_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_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + # 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_qty_front_width,y_position], :width => item_qty_end_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_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix if show_alt_name if !(item.product_alt_name).empty? @@ -326,23 +326,73 @@ class ReceiptBillPdf < Prawn::Document bounding_box([self.item_description_width,y_position], :width =>self.label_width) do text "( #{number_with_precision(sale_data.total_discount, :precision => precision.to_i, :delimiter => delimiter)} )" , :size => self.item_font_size,:align => :right end - + @Service_Tax_Desc = "" + @Service_Tax_amount = 0 + @Service_Tax_Rate = 0 + @Com_Tax_Desc = "" + @Com_Tax_Amount = 0 + @Com_Tax_Rate = 0 if sale_data.sale_taxes.length > 0 incl_tax = "" if sale_data.tax_type == "inclusive" incl_tax = "Incl." end - sale_data.sale_taxes.each do |st| - move_down line_move - y_position = cursor + find_lookup = Lookup.find_by_lookup_type('show_sub_total_and_service_charges') + if find_lookup.value == '1' + sale_data.sale_taxes.each do |st| + if (st.tax_name.include? "Service") + @Service_Tax_Desc = st.tax_name + @Service_Tax_amount = number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter) + if incl_tax + @Service_Tax_Rate = st.tax_rate.to_i + end + end + if (st.tax_name.include? "Commercial") + @Com_Tax_Desc = st.tax_name + @Com_Tax_Amount = number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter) + if incl_tax + @Com_Tax_Rate = st.tax_rate.to_i + end + end + end + move_down line_move + y_position = cursor + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "#{ @Service_Tax_Desc } (#{incl_tax} #{ @Service_Tax_Rate }%)", :size => self.item_font_size,:align => :left + end + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "#{number_with_precision(@Service_Tax_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + end + move_down line_move + y_position = cursor + stroke_horizontal_rule + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "Sub Total + #{@Service_Tax_Desc}", :size => self.item_font_size,:align => :left + end + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "#{@Service_Tax_amount.to_i + @sub_total.to_i}" , :size => self.item_font_size,:align => :right + end + move_down line_move + y_position = cursor + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "#{ @Com_Tax_Desc } (#{incl_tax} #{ @Com_Tax_Rate.to_i }%)", :size => self.item_font_size,:align => :left + end + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "#{number_with_precision(@Com_Tax_Amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + end + else + sale_data.sale_taxes.each do |st| + move_down line_move + y_position = cursor - bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do - text "#{ st.tax_name } (#{incl_tax} #{ st.tax_rate.to_i }%)", :size => self.item_font_size,:align => :left - end - bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right - end + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "#{ st.tax_name } (#{incl_tax} #{ st.tax_rate.to_i }%)", :size => self.item_font_size,:align => :left + end + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "#{number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + end + end end else @@ -367,7 +417,7 @@ class ReceiptBillPdf < Prawn::Document end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do text "#{sale_data.rounding_adjustment}", :size => self.item_font_size,:align => :right - end + end end move_down line_move @@ -380,11 +430,11 @@ class ReceiptBillPdf < Prawn::Document text "#{number_with_precision(sale_data.grand_total, :precision => precision.to_i, :delimiter => delimiter)}" , :style => :bold, :size => self.header_font_size,:align => :right end move_down line_move - - sale_payment(sale_data,precision,delimiter) + + sale_payment(sale_data,precision,delimiter) end - def sale_payment(sale_data,precision,delimiter) + def sale_payment(sale_data,precision,delimiter) stroke_horizontal_rule #move_down line_move sql = "SELECT SUM(payment_amount) @@ -416,13 +466,13 @@ class ReceiptBillPdf < Prawn::Document text "#{payment.payment_method.capitalize} Payment", :size => self.item_font_size,:align => :left end end - + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do text "#{number_with_precision(payment.payment_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end move_down line_move end - if sale_data.amount_received > 0 + if sale_data.amount_received > 0 y_position = cursor move_down line_move bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do @@ -437,7 +487,7 @@ class ReceiptBillPdf < Prawn::Document # show member information def member_info(member_info,customer_name,rebate_amount,sale_data,precision,delimiter,current_balance) - if rebate_amount != nil + if rebate_amount != nil if rebate_amount["status"] == true stroke_horizontal_rule total = 0 @@ -466,8 +516,8 @@ class ReceiptBillPdf < Prawn::Document bounding_box([self.item_description_width,y_position], :width =>self.label_width) do text "#{number_with_precision(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end - - end + + end # Total Rebate Amount if birthday if res["receipt_no"]== sale_data.receipt_no && res["account_status"]== "RebatebonusAccount" && res["status"]== "Rebate" rebate_balance = rebate_balance + res["deposit"] @@ -479,7 +529,7 @@ class ReceiptBillPdf < Prawn::Document bounding_box([self.item_description_width,y_position], :width =>self.label_width) do text "#{number_with_precision(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end - end + end #end Total rebate if birthday end @@ -502,7 +552,7 @@ class ReceiptBillPdf < Prawn::Document text "#{number_with_precision(current_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right end end - + end end @@ -512,7 +562,7 @@ class ReceiptBillPdf < Prawn::Document if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount" total_balance = total_balance + res["balance"] - + end end move_down line_move @@ -524,7 +574,7 @@ class ReceiptBillPdf < Prawn::Document text "#{number_with_precision(total_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end end - + end def customer(customer_name) @@ -554,7 +604,7 @@ class ReceiptBillPdf < Prawn::Document end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do text "(" + "#{ number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter) }" + ")" , :size => self.item_font_size,:align => :right - end + end move_down line_move end end @@ -571,7 +621,7 @@ class ReceiptBillPdf < Prawn::Document bounding_box([self.label_width,y_position], :width =>self.item_description_width) do text "#{number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end - move_down line_move + move_down line_move end end @@ -583,7 +633,7 @@ class ReceiptBillPdf < Prawn::Document bounding_box([self.label_width,y_position], :width =>self.item_description_width) do text "#{number_with_precision(other_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end - move_down line_move + move_down line_move end #individual payment per person @@ -623,17 +673,17 @@ class ReceiptBillPdf < Prawn::Document JOIN sale_audits sa ON SUBSTRING_INDEX(sa.remark,'||',1)=sale_payment_id where sa.sale_id='#{sale_data.sale_id}')) = 0 - THEN payment_method!='creditnote' ELSE 1 END) AND sale_id = ?", sale_data.sale_id).each do |payment| + THEN payment_method!='creditnote' ELSE 1 END) AND sale_id = ?", sale_data.sale_id).each do |payment| if payment.payment_method == "creditnote" y_position = cursor stroke_horizontal_rule - + bounding_box([self.label_width,y_position], :width =>self.item_description_width) do move_down 70 stroke_horizontal_rule end - + bounding_box([self.label_width,y_position], :width =>self.item_description_width) do move_down 73 text "Approved By" , :size => self.item_font_size,:align => :center @@ -650,7 +700,7 @@ class ReceiptBillPdf < Prawn::Document move_down 70 stroke_horizontal_rule end - + if sale_data.payment_status == "foc" bounding_box([self.label_width,y_position], :width =>self.item_description_width) do move_down 73 @@ -661,9 +711,9 @@ class ReceiptBillPdf < Prawn::Document move_down 73 text "Approved By" , :size => self.item_font_size,:align => :center end - end + end end - + end def shop_note(shop) @@ -673,8 +723,8 @@ class ReceiptBillPdf < Prawn::Document move_down line_move y_position = cursor - - text "#{shop.note}", :size => self.item_font_size, :align => :left + + text "#{shop.note}", :size => self.item_font_size, :align => :left move_down line_move end @@ -688,10 +738,10 @@ class ReceiptBillPdf < Prawn::Document y_position = cursor bounding_box([0, y_position], :width =>self.label_width) do text "#{printed_status}",:style => :bold, :size => header_font_size,:align => :left - end + end bounding_box([self.item_description_width,y_position], :width =>self.item_description_width, :height => self.item_height) do text "Thank You! See you Again", :left_margin => -5, :size => self.item_font_size,:align => :left - end + end move_down line_move end @@ -729,7 +779,7 @@ class ReceiptBillPdf < Prawn::Document y_position = cursor bounding_box([0, y_position], :width =>self.label_width) do text "Card Balance: ",:style => :bold, :size => header_font_size,:align => :left - end + end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do text "#{card_balance_amount}" , :size => self.item_font_size,:align => :right end @@ -753,4 +803,4 @@ class ReceiptBillPdf < Prawn::Document end return status end -end \ No newline at end of file +end From 8a6b8dfa59bae05cdae900c79b0ea7402d3d290f Mon Sep 17 00:00:00 2001 From: Zoey Date: Thu, 27 Jun 2019 17:25:23 +0630 Subject: [PATCH 2/4] foc receipt bill --- app/controllers/origami/payments_controller.rb | 4 ++-- app/controllers/origami/void_controller.rb | 2 +- app/controllers/origami/waste_spoile_controller.rb | 2 +- app/controllers/transactions/sales_controller.rb | 2 +- app/models/order_reservation.rb | 2 +- app/pdf/receipt_bill_star_pdf.rb | 2 +- config/puma.rb | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 73e1f909..cb9fe88f 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -586,7 +586,7 @@ class Origami::PaymentsController < BaseOrigamiController other_amount = SaleItem.calculate_other_charges(saleObj.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil) + filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil) result = { :status => true, @@ -685,7 +685,7 @@ class Origami::PaymentsController < BaseOrigamiController printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "FOC",nil,nil,other_amount,nil,nil,nil) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "FOC",nil,nil,other_amount,nil,nil,nil) result = { :status => true, :filepath => filename, diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb index 75bb7074..980fd6bd 100755 --- a/app/controllers/origami/void_controller.rb +++ b/app/controllers/origami/void_controller.rb @@ -148,7 +148,7 @@ class Origami::VoidController < BaseOrigamiController discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items) other_amount = SaleItem.calculate_other_charges(sale.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount,nil,nil,nil) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount,nil,nil,nil) result = { :filepath => filename, :printer_model => print_settings.brand_name, diff --git a/app/controllers/origami/waste_spoile_controller.rb b/app/controllers/origami/waste_spoile_controller.rb index 92720467..2d4c9367 100755 --- a/app/controllers/origami/waste_spoile_controller.rb +++ b/app/controllers/origami/waste_spoile_controller.rb @@ -122,7 +122,7 @@ class Origami::WasteSpoileController < BaseOrigamiController discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items) other_amount = SaleItem.calculate_other_charges(sale.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, remark,current_balance,nil,other_amount,nil,nil,nil) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, remark,current_balance,nil,other_amount,nil,nil,nil) result = { :filepath => filename, :printer_model => print_settings.brand_name, diff --git a/app/controllers/transactions/sales_controller.rb b/app/controllers/transactions/sales_controller.rb index 24c76b1d..e8a2d9e4 100755 --- a/app/controllers/transactions/sales_controller.rb +++ b/app/controllers/transactions/sales_controller.rb @@ -364,7 +364,7 @@ class Transactions::SalesController < ApplicationController other_amount = SaleItem.calculate_other_charges(sale.sale_items) #other charges printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount,nil,nil,nil) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount,nil,nil,nil) result = { :filepath => filename, :printer_model => print_settings.brand_name, diff --git a/app/models/order_reservation.rb b/app/models/order_reservation.rb index c75ad748..0be86204 100644 --- a/app/models/order_reservation.rb +++ b/app/models/order_reservation.rb @@ -203,7 +203,7 @@ class OrderReservation < ApplicationRecord other_amount = SaleItem.calculate_other_charges(saleObj.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,saleObj.customer.name, item_price_by_accounts, discount_price_by_accounts, nil,nil,shop_detail, "Paid",nil,nil,other_amount,nil,nil, order_reservation) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,saleObj.sale_items,saleObj,saleObj.customer.name, item_price_by_accounts, discount_price_by_accounts, nil,nil,shop_detail, "Paid",nil,nil,other_amount,nil,nil, order_reservation) #receipt bill pdf setting result = {:status=> true, diff --git a/app/pdf/receipt_bill_star_pdf.rb b/app/pdf/receipt_bill_star_pdf.rb index 447e0a2e..0b1f8ce2 100644 --- a/app/pdf/receipt_bill_star_pdf.rb +++ b/app/pdf/receipt_bill_star_pdf.rb @@ -3,7 +3,7 @@ class ReceiptBillStarPdf < Prawn::Document attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :margin_top, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width, :line_move - def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no,card_balance_amount) + def initialize(printer_settings, status, qr , sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no,card_balance_amount) self.page_width = printer_settings.page_width self.page_height = printer_settings.page_height self.header_font_size = printer_settings.header_font_size.to_i diff --git a/config/puma.rb b/config/puma.rb index a0dae8b3..6f7c4941 100755 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,6 +1,6 @@ application_path="#{File.expand_path("../..", __FILE__)}" directory application_path -environment ENV.fetch("RAILS_ENV") { "production" } +# environment ENV.fetch("RAILS_ENV") { "production" } environment "production" pidfile "#{application_path}/tmp/puma/pid" state_path "#{application_path}/tmp/puma/state" From 0872ce50510a44b9448c1d8a7315d081d832b6be Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Fri, 28 Jun 2019 14:36:21 +0630 Subject: [PATCH 3/4] fix conflict --- app/pdf/receipt_bill_pdf.rb | 7 ------- 1 file changed, 7 deletions(-) diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index d6c1fc13..4d1bd875 100755 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -4,13 +4,9 @@ class ReceiptBillPdf < Prawn::Document include ActionView::Helpers::NumberHelper 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, :description_width, :price_num_width, :line_move -<<<<<<< HEAD - def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no,card_balance_amount) -======= def initialize(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no,card_balance_amount) ->>>>>>> 29ef6c17f910e846500d77b9f91268cb710b3a64 self.page_width = printer_settings.page_width self.page_height = printer_settings.page_height self.header_font_size = printer_settings.header_font_size.to_i @@ -109,13 +105,10 @@ class ReceiptBillPdf < Prawn::Document shop_note(shop_details) end -<<<<<<< HEAD -======= if kbz_pay_status kbzpay_qr_generator(printed_status, qr_code) end ->>>>>>> 29ef6c17f910e846500d77b9f91268cb710b3a64 footer(printed_status) end From aca0c390c9f7d4a64fe13237c0b7ad5a198e49a6 Mon Sep 17 00:00:00 2001 From: NyanLinHtut Date: Mon, 1 Jul 2019 11:11:44 +0630 Subject: [PATCH 4/4] insert looktype for receipt bill --- README.md | 4 +-- app/pdf/receipt_bill_pdf.rb | 58 +++++++++++++++++-------------------- 2 files changed, 28 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 4d7f8a11..9df29b68 100755 --- a/README.md +++ b/README.md @@ -290,8 +290,8 @@ settings/lookups => {type:close_cashier_print, name:CloseCashierPrint, value: {0 For Second Display View Setting settings/lookups => {type:display_type, name: Display Type, value: 2} -For show total and service charges in receipt bill -settings/lookups => {type:show_sub_total_and_service_charges, name:Show Sub Total and Service charges, value: {0 or 1}} +For show total before tax in receipt bill +settings/lookups => {type:show_total_before_tax, name:Show Total Before Tax, value: {0 or 1}} * ToDo list diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index d6c1fc13..b95c8e57 100755 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -4,13 +4,8 @@ class ReceiptBillPdf < Prawn::Document include ActionView::Helpers::NumberHelper 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, :description_width, :price_num_width, :line_move -<<<<<<< HEAD - def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no,card_balance_amount) -======= - def initialize(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no,card_balance_amount) ->>>>>>> 29ef6c17f910e846500d77b9f91268cb710b3a64 self.page_width = printer_settings.page_width self.page_height = printer_settings.page_height self.header_font_size = printer_settings.header_font_size.to_i @@ -109,13 +104,6 @@ class ReceiptBillPdf < Prawn::Document shop_note(shop_details) end -<<<<<<< HEAD -======= - if kbz_pay_status - kbzpay_qr_generator(printed_status, qr_code) - end - ->>>>>>> 29ef6c17f910e846500d77b9f91268cb710b3a64 footer(printed_status) end @@ -340,60 +328,66 @@ class ReceiptBillPdf < Prawn::Document bounding_box([self.item_description_width,y_position], :width =>self.label_width) do text "( #{number_with_precision(sale_data.total_discount, :precision => precision.to_i, :delimiter => delimiter)} )" , :size => self.item_font_size,:align => :right end - @Service_Tax_Desc = "" - @Service_Tax_amount = 0 - @Service_Tax_Rate = 0 - @Com_Tax_Desc = "" - @Com_Tax_Amount = 0 - @Com_Tax_Rate = 0 + + service_tax_desc = "" + service_tax_amount = 0 + service_tax_rate = 0 + com_tax_desc = "" + com_tax_amount = 0 + com_tax_rate = 0 if sale_data.sale_taxes.length > 0 incl_tax = "" if sale_data.tax_type == "inclusive" incl_tax = "Incl." end - find_lookup = Lookup.find_by_lookup_type('show_sub_total_and_service_charges') - if find_lookup.value == '1' + find_lookup = Lookup.find_by_lookup_type('show_total_before_tax') + if find_lookup.nil? || find_lookup == nil + lookup = Lookup.new(lookup_type: 'show_total_before_tax', name: 'Show Total Before Tax', value: '0') + lookup.save + end + check_lookup_type = Lookup.find_by_lookup_type('show_total_before_tax') + if check_lookup_type.value == '1' sale_data.sale_taxes.each do |st| if (st.tax_name.include? "Service") - @Service_Tax_Desc = st.tax_name - @Service_Tax_amount = number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter) + service_tax_desc = st.tax_name + service_tax_amount = number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter) if incl_tax - @Service_Tax_Rate = st.tax_rate.to_i + service_tax_rate = st.tax_rate.to_i end end if (st.tax_name.include? "Commercial") - @Com_Tax_Desc = st.tax_name - @Com_Tax_Amount = number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter) + com_tax_desc = st.tax_name + com_tax_amount = number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter) if incl_tax - @Com_Tax_Rate = st.tax_rate.to_i + com_tax_rate = st.tax_rate.to_i end end end move_down line_move y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do - text "#{ @Service_Tax_Desc } (#{incl_tax} #{ @Service_Tax_Rate }%)", :size => self.item_font_size,:align => :left + text "#{ service_tax_desc } (#{incl_tax} #{ service_tax_rate }%)", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(@Service_Tax_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + text "#{number_with_precision(service_tax_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end move_down line_move y_position = cursor stroke_horizontal_rule bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do - text "Sub Total + #{@Service_Tax_Desc}", :size => self.item_font_size,:align => :left + text "Total Before Tax", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{@Service_Tax_amount.to_i + @sub_total.to_i}" , :size => self.item_font_size,:align => :right + text "#{service_tax_amount.to_i + @sub_total.to_i}" , :size => self.item_font_size,:align => :right end move_down line_move y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do - text "#{ @Com_Tax_Desc } (#{incl_tax} #{ @Com_Tax_Rate.to_i }%)", :size => self.item_font_size,:align => :left + text "#{ com_tax_desc } (#{incl_tax} #{ com_tax_rate.to_i }%)", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(@Com_Tax_Amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + text "#{number_with_precision(com_tax_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end else sale_data.sale_taxes.each do |st|