Fix hire check bug.

This commit is contained in:
BoHung Chiu 2022-02-23 17:36:59 +08:00
parent 28ef7b0ae0
commit 90dabd7560
1 changed files with 9 additions and 8 deletions

View File

@ -271,11 +271,9 @@ class Property
time_now = Time.now.to_datetime
if self.can_hire_before_months != 0
return 2 if ((stime - (self.can_hire_before_months).month) > time_now)
available = 1
end
if self.need_hire_before != 0
return 3 if (time_now + (self.need_hire_before).send(self.need_hire_before_unit) > stime)
available = 1
end
startt = self.start_date.nil? ? stime : self.start_date
endt = self.end_date.nil? ? etime : self.end_date
@ -293,14 +291,17 @@ class Property
end
time_weekdays.uniq!
weekdays = weekdays & time_weekdays
available = 1 if weekdays.blank?
startt = DateTime.parse(stime.strftime("%Y-%m-%d " + (self.start_time.blank? ? "00:00" : self.start_time) + Time.zone.to_s))
endt = DateTime.parse(etime.strftime("%Y-%m-%d " + (self.end_time.blank? ? "23:59" : self.end_time) + Time.zone.to_s))
common_dates = (startt..endt) & (stime..etime)
available = common_dates.nil?
if weekdays.blank?
available = 1
else
startt = DateTime.parse(stime.strftime("%Y-%m-%d " + (self.start_time.blank? ? "00:00" : self.start_time) + Time.zone.to_s))
endt = DateTime.parse(etime.strftime("%Y-%m-%d " + (self.end_time.blank? ? "23:59" : self.end_time) + Time.zone.to_s))
common_dates = (startt..endt) & (stime..etime)
available = common_dates.nil? ? 1 : 0
end
end
end
if available
if available == 1
if !recurring_end_date.blank?
case interval
when 'week'