From 23c6753646b4fec7ac621f7e813c67ac82bb4877 Mon Sep 17 00:00:00 2001 From: chiu Date: Tue, 19 May 2020 23:17:25 +0800 Subject: [PATCH] fix error --- app/models/property.rb | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/app/models/property.rb b/app/models/property.rb index d027357..cec836d 100644 --- a/app/models/property.rb +++ b/app/models/property.rb @@ -95,12 +95,14 @@ class Property case interval when 'week' d_step = 1.week - when 'day' - d_step = 1.day + when 'month' + d_step = 1.month else d_step = 0 end bookings.each do |booking| + stime_tp = stime + etime_tp = etime b_interval = booking.recurring_interval if b_interval == 'month' b_sdata = booking.start_time.day*10000 + booking.start_time.hour*100 + booking.start_time.minute @@ -111,18 +113,18 @@ class Property end while true if b_interval == 'month' - sdata = stime.day*10000 + stime.hour*100 + stime.minute - edata = etime.day*10000 + etime.hour*100 + etime.minute + sdata = stime_tp.day*10000 + stime_tp.hour*100 + stime_tp.minute + edata = etime_tp.day*10000 + etime_tp.hour*100 + etime_tp.minute elsif b_interval == 'week' - sdata = stime.wday*10000 + stime.hour*100 + stime.minute - edata = etime.wday*10000 + etime.hour*100 + etime.minute + sdata = stime_tp.wday*10000 + stime_tp.hour*100 + stime_tp.minute + edata = etime_tp.wday*10000 + etime_tp.hour*100 + etime_tp.minute end if (b_sdata <= sdata && b_edata >= sdata) || (b_sdata >= sdata && b_edata <= edata) || (b_sdata <= edata && b_edata >= edata) available = false end - stime = stime + d_step - etime = etime + d_step - break if recurring_end_date.nil? || recurring_end_date < stime + stime_tp = stime_tp + d_step + etime_tp = etime_tp + d_step + break if recurring_end_date.nil? || recurring_end_date < stime_tp end break if available == false end