fixed autoremove tax when discount & precision at receipt no report

This commit is contained in:
NyanLinHtut
2019-12-11 11:34:23 +06:30
parent 56ec8c83b2
commit 26edf23b46
2 changed files with 16 additions and 4 deletions

View File

@@ -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

View File

@@ -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?