def get_due_date(self, date1): assert isinstance(date1, datetime.date), \ "%s is not a date" % date1 d = date1 + relativedelta(months=self.months, days=self.days) if self.end_of_month: d = last_day_of_month(d) return d
def daterange2hours(self, sd, ed, summary): if sd and ed: ssd = datetime.date(summary.year, summary.month or 1, 1) sd = max(sd, ssd) sed = last_day_of_month( datetime.date(summary.year, summary.month or 12, 1)) ed = min(ed, sed) nb_of_days = weekdays(sd, ed) return Duration("38:00") * nb_of_days / 7
def get_default_for_date(cls, d): ref = cls.get_ref_for_date(d) obj = rt.models.ledger.AccountingPeriod.get_by_ref(ref, None) if obj is None: values = dict(start_date=d.replace(day=1)) values.update(end_date=last_day_of_month(d)) values.update(ref=ref) obj = AccountingPeriod(**values) obj.full_clean() obj.save() return obj
def get_default_for_date(cls, d): ref = cls.get_ref_for_date(d) obj = rt.modules.ledger.AccountingPeriod.get_by_ref(ref, None) if obj is None: values = dict(start_date=d.replace(day=1)) values.update(end_date=last_day_of_month(d)) values.update(ref=ref) obj = AccountingPeriod(**values) obj.full_clean() obj.save() return obj
def get_default_end_date(self): return last_day_of_month(dd.today())