tax profiles

This commit is contained in:
Myat Zin Wai Maw
2020-01-16 10:05:45 +06:30
parent bad510c6b4
commit 676251a12c
14 changed files with 79 additions and 66 deletions

View File

@@ -4,4 +4,21 @@ class TaxProfile < ApplicationRecord
default_scope { order('order_by asc') }
# validations
validates_presence_of :name, :rate, :group_type
def self.calculate_tax(group_type)
divided_value =0.0
exclusive =0.0
tax_profiles = TaxProfile.where(group_type: group_type)
if !tax_profiles.empty?
tax_profiles.each do |tax|
#include or execulive
if tax.inclusive
rate = tax.rate
divided_value += (100 + rate)/rate
else
exclusive +=tax.rate / 100
end
end
end
return divided_value,exclusive
end
end