From 1f0739c85886e91ba262ffb3c4609337ab203a22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= Date: Mon, 23 Mar 2026 10:09:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=A5=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/receivable_flow_report.py | 52 ++----------------- 1 file changed, 4 insertions(+), 48 deletions(-) diff --git a/yuthon_report/models/receivable_flow_report.py b/yuthon_report/models/receivable_flow_report.py index 14d911f75..baf5d4304 100644 --- a/yuthon_report/models/receivable_flow_report.py +++ b/yuthon_report/models/receivable_flow_report.py @@ -133,7 +133,7 @@ class ReceivableFlowReport(models.Model): if billing_period: try: - # 兼容中文"到"和英文"~"两种分隔符 + # 兼容中文“到”和英文“~”两种分隔符 if ' 到 ' in billing_period: date_parts = billing_period.split(' 到 ') elif ' ~ ' in billing_period: @@ -148,55 +148,11 @@ class ReceivableFlowReport(models.Model): days_diff = (end_date - start_date).days + 1 billing_period = f"{days_diff} {start_date_str} ~ {end_date_str}" except Exception: - if rec.due_date: - start_date = rec.due_date.replace(day=1) - if rec.payout_date: - end_date = rec.payout_date - else: - if date_end: - end_date_obj = datetime.datetime.fromisoformat(date_end).date() - if end_date_obj.month == 12: - last_day = datetime.date(end_date_obj.year, 12, 31) - else: - last_day = datetime.date(end_date_obj.year, end_date_obj.month + 1, 1) - datetime.timedelta(days=1) - end_date = last_day - else: - today = datetime.date.today() - if today.month == 12: - last_day = datetime.date(today.year, 12, 31) - else: - last_day = datetime.date(today.year, today.month + 1, 1) - datetime.timedelta(days=1) - end_date = last_day - - days_diff = (end_date - start_date).days + 1 - billing_period = f"{days_diff} {start_date.strftime('%Y-%m-%d')} ~ {end_date.strftime('%Y-%m-%d')}" - else: - if rec.due_date: - start_date = rec.due_date.replace(day=1) - if rec.payout_date: - end_date = rec.payout_date - else: - if date_end: - end_date_obj = datetime.datetime.fromisoformat(date_end).date() - if end_date_obj.month == 12: - last_day = datetime.date(end_date_obj.year, 12, 31) - else: - last_day = datetime.date(end_date_obj.year, end_date_obj.month + 1, 1) - datetime.timedelta(days=1) - end_date = last_day - else: - today = datetime.date.today() - if today.month == 12: - last_day = datetime.date(today.year, 12, 31) - else: - last_day = datetime.date(today.year, today.month + 1, 1) - datetime.timedelta(days=1) - end_date = last_day - - days_diff = (end_date - start_date).days + 1 - billing_period = f"{days_diff} {start_date.strftime('%Y-%m-%d')} ~ {end_date.strftime('%Y-%m-%d')}" + billing_period = rec.charging_range or "" + days_diff = 0 # 计算违约金金额 - penalty_amount = days_diff * per_day - penalty_amount = penalty_amount or rec.penalty or rec.original_amount or 0.0 + penalty_amount = round(days_diff * per_day, 2) # 获取违约金收款信息(从预加载字典取) wz_list = wizard_map.get(rec.id, [])