fix discount and receipt bill

This commit is contained in:
Yan
2017-07-21 18:15:10 +06:30
parent 2e8c866761
commit b8fc67745d
3 changed files with 55 additions and 49 deletions

View File

@@ -97,13 +97,14 @@ class Origami::DiscountsController < 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
table_type = DiningFacility.find(table_id).type
discount_items = []
#destroy all discount sale item
sale.sale_items.each do |si|
if si.remark == "Discount" && si.price < 0
sale.total_amount = (sale.total_amount + si.price.abs)
si.destroy
sale.sale_items.each do |si|
if si.remark == "Discount" && si.price < 0
sale.total_amount = (sale.total_amount + si.price.abs)
discount_items.push(si)
end
end
@@ -111,6 +112,9 @@ class Origami::DiscountsController < BaseOrigamiController
# sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax;
# sale.save
#destroy in sale.sale_items
sale.sale_items.destroy(discount_items)
# Re-calc All Amount in Sale
sale.compute_by_sale_items(sale_id, sale.sale_items, 0)
result = {:status=> "Success", :table_id => table_id, :table_type => table_type }
@@ -139,7 +143,6 @@ class Origami::DiscountsController < BaseOrigamiController
arr.push(str)
end
end
end
generic_customer_id = sale.customer.membership_id