add calc tax order in sale
This commit is contained in:
@@ -292,6 +292,8 @@ class Sale < ApplicationRecord
|
|||||||
|
|
||||||
# Tax Re-Calculte
|
# Tax Re-Calculte
|
||||||
def compute_tax(sale, total_taxable, total_discount = 0)
|
def compute_tax(sale, total_taxable, total_discount = 0)
|
||||||
|
shop = Shop.first();
|
||||||
|
|
||||||
#if tax is not apply create new record
|
#if tax is not apply create new record
|
||||||
SaleTax.where("sale_id='#{sale.sale_id}'").find_each do |existing_tax|
|
SaleTax.where("sale_id='#{sale.sale_id}'").find_each do |existing_tax|
|
||||||
#delete existing and create new
|
#delete existing and create new
|
||||||
@@ -322,7 +324,9 @@ class Sale < ApplicationRecord
|
|||||||
total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
|
total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
|
||||||
end
|
end
|
||||||
#new taxable amount is standard rule for step by step
|
#new taxable amount is standard rule for step by step
|
||||||
# total_taxable = total_taxable + sale_tax.tax_payable_amount
|
if shop.calc_tax_order
|
||||||
|
total_taxable = total_taxable + sale_tax.tax_payable_amount
|
||||||
|
end
|
||||||
|
|
||||||
sale_tax.inclusive = tax.inclusive
|
sale_tax.inclusive = tax.inclusive
|
||||||
sale_tax.save
|
sale_tax.save
|
||||||
@@ -346,7 +350,7 @@ class Sale < ApplicationRecord
|
|||||||
tax_profiles = TaxProfile.all.order("order_by asc")
|
tax_profiles = TaxProfile.all.order("order_by asc")
|
||||||
|
|
||||||
customer = Customer.find(self.customer_id)
|
customer = Customer.find(self.customer_id)
|
||||||
puts customer
|
|
||||||
#Create new tax records
|
#Create new tax records
|
||||||
tax_profiles.each do |tax|
|
tax_profiles.each do |tax|
|
||||||
customer.tax_profiles.each do |cus_tax|
|
customer.tax_profiles.each do |cus_tax|
|
||||||
@@ -368,7 +372,9 @@ class Sale < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
#new taxable amount is standard rule for step by step
|
#new taxable amount is standard rule for step by step
|
||||||
# total_taxable = total_taxable + sale_tax.tax_payable_amount
|
if shop.calc_tax_order
|
||||||
|
total_taxable = total_taxable + sale_tax.tax_payable_amount
|
||||||
|
end
|
||||||
|
|
||||||
sale_tax.inclusive = tax.inclusive
|
sale_tax.inclusive = tax.inclusive
|
||||||
sale_tax.save
|
sale_tax.save
|
||||||
|
|||||||
Reference in New Issue
Block a user