seed generator fun:

This commit is contained in:
phyusin
2018-10-16 17:38:33 +06:30
parent ed2398a495
commit a6393a5140
2 changed files with 8 additions and 6 deletions

View File

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

View File

@@ -21,7 +21,6 @@ class SeedGenerator < ApplicationRecord
seed.model = "sale" seed.model = "sale"
new_receipt_no = seed.next new_receipt_no = seed.next
seed.save seed.save
else else
current_no = seed.next current_no = seed.next
seed.next = seed.next seed.next = seed.next
@@ -85,7 +84,7 @@ class SeedGenerator < ApplicationRecord
current = 0 current = 0
nex = 0 nex = 0
update_sql = "UPDATE seed_generators set current = current + 1, next = next + 1 WHERE model='#{model}';" update_sql = "UPDATE seed_generators set current = next, next = next + 1 WHERE model='#{model}';"
select_sql = "select * from seed_generators where model='#{model}';" select_sql = "select * from seed_generators where model='#{model}';"
update_result = ActiveRecord::Base.connection.execute(update_sql); update_result = ActiveRecord::Base.connection.execute(update_sql);