Merge branch 'crm' of bitbucket.org:code2lab/sxrestaurant

This commit is contained in:
Yan
2017-08-09 11:10:53 +06:30

View File

@@ -279,12 +279,15 @@ class Sale < ApplicationRecord
sale_tax = SaleTax.new(:sale => sale)
sale_tax.tax_name = tax.name
sale_tax.tax_rate = tax.rate
#include or execulive
# sale_tax.tax_payable_amount = total_taxable * tax.rate
# substract , to give after discount
total_tax = total_taxable - total_discount
sale_tax.tax_payable_amount = total_tax * tax.rate / 100
#include or execulive
if tax.inclusive
sale_tax.tax_payable_amount = total_tax / 21
else
sale_tax.tax_payable_amount = total_tax * tax.rate / 100
end
#new taxable amount is standard rule for step by step
# total_taxable = total_taxable + sale_tax.tax_payable_amount
@@ -299,12 +302,6 @@ class Sale < ApplicationRecord
# Tax Calculate
def apply_tax(total_taxable)
#if tax is not apply create new record
# self.sale_taxes.each do |existing_tax|
# #delete existing and create new
# existing_tax.delete
# end
#if tax is not apply create new record
SaleTax.where("sale_id='#{self.sale_id}'").find_each do |existing_tax|
#delete existing and create new
@@ -320,10 +317,16 @@ class Sale < ApplicationRecord
sale_tax = SaleTax.new(:sale => self)
sale_tax.tax_name = tax.name
sale_tax.tax_rate = tax.rate
#include or execulive
# sale_tax.tax_payable_amount = total_taxable * tax.rate
# substract , to give after discount
total_tax = total_taxable - self.total_discount
sale_tax.tax_payable_amount = total_tax * tax.rate / 100
#include or execulive
if tax.inclusive
sale_tax.tax_payable_amount = total_tax / 21
else
sale_tax.tax_payable_amount = total_tax * tax.rate / 100
end
#new taxable amount is standard rule for step by step
# total_taxable = total_taxable + sale_tax.tax_payable_amount