add Re-compute all amoute for sale

This commit is contained in:
Yan
2017-06-30 19:05:13 +06:30
parent 02cc6e8cbd
commit 71636b36db
5 changed files with 93 additions and 12 deletions

View File

@@ -16,10 +16,11 @@ class Origami::OtherChargesController < BaseOrigamiController
if Sale.exists?(sale_id)
sale = Sale.find(sale_id)
table_id = sale.bookings[0].dining_facility_id
table_type = DiningFacility.find(table_id).type
sale.total_amount = sub_total.to_f
sale.grand_total = sub_total.to_f + sale.total_tax;
sale.save
table_type = DiningFacility.find(table_id).type
# sale.total_amount = sub_total.to_f
# sale.grand_total = sub_total.to_f + sale.total_tax;
# sale.save
if other_charges_items.length > 0
#save sale item for discount
other_charges_items.each do |di|
@@ -34,14 +35,17 @@ class Origami::OtherChargesController < BaseOrigamiController
sale_item.qty = 1
sale_item.unit_price = di["price"]
sale_item.taxable_price = di["price"]
sale_item.taxable_price = 0
sale_item.is_taxable = 0
sale_item.price = di["price"]
sale_item.save
end
end
end
end
# Re-calc All Amount in Sale
sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount)
end
dining = {:table_id => table_id, :table_type => table_type }
render :json => dining.to_json