check tax profile
This commit is contained in:
@@ -512,13 +512,23 @@ class Sale < ApplicationRecord
|
||||
total_tax_amount = 0
|
||||
tax_incl_exec = "exclusive"
|
||||
#tax_profile - list by order_by
|
||||
tax_profiles = TaxProfile.all.order("order_by asc")
|
||||
|
||||
customer = Customer.find(self.customer_id)
|
||||
# tax_profiles = TaxProfile.all.order("order_by asc")
|
||||
if order_source.to_s == "emenu"
|
||||
order_source = "cashier"
|
||||
end
|
||||
|
||||
tax_data = TaxProfile.unscoped.where("group_type=?",order_source).pluck(:id)
|
||||
customer = Customer.find(self.customer_id).tax_profiles
|
||||
|
||||
arr_tax = []
|
||||
|
||||
arr_tax = customer - tax_data
|
||||
|
||||
if !arr_tax.empty?
|
||||
tax_profiles = TaxProfile.unscoped.where("id in ?",arr_tax)
|
||||
else
|
||||
tax_profiles = TaxProfile.unscoped.where("group_type=?",order_source)
|
||||
end
|
||||
#Create new tax records
|
||||
tax_profiles.each do |tax|
|
||||
if tax.group_type.to_s == order_source.to_s
|
||||
@@ -552,8 +562,8 @@ class Sale < ApplicationRecord
|
||||
# end
|
||||
end
|
||||
end
|
||||
self.tax_type = tax_incl_exec
|
||||
self.total_tax = total_tax_amount
|
||||
self.tax_type = tax_incl_exec
|
||||
self.total_tax = total_tax_amount
|
||||
end
|
||||
|
||||
def product_get_unit_price(item_code)
|
||||
@@ -2774,6 +2784,11 @@ def self.get_sale_data_for_other_payment_credit(sale_id)
|
||||
return query
|
||||
end
|
||||
|
||||
def difference(other)
|
||||
h = other.each_with_object(Hash.new(0)) { |e,h| h[e] += 1 }
|
||||
reject { |e| h[e] > 0 && h[e] -= 1 }
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def generate_custom_id
|
||||
|
||||
Reference in New Issue
Block a user