Files
sx-fc/app/models/seed_generator.rb
2017-04-11 13:51:09 +08:00

21 lines
440 B
Ruby

class SeedGenerator < ApplicationRecord
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
else
current_no = seed.next
seed.next = seed.next + seed.increase_by
seed.current = current_no
seed.save
end
return seed.current
end
end