update split bill

This commit is contained in:
Thein Lin Kyaw
2019-12-16 11:20:15 +06:30
parent a4c2b47f7a
commit 40ad724e77
5 changed files with 113 additions and 347 deletions

View File

@@ -1,7 +1,7 @@
class Origami::TableInvoicesController < BaseOrigamiController
def index
@table = DiningFacility.find(params[:table_id])
shop = Shop.current_shop
shop = Shop.current_shop
puts "table bookig lenght"
@sale_array = Array.new
@table.bookings.each do |booking|
@@ -34,30 +34,7 @@ class Origami::TableInvoicesController < BaseOrigamiController
@table = DiningFacility.find(params[:table_id])
@membership = MembershipSetting::MembershipSetting
@payment_methods = PaymentMethodSetting.all
shop = Shop.current_shop
@sale_array = Array.new
@table.bookings.each do |booking|
if booking.sale_id.nil?
else
sale = Sale.find(booking.sale_id)
# rounding adjustment
if shop.is_rounding_adj
a = sale.grand_total % 25 # Modulus
b = sale.grand_total / 25 # Division
#not calculate rounding if modulus is 0 and division is even
#calculate rounding if modulus is zero or not zero and division are not even
if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
new_total = Sale.get_rounding_adjustment(sale.grand_total)
sale.rounding_adjustment = new_total-sale.grand_total
sale.update_attributes(grand_total: new_total,old_grand_total: sale.grand_total,rounding_adjustment:sale.rounding_adjustment)
end
end
#end rounding adjustment
if sale.sale_status != "completed" && sale.sale_status != 'void' && sale.sale_status != "waste" && sale.sale_status != "spoile"
@sale_array.push(sale)
end
end
end
@sale_array = @table.current_sales
@sale = Sale.find(params[:invoice_id])
@date = @sale.created_at