fix(opportunity-flow): wait after sent quote until payment evidence

This commit is contained in:
plx
2026-08-18 14:47:13 +00:00
parent 5f0c151feb
commit 7e521a377e
2 changed files with 49 additions and 12 deletions

View File

@@ -17,18 +17,39 @@ def test_blif_profile_loads_defaults_and_labels():
assert profile.documents["invoice"]["label"] == "Fatura"
def test_quote_before_shipping_requires_confirm_payment_before_invoice():
def test_sent_quote_waits_for_customer_or_payment_evidence():
evidence = build_opportunity_evidence(
{"id": "opp-1", "stage": "QUOTE_SENT", "metadata": {"payment_terms": "before_shipping"}},
linked_customer={"id": "c1", "tax_id": "123", "billing_email": "a@b.pt", "address": "Rua", "postal_code": "1000", "city": "Lisboa"},
linked_documents=[{"id": "q1", "document_kind": "quotation", "document_number": "ORC.ORC2026.177", "total_amount": 202.95}],
{
"id": "opp-1",
"stage": "QUOTE_SENT",
"metadata": {"payment_terms": "before_shipping"},
},
linked_customer={
"id": "c1",
"tax_id": "123",
"billing_email": "a@b.pt",
"address": "Rua",
"postal_code": "1000",
"city": "Lisboa",
},
linked_documents=[
{
"id": "q1",
"document_kind": "quotation",
"document_number": "ORC.ORC2026.177",
"total_amount": 202.95,
}
],
operation_snapshot={"links": [], "cards": []},
fiscal_data_complete=True,
)
decision = decide_opportunity_next_action(evidence, _profile())
assert decision.next_action.code == "CONFIRM_PAYMENT"
assert decision.next_action.code == "NO_ACTION"
assert decision.commercial_stage == "WAITING_PAYMENT"
assert decision.next_action.document_number == "ORC.ORC2026.177"
assert "antes da fatura" in decision.next_action.description or "antes de emitir fatura" in decision.next_action.description
assert "Aguardar" in decision.next_action.description
def test_payment_confirmed_without_invoice_sends_invoice():