From d159171993d2e43b1dbf0a57c40accc5c8beef67 Mon Sep 17 00:00:00 2001 From: chiu Date: Mon, 25 May 2020 12:09:19 +0800 Subject: [PATCH] fix error --- app/models/property.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/models/property.rb b/app/models/property.rb index a9adfb1..07984fb 100644 --- a/app/models/property.rb +++ b/app/models/property.rb @@ -105,6 +105,9 @@ class Property stime_tp = stime etime_tp = etime b_interval = booking.recurring_interval + if (b_interval == 'month' || b_interval == 'week') && booking.recurring_end_date.nil? + b_interval = nil + end if b_interval == 'month' b_sdata = booking.start_time.day*10000 + booking.start_time.hour*100 + booking.start_time.minute b_edata = booking.end_time.day*10000 + booking.end_time.hour*100 + booking.end_time.minute @@ -126,9 +129,9 @@ class Property sdata = stime_tp edata = etime_tp end - if (sdata <= b_sdata && edata >= b_sdata) || (sdata >= b_sdata && edata <= b_edata) || (sdata <= b_edata && edata >= b_edata) - if etime_tp > booking.start_time - available = false + if etime_tp > booking.start_time + if (sdata <= b_sdata && edata >= b_sdata) || (sdata >= b_sdata && edata <= b_edata) || (sdata <= b_edata && edata >= b_edata) + available = false end end stime_tp = stime_tp + d_step