calculate induties bill with min
This commit is contained in:
@@ -50,20 +50,15 @@ class Sale < ApplicationRecord
|
||||
# dining charges
|
||||
charges = DiningCharge.where('dining_facility_id=?',booking.dining_facility_id).take
|
||||
if !charges.nil?
|
||||
block_count, diningprice , checkin_minutes = DiningCharge.amount_calculate(charges, booking.checkin_at, booking.checkout_at)
|
||||
block_count, diningprice = DiningCharge.amount_calculate(charges, booking.checkin_at, booking.checkout_at)
|
||||
if charges.charge_type =='hr'
|
||||
dining_time = booking.checkin_at.strftime('%H:%M %p').to_s + " - " + booking.checkout_at.strftime('%H:%M %p').to_s
|
||||
else
|
||||
dining_time = booking.checkin_at.strftime('%B %d, %H:%M %p').to_s + " - " + booking.checkout_at.strftime('%B %d, %H:%M %p').to_s
|
||||
end
|
||||
# later_time = booking.checkout_at
|
||||
# early_time = booking.checkin_at
|
||||
# distance_in_minutes = ((later_time - early_time)/60.0).round
|
||||
# # time = ((later_time.hour*3600+later_time.min*60+later_time.sec) - (early_time.hour*3600+early_time.min*60+early_time.sec))/24
|
||||
# puts "Hello time"
|
||||
# puts distance_in_minutes
|
||||
# # puts checkin_minutes / 60
|
||||
# puts "Hello block_count"
|
||||
later_time = booking.checkout_at
|
||||
early_time = booking.checkin_at
|
||||
distance_in_minutes = ((later_time - early_time)/60.0).round
|
||||
basic_pay_amount =0
|
||||
name =""
|
||||
if current_checkin_induties_count != "0"
|
||||
@@ -72,7 +67,7 @@ class Sale < ApplicationRecord
|
||||
basic_pay_amount =pay.amount
|
||||
name =pay.name
|
||||
end
|
||||
induties_pay_amount = (current_checkin_induties_count.to_i * (checkin_minutes.to_i / 60).to_f * basic_pay_amount).to_i
|
||||
induties_pay_amount = (current_checkin_induties_count.to_i * (distance_in_minutes / 60.0).to_f * basic_pay_amount).to_i
|
||||
create_saleitem_indutycharges(charges, current_checkin_induties_count.to_i, induties_pay_amount, booking.dining_facility.name, dining_time, order_source, basic_pay_amount)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user