hotfix(backend): Fix month credit calculation on December (#8851)

This commit is contained in:
Zamil Majdy 2024-12-02 09:00:01 +07:00
parent d26105d382
commit 0c2940353f
1 changed files with 5 additions and 1 deletions

View File

@ -70,7 +70,11 @@ class UserCredit(UserCreditBase):
async def get_or_refill_credit(self, user_id: str) -> int:
cur_time = self.time_now()
cur_month = cur_time.replace(day=1, hour=0, minute=0, second=0, microsecond=0)
nxt_month = cur_month.replace(month=cur_month.month % 12 + 1)
nxt_month = (
cur_month.replace(month=cur_month.month + 1)
if cur_month.month < 12
else cur_month.replace(year=cur_month.year + 1, month=1)
)
user_credit = await UserBlockCredit.prisma().group_by(
by=["userId"],