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

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