update optimzation

This commit is contained in:
Aung Myo
2018-07-05 12:50:16 +06:30
parent 43fffe9c62
commit f0df6a80ba
5 changed files with 29 additions and 57 deletions

View File

@@ -415,10 +415,12 @@ class Sale < ApplicationRecord
shop = Shop.first
#if tax is not apply create new record
SaleTax.where("sale_id='#{sale.sale_id}'").find_each do |existing_tax|
#delete existing and create new
existing_tax.delete
end
# SaleTax.where("sale_id='#{sale.sale_id}'").find_each do |existing_tax|
# #delete existing and create new
# existing_tax.delete
# end
taxes = SaleTax.where("sale_id='#{sale.sale_id}'").pluck(:sale_tax_id)
SaleTax.where("sale_tax_id IN (?)", taxes).destroy_all
total_tax_amount = 0
tax_incl_exec = "exclusive"