custom primary key for transaction
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
class Order < ApplicationRecord
|
||||
#primary key - need to be unique
|
||||
|
||||
before_create :generate_custom_id
|
||||
before_create :set_order_date
|
||||
|
||||
belongs_to :customer
|
||||
@@ -18,7 +18,7 @@ class Order < ApplicationRecord
|
||||
# option_values : [],
|
||||
# sub_order_items : [],
|
||||
# }
|
||||
|
||||
|
||||
def generate
|
||||
booking = nil
|
||||
|
||||
@@ -182,14 +182,6 @@ class Order < ApplicationRecord
|
||||
return new_items_list
|
||||
end
|
||||
|
||||
private
|
||||
def validate_api_inputs
|
||||
|
||||
end
|
||||
|
||||
def set_order_date
|
||||
self.date = Time.now.utc
|
||||
end
|
||||
|
||||
#Update Items Count and Quantity changes whenever there is changes
|
||||
def update_products_and_quantity_count
|
||||
@@ -249,4 +241,14 @@ class Order < ApplicationRecord
|
||||
.where("dining_facilities.is_active=? and orders.date between ? and ?",true,from,to)
|
||||
.group("orders.id")
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
def generate_custom_id
|
||||
self.order_id = SeedGenerator.generate_id(self.class.name, "ODR")
|
||||
end
|
||||
|
||||
def set_order_date
|
||||
self.date = Time.now.utc
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user