feat: 同步报销流程与工作台改动
This commit is contained in:
@@ -352,9 +352,15 @@ class ExpenseClaimAttachmentOperationsMixin:
|
||||
self._ensure_draft_claim(claim)
|
||||
self._ensure_mutable_claim_item(item)
|
||||
before_json = self._serialize_claim(claim)
|
||||
previous_invoice_id = str(item.invoice_id or "").strip()
|
||||
previous_name = self._attachment_presentation.resolve_display_name(item.invoice_id)
|
||||
self._attachment_storage.delete_item_files(item)
|
||||
item.invoice_id = None
|
||||
claim.risk_flags_json = self._remove_deleted_attachment_risk_flags(
|
||||
claim.risk_flags_json,
|
||||
item_id=item.id,
|
||||
invoice_id=previous_invoice_id,
|
||||
)
|
||||
|
||||
self._sync_claim_from_items(claim)
|
||||
self._refresh_claim_pre_review_flags(claim, is_application_claim=False)
|
||||
@@ -379,6 +385,36 @@ class ExpenseClaimAttachmentOperationsMixin:
|
||||
"attachment": None,
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def _remove_deleted_attachment_risk_flags(
|
||||
risk_flags: Any,
|
||||
*,
|
||||
item_id: str | None,
|
||||
invoice_id: str | None,
|
||||
) -> list[Any]:
|
||||
normalized_item_id = str(item_id or "").strip()
|
||||
normalized_invoice_id = str(invoice_id or "").strip()
|
||||
cleaned_flags: list[Any] = []
|
||||
for flag in list(risk_flags or []):
|
||||
if not isinstance(flag, dict):
|
||||
cleaned_flags.append(flag)
|
||||
continue
|
||||
|
||||
source = str(flag.get("source") or "").strip()
|
||||
if source != "attachment_analysis":
|
||||
cleaned_flags.append(flag)
|
||||
continue
|
||||
|
||||
flag_item_id = str(flag.get("item_id") or flag.get("itemId") or "").strip()
|
||||
flag_invoice_id = str(flag.get("invoice_id") or flag.get("invoiceId") or "").strip()
|
||||
matches_deleted_item = bool(normalized_item_id and flag_item_id == normalized_item_id)
|
||||
matches_deleted_invoice = bool(normalized_invoice_id and flag_invoice_id == normalized_invoice_id)
|
||||
if matches_deleted_item or matches_deleted_invoice:
|
||||
continue
|
||||
|
||||
cleaned_flags.append(flag)
|
||||
return cleaned_flags
|
||||
|
||||
def _get_claim_item_or_raise(
|
||||
self,
|
||||
*,
|
||||
|
||||
Reference in New Issue
Block a user