add tax in charges

This commit is contained in:
phyusin
2018-03-22 11:09:12 +06:30
parent b8a71079f4
commit ebadfff25b
3 changed files with 6 additions and 4 deletions

View File

@@ -19,6 +19,7 @@ class Origami::OtherChargesController < BaseOrigamiController
sale_id = params[:sale_id] sale_id = params[:sale_id]
other_charges_items = JSON.parse(params[:other_charges_items]) other_charges_items = JSON.parse(params[:other_charges_items])
sub_total = params[:sub_total] sub_total = params[:sub_total]
cashier_type = params[:cashier_type]
if Sale.exists?(sale_id) if Sale.exists?(sale_id)
sale = Sale.find(sale_id) sale = Sale.find(sale_id)
@@ -68,7 +69,7 @@ class Origami::OtherChargesController < BaseOrigamiController
end end
# Re-calc All Amount in Sale # 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 end
if !table.nil? if !table.nil?
dining = {:table_id => table_id, :table_type => table.type } dining = {:table_id => table_id, :table_type => table.type }

View File

@@ -361,7 +361,6 @@ class Sale < ApplicationRecord
end end
end end
compute_tax(sale, total_taxable, total_discount, order_source)
sale.total_amount = subtotal_price sale.total_amount = subtotal_price
sale.total_discount = total_discount sale.total_discount = total_discount
sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax
@@ -372,8 +371,9 @@ class Sale < ApplicationRecord
# adjust_rounding # adjust_rounding
sale.rounding_adjustment = compute_adjust_rounding(sale.grand_total) sale.rounding_adjustment = compute_adjust_rounding(sale.grand_total)
sale.save! compute_tax(sale, total_taxable, total_discount, order_source)
sale.save!
end end
# No Use too many wrong # No Use too many wrong
@@ -454,6 +454,7 @@ class Sale < ApplicationRecord
# end # end
end end
end end
sale.total_tax = total_tax_amount sale.total_tax = total_tax_amount
end end

View File

@@ -308,7 +308,7 @@ var cashier_type = "<%= @cashier_type %>";
var other_charges_items = JSON.stringify(get_other_item_rows()); var other_charges_items = JSON.stringify(get_other_item_rows());
var ajax_url = "/origami/" + sale_id + "/other_charges"; 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({ $.ajax({
type: "POST", type: "POST",