bugfix: Invoice details

This commit is contained in:
2026-08-24 16:39:08 -03:00
parent 4b3e4d44e8
commit d7f270f52a
102 changed files with 183 additions and 10 deletions

View File

@@ -36,8 +36,29 @@ class ContasDomainService:
partial = [p for p in products if needle in str(p.get("name") or p.get("description") or "").lower() or str(p.get("name") or p.get("description") or "").lower() in needle]
return partial[0] if partial else None
def consultar_faturas(self, *, msisdn: str, **_: Any) -> Any:
return self.client.consultar_faturas(msisdn)
def consultar_faturas(self, *, msisdn: str, **args: Any) -> Any:
"""Consulta faturas e expõe o resumo semântico quando pré-carregado.
A fonte de ``invoice_amount`` continua sendo a fatura detalhada (Bill PDF),
como no Contas original. O MCP apenas apresenta esse dado junto do retorno
de Complete Invoices; não altera o contrato do backend TIM nem inventa valor.
"""
complete = args.get("complete_invoices_payload")
if not isinstance(complete, dict):
complete = self.client.consultar_faturas(msisdn)
if not isinstance(complete, dict):
return complete
result = dict(complete)
for key in ("invoice_amount", "invoice_amount_open", "invoice_period", "invoice_emissao"):
value = args.get(key)
if value not in (None, ""):
result[key] = value
if args.get("invoice_id") not in (None, ""):
result.setdefault("invoice_id", args.get("invoice_id"))
if args.get("customer_id") not in (None, ""):
result.setdefault("customer_id", args.get("customer_id"))
return result
def consultar_plano(self, *, msisdn: str, **args: Any) -> dict[str, Any]:
"""Retorna somente os planos presentes na evidência de billing analysis.