sale receipt no

This commit is contained in:
Yan
2017-11-04 15:00:18 +06:30
parent 15196053a0
commit d4e73a18d1

View File

@@ -12,16 +12,24 @@ class SeedGenerator < ApplicationRecord
return saleOrderId return saleOrderId
end end
# Generate Receipt No # Generate Receipt No for number order (1,2,3) Don't touch
def self.new_receipt_no def self.new_receipt_no
# Only return seed no seed = SeedGenerator.find_by_model("sale")
cur_val, next_val = self.update_seed("sale") new_receipt_no = 0
if (seed.nil?)
seed = SeedGenerator.new()
seed.model = "sale"
new_receipt_no = seed.next
seed.save
if (cur_val == 0) else
cur_val, next_val = self.execute_query("sale") current_no = seed.next
seed.next = seed.next
seed.current = current_no
seed.save
end end
return cur_val return seed.current
end end
# Generate for 4 digit Code # Generate for 4 digit Code