Esempio n. 1
0
    def _adjust_for_vhnd_presence(self, non_adjusted_month, anchor_date_to_check):
        """
        check the base window month for a VHND after the anchor date.
        if no VHND occurs then the month is bumped back a month
        """
        # look at vhnds in the same month as the anchor date
        startdate = datetime.date(anchor_date_to_check.year, anchor_date_to_check.month, 1)
        enddate = first_of_next_month(startdate)
        vhnds_to_check = self.data_provider.get_dates_in_range(self.owner_id, startdate, enddate)

        # if any vhnd in the month occurred after the anchor date or it didn't occur at all, no need to adjust.
        # if it occurred before the anchor date, adjust, by subtracting one from the non-adjusted month
        adjust = max(vhnds_to_check) < anchor_date_to_check if vhnds_to_check else False
        return non_adjusted_month - 1 if adjust else non_adjusted_month
Esempio n. 2
0
    def _adjust_for_vhnd_presence(self, non_adjusted_month, anchor_date_to_check):
        """
        check the base window month for a VHND after the anchor date.
        if no VHND occurs then the month is bumped back a month
        """
        # look at vhnds in the same month as the anchor date
        startdate = datetime.date(anchor_date_to_check.year, anchor_date_to_check.month, 1)
        enddate = first_of_next_month(startdate)
        vhnds_to_check = self.data_provider.get_dates_in_range(self.owner_id, startdate, enddate)

        # if any vhnd in the month occurred after the anchor date or it didn't occur at all, no need to adjust.
        # if it occurred before the anchor date, adjust, by subtracting one from the non-adjusted month
        adjust = max(vhnds_to_check) < anchor_date_to_check if vhnds_to_check else False
        return non_adjusted_month - 1 if adjust else non_adjusted_month
Esempio n. 3
0
 def get_months_after(self, months_after=None):
     new_year, new_month = add_months(self.year, self.month, months_after)
     return first_of_next_month(datetime.datetime(new_year, new_month, 1))
Esempio n. 4
0
 def get_months_before(self, months_before=None):
     new_year, new_month = add_months(self.year, self.month, -months_before)
     return first_of_next_month(datetime.datetime(new_year, new_month, 1))
Esempio n. 5
0
 def reporting_window_end(self):
     return first_of_next_month(datetime.date(self.year, self.month, 1))
Esempio n. 6
0
 def get_months_after(self, months_after=None):
     new_year, new_month = add_months(self.year, self.month, months_after)
     return first_of_next_month(datetime.datetime(new_year, new_month, 1))
Esempio n. 7
0
 def get_months_before(self, months_before=None):
     new_year, new_month = add_months(self.year, self.month, -months_before)
     return first_of_next_month(datetime.datetime(new_year, new_month, 1))
Esempio n. 8
0
 def reporting_window_end(self):
     return first_of_next_month(datetime.date(self.year, self.month, 1))