fix(billing): skip zero-amount invoices (no lines) — drop empty move, don't post nothing

This commit is contained in:
gsinghpal
2026-05-27 17:33:36 -04:00
parent c8529b8a99
commit 95378ff1da
2 changed files with 16 additions and 1 deletions

View File

@@ -171,6 +171,12 @@ class FusionBillingInvoiceLedgerWizard(models.TransientModel):
"account_id": self._fc_income_account("base").id,
"tax_ids": [(6, 0, tax.ids)] if tax else [(5, 0, 0)],
}))
if not line_vals:
# zero-amount invoice (no items, $0 subtotal) — nothing to record;
# drop the empty move (whether just-created or a pre-existing draft).
move.unlink()
summary["skipped"].append({"id": nc_id, "reason": "zero-amount invoice"})
continue
move.write({"invoice_line_ids": line_vals})
summary["updated" if existing else "created"] += 1
if post:
@@ -213,7 +219,7 @@ class FusionBillingInvoiceLedgerWizard(models.TransientModel):
continue
mv = Move.search([("x_fc_nexacloud_invoice_id", "=", nc_id),
("move_type", "=", "out_invoice")], limit=1)
if not mv:
if not mv or not mv.invoice_line_ids:
summary["skipped_missing"] += 1
continue
try: