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

@@ -22,10 +22,10 @@ class Origami::DiscountsController < BaseOrigamiController
sale = Sale.find(sale_id)
table_id = sale.bookings[0].dining_facility_id
table_type = DiningFacility.find(table_id).type
sale.total_discount = overall_discount.to_f
sale.total_amount = sub_total.to_f
sale.grand_total = (sub_total.to_f - overall_discount.to_f) + sale.total_tax;
sale.save
# sale.total_discount = overall_discount.to_f
# sale.total_amount = sub_total.to_f
# sale.grand_total = (sub_total.to_f - overall_discount.to_f) + sale.total_tax;
# sale.save
if discount_items.length > 0
#save sale item for discount
discount_items.each do |di|
@@ -35,6 +35,7 @@ class Origami::DiscountsController < BaseOrigamiController
sale_item.sale_id = sale_id
sale_item.product_code = origin_sale_item != nil ? origin_sale_item.product_code : sale_id
sale_item.product_name = di["name"]
sale_item.product_alt_name = ""
sale_item.remark = "Discount"
sale_item.qty = 1
@@ -45,7 +46,10 @@ class Origami::DiscountsController < BaseOrigamiController
sale_item.price = di["price"]
sale_item.save
end
end
end
# Re-calc All Amount in Sale
sale.compute_by_sale_items(sale_id, sale.sale_items, overall_discount.to_f)
end
dining = {:table_id => table_id, :table_type => table_type }