update pending and quick service

This commit is contained in:
Aung Myo
2018-02-15 15:26:34 +06:30
parent a8fdf2ec30
commit cf644892c9
9 changed files with 164 additions and 27 deletions

View File

@@ -161,9 +161,16 @@ class Origami::DiscountsController < BaseOrigamiController
if Sale.exists?(sale_id)
sale = Sale.find(sale_id)
table_id = sale.bookings[0].dining_facility_id
dining = DiningFacility.find(table_id)
table_type = dining.type
if sale.bookings[0].dining_facility_id.to_i > 0
table_id = sale.bookings[0].dining_facility_id
table = DiningFacility.find(table_id)
table_type = table.type
else
table_id = nil
table = nil
table_type = nil
end
discount_items = []
#destroy all discount sale item
@@ -182,14 +189,28 @@ class Origami::DiscountsController < BaseOrigamiController
sale.sale_items.destroy(discount_items)
action_by = current_user.id
remark = "Remove Discount Sale Id [#{sale.sale_id}]| Receipt No #{sale.receipt_no} | Table- #{dining.name} "
if table.nil?
remark = "Remove Discount Sale Id [#{sale.sale_id}]| Receipt No #{sale.receipt_no} | Table- No Table"
else
remark = "Remove Discount Sale Id [#{sale.sale_id}]| Receipt No #{sale.receipt_no} | Table- #{table.name} "
end
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_id, action_by,remark,"REMOVEALLDISCOUNT" )
# Re-calc All Amount in Sale
sale.compute_by_sale_items(sale_id, sale.sale_items, 0)
result = {:status=> "Success", :table_id => table_id, :dining => dining.name, :table_type => table_type }
if table.nil?
result = {:status=> "Success"}
else
result = {:status=> "Success", :table_id => table_id, :dining => table.name, :table_type => table_type }
end
else
result = {:status=> "Please, Check Again!", :table_id => table_id, :dining => dining.name, :table_type => table_type }
if table.nil?
result = {:status=> "Please, Check Again!"}
else
result = {:status=> "Please, Check Again!", :table_id => table_id, :dining => table.name, :table_type => table_type }
end
end
render :json => result.to_json