def _add_correction(self, total_amount):
"""Adds a correction for the value of `total_amount` in the month being
processed.
"""
server_tz = timezone.get_default_timezone()
local_now = timezone.localtime(self.now, server_tz)
initial_moment = local_now.replace(day=1, hour=0, minute=0, second=0)
PaidTask.objects.get_or_create(
task_type=PaidTaskTypes.CORRECTION,
amount=(-1) * total_amount,
rate=1,
datetime=self.month_end,
description='Carryover to the next month',
user=self.user,
)
PaidTask.objects.get_or_create(
task_type=PaidTaskTypes.CORRECTION,
amount=total_amount,
rate=1,
datetime=initial_moment,
description='Carryover from the previous month',
user=self.user,
)
评论列表
文章目录