diff --git a/app/controllers/concerns/number_formattable.rb b/app/controllers/concerns/number_formattable.rb index bb022263..2507b10a 100644 --- a/app/controllers/concerns/number_formattable.rb +++ b/app/controllers/concerns/number_formattable.rb @@ -8,7 +8,7 @@ module NumberFormattable @precision = @number_formats.find? { |x| x.name.parameterize.underscore == 'precision'}.value.to_i rescue nil end if @precision.nil? - @print_settings = PrintSetting.get_precision_delimiter if !defined? @number_formats + @print_settings = PrintSetting.get_precision_delimiter if !defined? @print_settings if @print_settings @precision = @print_settings.precision.to_i else @@ -45,7 +45,7 @@ module NumberFormattable options[:precision] = options[:precision] || precision # options[:delimiter] = options[:delimiter] || delimiter options[:strip_insignificant_zeros] = options[:strip_insignificant_zeros] || strip_insignificant_zeros - + number = number.to_f.round(options[:precision]) if options[:precision] > 0 diff --git a/app/models/sale.rb b/app/models/sale.rb index 27d0416c..d9fa7db4 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -527,6 +527,19 @@ class Sale < ApplicationRecord end tax_profiles = unique_tax_profiles(order_source, self.customer_id) + if tax_type.nil? + if tax_profiles.count == 2 + tax_type = "all" + elsif tax_profiles.count == 1 + if tax_profiles.name.downcase == "service charges" + tax_type = "Service Charges" + else + tax_type = "Commercial Tax" + end + elsif tax_profiles.count < 1 + tax_type = "no_tax" + end + end # #Creat new tax records if self.payment_status != 'foc' && tax_type.to_s == "all" @@ -2076,8 +2089,7 @@ def self.get_sale_data_for_other_payment_credit(sale_id) end def unique_tax_profiles(order_source, customer_id) - tax_data = TaxProfile - .where(group_type: order_source) + tax_data = TaxProfile.where(group_type: order_source) customer_tax_profiles = Customer.select(:tax_profiles).where(customer_id: customer_id).first if customer_tax_profiles.present?