Fix sales post-repair acceptance gaps

This commit is contained in:
Magzhan Zhumabayev
2026-05-11 17:33:08 +05:00
parent ea200ab4fd
commit 67a0255c0d
3 changed files with 53 additions and 20 deletions
+25 -20
View File
@@ -4108,6 +4108,7 @@ def close_deal(
session.close()
@app.post("/api/v1/deals/{deal_id}/escalations", response_model=SalesEscalationOut)
@app.post("/api/v1/deals/{deal_id}/escalate", response_model=SalesEscalationOut)
def escalate_deal(
deal_id: str,
@@ -6613,28 +6614,32 @@ def reconcile_payment(
else:
adapter = get_payment_provider_adapter(provider)
if adapter is None:
raise HTTPException(status_code=400, detail="Payment provider adapter is not configured")
if not row.external_payment_id:
if provider == "manual":
status = row.status
else:
raise HTTPException(status_code=400, detail="Payment provider adapter is not configured")
elif not row.external_payment_id:
raise HTTPException(status_code=400, detail="Payment external_payment_id is required for reconcile")
provider_result = adapter.get_status(
row.external_payment_id,
context={
"tenant_id": tenant_id,
"payment_id": row.payment_id,
"payment_provider": provider,
"integration_id": integration.integration_id if integration is not None else None,
},
)
if isinstance(provider_result, dict):
status = normalize_payment_status(provider, str(provider_result.get("status") or provider_result.get("provider_status") or ""))
failure_reason = str(provider_result.get("failure_reason") or failure_reason or "") or None
metadata.update(provider_result.get("metadata") if isinstance(provider_result.get("metadata"), dict) else {})
if provider_result.get("amount") is not None:
row.amount = _coerce_payment_amount(provider_result.get("amount"))
if provider_result.get("currency"):
row.currency = str(provider_result.get("currency")).upper()
else:
status = normalize_payment_status(provider, str(provider_result))
provider_result = adapter.get_status(
row.external_payment_id,
context={
"tenant_id": tenant_id,
"payment_id": row.payment_id,
"payment_provider": provider,
"integration_id": integration.integration_id if integration is not None else None,
},
)
if isinstance(provider_result, dict):
status = normalize_payment_status(provider, str(provider_result.get("status") or provider_result.get("provider_status") or ""))
failure_reason = str(provider_result.get("failure_reason") or failure_reason or "") or None
metadata.update(provider_result.get("metadata") if isinstance(provider_result.get("metadata"), dict) else {})
if provider_result.get("amount") is not None:
row.amount = _coerce_payment_amount(provider_result.get("amount"))
if provider_result.get("currency"):
row.currency = str(provider_result.get("currency")).upper()
else:
status = normalize_payment_status(provider, str(provider_result))
updated = _apply_payment_update(
session,