from pathlib import Path

ROOT = Path(__file__).resolve().parents[1]


def read(path: str) -> str:
    return (ROOT / path).read_text(encoding="utf-8")


def test_after_delivery_odoo_sale_order_is_not_blocked_by_missing_payment():
    guard = read("app/workflow_guard.py")
    assert 'if payment_terms == "after_delivery"' in guard
    assert 'return None' in guard
    assert 'exceto quando a condição é pagamento após entrega' in guard
    assert 'Pagamento após entrega permite avançar Odoo' in guard


def test_quick_finance_after_delivery_has_specific_payment_label():
    opps = read("app/admin_ui/pages/opportunities.py")
    assert 'button_label = "Confirmar pagamento pós-entrega"' in opps
    assert 'Registar pagamento recebido após entrega/acordo comercial.' in opps
