From ebadfff25ba468cd59e1e961e271a8899d46d31d Mon Sep 17 00:00:00 2001 From: phyusin Date: Thu, 22 Mar 2018 11:09:12 +0630 Subject: [PATCH] add tax in charges --- app/controllers/origami/other_charges_controller.rb | 3 ++- app/models/sale.rb | 5 +++-- app/views/origami/other_charges/index.html.erb | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/controllers/origami/other_charges_controller.rb b/app/controllers/origami/other_charges_controller.rb index 8bba3800..def94a1f 100755 --- a/app/controllers/origami/other_charges_controller.rb +++ b/app/controllers/origami/other_charges_controller.rb @@ -19,6 +19,7 @@ class Origami::OtherChargesController < BaseOrigamiController sale_id = params[:sale_id] other_charges_items = JSON.parse(params[:other_charges_items]) sub_total = params[:sub_total] + cashier_type = params[:cashier_type] if Sale.exists?(sale_id) sale = Sale.find(sale_id) @@ -68,7 +69,7 @@ class Origami::OtherChargesController < BaseOrigamiController end # Re-calc All Amount in Sale - sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount) + sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount, nil, cashier_type) end if !table.nil? dining = {:table_id => table_id, :table_type => table.type } diff --git a/app/models/sale.rb b/app/models/sale.rb index 2b93cfb2..5fc0c06f 100755 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -361,7 +361,6 @@ class Sale < ApplicationRecord end end - compute_tax(sale, total_taxable, total_discount, order_source) sale.total_amount = subtotal_price sale.total_discount = total_discount sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax @@ -372,8 +371,9 @@ class Sale < ApplicationRecord # adjust_rounding sale.rounding_adjustment = compute_adjust_rounding(sale.grand_total) - sale.save! + compute_tax(sale, total_taxable, total_discount, order_source) + sale.save! end # No Use too many wrong @@ -454,6 +454,7 @@ class Sale < ApplicationRecord # end end end + sale.total_tax = total_tax_amount end diff --git a/app/views/origami/other_charges/index.html.erb b/app/views/origami/other_charges/index.html.erb index a194e03a..caa578a5 100755 --- a/app/views/origami/other_charges/index.html.erb +++ b/app/views/origami/other_charges/index.html.erb @@ -308,7 +308,7 @@ var cashier_type = "<%= @cashier_type %>"; var other_charges_items = JSON.stringify(get_other_item_rows()); var ajax_url = "/origami/" + sale_id + "/other_charges"; - var params = { 'sale_id': sale_id, 'sub_total': sub_total, 'other_charges_items': other_charges_items }; + var params = { 'cashier_type' : cashier_type,'sale_id': sale_id, 'sub_total': sub_total, 'other_charges_items': other_charges_items }; $.ajax({ type: "POST",