Skip to main content

Supplier invoice from a purchase order (MIRO)

Use the curated action invoice/create_supplier_invoice_from_po. It opens the soft-state draft, binds the PO, derives the items, and (optionally) posts — in one call. (Background on the session model: Overview.)

1. Confirm the PO is billable

from abstra.connectors import run_connection_action

run_connection_action(
connection_name="my_sap",
action_name="invoice/lookup_purchase_order_for_invoice",
params={"purchaseOrder": "4500000001"},
)
# -> { results: [{ purchaseOrder, companyCode, invoicingParty, ... }] }

2. Create the invoice

Create a draft first — set post: true only when ready to effectivate.

run_connection_action(
connection_name="my_sap",
action_name="invoice/create_supplier_invoice_from_po",
params={
"purchaseOrder": "4500000001",
"companyCode": "1000", # from the lookup
"invoicingParty": "0001000000", # from the lookup
"documentDate": "2026-01-31",
"invoiceGrossAmount": "1190.00",
"documentCurrency": "BRL",
"supplierInvoiceReference": "INV-EXTERNAL-001",
"post": False, # leave as a draft
},
)

Smart Chat:

Using my "my_sap" connector, create a supplier invoice from purchase order
4500000001 for company 1000, gross amount 1190.00 BRL, document date 2026-01-31.
Leave it as a draft (do not post).
Billability is a data prerequisite

A PO is only billable when it has a posted goods receipt with an open amount. lookup_purchase_order_for_invoice returning no rows means there is nothing to invoice yet — that is data, not a connector error.

Don’t use these for invoices

odata/..._create_* on invoice list/import services and the raw softstate/* actions are the wrong tools for MIRO — they return 501, 400 Property … is invalid, or short dumps. Use invoice/create_supplier_invoice_from_po.