custom primary key for transaction

This commit is contained in:
Min Zeya Phyo
2017-06-04 16:27:14 +06:30
parent 394d2ed938
commit 4fc511d531
19 changed files with 88 additions and 55 deletions

View File

@@ -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