Merge branch 'menu_sync' of bitbucket.org:code2lab/sxrestaurant into staging

This commit is contained in:
Aung Myo
2017-08-14 15:35:44 +06:30
71 changed files with 1405 additions and 44 deletions

View File

@@ -0,0 +1,41 @@
class DiningCharge < ApplicationRecord
belongs_to :table
belongs_to :room
def amount_calculate(dining_charges_obj, checkin , checkout)
if !checkin.nil? && !checkout.nil? && !dining_charges_obj.nil?
minutes = ((checkin - checkout) * 24 * 60).to_i # stay minutes
dining_minutes = minutes - dining_charges_obj.minimum_free_time # stayminutes - free minutes
charge_type = dining_charges_obj.charge_type
if charge_type == 'hr'
elsif charge_type == 'day'
price = charge_by_day
end
end
end
def charge_by_hour
end
def charge_by_day(chargesObj, dining_minutes)
minues_per_day = 12 * 60
result = dining_minutes / minues_per_day
if result < 1
return chargesObj.unit_price
elsif result > 1
solid_price = result * chargesObj.unit_price
remain_value = dining_minutes % minues_per_day
roundingblock = remain_value / chargesObj.time_rounding_block
if roundingblock > 1
end
end
end
end

View File

@@ -1,5 +1,6 @@
class DiningFacility < ApplicationRecord
belongs_to :zone
has_many :dining_charges
TABLE_TYPE = "Table"
ROOM_TYPE = "Room"

7
app/models/item_set.rb Normal file
View File

@@ -0,0 +1,7 @@
class ItemSet < ApplicationRecord
has_many :menu_item_sets
has_many :menu_items, through: :menu_item_sets
has_many :menu_instance_item_sets
has_many :menu_item_instances, through: :menu_instance_item_sets
end

View File

@@ -1,5 +1,5 @@
class MenuCategory < ApplicationRecord
before_create :generate_menu_category_code
# before_create :generate_menu_category_code
belongs_to :menu
has_many :children, :class_name => "MenuCategory", foreign_key: "menu_category_id"
@@ -37,7 +37,7 @@ class MenuCategory < ApplicationRecord
private
def generate_menu_category_code
self.code = SeedGenerator.generate_code(self.class.name, "C")
end
# def generate_menu_category_code
# self.code = SeedGenerator.generate_code(self.class.name, "C")
# end
end

View File

@@ -0,0 +1,4 @@
class MenuInstanceItemSet < ApplicationRecord
belongs_to :item_set
belongs_to :menu_item_instance
end

View File

@@ -1,6 +1,5 @@
class MenuItem < ApplicationRecord
before_create :generate_menu_item_code
# before_create :generate_menu_item_code
belongs_to :menu_category, :optional => true
has_many :menu_item_instances
@@ -8,6 +7,9 @@ class MenuItem < ApplicationRecord
has_many :children, :class_name => "MenuItem", foreign_key: "menu_item_id"
belongs_to :account
has_many :menu_item_sets
has_many :item_sets, through: :menu_item_sets
validates_presence_of :name, :type, :min_qty, :taxable, :min_selectable_item, :max_selectable_item
default_scope { order('item_code asc') }
@@ -70,10 +72,10 @@ class MenuItem < ApplicationRecord
end
private
# private
def generate_menu_item_code
self.item_code = SeedGenerator.generate_code(self.class.name, "I")
end
# def generate_menu_item_code
# self.item_code = SeedGenerator.generate_code(self.class.name, "I")
# end
end

View File

@@ -1,6 +1,6 @@
class MenuItemInstance < ApplicationRecord
belongs_to :menu_item
before_create :generate_menu_item_instance_code
# before_create :generate_menu_item_instance_code
def self.findParentCategory(item)
if item.menu_category_id
@@ -11,9 +11,9 @@ class MenuItemInstance < ApplicationRecord
end
end
private
# private
def generate_menu_item_instance_code
self.item_instance_code = SeedGenerator.generate_code(self.class.name, "II")
end
# def generate_menu_item_instance_code
# self.item_instance_code = SeedGenerator.generate_code(self.class.name, "II")
# end
end

View File

@@ -0,0 +1,4 @@
class MenuItemSet < ApplicationRecord
belongs_to :item_set
belongs_to :menu_item
end

View File

@@ -65,7 +65,6 @@ class Order < ApplicationRecord
end
def adding_line_items
if self.items
#re-order to
ordered_list = re_order_items(self.items)