fix dining charge calc
This commit is contained in:
@@ -187,7 +187,10 @@ class Sale < ApplicationRecord
|
|||||||
sale_item.sale_id = self.id
|
sale_item.sale_id = self.id
|
||||||
sale_item.price = diningprice
|
sale_item.price = diningprice
|
||||||
sale_item.save
|
sale_item.save
|
||||||
self.compute_by_sale_items(self.id, self.sale_items, self.total_discount)
|
|
||||||
|
# Re-calc
|
||||||
|
sale = Sale.find(self.id)
|
||||||
|
self.compute_by_sale_items(self.id, sale.sale_items, self.total_discount)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_item (item)
|
def update_item (item)
|
||||||
@@ -224,7 +227,9 @@ class Sale < ApplicationRecord
|
|||||||
subtotal_price = subtotal_price + item.price
|
subtotal_price = subtotal_price + item.price
|
||||||
total_taxable = total_taxable + (item.taxable_price * item.qty)
|
total_taxable = total_taxable + (item.taxable_price * item.qty)
|
||||||
end
|
end
|
||||||
|
|
||||||
apply_tax (total_taxable)
|
apply_tax (total_taxable)
|
||||||
|
|
||||||
self.total_amount = subtotal_price
|
self.total_amount = subtotal_price
|
||||||
self.total_discount = total_discount
|
self.total_discount = total_discount
|
||||||
self.grand_total = (self.total_amount - self.total_discount) + self.total_tax
|
self.grand_total = (self.total_amount - self.total_discount) + self.total_tax
|
||||||
@@ -339,6 +344,8 @@ class Sale < ApplicationRecord
|
|||||||
|
|
||||||
# Tax Calculate
|
# Tax Calculate
|
||||||
def apply_tax(total_taxable)
|
def apply_tax(total_taxable)
|
||||||
|
shop = Shop.first();
|
||||||
|
|
||||||
#if tax is not apply create new record
|
#if tax is not apply create new record
|
||||||
SaleTax.where("sale_id='#{self.sale_id}'").find_each do |existing_tax|
|
SaleTax.where("sale_id='#{self.sale_id}'").find_each do |existing_tax|
|
||||||
#delete existing and create new
|
#delete existing and create new
|
||||||
|
|||||||
Reference in New Issue
Block a user