change receipt no generator
This commit is contained in:
@@ -3,7 +3,7 @@ class Sale < ApplicationRecord
|
||||
|
||||
#primary key - need to be unique generated for multiple shops
|
||||
before_create :generate_custom_id
|
||||
#before_create :generate_receipt_no
|
||||
before_create :generate_receipt_no
|
||||
belongs_to :cashier, :optional => true
|
||||
belongs_to :customer, :optional => true
|
||||
belongs_to :employees
|
||||
@@ -76,7 +76,7 @@ class Sale < ApplicationRecord
|
||||
return false, "Invoice is void. Cannot be edited"
|
||||
else
|
||||
#if this is new sale generate_receipt_no
|
||||
generate_receipt_no
|
||||
# generate_receipt_no
|
||||
order = Order.find(order_id)
|
||||
|
||||
#Default Tax - Values
|
||||
@@ -698,19 +698,20 @@ class Sale < ApplicationRecord
|
||||
def generate_receipt_no
|
||||
#shop_code and client_code
|
||||
shop_details = Shop.first
|
||||
|
||||
#Date-Shift-
|
||||
if self.receipt_no.nil?
|
||||
prefix = DateTime.now().utc
|
||||
#self.receipt_no = prefix.to_s + "/" + self.shit_id.to_s + "/" + SeedGenerator.new_receipt_no().to_s
|
||||
new_receipt_no = SeedGenerator.new_receipt_no().to_s
|
||||
|
||||
if !shop_details.nil?
|
||||
if !shop_details.shop_code.nil?
|
||||
self.receipt_no = shop_details.shop_code + "-" + prefix.strftime("%Y%m%d") + "-" + SeedGenerator.new_receipt_no().to_s
|
||||
self.receipt_no = shop_details.shop_code + "-" + prefix.strftime("%Y%m%d") + "-" + new_receipt_no
|
||||
else
|
||||
self.receipt_no = prefix.strftime("%Y%m%d") + "-" + SeedGenerator.new_receipt_no().to_s
|
||||
self.receipt_no = prefix.strftime("%Y%m%d") + "-" + new_receipt_no
|
||||
end
|
||||
else
|
||||
self.receipt_no = prefix.strftime("%Y%m%d") + "-" + SeedGenerator.new_receipt_no().to_s
|
||||
self.receipt_no = prefix.strftime("%Y%m%d") + "-" + new_receipt_no
|
||||
end
|
||||
|
||||
self.receipt_date = prefix
|
||||
|
||||
Reference in New Issue
Block a user