shop_setup branch

This commit is contained in:
Min Zeya Phyo
2017-05-30 23:46:22 +08:00
parent 9361e24a8a
commit 516b854fba
17 changed files with 79 additions and 3 deletions

View File

@@ -1,4 +1,23 @@
class SeedGenerator < ApplicationRecord
def self.generate_id(model, prefix)
seed = SeedGenerator.find_by_model(model)
new_receipt_no = 0
if (seed.nil?)
seed = SeedGenerator.new()
seed.model = model
new_receipt_no = seed.next
seed.save
else
current_no = seed.next
seed.next = seed.next + seed.increase_by
seed.current = current_no
seed.save
end
return prefix + "-" + seed.current.to_s
end
def self.new_receipt_no
seed = SeedGenerator.find_by_model("sale")
new_receipt_no = 0