myinvois_invoice_generate
Mint a sealed LHDN e-invoice in ONE call: invoice_type, line_items (unit_price_cents in integer CENTS, tax_rate_bps in basis points), and a buyer as customer_id or an inline buyer object. Refuses until myinvois_settings_save is done; invoice_type 02/03/04 also needs original_invoice_id naming a type-01 invoice with a recorded LHDN UUID, checked BEFORE the number is claimed, so a rejected note never burns a number. The result is immutable and carries portal_field_sheet; Simpler never submits it to LHDN. NEXT: the owner keys the field sheet into the MyInvois portal form, then myinvois_invoice_record_submission with the UUID the portal assigns.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| buyer | No | Inline one-off buyer party — {name, tin, brn?, address?, city?, state_code?, postal_code?, country_code?, email?, contact_number?}. Required when customer_id is not given; ignored when it is. | |
| notes | No | Free-text notes printed on the generated e-invoice; optional. | |
| status | No | ||
| currency | No | ||
| buyer_tin | No | ||
| lhdn_uuid | No | ||
| tax_cents | No | ||
| buyer_name | No | ||
| issue_date | No | ||
| line_items | Yes | Line items: [{description, quantity, unit_price_cents, tax_rate_bps?, tax_type?, classification_code?, unit_code?}]. Money is integer CENTS, tax_rate_bps is basis points (600 = 6%); tax_type/classification_code/unit_code default when omitted and validate against the LHDN code tables (GET /api/myinvois/codes). | |
| customer_id | No | ||
| total_cents | No | ||
| invoice_data | No | ||
| invoice_type | No | ||
| lhdn_long_id | No | ||
| payment_terms | No | Payment terms text for this document; defaults to the supplier profile's default_payment_terms when omitted. | |
| billing_period | No | Optional LHDN billing period {start_date, end_date, frequency?}: dates as YYYY-MM-DD, end on or after start, frequency up to 50 characters (for example Monthly). Leave it out when the invoice covers no period; the e-invoice then carries none. | |
| invoice_number | No | ||
| subtotal_cents | No | ||
| lhdn_submitted_at | No | ||
| original_invoice_id | No | The type-01 original this note references — required for invoice_type 02, 03 or 04, refused for 01. Must already carry an LHDN UUID (myinvois_invoice_record_submission). | |
| reference_invoice_id | No |