update order and request bill

This commit is contained in:
Thein Lin Kyaw
2019-12-11 17:56:39 +06:30
parent 26edf23b46
commit 58117d0f48
28 changed files with 336 additions and 448 deletions

View File

@@ -4,7 +4,7 @@ class DiningCharge < ApplicationRecord
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?
if !checkin.nil? && !checkout.nil? && !dining_charges_obj.nil?
block_count = 0
price = 0
minutes = DiningCharge.time_diff(checkout, checkin)
@@ -13,18 +13,17 @@ class DiningCharge < ApplicationRecord
if dining_minutes <= free_time
price = 0
else
charge_type = dining_charges_obj.charge_type
charge_type = dining_charges_obj.charge_type
if charge_type == 'hr'
block_count, price = DiningCharge.charges(dining_charges_obj, dining_minutes, 'hr')
elsif charge_type == 'day'
block_count, price = DiningCharge.charges(dining_charges_obj, dining_minutes, 'day')
end
end
return block_count, price
return block_count, price
else
puts "<<<<<<<< NO"
return 0, 0
end
end
# dining charges calculate
@@ -37,7 +36,7 @@ class DiningCharge < ApplicationRecord
rounding_time = DiningCharge.convert_to_minutes(chargesObj.time_rounding_block.utc.strftime('%H:%M'))
if result.to_i < 1
# for dining minute is under charge_block
if dining_minutes > rounding_time
if dining_minutes > rounding_time
rounding_block = dining_minutes / rounding_time
solid_price = rounding_block * chargesObj.time_rounding_block_price
@@ -46,7 +45,7 @@ class DiningCharge < ApplicationRecord
else
return 1, result.to_i,chargesObj.unit_price
end
elsif result.to_i >= 1
elsif result.to_i >= 1
solid_price = result * chargesObj.unit_price
@@ -64,7 +63,7 @@ class DiningCharge < ApplicationRecord
else
solid_price += (roundingblock * chargesObj.time_rounding_block_price)
return result.to_i, DiningCharge.check_rounding(chargesObj, solid_price, extra_minutes)
return result.to_i, DiningCharge.check_rounding(chargesObj, solid_price, extra_minutes)
end
end
end
@@ -74,7 +73,7 @@ class DiningCharge < ApplicationRecord
# rounding_block_remain = roundingblock / 1
free_time = DiningCharge.convert_to_minutes(chargesObj.minimum_free_time.utc.strftime('%H:%M'))
rounding_block_remain = extra_minutes - free_time
if chargesObj.time_rounding == "down"
return solid_price
else