The NexaCloud->Odoo ledger now verifies every new invoice against its
SOURCE billing system before posting, instead of trusting NexaCloud's
unreliable created_at/status/paid_at:
- _fc_verify routes by stripe_invoice_id prefix (in_ -> Stripe REST,
lago: -> Lago REST) and returns source-truth
{invoice_date, void, draft, paid, paid_at, amount_paid}, or None when it
can't be determined/reached (left for the next run).
- _ingest_invoices(post=True, verified=...) uses the source invoice date
(and accounting date), and reconciles a payment ONLY when the source
confirms paid.
- _cron_sync_verified posts only finalized invoices; skips void + draft,
logs unverified for retry. Replaces the old _cron_ingest_recent.
Cron cron_fc_invoice_ledger is enabled daily on nexamain. First live run:
23 already-posted, 1 void + 2 Stripe drafts + 5 zero-amount all skipped,
0 new posted, ledger intact at $3,403.46.
Tests: routing/guards (no network), verified date+reconcile, and the cron's
void/draft/unverified filtering (sources patched). FCB_EXIT=0 on odoo-trial.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
36 lines
1.7 KiB
XML
36 lines
1.7 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<odoo noupdate="1">
|
|
<record id="cron_fc_rate_usage" model="ir.cron">
|
|
<field name="name">Fusion Billing: Rate usage before invoicing</field>
|
|
<field name="model_id" ref="model_fusion_billing_usage"/>
|
|
<field name="state">code</field>
|
|
<field name="code">model._cron_rate_open_periods()</field>
|
|
<field name="interval_number">1</field>
|
|
<field name="interval_type">hours</field>
|
|
<field name="active">True</field>
|
|
</record>
|
|
|
|
<record id="cron_fc_dispatch_webhooks" model="ir.cron">
|
|
<field name="name">Fusion Billing: Dispatch outbound webhooks</field>
|
|
<field name="model_id" ref="model_fusion_billing_webhook"/>
|
|
<field name="state">code</field>
|
|
<field name="code">model._cron_dispatch()</field>
|
|
<field name="interval_number">2</field>
|
|
<field name="interval_type">minutes</field>
|
|
<field name="active">True</field>
|
|
</record>
|
|
|
|
<!-- Go-forward NexaCloud ledger sync. Ships INACTIVE: only enable once the Stripe
|
|
(and Lago) API credentials are set on the instance and a manual run is verified,
|
|
because the sync verifies each invoice against those sources before posting. -->
|
|
<record id="cron_fc_invoice_ledger" model="ir.cron">
|
|
<field name="name">Fusion Billing: Sync NexaCloud invoices (Stripe/Lago verified)</field>
|
|
<field name="model_id" ref="model_fusion_billing_invoice_ledger_wizard"/>
|
|
<field name="state">code</field>
|
|
<field name="code">model._cron_sync_verified()</field>
|
|
<field name="interval_number">1</field>
|
|
<field name="interval_type">days</field>
|
|
<field name="active">False</field>
|
|
</record>
|
|
</odoo>
|