fix error

This commit is contained in:
chiu 2020-05-20 00:28:21 +08:00
parent c43dd3c625
commit 73241e7b18
1 changed files with 7 additions and 14 deletions

View File

@ -83,15 +83,16 @@ class Property
end
def is_already_hired?(stime, etime, interval, recurring_end_date)
bookings = self.p_hires.where(:start_time.lte => stime,:end_time.gte => stime,:recurring => false)
.or(:start_time.gte => stime,:end_time.lte => etime,:recurring => false)
.or(:start_time.lte => etime,:end_time.gte => etime,:recurring => false)
phires = self.p_hires
bookings_count = phires.where(:start_time.lte => stime,:end_time.gte => stime,:recurring => false).count
+ phires.where(:start_time.gte => stime,:end_time.lte => etime,:recurring => false).count
+phires.where(:start_time.lte => etime,:end_time.gte => etime,:recurring => false).count
available = true
if bookings.count != 0
if bookings_count != 0
available = false
end
if available
bookings = self.p_hires.where(:recurring_end_date.gte => stime, :recurring => true).or(:recurring => false)
bookings = phires.where(:recurring_end_date.gte => stime, :recurring => true) + phires.where(:recurring => false)
case interval
when 'week'
d_step = 1.week
@ -145,11 +146,3 @@ class Property
end
end