From ed76c2eac1e343a445c1e056a25ce74d4b913fc6 Mon Sep 17 00:00:00 2001 From: Zoey Date: Thu, 30 May 2019 14:03:59 +0630 Subject: [PATCH 1/7] update --- config/initializers/action_controller.rb | 10 +++++----- config/puma.rb | 20 ++++++++++---------- dump.rdb | Bin 883 -> 1272 bytes 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index 205c330a..85f38ec5 100644 --- a/config/initializers/action_controller.rb +++ b/config/initializers/action_controller.rb @@ -21,11 +21,11 @@ class ActionController::Base end else # check for license file - if check_license - current_license(ENV["SX_PROVISION_URL"]) - else - redirect_to activate_path - end + # if check_license + # current_license(ENV["SX_PROVISION_URL"]) + # else + # redirect_to activate_path + # end end end diff --git a/config/puma.rb b/config/puma.rb index fd89392f..6a545bed 100755 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,10 +1,10 @@ -application_path="#{File.expand_path("../..", __FILE__)}" -directory application_path -#environment ENV.fetch("RAILS_ENV") { "production" } -environment "production" -pidfile "#{application_path}/tmp/puma/pid" -state_path "#{application_path}/tmp/puma/state" -stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" -port ENV.fetch("PORT") { 62158 } -workers 2 -preload_app! +# application_path="#{File.expand_path("../..", __FILE__)}" +# directory application_path +# #environment ENV.fetch("RAILS_ENV") { "production" } +# environment "production" +# pidfile "#{application_path}/tmp/puma/pid" +# state_path "#{application_path}/tmp/puma/state" +# stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" +# port ENV.fetch("PORT") { 62158 } +# workers 2 +# preload_app! diff --git a/dump.rdb b/dump.rdb index f5a525467f8cf0157f915e4bb280d887dd931c1d..2ea537b2f0abe2ba8e3211043f22127a860b68c4 100644 GIT binary patch literal 1272 zcmaJ>%Zt-M9G;Z6yK8k3!Pk0d89X*+CNa$e4@LB_h$sqPe3VHtX@g1ACX1o2PsEP^)=wLYfl?sj)c_L|=>-}n0-$@NPYS8pJMwDD3%Z8s9v zXjneiKn;w?hh|SqmqkfyT(X$!)6JWYf8HK1#u2qepZc56I>*8IFbN#7A5!9*9!3piLbT1Fv=VXxHs@+x^fDLYEEUojR;N6eu6mDgtL%ZJqoktUrpD_vnKUN`u&? ztmF_cqJ^dH^djLPSHSY#s7IfL$*<-2gEZj%DW&ORB`Hj-Ya4G4?102mo^NFWr7JsJ z8I{|j8-3c3%I``_&la-D9gVLAt6!Pyz$U@#ab-!ivuP_gA$~Jc>V=GODn?!Sb&_u4OJlB*5 ak;L6_+HISQQlIC#MzzO*wd)@y|J3WADiqnWaPx z%nvXyu@#o4mZlanvZth`C6?xt0QF0<7+D@*o48Ag_0OzVn|(oQnG7r@Z(tT Date: Fri, 31 May 2019 09:33:32 +0630 Subject: [PATCH 2/7] update --- dump.rdb | Bin 1272 -> 1229 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/dump.rdb b/dump.rdb index 2ea537b2f0abe2ba8e3211043f22127a860b68c4..55991a961be21afb68a1f837181456658497ba6a 100644 GIT binary patch delta 504 zcmeytd6sj6q3-RY?_+*(loqF^=;o&89@@dd!|;nIF+WYWpeQvlHz_Ce0K-3q-*Vi4 zI2Q@+pIpx*%VKPBz<#m=i}+*(7R8CXg@Ke5i-oSS;pBNtsvz-+1#Cb{lEujK0Ndm$ zCbh|%m_@kFb&U)TFhC5s$Sf-)#Kcxunp&D#%*dXSnwD6aQv%c@H~9!qInW44pmH;y z@~jPWIkFiU7+9o}^HWldauSoQj14S|Osx!!OcPU$O)ZiW&5T%B3rjOoOIXtqbBa@0 zGV{{%4?Ap|9LA`u%%51IWMyb-YH4I>Y-VJkXQaR_Y-VPrqg0TYq69H%@*GA91)k*m zyyViNqSUb@IjZsGj*-E8amZZ|+$^#56NvVk?f)Fdr&5R86 zOe_ry&5c2RkTlmdv^c=Pz*k(7SYlOBl%Jeh3=HLiTuh+Qnasf=G4Y%fw}mb+m>B+? z(>3;Gy}`Np@u5G2TAXnFvoNs7@BC@IDQ3Y^K&EE=qTX1&_% q3sNCr0J4c2Y*SidW=?9#0TGBKFv9o@EDla*`0u&(+2%L;)9e5j9ifu| delta 560 zcmaKpy>HV%7{<@`If-diAxI%IRIMB&7~;xzmOmHR8DQXJ07W|6XB5?mli04*p(|rm z>*kD%MGPP@6&Dr+g2KQbzzh;h2$k|-$3kLaeDyr<`+M%WH_~@$7hSq_|I6K@R+i8} z9n#_R-FwU6XpzLBI-XK8^dee-U*N~;0{h6dB}>&T6>9}xGk7ug+WFoJ+Yw}T88+B^ zp?#wkkNdL+%?%C!c+QUliX-B=$aJvodOATN(yhR@Z3sO|(o@JV9IPST#OtPQIEICx zmnB;TfP+yOzqs<0-R8SpnWTzaTQy{&b;l~L2JR{2L9o_oRma(k?Ulr?F3ygeKho(u1WWC8_(@ z92~sn*e9VY9{bn#ALsoQ3EKsj5A3TT*VDJ9XOmJAk#X=6unl-2_fNA!uF*yX;2U*N zt~rkxrR8-MIN7Yb~ljUYzzsU}T^JU# Date: Mon, 3 Jun 2019 16:47:49 +0630 Subject: [PATCH 3/7] total other amount added to SaleItemsPdf --- .../reports/saleitem_controller.rb | 12 ++++-- app/models/printer/cashier_station_printer.rb | 6 +-- app/models/shift_sale.rb | 9 +++- app/pdf/close_cashier_pdf.rb | 25 +++++++---- app/pdf/sale_items_pdf.rb | 40 +++++++++++++----- app/pdf/sale_items_star_pdf.rb | 39 ++++++++++++----- dump.rdb | Bin 1229 -> 1343 bytes 7 files changed, 95 insertions(+), 36 deletions(-) diff --git a/app/controllers/reports/saleitem_controller.rb b/app/controllers/reports/saleitem_controller.rb index 1db8f7f3..df61d197 100755 --- a/app/controllers/reports/saleitem_controller.rb +++ b/app/controllers/reports/saleitem_controller.rb @@ -117,8 +117,14 @@ class Reports::SaleitemController < BaseReportController account_type = params[:account_type] @type = params[:period_type] period_name = get_period_name(params[:period]) - @sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type,account_type) + @sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type,account_type) + other_charges = Sale.get_other_charges() + if shift.present? + @total_other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a) + else + @total_other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to) + end # get printer info print_settings = PrintSetting.find_by_unique_code('CloseCashierPdf') # SaleItemsPdf @@ -127,11 +133,11 @@ class Reports::SaleitemController < BaseReportController if print_settings.nil? if !print_settings_star.nil? printer = Printer::CashierStationPrinter.new(print_settings_star) - printer.print_sale_items_report(print_settings_star, shop_details, period_name, @type, account_type, from, to, shift_name, @sale_data) + printer.print_sale_items_report(print_settings_star, shop_details, period_name, @type, account_type, from, to, shift_name, @sale_data, @total_other_charges) end else printer = Printer::CashierStationPrinter.new(print_settings) - printer.print_sale_items_report(print_settings, shop_details, period_name, @type, account_type, from, to, shift_name, @sale_data) + printer.print_sale_items_report(print_settings, shop_details, period_name, @type, account_type, from, to, shift_name, @sale_data, @total_other_charges) end diff --git a/app/models/printer/cashier_station_printer.rb b/app/models/printer/cashier_station_printer.rb index b2762071..d5ac2e73 100755 --- a/app/models/printer/cashier_station_printer.rb +++ b/app/models/printer/cashier_station_printer.rb @@ -81,15 +81,15 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker end end - def print_sale_items_report(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items) + def print_sale_items_report(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items, total_other_charges) filename = "tmp/reports_sale_items.pdf" if print_settings.unique_code == "CloseCashierPdf" - pdf = SaleItemsPdf.new(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items, nil, nil, nil) + pdf = SaleItemsPdf.new(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items, total_other_charges, nil, nil, nil) puts 'Printing!!!!' end if print_settings.unique_code == "CloseCashierStarPdf" - pdf = SaleItemsStarPdf.new(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items, nil, nil, nil) + pdf = SaleItemsStarPdf.new(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items, total_other_charges, nil, nil, nil) puts 'PrintingStar!!!!' end diff --git a/app/models/shift_sale.rb b/app/models/shift_sale.rb index eb812b7b..21386e90 100755 --- a/app/models/shift_sale.rb +++ b/app/models/shift_sale.rb @@ -156,7 +156,14 @@ class ShiftSale < ApplicationRecord .joins("JOIN customers as c ON c.customer_id = sales.customer_id") .where('shift_sale_id =? and sales.sale_status = "completed" and c.customer_type = "Takeaway" and c.membership_id is null',shift.id) .first() - end + end + + # def self.get_total_other_charges_for_sale_item_report(from, to) + # query = SaleItem.select("sum(sale_items.qty * sale_items.unit_price) as total_other_charges_amount") + # .joins("JOIN sales as s ON s.sale_id = sale_items.sale_id") + # .joins("JOIN shift_sales ss ON ss.id = s.shift_sale_id") + # .where('s.sale_status = "completed" and sale_items.product_code = "Other Charges" and sale_items.item_instance_code is null and s.receipt_date between ? and ?',from, to) + # end def self.get_total_other_charges(shift) query = SaleItem.select("sum(sale_items.qty * sale_items.unit_price) as total_other_charges_amount") diff --git a/app/pdf/close_cashier_pdf.rb b/app/pdf/close_cashier_pdf.rb index 4e2fc443..100b4bfb 100755 --- a/app/pdf/close_cashier_pdf.rb +++ b/app/pdf/close_cashier_pdf.rb @@ -57,7 +57,7 @@ class CloseCashierPdf < Prawn::Document shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,printer_settings.precision,delimiter,total_waste,total_spoile,total_other_charges,total_credit_payments) if !sale_items.nil? or !sale_items.blank? - sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc) + sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc, total_other_charges) end end @@ -504,7 +504,7 @@ class CloseCashierPdf < Prawn::Document end - def sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc) + def sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc, total_other_charges) self.item_width = 73 self.price_width = 60 item_label_qty_front_width = (self.item_width+self.price_width) + 2 @@ -521,6 +521,7 @@ class CloseCashierPdf < Prawn::Document total_amount = 0 total_qty = 0 sub_total = 0 + flag = false arr = Array.new @@ -529,12 +530,15 @@ class CloseCashierPdf < Prawn::Document if !arr.include?(item['menu_category_id']) - unless total_qty == 0 and sub_total == 0 + if flag == true + move_down 5 + stroke_horizontal_rule total_details('Sub Total', total_qty, sub_total) end total_qty = 0 sub_total = 0 + flag = true move_down 10 @@ -571,7 +575,7 @@ class CloseCashierPdf < Prawn::Document text_box "#{item['grand_total'].to_i}", :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 } - if item['total_item'].to_i > 0 + if item['total_item'].to_i > 0 or item['status_type'] == 'foc' or item['status_type'] == 'void' total_qty += item['total_item'].to_i total_items += item['total_item'].to_i end @@ -581,11 +585,17 @@ class CloseCashierPdf < Prawn::Document arr.push(item['menu_category_id']) end - # stroke_horizontal_rule + move_down 5 + stroke_horizontal_rule total_details('Sub Total', total_qty, sub_total) move_down 5 + move_down 5 + stroke_horizontal_rule total_details('Total Amount', total_items, total_amount) - move_down 10 + + # other_charges = get_other_charges(total_other_charges) + total_details('Total Other Amount', nil, total_other_charges) + move_down 20 end end @@ -597,8 +607,7 @@ class CloseCashierPdf < Prawn::Document item_label_total_front_width = (self.item_width+self.price_width) + 2 item_label_total_end_width = 64 - move_down 5 - stroke_horizontal_rule + y_position = cursor pad_top(15) { text_box "#{col_name}", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix diff --git a/app/pdf/sale_items_pdf.rb b/app/pdf/sale_items_pdf.rb index 3b92fac8..91a6ac65 100644 --- a/app/pdf/sale_items_pdf.rb +++ b/app/pdf/sale_items_pdf.rb @@ -2,7 +2,7 @@ class SaleItemsPdf < 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,:text_width - def initialize(printer_settings, shop_details, period, type, account, from_date, to_date, shift, sale_items, acc_cate_count, menu_cate_count, total_by_acc) + def initialize(printer_settings, shop_details, period, type, account, from_date, to_date, shift, sale_items, total_other_charges, acc_cate_count, menu_cate_count, total_by_acc) self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width self.page_height = printer_settings.page_height self.header_font_size = printer_settings.header_font_size.to_i @@ -58,7 +58,7 @@ class SaleItemsPdf < Prawn::Document sale_details(period, type, account, from_date, to_date, shift) - sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc) + sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc, total_other_charges) end def header (shop_details) @@ -127,7 +127,7 @@ class SaleItemsPdf < Prawn::Document move_down 10 end - def sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc) + def sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc, total_other_charges) self.item_width = 73 self.price_width = 60 item_label_qty_front_width = (self.item_width+self.price_width) + 2 @@ -144,6 +144,7 @@ class SaleItemsPdf < Prawn::Document total_amount = 0 total_qty = 0 sub_total = 0 + flag = false arr = Array.new @@ -152,10 +153,14 @@ class SaleItemsPdf < Prawn::Document if !arr.include?(item['menu_category_id']) - unless total_qty == 0 and sub_total == 0 + if flag == true + move_down 5 + stroke_horizontal_rule total_details('Sub Total', total_qty, sub_total) end + flag = true + total_qty = 0 sub_total = 0 @@ -173,7 +178,7 @@ class SaleItemsPdf < Prawn::Document y_position = cursor pad_top(15) { 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 => :left, :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 =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :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 } @@ -194,7 +199,7 @@ class SaleItemsPdf < Prawn::Document text_box "#{item['grand_total'].to_i}", :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 } - if item['total_item'].to_i > 0 + if item['total_item'].to_i > 0 or item['status_type'] == 'foc' or item['status_type'] == 'void' total_qty += item['total_item'].to_i total_items += item['total_item'].to_i end @@ -204,11 +209,17 @@ class SaleItemsPdf < Prawn::Document arr.push(item['menu_category_id']) end - # stroke_horizontal_rule + move_down 5 + stroke_horizontal_rule total_details('Sub Total', total_qty, sub_total) move_down 5 + move_down 5 + stroke_horizontal_rule total_details('Total Amount', total_items, total_amount) - move_down 10 + + other_charges = get_other_charges(total_other_charges) + total_details('Total Other Amount', nil, other_charges) + move_down 20 end end @@ -220,8 +231,6 @@ class SaleItemsPdf < Prawn::Document item_label_total_front_width = (self.item_width+self.price_width) + 2 item_label_total_end_width = 64 - move_down 5 - stroke_horizontal_rule y_position = cursor pad_top(15) { text_box "#{col_name}", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix @@ -230,4 +239,15 @@ class SaleItemsPdf < Prawn::Document } end + def get_other_charges(total_other_charges) + other_sub_total = 0 + unless total_other_charges.nil? + total_other_charges.each do |charges| + other_sub_total += charges.grand_total + end + end + + return other_sub_total + end + end diff --git a/app/pdf/sale_items_star_pdf.rb b/app/pdf/sale_items_star_pdf.rb index 8ce08f28..b407cf86 100644 --- a/app/pdf/sale_items_star_pdf.rb +++ b/app/pdf/sale_items_star_pdf.rb @@ -2,7 +2,7 @@ class SaleItemsStarPdf < 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,:text_width - def initialize(printer_settings, shop_details, period, type, account, from_date, to_date, shift, sale_items, acc_cate_count, menu_cate_count, total_by_acc) + def initialize(printer_settings, shop_details, period, type, account, from_date, to_date, shift, sale_items, total_other_charges, acc_cate_count, menu_cate_count, total_by_acc) self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width self.page_height = printer_settings.page_height self.header_font_size = printer_settings.header_font_size.to_i @@ -58,7 +58,7 @@ class SaleItemsStarPdf < Prawn::Document sale_details(period, type, account, from_date, to_date, shift) - sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc) + sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc, total_other_charges) end def header (shop_details) @@ -127,7 +127,7 @@ class SaleItemsStarPdf < Prawn::Document move_down 10 end - def sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc) + def sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc, total_other_charges) self.item_width = 73 self.price_width = 35 item_label_qty_front_width = (self.item_width+self.price_width) + 2 @@ -152,9 +152,11 @@ class SaleItemsStarPdf < Prawn::Document if !arr.include?(item['menu_category_id']) - unless total_qty == 0 and sub_total == 0 - total_details('Sub Total', total_qty, sub_total) - end + if flag == true + move_down 5 + stroke_horizontal_rule + total_details('Sub Total', total_qty, sub_total) + end total_qty = 0 sub_total = 0 @@ -194,7 +196,7 @@ class SaleItemsStarPdf < Prawn::Document text_box "#{item['grand_total'].to_i}", :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 } - if item['total_item'].to_i > 0 + if item['total_item'].to_i > 0 or item['status_type'] == 'foc' or item['status_type'] == 'void' total_qty += item['total_item'].to_i total_items += item['total_item'].to_i end @@ -204,11 +206,17 @@ class SaleItemsStarPdf < Prawn::Document arr.push(item['menu_category_id']) end - # stroke_horizontal_rule + move_down 5 + stroke_horizontal_rule total_details('Sub Total', total_qty, sub_total) move_down 5 + move_down 5 + stroke_horizontal_rule total_details('Total Amount', total_items, total_amount) - move_down 10 + + other_charges = get_other_charges(total_other_charges) + total_details('Total Other Amount', nil, other_charges) + move_down 20 end end @@ -220,8 +228,6 @@ class SaleItemsStarPdf < Prawn::Document item_label_total_front_width = (self.item_width+self.price_width) + 2 item_label_total_end_width = 64 - move_down 5 - stroke_horizontal_rule y_position = cursor pad_top(15) { text_box "#{col_name}", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix @@ -230,4 +236,15 @@ class SaleItemsStarPdf < Prawn::Document } end + def get_other_charges(total_other_charges) + other_sub_total = 0 + unless total_other_charges.nil? + total_other_charges.each do |charges| + other_sub_total += charges.grand_total + end + end + + return other_sub_total + end + end diff --git a/dump.rdb b/dump.rdb index 55991a961be21afb68a1f837181456658497ba6a..cfefa63bd033120c872b15045cbd92045a6778fb 100644 GIT binary patch literal 1343 zcmaJ>&5P4O6rYr~+O1oph_WKI4jwyYk~C==4_45_qJkfIQmNBq+6I%RO(qLP_HPhR zqTcjR(1Ry8yL<8E#e-LGf=3k(v8+y0w);WSYu@j@{65~ByVtL+-@_PdQNg38<)aPi zfg|LET99~K8moV@D z+4*|m3GdIIH(ZlSHtFiJibdVPEka0-5Q8e&+&Hi(%k_xu(`=U#Ru&bdr6_8vq12_8 zCQ7oJ?FRlN1X*j?b9dVx+PjsfaNzoENE`}vxIZ1%ASdcEYIZ7wK|LNMV+G^7)(};# z*{H#hWx^SYoLGa5^sARwO~>z;bi;N>4jr=U)r#Q`jllEh(3n77QfhD<(17|-e*jI| zBLT46mrf6?{-87REZ4Kx1U{<4>ZU+>p;{Cyv%20s_f2^D*ee~;3OAFSNYK8gf zpVHQNso$cq{RtevjwcsqA}V19l#T|ry^=|ZNew}!upg{1ED0)wI{&8_f~4u%Y(2pA z)sJ_#Vo`}~G2gSK=A~o#4>S3BD8h+25}Qq*-?{l^iFqo*GH0_uC9s)8QgqHwBBeN& zno?{ciMyOq)DV_J;lQM{OT*gs3otcqe|*10qk^Q_*?vayjU|pZIb?C!2{y!MT}}!m zCVPlQV)Kkbs#tlpD+wCoHz$5G7UUC9@qXiGNR!F&8v>ws=rs$^{QLfPuOFGk*Z%>G C->JC( delta 576 zcmY*W&ui0Q7*5i!KhoCL)v`hd62rzkG+XjzP17I}^fW~At}?zRU$HApiYlo zZ2iE)KoI|e!BjlisO+f!fDAl&5MehDv#9CH5DzcB@VxKyKJW94^PkwEBz@UGym^$1 z0&EHnc0Rn#6{({la=U`(W8`#f98s!k5*Y|gm;?$y7QG=Q_=+GrP$Yk;3)GW`fgIH0p8?xM&J6Yg4B z6=X4{CO=E#{>k!FCO?HPC*(>3-QInkyOT%(3x;cAXrqoMiz;kt5^N$YH&p{E5TyH& zg~N0g*#QPtuj_u)-{||KM4x+5Mj@|B&1M@)vI5l=$Q8~giqhac%j9QV4L(Gh+=Wx7 z6Kt6HuI+jb?uFc?qT%+8$oFy281S0DT%NtaYd84W6Z+!mEo*aY!}BfIx55E`tHE>k zX>99@T!FSsZe3rieWiD{gVKL``Fo%f1%sFZ9gM=cnYxw&#g( Date: Tue, 4 Jun 2019 09:39:30 +0630 Subject: [PATCH 4/7] SaleItemsPdf updated --- .../reports/saleitem_controller.rb | 2 -- app/models/printer/cashier_station_printer.rb | 4 ++-- app/models/sale.rb | 3 ++- dump.rdb | Bin 1343 -> 1304 bytes 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/controllers/reports/saleitem_controller.rb b/app/controllers/reports/saleitem_controller.rb index cc44be48..5beb919e 100755 --- a/app/controllers/reports/saleitem_controller.rb +++ b/app/controllers/reports/saleitem_controller.rb @@ -140,8 +140,6 @@ class Reports::SaleitemController < BaseReportController printer.print_sale_items_report(print_settings, shop_details, period_name, @type, account_type, from, to, shift_name, @sale_data, @total_other_charges) end - - respond_to do |format| format.html { redirect_to '/en/reports/saleitem/', notice: 'Printing Completed.'} format diff --git a/app/models/printer/cashier_station_printer.rb b/app/models/printer/cashier_station_printer.rb index d5ac2e73..a98ed730 100755 --- a/app/models/printer/cashier_station_printer.rb +++ b/app/models/printer/cashier_station_printer.rb @@ -84,11 +84,11 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker def print_sale_items_report(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items, total_other_charges) filename = "tmp/reports_sale_items.pdf" - if print_settings.unique_code == "CloseCashierPdf" + if print_settings.unique_code == "SaleItemsPdf" pdf = SaleItemsPdf.new(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items, total_other_charges, nil, nil, nil) puts 'Printing!!!!' end - if print_settings.unique_code == "CloseCashierStarPdf" + if print_settings.unique_code == "SaleItemsStarPdf" pdf = SaleItemsStarPdf.new(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items, total_other_charges, nil, nil, nil) puts 'PrintingStar!!!!' end diff --git a/app/models/sale.rb b/app/models/sale.rb index 81322e77..be7989db 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -1016,7 +1016,8 @@ def self.get_item_query(type) query = query.joins(" JOIN accounts acc ON acc.id = i.account_id") query = query.where("#{sale_type}") query = query.group("acc.title,i.account_id,i.menu_category_code,i.item_instance_code,i.product_name,i.unit_price") - .order("acc.title desc, i.account_id desc, i.menu_category_code desc, i.unit_price asc") + .order("acc.title desc, i.account_id desc, SUM(i.qty) desc, i.menu_category_code desc, i.unit_price asc") + # query = query.order("SUM(i.qty) desc") end def self.get_other_charges() diff --git a/dump.rdb b/dump.rdb index 31fb9928329e5bcc7ff324e7e7ab3adfe6970fc9..00f10dc5b3043bafa20482f470f1183801e5e817 100644 GIT binary patch delta 128 zcmV-`0Du3#3YZFzF(}Ij^<4T0b#rB8Ep26O!e9Um0QwAJZ)PoUa%Ev{Vr*r=0R8~` zAPtj10v3^PMFd(MD;<%zI1M&3G&3_UGB-0hFgY`^{apc*zylYPm;#9i`3|7dj{yJx ilYs&hlRX0p1o;l2(~}PZ7_(yo)By-fZkLJpk$}m89WA2( delta 139 zcmV;60CfMD3cm`FF(`uc^j!J~b#rB8Ep26O!k`)&0QwAJZ)PoUa%Ev{Vr*r=0R8~` zAq|s20v3^PMFe&9+Z>U&I1M#7GBh%fn=Cdn Date: Tue, 4 Jun 2019 11:29:24 +0630 Subject: [PATCH 5/7] Other Charges added to CloseCashierPdf and SaleItemsPdf --- app/controllers/origami/shifts_controller.rb | 4 +- app/models/printer/cashier_station_printer.rb | 6 +- app/models/sale.rb | 4 +- app/pdf/close_cashier_pdf.rb | 102 ++++++++++++------ app/pdf/sale_items_pdf.rb | 85 ++++++++------- dump.rdb | Bin 1304 -> 1415 bytes 6 files changed, 124 insertions(+), 77 deletions(-) diff --git a/app/controllers/origami/shifts_controller.rb b/app/controllers/origami/shifts_controller.rb index f5be805e..f28c1428 100755 --- a/app/controllers/origami/shifts_controller.rb +++ b/app/controllers/origami/shifts_controller.rb @@ -95,6 +95,8 @@ class Origami::ShiftsController < BaseOrigamiController @lookup = Lookup.shift_sale_items_lookup_value if @lookup.to_i == 1 @sale_items = Sale.get_shift_sale_items(@shift.id) + other_charges = Sale.get_other_charges() + @total_other_charges_info = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",@shift) end @sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='') @total_waste = Sale.get_total_waste(shift_id).sum(:grand_total) @@ -123,7 +125,7 @@ class Origami::ShiftsController < BaseOrigamiController end find_close_cashier_print = Lookup.collection_of('close_cashier_print') if find_close_cashier_print[0][1].to_i > 0 - printer.print_close_cashier(print_settings,cashier_terminal,@shift, @sale_items, shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments) + printer.print_close_cashier(print_settings,cashier_terminal,@shift, @sale_items, @total_other_charges_info, shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments) end end end diff --git a/app/models/printer/cashier_station_printer.rb b/app/models/printer/cashier_station_printer.rb index a98ed730..ef719810 100755 --- a/app/models/printer/cashier_station_printer.rb +++ b/app/models/printer/cashier_station_printer.rb @@ -38,7 +38,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker # self.print(filename, cashier_terminal.printer_name) # end - def print_close_cashier(printer_settings,cashier_terminal,shift_sale, sale_items,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments) + def print_close_cashier(printer_settings,cashier_terminal,shift_sale, sale_items, total_other_charges_info,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments) if !sale_items.blank? or !sale_items.nil? @account_cate_count = Hash.new {|hash, key| hash[key] = 0} @@ -59,7 +59,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker cashier = shift_sale.employee.name shift_name = shift_sale.shift_started_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") + "_" + shift_sale.shift_closed_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") filename = "tmp/close_cashier_#{cashier}_#{shift_name}.pdf" - pdf = CloseCashierPdf.new(printer_settings,shift_sale, sale_items, @account_cate_count, @menu_cate_count, @totalByAccount, shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments) + pdf = CloseCashierPdf.new(printer_settings,shift_sale, sale_items, total_other_charges_info, @account_cate_count, @menu_cate_count, @totalByAccount, shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments) close_cashier_pdf = Lookup.collection_of("print_settings") #print_settings with name:CloseCashierPdf if !close_cashier_pdf.empty? @@ -68,7 +68,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker if close_cashier[1] == '1' pdf = CloseCashierCustomisePdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments) else - pdf = CloseCashierPdf.new(printer_settings,shift_sale, sale_items, @account_cate_count, @menu_cate_count, @totalByAccount, shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments) + pdf = CloseCashierPdf.new(printer_settings,shift_sale, sale_items, total_other_charges_info, @account_cate_count, @menu_cate_count, @totalByAccount, shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments) end end end diff --git a/app/models/sale.rb b/app/models/sale.rb index be7989db..ebd45b8a 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -1016,8 +1016,8 @@ def self.get_item_query(type) query = query.joins(" JOIN accounts acc ON acc.id = i.account_id") query = query.where("#{sale_type}") query = query.group("acc.title,i.account_id,i.menu_category_code,i.item_instance_code,i.product_name,i.unit_price") - .order("acc.title desc, i.account_id desc, SUM(i.qty) desc, i.menu_category_code desc, i.unit_price asc") - # query = query.order("SUM(i.qty) desc") + .order("acc.title desc, i.account_id desc, i.menu_category_code desc, i.item_instance_code asc, SUM(i.qty) desc, i.unit_price asc") + # query = query.order("i.menu_category_name asc, SUM(i.qty) desc") end def self.get_other_charges() diff --git a/app/pdf/close_cashier_pdf.rb b/app/pdf/close_cashier_pdf.rb index 100b4bfb..9ff2f17a 100755 --- a/app/pdf/close_cashier_pdf.rb +++ b/app/pdf/close_cashier_pdf.rb @@ -2,7 +2,7 @@ class CloseCashierPdf < 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,:text_width - def initialize(printer_settings, shift_sale, sale_items, acc_cate_count, menu_cate_count, total_by_acc, shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments) + def initialize(printer_settings, shift_sale, sale_items, total_other_charges_info, acc_cate_count, menu_cate_count, total_by_acc, shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments) self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width self.page_height = printer_settings.page_height self.header_font_size = printer_settings.header_font_size.to_i @@ -57,7 +57,7 @@ class CloseCashierPdf < Prawn::Document shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,printer_settings.precision,delimiter,total_waste,total_spoile,total_other_charges,total_credit_payments) if !sale_items.nil? or !sale_items.blank? - sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc, total_other_charges) + sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc, total_other_charges_info) end end @@ -505,13 +505,6 @@ class CloseCashierPdf < Prawn::Document end def sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc, total_other_charges) - self.item_width = 73 - self.price_width = 60 - item_label_qty_front_width = (self.item_width+self.price_width) + 2 - item_label_qty_end_width = 32 - item_label_total_front_width = (self.item_width+self.price_width) + 2 - item_label_total_end_width = 64 - y_position = cursor bounding_box([0,y_position], :width =>self.page_width - 10, :height => 20) do text "Sale Items Summary", :size => self.header_font_size, :align => :center @@ -547,33 +540,23 @@ class CloseCashierPdf < Prawn::Document text "#{item['menu_category_name']}", :size => self.header_font_size, :align => :left end - # write_stroke_dash - # dash(1, :space => 1, :phase => 1) - # stroke_horizontal_rule - # move_down 2 - y_position = cursor - pad_top(15) { - 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 =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :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 - } + add_item_line('Items', 'Price', 'Qty', 'Total') move_down 2 stroke_horizontal_rule end - move_down 3 - y_position = cursor - pad_top(15) { - bounding_box([0,y_position], :width =>self.item_width) do - text "#{item['product_name']}", :size => self.item_font_size, :align => :left#, :overflow => :shrink_to_fix - end - text_box "#{item['unit_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 "#{item['total_item'].to_i}", :at =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix - text_box "#{item['grand_total'].to_i}", :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 - } + # y_position = cursor + # pad_top(15) { + # bounding_box([0,y_position], :width =>self.item_width) do + # text "#{item['product_name']}", :size => self.item_font_size, :align => :left#, :overflow => :shrink_to_fix + # end + # text_box "#{item['unit_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 "#{item['total_item'].to_i}", :at =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix + # text_box "#{item['grand_total'].to_i}", :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 + # } + add_item_line(item['product_name'], item['unit_price'].to_i, item['total_item'].to_i, item['grand_total'].to_i) if item['total_item'].to_i > 0 or item['status_type'] == 'foc' or item['status_type'] == 'void' total_qty += item['total_item'].to_i @@ -589,16 +572,66 @@ class CloseCashierPdf < Prawn::Document stroke_horizontal_rule total_details('Sub Total', total_qty, sub_total) move_down 5 + total_other_amount, total_other_item = other_charges_detail(total_other_charges) + + total_items += total_other_item + total_amount += total_other_amount move_down 5 stroke_horizontal_rule total_details('Total Amount', total_items, total_amount) - - # other_charges = get_other_charges(total_other_charges) - total_details('Total Other Amount', nil, total_other_charges) - move_down 20 end end + def other_charges_detail(total_other_charges) + total_charges = 0 + total_charges_items = 0 + + unless total_other_charges.nil? + y_position = cursor + bounding_box([0,y_position], :width =>self.page_width - 10, :height => 20) do + text "Other Charges", :size => self.header_font_size, :align => :left + end + + move_down 5 + add_item_line('Items', 'Price', 'Qty', 'Total') + move_down 2 + stroke_horizontal_rule + + total_other_charges.each do |charges| + move_down 3 + add_item_line(charges['product_name'], charges['unit_price'].to_i, charges['total_item'].to_i, charges['grand_total'].to_i) + + total_charges_items += charges['total_item'].to_i + total_charges += charges['grand_total'].to_i + end + end + + move_down 5 + stroke_horizontal_rule + total_details('Total Charges Amount', total_charges_items, total_charges) + + return total_charges, total_charges_items + end + + def add_item_line(product_name, unit_price, total_item, grand_total) + self.item_width = 73 + self.price_width = 60 + item_label_qty_front_width = (self.item_width+self.price_width) + 2 + item_label_qty_end_width = 32 + item_label_total_front_width = (self.item_width+self.price_width) + 2 + item_label_total_end_width = 64 + + y_position = cursor + pad_top(15) { + bounding_box([0,y_position], :width =>self.item_width) do + text "#{product_name}", :size => self.item_font_size, :align => :left#, :overflow => :shrink_to_fix + end + text_box "#{unit_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 "#{total_item}", :at =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix + text_box "#{grand_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 + } + end + def total_details(col_name, total_qty, sub_total) self.item_width = 73 self.price_width = 60 @@ -607,7 +640,6 @@ class CloseCashierPdf < Prawn::Document item_label_total_front_width = (self.item_width+self.price_width) + 2 item_label_total_end_width = 64 - y_position = cursor pad_top(15) { text_box "#{col_name}", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix diff --git a/app/pdf/sale_items_pdf.rb b/app/pdf/sale_items_pdf.rb index 91a6ac65..f27d5f35 100644 --- a/app/pdf/sale_items_pdf.rb +++ b/app/pdf/sale_items_pdf.rb @@ -59,6 +59,7 @@ class SaleItemsPdf < Prawn::Document sale_details(period, type, account, from_date, to_date, shift) sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc, total_other_charges) + move_down 10 end def header (shop_details) @@ -128,13 +129,6 @@ class SaleItemsPdf < Prawn::Document end def sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc, total_other_charges) - self.item_width = 73 - self.price_width = 60 - item_label_qty_front_width = (self.item_width+self.price_width) + 2 - item_label_qty_end_width = 32 - item_label_total_front_width = (self.item_width+self.price_width) + 2 - item_label_total_end_width = 64 - y_position = cursor bounding_box([0,y_position], :width =>self.page_width - 10, :height => 20) do text "Sale Items Summary", :size => self.header_font_size, :align => :center @@ -171,33 +165,14 @@ class SaleItemsPdf < Prawn::Document text "#{item['menu_category_name']}", :size => self.header_font_size, :align => :left end - # write_stroke_dash - # dash(1, :space => 1, :phase => 1) - # stroke_horizontal_rule - # move_down 2 - y_position = cursor - pad_top(15) { - 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 =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :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 - } + add_item_line('Items', 'Price', 'Qty', 'Total') move_down 2 stroke_horizontal_rule end move_down 3 - - y_position = cursor - pad_top(15) { - bounding_box([0,y_position], :width =>self.item_width) do - text "#{item['product_name']}", :size => self.item_font_size, :align => :left#, :overflow => :shrink_to_fix - end - text_box "#{item['unit_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 "#{item['total_item'].to_i}", :at =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix - text_box "#{item['grand_total'].to_i}", :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 - } + add_item_line(item['product_name'], item['unit_price'].to_i, item['total_item'].to_i, item['grand_total'].to_i) if item['total_item'].to_i > 0 or item['status_type'] == 'foc' or item['status_type'] == 'void' total_qty += item['total_item'].to_i @@ -213,13 +188,13 @@ class SaleItemsPdf < Prawn::Document stroke_horizontal_rule total_details('Sub Total', total_qty, sub_total) move_down 5 + total_other_amount, total_other_item = other_charges_detail(total_other_charges) + + total_items += total_other_item + total_amount += total_other_amount move_down 5 stroke_horizontal_rule total_details('Total Amount', total_items, total_amount) - - other_charges = get_other_charges(total_other_charges) - total_details('Total Other Amount', nil, other_charges) - move_down 20 end end @@ -239,15 +214,53 @@ class SaleItemsPdf < Prawn::Document } end - def get_other_charges(total_other_charges) - other_sub_total = 0 + def other_charges_detail(total_other_charges) + total_charges = 0 + total_charges_items = 0 + unless total_other_charges.nil? + y_position = cursor + bounding_box([0,y_position], :width =>self.page_width - 10, :height => 20) do + text "Other Charges", :size => self.header_font_size, :align => :left + end + + move_down 5 + add_item_line('Items', 'Price', 'Qty', 'Total') + move_down 2 + stroke_horizontal_rule + total_other_charges.each do |charges| - other_sub_total += charges.grand_total + move_down 3 + add_item_line(charges['product_name'], charges['unit_price'].to_i, charges['total_item'].to_i, charges['grand_total'].to_i) + + total_charges_items += charges['total_item'].to_i + total_charges += charges['grand_total'].to_i end end - return other_sub_total + move_down 5 + stroke_horizontal_rule + total_details('Total Charges Amount', total_charges_items, total_charges) + + return total_charges, total_charges_items end + def add_item_line(product_name, unit_price, total_item, grand_total) + self.item_width = 73 + self.price_width = 60 + item_label_qty_front_width = (self.item_width+self.price_width) + 2 + item_label_qty_end_width = 32 + item_label_total_front_width = (self.item_width+self.price_width) + 2 + item_label_total_end_width = 64 + + y_position = cursor + pad_top(15) { + bounding_box([0,y_position], :width =>self.item_width) do + text "#{product_name}", :size => self.item_font_size, :align => :left#, :overflow => :shrink_to_fix + end + text_box "#{unit_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 "#{total_item}", :at =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix + text_box "#{grand_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 + } + end end diff --git a/dump.rdb b/dump.rdb index 00f10dc5b3043bafa20482f470f1183801e5e817..0846110ca6414d7928a6fe22d5c139742961c970 100644 GIT binary patch delta 608 zcmaKpKX21O7>6(Cvmp&_q|ic}C~f3c1&O$_FR|kohGa#mI+U$QaJDZHVaG{qBUK2o zAh9sC+yG*te1b>}jB)6K`UQ{>GXpb!M2JeA1Q1iVTb}o)d!83FPf~lz<;~%@o5QoA zPi@Ji?z^750EXv?*O1y>N?g;S5jY0FR@3Y!TxT_SaleNcLaWS1RdxgBS&tJgK%o=T zkot);Hf@m52}a4+nLay)xqX)Bv)o>YWm5s8dRZA5WnW4WM z0lpJ9X}~v#<5SdZHN3;x+uGsE1M#ls2QA`K(GV?`Pvo{WEX#_#p;S~AtGFn(o3=Rq zC$AR8fZQouowZ&6mQC+FUfZRupirN+yp|PqyR>EPiUuxRN>BBQ#*R1<%$_ES=l{1P zJ{%oA+xifjSmw%8-9oHc`S*-9Od{|T`Ro&?up^Xbx4ES_31W4)z;?JCUy&3&VoA8h zPw%DSVoH9}t^`1|qauUpsqKekT*j|jx? delta 500 zcmYk3J#W)c7=^Fx>oznbLx_T!kP=xHAh64|9mlbue9T=Kn4l89v9D2tKa$u+>Hq>U zAU3RbfD!Qv7!gYySU^Y!iC=)=FMwzXA5K`<&wI{!pYyQ%bmg&n>V4_k_CYC)nX3dW zc)f!v=-@DoJY_UtG#L0SN59d}P6e)T4S0buoaQ#SNseaM+GpCgID~N1iCm`nbYSZ} zqS_9zD5V~y4l}SgPKPWJJ?h5{4;W2qs$p10PwVRXhGyy(v2;90HNni;T(`D(2BGqzxkraSbMyM2t? Date: Tue, 4 Jun 2019 11:30:24 +0630 Subject: [PATCH 6/7] puma.rb --- config/initializers/action_controller.rb | 10 +++++----- config/puma.rb | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index 85f38ec5..205c330a 100644 --- a/config/initializers/action_controller.rb +++ b/config/initializers/action_controller.rb @@ -21,11 +21,11 @@ class ActionController::Base end else # check for license file - # if check_license - # current_license(ENV["SX_PROVISION_URL"]) - # else - # redirect_to activate_path - # end + if check_license + current_license(ENV["SX_PROVISION_URL"]) + else + redirect_to activate_path + end end end diff --git a/config/puma.rb b/config/puma.rb index 99c23b5a..c42b69ae 100755 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,11 +1,11 @@ -# application_path="#{File.expand_path("../..", __FILE__)}" -# directory application_path -# #environment ENV.fetch("RAILS_ENV") { "production" } -# environment "production" -# pidfile "#{application_path}/tmp/puma/pid" -# state_path "#{application_path}/tmp/puma/state" -# stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" -# port ENV.fetch("PORT") { 62158 } -# workers 2 -# preload_app! +application_path="#{File.expand_path("../..", __FILE__)}" +directory application_path +#environment ENV.fetch("RAILS_ENV") { "production" } +environment "production" +pidfile "#{application_path}/tmp/puma/pid" +state_path "#{application_path}/tmp/puma/state" +stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" +port ENV.fetch("PORT") { 62158 } +workers 2 +preload_app! From 3c89891f2f4e02b4ba5ad1fd9579eab7e939802d Mon Sep 17 00:00:00 2001 From: NyanLinHtut Date: Tue, 4 Jun 2019 18:55:42 +0630 Subject: [PATCH 7/7] fixed shift sales print --- app/controllers/reports/shiftsale_controller.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/reports/shiftsale_controller.rb b/app/controllers/reports/shiftsale_controller.rb index 0a969ca0..0c42a05f 100755 --- a/app/controllers/reports/shiftsale_controller.rb +++ b/app/controllers/reports/shiftsale_controller.rb @@ -94,8 +94,9 @@ class Reports::ShiftsaleController < BaseReportController print_settings = PrintSetting.find_by_unique_code(unique_code) printer = Printer::CashierStationPrinter.new(print_settings) - printer.print_close_cashier(print_settings,cashier_terminal,@shift, nil, shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments) - + # printer.print_close_cashier(print_settings,cashier_terminal,@shift, nil, shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments) + printer.print_close_cashier(print_settings,cashier_terminal,@shift, @sale_items, @total_other_charges_info, shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments) + respond_to do |format| format.html { redirect_to '/en/reports/shiftsale/', notice: 'Printing Completed.'} format