diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index fdd55f06..a551b585 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -54,6 +54,15 @@ class Origami::PaymentsController < BaseOrigamiController if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) + shop_details = Shop.find(1) + + if shop_details.is_rounding_adj + new_total = Sale.get_rounding_adjustment(saleObj.grand_total) + rounding_adj = new_total-saleObj.grand_total + saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) + #end rounding adjment + end + sale_payment = SalePayment.new sale_payment.process_payment(saleObj, @user, cash, "cash") @@ -75,9 +84,7 @@ class Origami::PaymentsController < BaseOrigamiController # For Print unique_code = "ReceiptBillPdf" customer= Customer.find(saleObj.customer_id) - - #shop detail - shop_details = Shop.find(1) + # get member information rebate = MembershipSetting.find_by_rebate(1) if customer.membership_id != nil && rebate @@ -114,6 +121,14 @@ class Origami::PaymentsController < BaseOrigamiController @accountable_type = '' @table_no = '' + @shop = Shop.find_by_id(1) + if @shop.is_rounding_adj + new_total = Sale.get_rounding_adjustment(@sale_data.grand_total) + else + new_total = @sale_data.grand_total + end + @rounding_adj = new_total-@sale_data.grand_total + #get customer amount @customer = Customer.find(@sale_data.customer_id) accounts = @customer.tax_profiles @@ -127,7 +142,6 @@ class Origami::PaymentsController < BaseOrigamiController # get member information if @customer.membership_id != nil && rebate response = Customer.get_member_account(@customer) - puts response.to_json if response["status"]==true response["account_data"].each do |res| if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount" diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index c0845822..f479fdd5 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -524,19 +524,20 @@ }); }); + // $('#pay').on('click', function () { + // var sale_id = $('#sale_id').val(); + // var url = '/origami/sale/' + sale_id + "/rounding_adj"; + // $.ajax({ + // type: "POST", + // url: '/origami/sale/' + sale_id + "/rounding_adj", + // success: function (result) { + // window.location.href = '/origami/sale/' + sale_id + "/payment"; + // } + // }); + // }); $('#pay').on('click', function () { var sale_id = $('#sale_id').val(); - - var url = '/origami/sale/' + sale_id + "/rounding_adj"; - $.ajax({ - type: "POST", - url: '/origami/sale/' + sale_id + "/rounding_adj", - success: function (result) { - window.location.href = '/origami/sale/' + sale_id + "/payment"; - } - }); - - + window.location.href = '/origami/sale/' + sale_id + "/payment"; }); // Bill Request diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index db23f9ba..b64a0310 100755 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -94,7 +94,7 @@