apply inclusive tax by divided by 21
This commit is contained in:
@@ -279,12 +279,15 @@ class Sale < ApplicationRecord
|
|||||||
sale_tax = SaleTax.new(:sale => sale)
|
sale_tax = SaleTax.new(:sale => sale)
|
||||||
sale_tax.tax_name = tax.name
|
sale_tax.tax_name = tax.name
|
||||||
sale_tax.tax_rate = tax.rate
|
sale_tax.tax_rate = tax.rate
|
||||||
#include or execulive
|
|
||||||
# sale_tax.tax_payable_amount = total_taxable * 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
|
||||||
|
if tax.inclusive
|
||||||
|
sale_tax.tax_payable_amount = total_tax / 21
|
||||||
|
else
|
||||||
sale_tax.tax_payable_amount = total_tax * tax.rate / 100
|
sale_tax.tax_payable_amount = total_tax * tax.rate / 100
|
||||||
|
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
|
# total_taxable = total_taxable + sale_tax.tax_payable_amount
|
||||||
|
|
||||||
@@ -299,12 +302,6 @@ class Sale < ApplicationRecord
|
|||||||
|
|
||||||
# Tax Calculate
|
# Tax Calculate
|
||||||
def apply_tax(total_taxable)
|
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
|
#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
|
||||||
@@ -320,10 +317,16 @@ class Sale < ApplicationRecord
|
|||||||
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
|
||||||
#include or execulive
|
|
||||||
# sale_tax.tax_payable_amount = total_taxable * tax.rate
|
# substract , to give after discount
|
||||||
total_tax = total_taxable - self.total_discount
|
total_tax = total_taxable - self.total_discount
|
||||||
|
#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
|
sale_tax.tax_payable_amount = total_tax * tax.rate / 100
|
||||||
|
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
|
# total_taxable = total_taxable + sale_tax.tax_payable_amount
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user