diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 15e8a986..639a763b 100755 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -103,4 +103,8 @@ i.logout_icon{ /* Second display image */ .second-display{ margin : 12px; +} + +.float_right{ + float : right; } \ No newline at end of file diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 9022d85e..215a0cfd 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -77,9 +77,11 @@ class Origami::PaymentsController < BaseOrigamiController item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale_items) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale_items) + other_amount = SaleItem.calculate_other_charges(sale_items) + printer = Printer::ReceiptPrinter.new(print_settings) - filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_detail, "Frt",current_balance,nil) + filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_detail, "Frt",current_balance,nil,other_amount) result = { :filepath => filename, @@ -216,9 +218,10 @@ class Origami::PaymentsController < BaseOrigamiController # Calculate Food and Beverage Total item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items) + other_amount = SaleItem.calculate_other_charges(sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Paid",current_balance,card_data) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Paid",current_balance,card_data,other_amount) render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error ", :filename => filename, :receipt_no => sale_receipt_no, :printer_name => printer_name}) @@ -475,9 +478,10 @@ class Origami::PaymentsController < BaseOrigamiController # Calculate price_by_accounts item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items) - + 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) + 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) result = { :status => true, @@ -560,9 +564,11 @@ class Origami::PaymentsController < BaseOrigamiController item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items) + 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,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "FOC",nil,nil) + 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) result = { :status => true, :filepath => filename, diff --git a/app/controllers/origami/shifts_controller.rb b/app/controllers/origami/shifts_controller.rb index fd82d474..81d41565 100755 --- a/app/controllers/origami/shifts_controller.rb +++ b/app/controllers/origami/shifts_controller.rb @@ -101,7 +101,7 @@ class Origami::ShiftsController < BaseOrigamiController print_settings = PrintSetting.find_by_unique_code(unique_code) printer = Printer::CashierStationPrinter.new(print_settings) - printer.print_close_cashier(print_settings,cashier_terminal,@shift,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) + printer.print_close_cashier(print_settings,cashier_terminal,@shift,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 ) end end Employee.logout(session[:session_token]) diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb index 891cd398..76533730 100755 --- a/app/controllers/origami/void_controller.rb +++ b/app/controllers/origami/void_controller.rb @@ -124,9 +124,9 @@ class Origami::VoidController < BaseOrigamiController # Calculate Food and Beverage Total item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items) 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) + 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) 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 d008a54d..e7ca1091 100755 --- a/app/controllers/origami/waste_spoile_controller.rb +++ b/app/controllers/origami/waste_spoile_controller.rb @@ -105,9 +105,9 @@ class Origami::WasteSpoileController < BaseOrigamiController # Calculate Food and Beverage Total item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items) 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) + 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) result = { :filepath => filename, :printer_model => print_settings.brand_name, diff --git a/app/controllers/reports/receipt_no_detail_controller.rb b/app/controllers/reports/receipt_no_detail_controller.rb new file mode 100755 index 00000000..d7b018d7 --- /dev/null +++ b/app/controllers/reports/receipt_no_detail_controller.rb @@ -0,0 +1,71 @@ +class Reports::ReceiptNoDetailController < BaseReportController +authorize_resource :class => false + def index + @payments = [["All Payment",''], ["Cash Payment","cash"], ["Credit Payment","creditnote"], ["FOC Payment","foc"]] + @payment_method = PaymentMethodSetting.all + from, to = get_date_range_from_params + + @shift_sale_range = '' + + @shift = '' + if params[:shift_name].to_i != 0 + + @shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) + + @shift_sale = ShiftSale.find(params[:shift_name]) + if to.blank? + @shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',@shift_sale.shift_started_at) + else + if @shift_sale.shift_closed_at.blank? + @shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL',@shift_sale.shift_started_at) + else + @shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',@shift_sale.shift_started_at, @shift_sale.shift_closed_at) + end + end + end + + payment_type = params[:payment_type] + @sale_data = Sale.get_shift_sales_by_receipt_no_detail(@shift_sale_range,@shift,from,to,payment_type) + + @from = from + @to = to + # get printer info + @print_settings = PrintSetting.get_precision_delimiter() + if @shift.present? + @shift.each do |sh| + @shift_from = sh.shift_started_at.nil? ? '-' : sh.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p") + @shift_to = sh.shift_closed_at.nil? ? '-' : sh.shift_closed_at.utc.getlocal.strftime("%e %b %I:%M%p") + @shift_data = sh + end + end + + respond_to do |format| + format.html + format.xls + end + end + + def show + from, to = get_date_range_from_params + + @sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) + + date_arr = Array.new + @sale_data.each do |sale| + local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p") + local_closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc.getlocal.strftime("%e %b %I:%M%p") + opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc + closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc + shift_id = sale.id.nil? ? '-' : sale.id + str = {:shift_id => shift_id, :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date} + date_arr.push(str) + end + + out = {:status => 'ok', :message => date_arr} + + respond_to do |format| + format.json { render json: out } + end + end + +end \ No newline at end of file diff --git a/app/controllers/reports/saleitem_controller.rb b/app/controllers/reports/saleitem_controller.rb index c49ba894..aff7f3c2 100755 --- a/app/controllers/reports/saleitem_controller.rb +++ b/app/controllers/reports/saleitem_controller.rb @@ -1,7 +1,8 @@ class Reports::SaleitemController < BaseReportController authorize_resource :class => false def index - + + @account = Account.all from, to = get_date_range_from_params shift_sale_range = '' @@ -23,8 +24,9 @@ class Reports::SaleitemController < BaseReportController end end + account_type = params[:account_type] @type = params[:sale_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) + @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_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil) diff --git a/app/models/assigned_order_item.rb b/app/models/assigned_order_item.rb index 64570f7d..38ea7a2a 100755 --- a/app/models/assigned_order_item.rb +++ b/app/models/assigned_order_item.rb @@ -8,6 +8,10 @@ class AssignedOrderItem < ApplicationRecord belongs_to :order_queue_station def self.assigned_order_item (order, item_code, instance_code, order_queue_station ) +<<<<<<< HEAD + AssignedOrderItem.transaction do +======= +>>>>>>> 146f727f462174b1daa31972b597448c12e26d8c assigned_order_item = AssignedOrderItem.new() assigned_order_item.order = order assigned_order_item.item_code = item_code @@ -16,6 +20,10 @@ class AssignedOrderItem < ApplicationRecord assigned_order_item.print_status = false assigned_order_item.delivery_status = false assigned_order_item.save! +<<<<<<< HEAD + end +======= +>>>>>>> 146f727f462174b1daa31972b597448c12e26d8c end def self.assigned_order_item_by_job(order_id) diff --git a/app/models/print_setting.rb b/app/models/print_setting.rb index 59c58001..c1a17c5a 100755 --- a/app/models/print_setting.rb +++ b/app/models/print_setting.rb @@ -3,7 +3,11 @@ class PrintSetting < ApplicationRecord validates_presence_of :name, :unique_code, :printer_name, :api_settings, :page_width, :page_height, :print_copies, :header_font_size, :item_font_size def self.get_precision_delimiter - PrintSetting.find_by_unique_code("CloseCashierPdf") + setting = PrintSetting.find_by_unique_code("CloseCashierPdf") + if setting.nil? + setting = PrintSetting.find_by_unique_code("CloseCashierCustomisePdf") + end + return setting end end diff --git a/app/models/printer/cashier_station_printer.rb b/app/models/printer/cashier_station_printer.rb index 73813d1a..f6473df4 100755 --- a/app/models/printer/cashier_station_printer.rb +++ b/app/models/printer/cashier_station_printer.rb @@ -37,7 +37,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker # pdf.render_file filename # self.print(filename, cashier_terminal.printer_name) # end - + def print_close_cashier(printer_settings,cashier_terminal,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile) #Use CUPS service @@ -46,16 +46,16 @@ 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,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_waste,total_spoile) + pdf = CloseCashierPdf.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) close_cashier_pdf = Lookup.collection_of("print_settings") #print_settings with name:CloseCashierPdf if !close_cashier_pdf.empty? close_cashier_pdf.each do |close_cashier| if close_cashier[0] == 'CloseCashierCustomisePdf' 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) + 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) else - pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_waste,total_spoile) + pdf = CloseCashierPdf.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) end end end diff --git a/app/models/printer/receipt_printer.rb b/app/models/printer/receipt_printer.rb index 2c925384..f77fc96c 100755 --- a/app/models/printer/receipt_printer.rb +++ b/app/models/printer/receipt_printer.rb @@ -188,19 +188,19 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker end #Bill Receipt Print - def print_receipt_bill(printer_settings,cashier_terminal,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details, printed_status,balance,card_data) + def print_receipt_bill(printer_settings,cashier_terminal,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details, printed_status,balance,card_data,other_amount) #Use CUPS service #Generate PDF #Print - pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data) + pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount) receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf if !receipt_bill_a5_pdf.empty? receipt_bill_a5_pdf.each do |receipt_bilA5| if receipt_bilA5[0] == 'ReceiptBillA5Pdf' if receipt_bilA5[1] == '1' - pdf = ReceiptBillA5Pdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data) + pdf = ReceiptBillA5Pdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount) else - pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data) + pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount) end end end diff --git a/app/models/sale.rb b/app/models/sale.rb index 1d1f5b56..3a0035df 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -913,9 +913,14 @@ def self.get_other_charges() query = query.group("i.sale_item_id") end -def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type) +def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,account_type) # date_type_selection = get_sql_function_for_report_type(report_type) - + if account_type.blank? + account_type = '' + else + account_type = " and acc.title = '#{account_type}'" + end + query = self.get_item_query(type) discount_query = 0 @@ -931,7 +936,7 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type) product = self.get_product_sale() if shift.present? - query = query.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a) + query = query.where("sales.shift_sale_id IN (?) #{account_type} and sale_status='completed'",shift.to_a) if type.nil? || type == 'all' || type == "other" other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a) end @@ -954,7 +959,7 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type) ### => get all sales range in shift_sales elsif shift_sale_range.present? - query = query.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a) + query = query.where("sales.shift_sale_id IN (?) #{account_type} and sale_status='completed'",shift_sale_range.to_a) if type.nil? || type == 'all' || type == "other" other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a) end @@ -977,11 +982,13 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type) total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f else - query = query.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to) + query = query.where("sales.receipt_date between ? and ? #{account_type} and sale_status='completed'",from,to) + if type.nil? || type == 'all' || type == "other" other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to) end product = product.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to) + discount_query = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount) change_amount = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed) sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount, @@ -1061,6 +1068,37 @@ def self.get_shift_sales_by_receipt_no(shift_sale_range,shift,from,to,payment_ty return query end +def self.get_shift_sales_by_receipt_no_detail(shift_sale_range,shift,from,to,payment_type) + ## => left join -> show all sales although no orders + if payment_type.blank? + payment_type = '' + else + payment_type = " and sale_payments.payment_method = '#{payment_type}'" + end + + query = Sale.select("sales.*,dining_facilities.name as table_name,dining_facilities.type as table_type") + if shift.present? + query = query.where("sales.shift_sale_id in (?) #{payment_type} and sale_status= 'completed' and sale_payments.payment_amount != 0", shift.to_a) + .joins("join sale_payments on sale_payments.sale_id = sales.sale_id") + .joins("join bookings on bookings.sale_id = sales.sale_id") + .joins("join dining_facilities on dining_facilities.id = bookings.dining_facility_id") + .group("sales.sale_id") + elsif shift_sale_range.present? + query = query.where("sale_status='completed' #{payment_type} and sale_payments.payment_amount != 0 and sales.shift_sale_id in (?)",shift_sale_range.to_a) + .joins("join sale_payments on sale_payments.sale_id = sales.sale_id") + .joins("join bookings on bookings.sale_id = sales.sale_id") + .joins("join dining_facilities on dining_facilities.id = bookings.dining_facility_id") + .group("sales.sale_id") + else + query = query.where("sale_status='completed' and sales.receipt_date between ? and ? #{payment_type} and sale_payments.payment_amount != 0",from,to) + .joins("join sale_payments on sale_payments.sale_id = sales.sale_id") + .joins("join bookings on bookings.sale_id = sales.sale_id") + .joins("join dining_facilities on dining_facilities.id = bookings.dining_facility_id") + .group("sales.sale_id") + end + return query +end + def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to) query = SalePayment.select("s.receipt_no, sale_payments.*,s.receipt_date as sale_date, s.cashier_name as cashier_name") diff --git a/app/models/sale_item.rb b/app/models/sale_item.rb index 3d5a659c..62db6097 100755 --- a/app/models/sale_item.rb +++ b/app/models/sale_item.rb @@ -150,6 +150,19 @@ class SaleItem < ApplicationRecord return price,type end + # Get Prices for each accounts (eg: food, beverage) + def self.calculate_other_charges(sale_items) + total = 0 + # Check for actual sale items + sale_items.each do |si| + if si.product_code == "Other Charges" && si.item_instance_code == nil + total = total + si.price + end + end + + return total + end + # def self.get_overall_discount(sale_id) # price = 0.0 # item=SaleItem.where("product_code=?", sale_id) diff --git a/app/models/sale_order.rb b/app/models/sale_order.rb index 631a5e62..600bc41f 100755 --- a/app/models/sale_order.rb +++ b/app/models/sale_order.rb @@ -8,10 +8,18 @@ class SaleOrder < ApplicationRecord belongs_to :order def create_sale_order(sale, order) +<<<<<<< HEAD + SaleOrder.transaction do +======= +>>>>>>> 146f727f462174b1daa31972b597448c12e26d8c sale_order = SaleOrder.new sale_order.sale_id = sale sale_order.order_id = order sale_order.save! +<<<<<<< HEAD + end +======= +>>>>>>> 146f727f462174b1daa31972b597448c12e26d8c end private diff --git a/app/pdf/close_cashier_pdf.rb b/app/pdf/close_cashier_pdf.rb index 3888c549..461022c1 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,shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,total_waste,total_spoile) + def initialize(printer_settings, shift_sale,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) 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 @@ -54,7 +54,7 @@ class CloseCashierPdf < Prawn::Document stroke_horizontal_rule - 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) + 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) end def header (shop_details) @@ -70,7 +70,7 @@ class CloseCashierPdf < Prawn::Document stroke_horizontal_rule end - def shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_waste,total_spoile) + def shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_waste,total_spoile,total_other_charges) move_down 7 y_position = cursor bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do @@ -449,6 +449,14 @@ class CloseCashierPdf < Prawn::Document text "#{number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right end end + + y_position = cursor + bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do + text "Total Other Amount :", :size => self.item_font_size, :align => :right + end + bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do + text "#{total_other_charges}", :size => self.item_font_size, :align => :right + end #end total amount by Account y_position = cursor diff --git a/app/pdf/receipt_bill_a5_pdf.rb b/app/pdf/receipt_bill_a5_pdf.rb index 4f6969c5..f6555bcb 100644 --- a/app/pdf/receipt_bill_a5_pdf.rb +++ b/app/pdf/receipt_bill_a5_pdf.rb @@ -2,7 +2,7 @@ class ReceiptBillA5Pdf < 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) + 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) 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 @@ -79,6 +79,9 @@ class ReceiptBillA5Pdf < Prawn::Document if shop_details.show_account_info items_account(item_price_by_accounts,printer_settings.precision,delimiter) + if other_charges_amount + show_other_charges_amount(other_charges_amount,printer_settings.precision,delimiter) + end end #start for individual payment @@ -537,6 +540,17 @@ class ReceiptBillA5Pdf < Prawn::Document end end + def show_other_charges_amount(other_amount,precision,delimiter) + y_position = cursor + bounding_box([0,y_position], :width =>self.label_width) do + text "Other Charges", :size => self.item_font_size,:align => :left + end + 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 + end + #individual payment per person def individual_payment(sale_data, precision, delimiter) per_person = sale_data.grand_total.to_i / sale_data.equal_persons.to_i diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 9a1f92b1..80a57c51 100755 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -3,7 +3,7 @@ class ReceiptBillPdf < Prawn::Document attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :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) + 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) 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 @@ -80,6 +80,9 @@ class ReceiptBillPdf < Prawn::Document if shop_details.show_account_info items_account(item_price_by_accounts,printer_settings.precision,delimiter) + if other_charges_amount + show_other_charges_amount(other_charges_amount,printer_settings.precision,delimiter) + end end #start for individual payment @@ -536,6 +539,17 @@ class ReceiptBillPdf < Prawn::Document end end + def show_other_charges_amount(other_amount,precision,delimiter) + y_position = cursor + bounding_box([0,y_position], :width =>self.label_width) do + text "Other Charges", :size => self.item_font_size,:align => :left + end + 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 + end + #individual payment per person def individual_payment(sale_data, survey, precision, delimiter) # per_person = sale_data.grand_total.to_f / survey.total_customer.to_i diff --git a/app/views/layouts/_left_sidebar.html.erb b/app/views/layouts/_left_sidebar.html.erb index f83284ae..0d324b95 100644 --- a/app/views/layouts/_left_sidebar.html.erb +++ b/app/views/layouts/_left_sidebar.html.erb @@ -143,6 +143,9 @@
  • Receipt
  • +
  • + Receipt Detail +
  • Shift Sales
  • diff --git a/app/views/reports/receipt_no_detail/_shift_sale_report_filter.html.erb b/app/views/reports/receipt_no_detail/_shift_sale_report_filter.html.erb new file mode 100755 index 00000000..1d7c2a94 --- /dev/null +++ b/app/views/reports/receipt_no_detail/_shift_sale_report_filter.html.erb @@ -0,0 +1,140 @@ +
    + <%= form_tag report_path, :method => :get, :id=>"frm_report", :class => "form" do %> + <% if period_type != false %> +
    +
    + + +
    + <% if defined? payments %> + +
    + + + +
    + <% end %> +
    + + + +
    +
    + + +
    +
    + + +
    +
    +
    + +
    +
    + <% end %> + + <% end %> +
    + + diff --git a/app/views/reports/receipt_no_detail/index.html.erb b/app/views/reports/receipt_no_detail/index.html.erb new file mode 100755 index 00000000..d2f7f11f --- /dev/null +++ b/app/views/reports/receipt_no_detail/index.html.erb @@ -0,0 +1,289 @@ +
    + +
    +
    + <%= render :partial=>'shift_sale_report_filter', + :locals=>{ :period_type => true, :shift_name => true,:payments => true, :report_path =>reports_receipt_no_detail_index_path} %> +
    + + +
    +
    + + + + + + <% if @shift_from %> + + <% if @shift_data.employee %> + <% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %> + <% end %> + + + <% end %> + + + + + + + + + + + <% grand_total = 0 %> + <% @sale_data.each do |result| %> + <% grand_total = grand_total.to_f + result.grand_total.to_f%> + + + + + + + + + + + + + + + + + + <% result.sale_items.each do |item|%> + + + + + + + + <% end %> + + + + <%survey = Survey.find_by_receipt_no(result.receipt_no)%> + <% if !survey.nil?%> + + + + + + + + <% end %> + + <% if !result.total_amount.nil?%> + + + + + + + + <% end %> + + <% if result.total_discount.to_f > 0 %> + + + + + + + + <% end %> + + <% if !result.total_tax.nil? %> + + + + + + + + <% end %> + + <% if result.sale_payments.count > 0%> + <% result.sale_payments.each do |rec| %> + + + + + + + + + <% if !rec.payment_reference.nil? %> + + + + + + + + <% end %> + <% end %> + <% if result.amount_changed != 0 && !result.amount_changed.nil? %> + + + + + + + + <% end %> + <% if !result.customer_id.nil?%> + + + + + + + + <% end %> + <% end %> + + <% end %> + + + + + + + + + +
    <%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <%= t("views.right_panel.detail.to_date") %> : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%> +
    <%= t("views.right_panel.detail.shift_name") %> = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )
    <%= t("views.right_panel.detail.shift_name") %><%= t("views.right_panel.detail.table") %><%= t("views.right_panel.detail.receipt_no") %><%= t :cashier %> <%= t("views.right_panel.detail.name") %><%= t("views.right_panel.detail.revenue") %> 
    <%= @shift_from %> - <%= @shift_to %><%= result.table_type %> - <%= result.table_name %><%= result.receipt_no rescue '-' %> <%= result.cashier_name rescue '-' %><%=result.grand_total%>
    <%= t("views.right_panel.detail.product") %><%= t("views.right_panel.detail.qty") %><%= t("views.right_panel.detail.unit_price") %><%= t("views.right_panel.detail.total_price") %><%= t("views.right_panel.detail.created_at") %>
    + <% if item.price.to_i < 0.to_i %> + <% if item.qty.to_i < 0.to_i%> + [PROMO QTY]<%= item.product_name rescue '-' %> + <% else %> + [PROMO PRICE]<%= item.product_name rescue '-' %> + <% end %> + <% else %> + <%= item.product_name rescue '-' %> + <% end %> + <%= item.qty rescue '-' %><%= item.unit_price rescue '-' %><%= item.price rescue '-' %><%=l item.created_at.utc.getlocal, :format => :short rescue '-' %>
     
      No. of Guest<%= survey.total_customer rescue '-' %> 
      <%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %><%= result.total_amount %> 
      <%= t("views.right_panel.detail.total") %> + <%= t("views.right_panel.detail.discount") %> + <%= t("views.right_panel.detail.amount") %> - <%= result.total_discount %>  
      Tax Amount <%= result.total_tax %>  
      Payment <%= rec.payment_method.upcase %><%= rec.payment_amount %> ( <%= result.payment_status %> ) 
      Payment Ref.<%= rec.payment_reference %> 
      <%= t("views.right_panel.detail.change") %> <%= t("views.right_panel.detail.amount") %><%= result.amount_changed %> 
      Customer<%= result.customer.name.contact_first_name rescue '-'%> + (<%= result.customer.company rescue '-' %>) +  
       Total Nett - <%= grand_total %> 
    +
    +
    +
    +
    +
    + \ No newline at end of file diff --git a/app/views/reports/receipt_no_detail/index.xls.erb b/app/views/reports/receipt_no_detail/index.xls.erb new file mode 100755 index 00000000..a4f5ed20 --- /dev/null +++ b/app/views/reports/receipt_no_detail/index.xls.erb @@ -0,0 +1,182 @@ + + + + + + + +
    +
    +
    +
    +
    + + + + + + <% if @shift_from %> + + <% if @shift_data.employee %> + <% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %> + <% end %> + + + <% end %> + + + + + + + + + + + <% grand_total = 0 %> + <% @sale_data.each do |result| %> + <% grand_total = grand_total.to_f + result.grand_total.to_f%> + + + + + + + + + + + + + + + + + + <% result.sale_items.each do |item|%> + + + + + + + + <% end %> + + + + <%survey = Survey.find_by_receipt_no(result.receipt_no)%> + <% if !survey.nil?%> + + + + + + + + <% end %> + + <% if !result.total_amount.nil?%> + + + + + + + + <% end %> + + <% if result.total_discount.to_f > 0 %> + + + + + + + + <% end %> + + <% if !result.total_tax.nil? %> + + + + + + + + <% end %> + + <% if result.sale_payments.count > 0%> + <% result.sale_payments.each do |rec| %> + + + + + + + + + <% if !rec.payment_reference.nil? %> + + + + + + + + <% end %> + <% end %> + <% if result.amount_changed != 0 && !result.amount_changed.nil? %> + + + + + + + + <% end %> + <% if !result.customer_id.nil?%> + + + + + + + + <% end %> + <% end %> + + <% end %> + + + + + + + + + +
    <%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <%= t("views.right_panel.detail.to_date") %> : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%> +
    <%= t("views.right_panel.detail.shift_name") %> = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )
    <%= t("views.right_panel.detail.shift_name") %><%= t("views.right_panel.detail.table") %><%= t("views.right_panel.detail.receipt_no") %><%= t :cashier %> <%= t("views.right_panel.detail.name") %><%= t("views.right_panel.detail.revenue") %> 
    <%= @shift_from %> - <%= @shift_to %><%= result.table_type %> - <%= result.table_name %><%= result.receipt_no rescue '-' %> <%= result.cashier_name rescue '-' %><%=result.grand_total%>
    <%= t("views.right_panel.detail.product") %><%= t("views.right_panel.detail.qty") %><%= t("views.right_panel.detail.unit_price") %><%= t("views.right_panel.detail.total_price") %><%= t("views.right_panel.detail.created_at") %>
    + <% if item.price.to_i < 0.to_i %> + <% if item.qty.to_i < 0.to_i%> + [PROMO QTY]<%= item.product_name rescue '-' %> + <% else %> + [PROMO PRICE]<%= item.product_name rescue '-' %> + <% end %> + <% else %> + <%= item.product_name rescue '-' %> + <% end %> + <%= item.qty rescue '-' %><%= item.unit_price rescue '-' %><%= item.price rescue '-' %><%=l item.created_at.utc.getlocal, :format => :short rescue '-' %>
     
      No. of Guest<%= survey.total_customer rescue '-' %> 
      <%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %><%= result.total_amount %> 
      <%= t("views.right_panel.detail.total") %> + <%= t("views.right_panel.detail.discount") %> + <%= t("views.right_panel.detail.amount") %> - <%= result.total_discount %>  
      Tax Amount <%= result.total_tax %>  
      Payment <%= rec.payment_method.upcase %><%= rec.payment_amount %> ( <%= result.payment_status %> ) 
      Payment Ref.<%= rec.payment_reference %> 
      <%= t("views.right_panel.detail.change") %> <%= t("views.right_panel.detail.amount") %><%= result.amount_changed %> 
      Customer<%= result.customer.name.contact_first_name rescue '-'%> + (<%= result.customer.company rescue '-' %>) +  
       Total Nett - <%= grand_total %> 
    + +
    +
    +
    +
    +
    + + \ No newline at end of file diff --git a/app/views/reports/saleitem/_shift_sale_report_filter.html.erb b/app/views/reports/saleitem/_shift_sale_report_filter.html.erb index d1a3ec5b..65df7aea 100755 --- a/app/views/reports/saleitem/_shift_sale_report_filter.html.erb +++ b/app/views/reports/saleitem/_shift_sale_report_filter.html.erb @@ -32,6 +32,16 @@ +
    + + + +
    @@ -46,9 +56,9 @@
    -
    +

    - +
    <% end %> @@ -70,6 +80,8 @@ var item = $('#item').val(); var payment_type = $('#payment_type'); + $("#account_type").val("<%=params[:account_type]%>"); + if(item == 'order'){ $('#cashier').hide(); $('#waiter').show(); diff --git a/config/routes.rb b/config/routes.rb index 95ff6ccd..84415803 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -473,6 +473,7 @@ scope "(:locale)", locale: /en|mm/ do #--------- Reports Controller Sections ------------# namespace :reports do resources :receipt_no + resources :receipt_no_detail resources :dailysale, :only => [:index, :show] resources :saleitem, :only => [:index, :show] resources :shiftsale, :only => [:index, :show]