rounding decimal to print_settings precision
This commit is contained in:
@@ -5,6 +5,8 @@ class SaleTax < ApplicationRecord
|
||||
before_create :generate_custom_id
|
||||
belongs_to :sale
|
||||
|
||||
before_validation :round_to_precision
|
||||
|
||||
def self.sync_sale_tax_records(sale_taxes)
|
||||
if !sale_taxes.nil?
|
||||
sale_taxes.each do |t|
|
||||
@@ -38,4 +40,13 @@ class SaleTax < ApplicationRecord
|
||||
self.sale_tax_id = SeedGenerator.generate_id(self.class.name, "STI")
|
||||
end
|
||||
end
|
||||
|
||||
def round_to_precision
|
||||
if self.tax_payable_amount != self.tax_payable_amount_was
|
||||
if self.tax_payable_amount % 1 > 0
|
||||
precision = PrintSetting.get_precision_delimiter().precision.to_i
|
||||
self.tax_payable_amount = self.tax_payable_amount.round(precision)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user