From d2549df2e941101fd49624f2dde204708b4a9811 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Wed, 21 Jun 2017 17:37:16 +0630 Subject: [PATCH] update receipt bill payment --- app/assets/javascripts/application.js | 1 - app/controllers/origami/payments_controller.rb | 6 +++--- .../reports/daily_sale_controller.rb | 2 +- .../reports/receipt_no_controller.rb | 2 +- .../reports/sale_item_controller.rb | 2 +- app/models/customer.rb | 2 +- app/pdf/receipt_bill_pdf.rb | 18 ++++++++++++++---- app/views/layouts/_header.html.erb | 2 +- 8 files changed, 22 insertions(+), 13 deletions(-) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 8604d3c8..63c871d9 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -28,7 +28,6 @@ $(document).on("focus", "[data-behaviour~='datepicker']", function(e){ function export_to(path) { var form_params = $("#frm_report").serialize(); - alert(form_params); window.location = path+"?"+ form_params; } diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 6a6f4ca6..38225fae 100644 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -16,7 +16,7 @@ class Origami::PaymentsController < BaseOrigamiController unique_code = "ReceiptBillPdf" customer= Customer.find(saleObj.customer_id) - + rebate_amount = Customer.get_membership_transactions(customer) # get member information member_info = Customer.get_member_account(customer) @@ -90,7 +90,7 @@ class Origami::PaymentsController < BaseOrigamiController # get member information member_info = Customer.get_member_account(customer) - + rebate_amount = Customer.get_membership_transactions(customer) # get printer info print_settings=PrintSetting.find_by_unique_code(unique_code) @@ -98,7 +98,7 @@ class Origami::PaymentsController < BaseOrigamiController food_total, beverage_total = SaleItem.calculate_food_beverage(saleObj.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, food_total, beverage_total, member_info) + printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, food_total, beverage_total, member_info,rebate_amount) end diff --git a/app/controllers/reports/daily_sale_controller.rb b/app/controllers/reports/daily_sale_controller.rb index 34a3b5e2..6e1eb85a 100644 --- a/app/controllers/reports/daily_sale_controller.rb +++ b/app/controllers/reports/daily_sale_controller.rb @@ -1,7 +1,7 @@ class Reports::DailySaleController < BaseReportController def index - from, to = get_date_range_from_params + from, to ,report_type = get_date_range_from_params @sale_data = Sale.daily_sales_list(from,to) @tax = SaleTax.get_tax(from,to) end diff --git a/app/controllers/reports/receipt_no_controller.rb b/app/controllers/reports/receipt_no_controller.rb index 6f501fd1..86c8d981 100644 --- a/app/controllers/reports/receipt_no_controller.rb +++ b/app/controllers/reports/receipt_no_controller.rb @@ -1,5 +1,5 @@ class Reports::ReceiptNoController < BaseReportController - load_and_authorize_resource + def index from, to = get_date_range_from_params puts "from..." diff --git a/app/controllers/reports/sale_item_controller.rb b/app/controllers/reports/sale_item_controller.rb index 9e2b728b..1da31aff 100644 --- a/app/controllers/reports/sale_item_controller.rb +++ b/app/controllers/reports/sale_item_controller.rb @@ -1,5 +1,5 @@ class Reports::SaleItemController < BaseReportController - load_and_authorize_resource + def index from, to, report_type = get_date_range_from_params diff --git a/app/models/customer.rb b/app/models/customer.rb index 32422185..e5dfb668 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -64,7 +64,7 @@ class Customer < ApplicationRecord def self.search(search) if search # find(:all, :conditions => ['name LIKE ? OR contact_no LIKE ?', "%#{search}%", "%#{search}%"]) - where("name LIKE ? OR contact_no LIKE ?", "%#{search}%", "%#{search}%",) + where("name LIKE ? OR contact_no LIKE ? OR card_no LIKE ?", "%#{search}%", "%#{search}%",) else find(:all) end diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 2b1ae2ae..516f5668 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -260,17 +260,27 @@ class ReceiptBillPdf < Prawn::Document if rebate_amount["status"] == true rebate_amount["data"].each do |res| - if res["receipt_no"]== sale_data.receipt_no + if res["receipt_no"]== sale_data.receipt_no && res["status"]== "Rebate" move_down 5 y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do - text "Rebate Balance", :size => self.item_font_size,:align => :left + text "Rebate Amount", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do text "#{ res["rebate"] }" , :size => self.item_font_size,:align => :right end - + end + if res["receipt_no"]== sale_data.receipt_no && res["status"]== "Redeem" + + move_down 5 + y_position = cursor + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "Redeem Amount", :size => self.item_font_size,:align => :left + end + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "#{ res["redeem"] }" , :size => self.item_font_size,:align => :right + end end end @@ -301,7 +311,7 @@ class ReceiptBillPdf < Prawn::Document move_down 5 y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do - text "Customer", :size => self.item_font_size,:align => :left + text "Customer Name", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do text "#{ customer_name }" , :size => self.item_font_size,:align => :right diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index 40ddae1f..c528003d 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -39,7 +39,7 @@