def deadline(self): # Applicant actions if self.type == self.TYPES.REQUEST: return Deadline(Deadline.TYPES.OBLIGEE_DEADLINE, self.delivered_date or workdays.advance(self.sent_date, 1), 8, Deadline.UNITS.WORKDAYS, self.snooze) elif self.type == self.TYPES.CLARIFICATION_RESPONSE: return Deadline(Deadline.TYPES.OBLIGEE_DEADLINE, self.delivered_date or workdays.advance(self.sent_date, 1), 8, Deadline.UNITS.WORKDAYS, self.snooze) elif self.type == self.TYPES.APPEAL: return Deadline(Deadline.TYPES.OBLIGEE_DEADLINE, self.delivered_date or workdays.advance(self.sent_date, 6), 15, Deadline.UNITS.CALENDAR_DAYS, self.snooze) # Obligee actions elif self.type == self.TYPES.CONFIRMATION: previous = self.previous_action.deadline return Deadline(Deadline.TYPES.OBLIGEE_DEADLINE, previous.base_date, previous.value, previous.unit, self.snooze or previous.snooze_date) elif self.type == self.TYPES.EXTENSION: previous = self.previous_action.deadline extension = self.extension or 0 return Deadline(Deadline.TYPES.OBLIGEE_DEADLINE, previous.base_date, previous.value + extension, previous.unit, self.snooze or previous.snooze_date) elif self.type == self.TYPES.ADVANCEMENT: # The user may send an appeal after advancement. But it is not very common, so we don't # show any deadline nor send deadline reminder. return None elif self.type == self.TYPES.CLARIFICATION_REQUEST: return Deadline(Deadline.TYPES.APPLICANT_DEADLINE, self.delivered_date, 7, Deadline.UNITS.CALENDAR_DAYS, 0) elif self.type == self.TYPES.DISCLOSURE: if self.disclosure_level == self.DISCLOSURE_LEVELS.FULL: return None return Deadline(Deadline.TYPES.APPLICANT_DEADLINE, self.delivered_date, 15, Deadline.UNITS.CALENDAR_DAYS, 0) elif self.type == self.TYPES.REFUSAL: return Deadline(Deadline.TYPES.APPLICANT_DEADLINE, self.delivered_date, 15, Deadline.UNITS.CALENDAR_DAYS, 0) elif self.type == self.TYPES.AFFIRMATION: return None elif self.type == self.TYPES.REVERSION: return None elif self.type == self.TYPES.REMANDMENT: return Deadline(Deadline.TYPES.OBLIGEE_DEADLINE, workdays.advance(self.legal_date, 4), 8, Deadline.UNITS.WORKDAYS, self.snooze) # Implicit actions elif self.type == self.TYPES.ADVANCED_REQUEST: return Deadline(Deadline.TYPES.OBLIGEE_DEADLINE, workdays.advance(self.legal_date, 4), 8, Deadline.UNITS.WORKDAYS, self.snooze) elif self.type == self.TYPES.EXPIRATION: return Deadline(Deadline.TYPES.APPLICANT_DEADLINE, self.legal_date, 15, Deadline.UNITS.CALENDAR_DAYS, 0) elif self.type == self.TYPES.APPEAL_EXPIRATION: return None raise ValueError(u'Invalid action type: {}'.format(self.type))
def deadline_date(self): if self.deadline is None: return None deadline = self.deadline + (self.extension or 0) return workdays.advance(self.effective_date, deadline)
def deadline_date(self): if self.is_in_calendar_days: return self.base_date + datetime.timedelta(days=self.value) else: return workdays.advance(self.base_date, self.value)
def deadline(self): # Applicant actions if self.type == self.TYPES.REQUEST: return Deadline(Deadline.TYPES.OBLIGEE_DEADLINE, self.delivered_date or workdays.advance(self.sent_date, 1), 8, Deadline.UNITS.WORKDAYS, self.snooze) elif self.type == self.TYPES.CLARIFICATION_RESPONSE: return Deadline(Deadline.TYPES.OBLIGEE_DEADLINE, self.delivered_date or workdays.advance(self.sent_date, 1), 8, Deadline.UNITS.WORKDAYS, self.snooze) elif self.type == self.TYPES.APPEAL: return Deadline(Deadline.TYPES.OBLIGEE_DEADLINE, self.delivered_date or workdays.advance(self.sent_date, 6), 15, Deadline.UNITS.CALENDAR_DAYS, self.snooze) # Obligee actions elif self.type == self.TYPES.CONFIRMATION: previous = self.previous_action.deadline return Deadline(Deadline.TYPES.OBLIGEE_DEADLINE, previous.base_date, previous.value, previous.unit, self.snooze or previous.snooze_date) elif self.type == self.TYPES.EXTENSION: previous = self.previous_action.deadline extension = self.extension or 0 return Deadline(Deadline.TYPES.OBLIGEE_DEADLINE, previous.base_date, previous.value + extension, previous.unit, self.snooze or previous.snooze_date) elif self.type == self.TYPES.ADVANCEMENT: # The user may send an appeal after advancement. But it is not very common, so we don't # show any deadline nor send deadline reminder. return None elif self.type == self.TYPES.CLARIFICATION_REQUEST: return Deadline(Deadline.TYPES.APPLICANT_DEADLINE, self.delivered_date, 7, Deadline.UNITS.CALENDAR_DAYS, 0) elif self.type == self.TYPES.DISCLOSURE: if self.disclosure_level == self.DISCLOSURE_LEVELS.FULL: return None return Deadline(Deadline.TYPES.APPLICANT_DEADLINE, self.delivered_date, 15, Deadline.UNITS.CALENDAR_DAYS, 0) elif self.type == self.TYPES.REFUSAL: return Deadline(Deadline.TYPES.APPLICANT_DEADLINE, self.delivered_date, 15, Deadline.UNITS.CALENDAR_DAYS, 0) elif self.type == self.TYPES.AFFIRMATION: return None elif self.type == self.TYPES.REVERSION: return None elif self.type == self.TYPES.REMANDMENT: return Deadline(Deadline.TYPES.OBLIGEE_DEADLINE, workdays.advance(self.legal_date, 4), 8, Deadline.UNITS.WORKDAYS, self.snooze) # Implicit actions elif self.type == self.TYPES.ADVANCED_REQUEST: return Deadline(Deadline.TYPES.OBLIGEE_DEADLINE, workdays.advance(self.legal_date, 4), 8, Deadline.UNITS.WORKDAYS, self.snooze) elif self.type == self.TYPES.EXPIRATION: return Deadline(Deadline.TYPES.APPLICANT_DEADLINE, self.legal_date, 15, Deadline.UNITS.CALENDAR_DAYS, 0) elif self.type == self.TYPES.APPEAL_EXPIRATION: return None raise ValueError(u'Invalid action type: {}'.format(self.type))