This commit is contained in:
Yan
2017-10-31 18:23:03 +06:30
parent 2ae1b5ba3d
commit f01fab0951

View File

@@ -14,22 +14,14 @@ class SeedGenerator < ApplicationRecord
# Generate Receipt No
def self.new_receipt_no
seed = SeedGenerator.find_by_model("sale")
new_receipt_no = 0
if (seed.nil?)
seed = SeedGenerator.new()
seed.model = "sale"
new_receipt_no = seed.next
seed.save
# Only return seed no
cur_val, next_val = self.update_seed("sale")
else
current_no = seed.next
seed.next = seed.next
seed.current = current_no
seed.save
end
if (cur_val == 0)
cur_val, next_val = self.execute_query("sale")
end
return seed.current
return cur_val
end
# Generate for 4 digit Code