Files
Django/config/management/commands/fix_today_income_count.py

30 lines
1.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""只修正今日 daily_income_stat.total_count不动金额、不动其它天"""
from datetime import date
from django.core.management.base import BaseCommand
from jituan.services.szjilu_accounting import fix_income_stat_count_for_date
class Command(BaseCommand):
help = '修正今日收入笔数repair 会把 total_count 虚增,本命令只改笔数列)'
def add_arguments(self, parser):
parser.add_argument('--date', type=str, default='', help='YYYY-MM-DD默认今天')
parser.add_argument('--yes', action='store_true')
def handle(self, *args, **options):
stat_date = date.fromisoformat(options['date']) if options['date'] else date.today()
dry_run = not options['yes']
r = fix_income_stat_count_for_date(stat_date, dry_run=dry_run)
self.stdout.write(f'日期: {r["date"]}')
self.stdout.write(f' 表内笔数合计(错): {r["before_count"]}')
self.stdout.write(self.style.SUCCESS(f' 修正后笔数: {r["after_count"]}'))
if r['clubs']:
for cid, cnt in r['clubs'].items():
self.stdout.write(f' club={cid}: {cnt}')
if dry_run:
self.stdout.write(self.style.WARNING('\n确认: python manage.py fix_today_income_count --yes'))
else:
self.stdout.write(self.style.SUCCESS('\n已写入 daily_income_stat.total_count请刷新财务页。'))