diff --git a/public_records_portal/db_helpers.py b/public_records_portal/db_helpers.py index b849297c7..a2362e4e5 100644 --- a/public_records_portal/db_helpers.py +++ b/public_records_portal/db_helpers.py @@ -13,6 +13,7 @@ from models import * from public_records_portal import cal, app +from business_calendar import Calendar, MO, TU, WE, TH, FR, FOLLOWING try: import ldap @@ -495,6 +496,7 @@ def change_request_status(request_id, status): (request_id, status)) date_created = req.date_received or req.date_created + date_created = cal.adjust(date_created, FOLLOWING) if "days" in status: days_to_fulfill = re.findall(r"(\d{2}) days",status)[0] app.logger.info("Changing Due Date: %s " % cal.addbusdays(date_created, int(days_to_fulfill))) diff --git a/public_records_portal/models.py b/public_records_portal/models.py index 8fbce407f..03db9c6c4 100644 --- a/public_records_portal/models.py +++ b/public_records_portal/models.py @@ -22,7 +22,7 @@ check_password_hash from public_records_portal import db, app, cal - +from business_calendar import Calendar, MO, TU, WE, TH, FR, FOLLOWING class notePrivacy: PUBLIC = 0x01 @@ -339,9 +339,13 @@ def set_due_date(self): if not self.date_received: self.date_received = self.date_created if self.extended == True: - self.due_date = cal.addbusdays(self.date_received, int(app.config['DAYS_AFTER_EXTENSION'])) + self.due_date = cal.addbusdays(cal.adjust(self.date_received, FOLLOWING), int(app.config['DAYS_AFTER_EXTENSION'])) + if self.date_received.hour > 17: + self.due_date = cal.addbusdays(self.due_date, 1) else: - self.due_date = cal.addbusdays(self.date_received, int(app.config['DAYS_TO_FULFILL'])) + self.due_date = cal.addbusdays(cal.adjust(self.date_received, FOLLOWING), int(app.config['DAYS_TO_FULFILL'])) + if self.date_received.hour > 17: + self.due_date = cal.addbusdays(self.due_date, 1) def extension(self, days_after=int(app.config['DAYS_AFTER_EXTENSION']),