Merge branch 'august_spring' of bitbucket.org:code2lab/sxrestaurant into august_spring
This commit is contained in:
@@ -1,2 +1,4 @@
|
||||
class Commission < ApplicationRecord
|
||||
belongs_to :menu_item, foreign_key: 'product_id'
|
||||
has_many :commissioners
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
class Commissioner < ApplicationRecord
|
||||
has_many :employees
|
||||
belongs_to :employee, foreign_key: 'emp_id'
|
||||
belongs_to :commission, foreign_key: 'commission_type'
|
||||
scope :active, -> { where(is_active: true) }
|
||||
end
|
||||
|
||||
@@ -3,19 +3,22 @@ class DiningCharge < ApplicationRecord
|
||||
belongs_to :room
|
||||
|
||||
def self.amount_calculate(dining_charges_obj, checkin , checkout)
|
||||
|
||||
# note :: the first Charge Block will cost all, the Time rounding block will included in 2nd Charge Block
|
||||
if !checkin.nil? && !checkout.nil? && !dining_charges_obj.nil?
|
||||
price = 0
|
||||
minutes = DiningCharge.time_diff(checkout, checkin)
|
||||
free_time = DiningCharge.convert_to_minutes(dining_charges_obj.minimum_free_time.strftime('%H:%M'))
|
||||
free_time = DiningCharge.convert_to_minutes(dining_charges_obj.minimum_free_time.utc.localtime.strftime('%H:%M'))
|
||||
dining_minutes = minutes - free_time # stayminutes - free minutes
|
||||
charge_type = dining_charges_obj.charge_type
|
||||
if charge_type == 'hr'
|
||||
price = DiningCharge.charges(dining_charges_obj, dining_minutes, 'hr')
|
||||
elsif charge_type == 'day'
|
||||
price = charges(dining_charges_obj, dining_minutes, 'day')
|
||||
if dining_minutes <= 0
|
||||
price = 0
|
||||
else
|
||||
charge_type = dining_charges_obj.charge_type
|
||||
if charge_type == 'hr'
|
||||
price = DiningCharge.charges(dining_charges_obj, dining_minutes, 'hr')
|
||||
elsif charge_type == 'day'
|
||||
price = charges(dining_charges_obj, dining_minutes, 'day')
|
||||
end
|
||||
end
|
||||
|
||||
return price
|
||||
else
|
||||
puts "<<<<<<<< NO"
|
||||
@@ -25,14 +28,15 @@ class DiningCharge < ApplicationRecord
|
||||
|
||||
def self.charges(chargesObj, dining_minutes, type)
|
||||
solid_price = 0
|
||||
block = DiningCharge.convert_to_minutes(chargesObj.charge_block.strftime('%H:%M'))
|
||||
block = DiningCharge.convert_to_minutes(chargesObj.charge_block.utc.localtime.strftime('%H:%M'))
|
||||
|
||||
result = dining_minutes / block
|
||||
if result.to_i < 1
|
||||
return chargesObj.unit_price
|
||||
elsif result.to_i >= 1
|
||||
solid_price = result * chargesObj.unit_price
|
||||
remain_value = dining_minutes % block
|
||||
rounding_block = DiningCharge.convert_to_minutes(chargesObj.time_rounding_block.strftime('%H:%M'))
|
||||
rounding_block = DiningCharge.convert_to_minutes(chargesObj.time_rounding_block.utc.localtime.strftime('%H:%M'))
|
||||
roundingblock = remain_value / rounding_block
|
||||
if roundingblock.to_i < 1
|
||||
return DiningCharge.check_rounding(chargesObj, solid_price)
|
||||
@@ -48,7 +52,7 @@ class DiningCharge < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def self.check_rounding(chargesObj)
|
||||
def self.check_rounding(chargesObj,solid_price)
|
||||
if chargesObj.time_rounding == "down"
|
||||
return solid_price
|
||||
else
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
class Employee < ApplicationRecord
|
||||
has_secure_password
|
||||
belongs_to :commissioner
|
||||
has_many :commissioners
|
||||
has_many :shit_sales
|
||||
|
||||
validates_presence_of :name, :role
|
||||
validates_presence_of :password, :on => [:create]
|
||||
validates :emp_id, uniqueness: true, numericality: true, length: {in: 1..4}, allow_blank: true
|
||||
|
||||
2
app/models/in_juty.rb
Normal file
2
app/models/in_juty.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
class InJuty < ApplicationRecord
|
||||
end
|
||||
@@ -3,6 +3,8 @@ class MenuItem < ApplicationRecord
|
||||
|
||||
belongs_to :menu_category, :optional => true
|
||||
has_many :menu_item_instances
|
||||
has_many :commissions
|
||||
|
||||
# belongs_to :parent, :class_name => "MenuItem", foreign_key: "menu_item_id", :optional => true
|
||||
# has_many :children, :class_name => "MenuItem", foreign_key: "menu_item_id"
|
||||
belongs_to :account
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Product < ApplicationRecord
|
||||
validates_presence_of :name
|
||||
|
||||
|
||||
# Product Image Uploader
|
||||
mount_uploader :image_path, ProductImageUploader
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user