Create invoice
invbg_create_invoiceWRITE: create a document (tax invoice by default; proforma, debit/credit note via type). It is saved as a DRAFT unless draft is false: an issued document takes the next legal number and cannot be undone through this tool. Address it to an existing client_id, or give to_name + to_address (+ to_mol and to_bulstat for a company, to_egn for a person) and inv.bg matches or creates the client from those details (an existing client matched by Bulstat or VAT number is UPDATED with the address, MOL and other details you pass). VAT: set vat_percent on the document, or on every item. POST /invoices.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| type | No | dan = tax invoice (default), prof = proforma, deb = debit note, cred = credit note. | |
| draft | No | Save as a draft (default true). Pass false to issue the document and consume its number. | |
| items | Yes | Line items. | |
| notes | No | Notes printed on the document. | |
| to_egn | No | Recipient EGN, 10 digits (individuals), as text so leading zeros survive. | |
| to_mol | No | Recipient accountable person (MOL); required for companies when no client_id. | |
| to_name | No | Recipient name (when no client_id). | |
| to_town | No | ||
| currency | No | Document currency (default BGN). | |
| client_id | No | Existing client id (invbg_list_clients). Then the to_* fields are ignored. | |
| po_number | No | The buyer's purchase order number. | |
| date_event | No | Tax event date (default: issue date). | |
| number_set | No | Number set id to take the number from (invbg_list_number_sets); omit unless you use several series. | |
| to_address | No | Recipient address (required when no client_id). | |
| to_bulstat | No | Recipient EIK/Bulstat (companies). | |
| to_country | No | Recipient country, ISO 3166-1 alpha-2. | |
| date_create | No | Issue date (default now). | |
| date_mature | No | Due date. | |
| vat_percent | No | VAT rate for the whole document in percent; ignored where items carry their own vat_percent. | |
| is_to_person | No | true when the recipient is an individual (then to_egn is needed). | |
| currency_rate | No | Exchange rate to BGN (BGN/XXX). Required when currency is not BGN: take it from invbg_get_exchange_rate. | |
| to_is_reg_vat | No | Whether the recipient company is VAT-registered. | |
| to_vat_number | No | Recipient VAT number (needed when to_is_reg_vat is true). | |
| items_with_vat | No | true if item prices already include VAT (default false). | |
| payment_method | No | How the client pays. | |
| reduction_percent | No | Discount on the whole document in percent. | |
| vat_exemption_reason | No | Why no VAT is charged (when VAT is 0); see invbg_list_vat_exemption_reasons. |