dining charge

This commit is contained in:
Nweni
2017-08-14 11:30:58 +06:30
parent b0ad2049c5
commit 6f39a024ca

View File

@@ -1,2 +1,39 @@
class DiningCharge < ApplicationRecord
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