def customer_monthly_usage(subscription_start, start=None, end=None):
if start is None:
start = subscription_start
# regardless of start, the monthly iterator must use subscription_start for
# the sake of enumerating.
periods = iter_months(start=subscription_start,
end=end or timezone.now())
for m, usage in enumerate(usage_for_periods(periods), 1):
if usage['period']['end'] <= start:
continue
usage.update(
labels=dict(
year_month=label_year_month_m(m),
year_quarter=label_year_quarter_m(m),
year=label_year_m(m),
),
)
yield usage
评论列表
文章目录