Fix hire check bug.
This commit is contained in:
parent
28ef7b0ae0
commit
90dabd7560
|
@ -271,11 +271,9 @@ class Property
|
||||||
time_now = Time.now.to_datetime
|
time_now = Time.now.to_datetime
|
||||||
if self.can_hire_before_months != 0
|
if self.can_hire_before_months != 0
|
||||||
return 2 if ((stime - (self.can_hire_before_months).month) > time_now)
|
return 2 if ((stime - (self.can_hire_before_months).month) > time_now)
|
||||||
available = 1
|
|
||||||
end
|
end
|
||||||
if self.need_hire_before != 0
|
if self.need_hire_before != 0
|
||||||
return 3 if (time_now + (self.need_hire_before).send(self.need_hire_before_unit) > stime)
|
return 3 if (time_now + (self.need_hire_before).send(self.need_hire_before_unit) > stime)
|
||||||
available = 1
|
|
||||||
end
|
end
|
||||||
startt = self.start_date.nil? ? stime : self.start_date
|
startt = self.start_date.nil? ? stime : self.start_date
|
||||||
endt = self.end_date.nil? ? etime : self.end_date
|
endt = self.end_date.nil? ? etime : self.end_date
|
||||||
|
@ -293,14 +291,17 @@ class Property
|
||||||
end
|
end
|
||||||
time_weekdays.uniq!
|
time_weekdays.uniq!
|
||||||
weekdays = weekdays & time_weekdays
|
weekdays = weekdays & time_weekdays
|
||||||
available = 1 if weekdays.blank?
|
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))
|
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))
|
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)
|
common_dates = (startt..endt) & (stime..etime)
|
||||||
available = common_dates.nil?
|
available = common_dates.nil? ? 1 : 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if available
|
end
|
||||||
|
if available == 1
|
||||||
if !recurring_end_date.blank?
|
if !recurring_end_date.blank?
|
||||||
case interval
|
case interval
|
||||||
when 'week'
|
when 'week'
|
||||||
|
|
Loading…
Reference in New Issue