change tax with takeaway
This commit is contained in:
@@ -430,28 +430,55 @@ class Sale < ApplicationRecord
|
|||||||
# customer.tax_profiles.each do |cus_tax|
|
# customer.tax_profiles.each do |cus_tax|
|
||||||
# if cus_tax.to_i == tax.id
|
# if cus_tax.to_i == tax.id
|
||||||
if tax.group_type.to_s == order_source.to_s
|
if tax.group_type.to_s == order_source.to_s
|
||||||
sale_tax = SaleTax.new(:sale => sale)
|
if customer.customer_type.downcase == 'takeaway'
|
||||||
sale_tax.tax_name = tax.name
|
if tax.name.downcase == 'commercial tax'
|
||||||
sale_tax.tax_rate = tax.rate
|
sale_tax = SaleTax.new(:sale => sale)
|
||||||
|
sale_tax.tax_name = tax.name
|
||||||
|
sale_tax.tax_rate = tax.rate
|
||||||
|
|
||||||
# substract , to give after discount
|
# substract , to give after discount
|
||||||
total_tax = total_taxable - total_discount
|
total_tax = total_taxable - total_discount
|
||||||
#include or execulive
|
#include or execulive
|
||||||
if tax.inclusive
|
if tax.inclusive
|
||||||
rate = tax.rate
|
rate = tax.rate
|
||||||
divided_value = (100 + rate)/rate
|
divided_value = (100 + rate)/rate
|
||||||
sale_tax.tax_payable_amount = total_tax / divided_value
|
sale_tax.tax_payable_amount = total_tax / divided_value
|
||||||
else
|
else
|
||||||
sale_tax.tax_payable_amount = total_tax * tax.rate / 100
|
sale_tax.tax_payable_amount = total_tax * tax.rate / 100
|
||||||
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
|
||||||
if shop.calc_tax_order
|
if shop.calc_tax_order
|
||||||
total_taxable = total_taxable + sale_tax.tax_payable_amount
|
total_taxable = total_taxable + sale_tax.tax_payable_amount
|
||||||
end
|
end
|
||||||
|
|
||||||
sale_tax.inclusive = tax.inclusive
|
sale_tax.inclusive = tax.inclusive
|
||||||
sale_tax.save
|
sale_tax.save
|
||||||
|
end
|
||||||
|
else
|
||||||
|
sale_tax = SaleTax.new(:sale => sale)
|
||||||
|
sale_tax.tax_name = tax.name
|
||||||
|
sale_tax.tax_rate = tax.rate
|
||||||
|
|
||||||
|
# substract , to give after discount
|
||||||
|
total_tax = total_taxable - total_discount
|
||||||
|
#include or execulive
|
||||||
|
if tax.inclusive
|
||||||
|
rate = tax.rate
|
||||||
|
divided_value = (100 + rate)/rate
|
||||||
|
sale_tax.tax_payable_amount = total_tax / divided_value
|
||||||
|
else
|
||||||
|
sale_tax.tax_payable_amount = total_tax * tax.rate / 100
|
||||||
|
total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
|
||||||
|
end
|
||||||
|
#new taxable amount is standard rule for step by step
|
||||||
|
if shop.calc_tax_order
|
||||||
|
total_taxable = total_taxable + sale_tax.tax_payable_amount
|
||||||
|
end
|
||||||
|
|
||||||
|
sale_tax.inclusive = tax.inclusive
|
||||||
|
sale_tax.save
|
||||||
|
end
|
||||||
end
|
end
|
||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
@@ -484,6 +511,33 @@ class Sale < ApplicationRecord
|
|||||||
# customer.tax_profiles.each do |cus_tax|
|
# customer.tax_profiles.each do |cus_tax|
|
||||||
# if cus_tax.to_i == tax.id
|
# if cus_tax.to_i == tax.id
|
||||||
if tax.group_type.to_s == order_source.to_s
|
if tax.group_type.to_s == order_source.to_s
|
||||||
|
if customer.customer_type.downcase == 'takeaway'
|
||||||
|
if tax.name.downcase == 'commercial tax'
|
||||||
|
sale_tax = SaleTax.new(:sale => self)
|
||||||
|
sale_tax.tax_name = tax.name
|
||||||
|
sale_tax.tax_rate = tax.rate
|
||||||
|
|
||||||
|
# substract , to give after discount
|
||||||
|
total_tax = total_taxable - self.total_discount
|
||||||
|
#include or execulive
|
||||||
|
if tax.inclusive
|
||||||
|
rate = tax.rate
|
||||||
|
divided_value = (100 + rate)/rate
|
||||||
|
sale_tax.tax_payable_amount = total_tax / divided_value
|
||||||
|
else
|
||||||
|
sale_tax.tax_payable_amount = total_tax * tax.rate / 100
|
||||||
|
total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
|
||||||
|
end
|
||||||
|
|
||||||
|
#new taxable amount is standard rule for step by step
|
||||||
|
if shop.calc_tax_order
|
||||||
|
total_taxable = total_taxable + sale_tax.tax_payable_amount
|
||||||
|
end
|
||||||
|
|
||||||
|
sale_tax.inclusive = tax.inclusive
|
||||||
|
sale_tax.save
|
||||||
|
end
|
||||||
|
else
|
||||||
sale_tax = SaleTax.new(:sale => self)
|
sale_tax = SaleTax.new(:sale => self)
|
||||||
sale_tax.tax_name = tax.name
|
sale_tax.tax_name = tax.name
|
||||||
sale_tax.tax_rate = tax.rate
|
sale_tax.tax_rate = tax.rate
|
||||||
@@ -507,6 +561,7 @@ class Sale < ApplicationRecord
|
|||||||
|
|
||||||
sale_tax.inclusive = tax.inclusive
|
sale_tax.inclusive = tax.inclusive
|
||||||
sale_tax.save
|
sale_tax.save
|
||||||
|
end
|
||||||
end
|
end
|
||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
|
|||||||
Reference in New Issue
Block a user