Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant

This commit is contained in:
Nweni
2017-07-01 09:46:44 +06:30
21 changed files with 346 additions and 254 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 }

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|
@@ -29,18 +30,22 @@ class Origami::OtherChargesController < BaseOrigamiController
sale_item.sale_id = sale_id
sale_item.product_code = "Other Charges"
sale_item.product_name = di["name"]
sale_item.product_alt_name = ""
sale_item.remark = "Other Charges"
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

View File

@@ -9,10 +9,6 @@ class Origami::PaymentsController < BaseOrigamiController
sale_data = Sale.find_by_sale_id(sale_id)
sale_items = SaleItem.where("sale_id=?",sale_id)
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
rounding_adj = sale_data.grand_total - new_total
sale_data.update_attributes(grand_total: new_total,rounding_adjustment:rounding_adj)
# Print for First Bill to Customer
unique_code = "ReceiptBillPdf"
@@ -43,7 +39,12 @@ class Origami::PaymentsController < BaseOrigamiController
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
sale_payment = SalePayment.new
sale_payment.process_payment(saleObj, @user, cash, "cash")
sale_payment.process_payment(saleObj, @user, cash, "cash")
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
rounding_adj = saleObj.grand_total - new_total
saleObj.update_attributes(grand_total: new_total,rounding_adjustment:rounding_adj)
rebate_amount = nil

View File

@@ -26,6 +26,9 @@ class Origami::SalesController < BaseOrigamiController
order.order_items.each do |orer_item|
saleobj.add_item (orer_item)
end
# Re-compute for add
saleobj.compute
saleobj.save
order.save
booking.save