优化案件模块
This commit is contained in:
@@ -3,6 +3,7 @@ from rest_framework.response import Response
|
||||
from rest_framework import status
|
||||
import json
|
||||
import ast
|
||||
import re
|
||||
from User.models import User, Approval
|
||||
from User.utils import log_operation, normalize_approvers_param, build_missing_approvers_message
|
||||
from .models import PreFiling, ProjectRegistration, Bid, Case, Invoice, Caselog, SealApplication, Warehousing, \
|
||||
@@ -1292,6 +1293,28 @@ class caseManagementDetail(APIView):
|
||||
except (json.JSONDecodeError, TypeError):
|
||||
closing_application_list = []
|
||||
|
||||
# 处理已开票字段:转换为数值
|
||||
invoice_status_value = "0"
|
||||
if info.invoice_status:
|
||||
try:
|
||||
# 尝试转换为数值(可能是字符串格式的数字)
|
||||
invoice_status_str = str(info.invoice_status).strip()
|
||||
# 如果是"未开票"等非数字字符串,返回0
|
||||
if invoice_status_str in ["未开票", "", None]:
|
||||
invoice_status_value = "0"
|
||||
else:
|
||||
# 尝试提取数字部分
|
||||
numbers = re.findall(r'\d+\.?\d*', invoice_status_str)
|
||||
if numbers:
|
||||
invoice_status_value = numbers[0]
|
||||
else:
|
||||
invoice_status_value = "0"
|
||||
except (ValueError, TypeError, AttributeError):
|
||||
invoice_status_value = "0"
|
||||
|
||||
# 处理已收款字段:确保是字符串格式
|
||||
paymentcollection_value = info.paymentcollection or "0"
|
||||
|
||||
data.append({
|
||||
"id": info.id,
|
||||
"ContractNo": contract_no or "", # 合同编号
|
||||
@@ -1311,8 +1334,8 @@ class caseManagementDetail(APIView):
|
||||
"ChangeItem": info.ChangeItem,
|
||||
"ChangeReason": info.ChangeReason,
|
||||
"ChangeAgreement": info.ChangeAgreement,
|
||||
"invoice_status": info.invoice_status or "未开票", # 已开票
|
||||
"paymentcollection": info.paymentcollection or "", # 已收款
|
||||
"invoice_status": invoice_status_value, # 已开票(数值字符串)
|
||||
"paymentcollection": paymentcollection_value, # 已收款
|
||||
"state": info.state,
|
||||
"project_id": info.project_id,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user