change receipt no

This commit is contained in:
phyusin
2018-11-01 18:07:06 +06:30
parent 225d0ac7a8
commit 2a9b93cffb

View File

@@ -16,19 +16,25 @@ class SeedGenerator < ApplicationRecord
def self.new_receipt_no def self.new_receipt_no
seed = SeedGenerator.find_by_model("Sale") seed = SeedGenerator.find_by_model("Sale")
new_receipt_no = 0 new_receipt_no = 0
if (seed.nil?) # if (seed.nil?)
seed = SeedGenerator.new() # seed = SeedGenerator.new()
seed.model = "Sale" # seed.model = "Sale"
new_receipt_no = seed.next # new_receipt_no = seed.next
seed.save # seed.save
# else # else
# current_no = seed.next # current_no = seed.next
# seed.next = seed.next # seed.next = seed.next
# seed.current = current_no # seed.current = current_no
# seed.save # seed.save
# end
if seed.current > 0
new_receipt_no = seed.current
else
new_receipt_no = seed.current + 1
end end
return seed.current return new_receipt_no
end end
# Generate for 4 digit Code # Generate for 4 digit Code