add shift id in authenticate and remove session token for close shift
This commit is contained in:
@@ -8,19 +8,20 @@ class SeedGenerator < ApplicationRecord
|
||||
end
|
||||
|
||||
padding_len = 15 - prefix.length
|
||||
generate_id = prefix +"-"+ cur_val.to_s.to_s.rjust((14-prefix.length)+1,'0')
|
||||
return generate_id
|
||||
last_val = prefix +"-"+ cur_val.to_s.to_s.rjust((14-prefix.length)+1,'0')
|
||||
return last_val
|
||||
end
|
||||
|
||||
# Generate Receipt No for number order (1,2,3) Don't touch
|
||||
def self.new_receipt_no
|
||||
seed = SeedGenerator.find_by_model("sale")
|
||||
seed = SeedGenerator.find_by_model("Sale")
|
||||
new_receipt_no = 0
|
||||
if (seed.nil?)
|
||||
seed = SeedGenerator.new()
|
||||
seed.model = "sale"
|
||||
seed.model = "Sale"
|
||||
new_receipt_no = seed.next
|
||||
seed.save
|
||||
|
||||
else
|
||||
current_no = seed.next
|
||||
seed.next = seed.next
|
||||
@@ -63,16 +64,14 @@ class SeedGenerator < ApplicationRecord
|
||||
def self.execute_query(model)
|
||||
current = 0
|
||||
nex = 0
|
||||
|
||||
|
||||
sql = "INSERT INTO seed_generators (model, created_at, updated_at)
|
||||
VALUES('#{ model }', NOW(), NOW())
|
||||
ON DUPLICATE KEY UPDATE current = next, next = next + 1;"
|
||||
|
||||
select_sql = "select * from seed_generators where model='#{model}';"
|
||||
ON DUPLICATE KEY UPDATE current = current + 1, next = next + 1;"
|
||||
|
||||
select_sql = "select * from seed_generators where model='#{model}';"
|
||||
ActiveRecord::Base.connection.execute(sql);
|
||||
select_result = ActiveRecord::Base.connection.execute(select_sql);
|
||||
|
||||
select_result = ActiveRecord::Base.connection.execute(select_sql);
|
||||
|
||||
select_result.each do |row|
|
||||
current = row [3]
|
||||
@@ -88,8 +87,8 @@ class SeedGenerator < ApplicationRecord
|
||||
|
||||
update_sql = "UPDATE seed_generators set current = next, next = next + 1 WHERE model='#{model}';"
|
||||
select_sql = "select * from seed_generators where model='#{model}';"
|
||||
|
||||
update_result = ActiveRecord::Base.connection.execute(update_sql);
|
||||
|
||||
select_result = ActiveRecord::Base.connection.execute(select_sql);
|
||||
|
||||
select_result.each do |row|
|
||||
|
||||
Reference in New Issue
Block a user