heck rounding adjustment error
This commit is contained in:
@@ -470,8 +470,24 @@ class Sale < ApplicationRecord
|
||||
end
|
||||
|
||||
def adjust_rounding
|
||||
self.grand_total
|
||||
self.rounding_adjustment = 0.00
|
||||
saleObj = Sale.find(self.sale_id)
|
||||
shop_details = Shop::ShopDetail
|
||||
# rounding adjustment
|
||||
if shop_details.is_rounding_adj
|
||||
a = saleObj.grand_total % 25 # Modulus
|
||||
b = saleObj.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(saleObj.grand_total)
|
||||
self.rounding_adjustment = new_total-saleObj.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
|
||||
|
||||
Reference in New Issue
Block a user