Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant into adminbsb_material_ui
This commit is contained in:
@@ -470,8 +470,23 @@ class Sale < ApplicationRecord
|
||||
end
|
||||
|
||||
def adjust_rounding
|
||||
self.grand_total
|
||||
self.rounding_adjustment = 0.00
|
||||
shop_details = Shop::ShopDetail
|
||||
# rounding adjustment
|
||||
if shop_details.is_rounding_adj
|
||||
a = self.grand_total % 25 # Modulus
|
||||
b = self.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(self.grand_total)
|
||||
self.rounding_adjustment = new_total - self.grand_total
|
||||
else
|
||||
self.rounding_adjustment = 0.00
|
||||
end
|
||||
else
|
||||
self.rounding_adjustment = 0.00
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
#Generate new Receipt No when it is not assigned
|
||||
@@ -740,7 +755,7 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status)
|
||||
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
|
||||
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
|
||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||
.where("sales.shift_sale_id in (?) and sale_status = 'completed' and sale_status!='void' and sale_payments.payment_amount != 0 ", shift.to_a)
|
||||
.where("sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift.to_a)
|
||||
sale_cash.each do |s_c|
|
||||
total_cash_amount += s_c.cash_amount.to_f
|
||||
total_card_amount += s_c.card_amount.to_f
|
||||
@@ -760,7 +775,7 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status)
|
||||
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
|
||||
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
|
||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||
.where("sales.shift_sale_id in (?) and sale_status = 'completed' and sale_status!='void' and sale_payments.payment_amount != 0 ", shift_sale_range.to_a)
|
||||
.where("sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift_sale_range.to_a)
|
||||
sale_cash.each do |s_c|
|
||||
total_cash_amount += s_c.cash_amount.to_f
|
||||
total_card_amount += s_c.card_amount.to_f
|
||||
@@ -780,7 +795,7 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status)
|
||||
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
|
||||
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
|
||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||
.where("sales.receipt_date between ? and ? and sale_status = 'completed' and sale_status!='void' and sale_payments.payment_amount != 0 ", from,to)
|
||||
.where("sales.receipt_date between ? and ? and sale_status = 'completed' and sale_payments.payment_amount != 0 ", from,to)
|
||||
sale_cash.each do |s_c|
|
||||
total_cash_amount += s_c.cash_amount.to_f
|
||||
total_card_amount += s_c.card_amount.to_f
|
||||
|
||||
Reference in New Issue
Block a user