Merge branch 'r-1902001-01-dev' of gitlab.com:code2lab/SXRestaurant into r-1902001-01-dev
This commit is contained in:
@@ -531,7 +531,7 @@ class Sale < ApplicationRecord
|
|||||||
tax_profiles = unique_tax_profiles(order_source, self.customer_id)
|
tax_profiles = unique_tax_profiles(order_source, self.customer_id)
|
||||||
|
|
||||||
# #Creat new tax records
|
# #Creat new tax records
|
||||||
if self.payment_status != 'foc'
|
if self.payment_status != 'foc' && tax_type.to_s == "all"
|
||||||
tax_profiles.each do |tax|
|
tax_profiles.each do |tax|
|
||||||
sale_tax = SaleTax.new(:sale => self)
|
sale_tax = SaleTax.new(:sale => self)
|
||||||
sale_tax.tax_name = tax.name
|
sale_tax.tax_name = tax.name
|
||||||
@@ -561,6 +561,67 @@ class Sale < ApplicationRecord
|
|||||||
total_taxable = total_taxable + sale_tax.tax_payable_amount
|
total_taxable = total_taxable + sale_tax.tax_payable_amount
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
elsif tax_type.to_s == "no_tax"
|
||||||
|
tax_profiles.each do |tax|
|
||||||
|
sale_tax = SaleTax.new(:sale => self)
|
||||||
|
sale_tax.tax_name = tax.name
|
||||||
|
sale_tax.tax_rate = 0
|
||||||
|
sale_tax.tax_payable_amount = 0
|
||||||
|
sale_tax.inclusive = tax.inclusive
|
||||||
|
sale_tax.save
|
||||||
|
end
|
||||||
|
elsif tax_type.to_s == "Commercial Tax"
|
||||||
|
tax_profiles.each do |tax|
|
||||||
|
if tax.name == tax_type.to_s
|
||||||
|
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 - total_discount
|
||||||
|
#include or execulive
|
||||||
|
if tax.inclusive
|
||||||
|
tax_incl_exec = "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
|
||||||
|
elsif tax_type.to_s == "Service Charges"
|
||||||
|
tax_profiles.each do |tax|
|
||||||
|
if tax.name == tax_type.to_s
|
||||||
|
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 - total_discount
|
||||||
|
#include or execulive
|
||||||
|
if tax.inclusive
|
||||||
|
tax_incl_exec = "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
|
||||||
self.tax_type = tax_incl_exec
|
self.tax_type = tax_incl_exec
|
||||||
self.total_tax = total_tax_amount
|
self.total_tax = total_tax_amount
|
||||||
|
|||||||
Reference in New Issue
Block a user