From 1dbd6eb60acc5058eaacc7537bba0a445f25c41e Mon Sep 17 00:00:00 2001 From: Yan Date: Thu, 10 Aug 2017 14:59:16 +0630 Subject: [PATCH] inclusive tax calc by rake --- app/models/sale.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/sale.rb b/app/models/sale.rb index 56f52b74..9f4ae9f7 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -287,7 +287,9 @@ class Sale < ApplicationRecord total_tax = total_taxable - total_discount #include or execulive if tax.inclusive - sale_tax.tax_payable_amount = total_tax / 21 + 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 @@ -330,7 +332,9 @@ class Sale < ApplicationRecord total_tax = total_taxable - self.total_discount #include or execulive if tax.inclusive - sale_tax.tax_payable_amount = total_tax / 21 + 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