Creates a new invoice
POST/invoices
Creates a new invoice with specified parameters.
Audit event:
- invoice.add
Privilege (one of):
- finance-invoices.manage
- finance-cust-invoices.manage
- finance-supplier-invoices.manage
- finance-netting-invoices.manage
Key Behaviors:
Automatic Invoice Generation (CUSTOMER/NETTING)
- For CUSTOMER_INVOICE and NETTING_INVOICE, only custID is required for customer data
- Customer data is automatically fetched from database: custName, custAttn, custAddress, custAddress2, custCity, custVatNumber, ownerVatNumber
- Status defaults to "draft"
Manual Invoice Generation (SUPPLIER)
- For SUPPLIER_INVOICE, personal data should be provided in request body
- Provided values have priority over database values
- Status defaults to "approved" for supplier invoices
- Required fields: custID, currency, invType, invDueDate, invDate, supplierInvNumber, amountNoVat, amountVat, total
Date Format Requirements
- invDate format: 2006-01-02 (mandatory for supplier invoices, defaults to current date if omitted)
- invDueDate format: 2006-01-02 (mandatory for supplier invoices, has priority over invDueDateDays)
- invDueDate must be after or equal to deliveryDate
Invoice Numbering
- invNumberFix: Fixed part of invoice number (required, or will error)
- For SUPPLIER_INVOICE, invNumberFix is populated from supplierInvNumber if not provided
- Automatic numbering handled for CUSTOMER_INVOICE, NETTING_INVOICE, CONTROL_INVOICE, CREDIT_DEBIT_NOTE based on numbering class
VAT Handling
- vatInPrice: 0=NET price, 1=GROSS price (optional, defaults to 0)
- vatInTotal: 0=NET total, 1=GROSS total (optional, defaults to 0)
- For domestic transactions, VAT rate is automatically calculated
Clearing and Payment
- Approved customer invoices automatically create clearing records
- If invoice is marked as fully paid, payment is recorded and applied
- Supplier invoices set paymentStatus to "on-hold"
File Registration
- Automatically registers generated files for NETTING_INVOICE, CREDIT_DEBIT_NOTE, and MO-POSTPAID CUSTOMER_INVOICE
- filesRegisterData contains account metadata for file registration
Errors:
- BAD_REQUEST_BODY_FORMAT: Unable to decode request body
- INVALID-DATA: Input data validation failed
- NOT_AUTHORIZED: Not authorized
- NOT_AUTHENTICATED: Not authenticated
- INVOICE_NOTFOUND: Invoice not found
- INT_APP_ERROR: Internal server error
- INVOICE_TYPE_NOT_SUPPORTED: Action not supported for invoice type
- INVOICE_TYPE_NOTFOUND: Invoice type not found
- INVOICE_TYPE_MISSING: Invoice type must not be empty
- WRONG_DELIVERY_DATE: Invoice delivery date can not be greater then invoice due date
- MISSING_TAX_DATA: Tax rates for invoice issuer country not configured
- BILLING_RECORD_NOTFOUND: Billing record not found
- CREDIT_RECORD_NOTFOUND: Credit record not found
- INSTANCE_OWNER_NOTFOUND: Instance owner data not found
- TEMPLATE_NOTFOUND: Template not found
Errors items:
- invalid value - CustID can not be 0
- invalid value - CustID can not be nil
- invalid value - invType can not be nil or 0
- invalid value - templateId can not be nil
- invalid value - InvNumberFix can not be nil
- invalid value - InvNumberFix expected
- invalid value - invNumberFix can not be longer than 100 characters
- invalid value - Currency can not be nil
- invalid value - Curency must be valid code number
- invalid value - VatInPrice must be 0 or 1
- invalid value - VatInTotal must be 0 or 1
- invalid value - amountNoVat can not be more than 99999999.9999
- invalid value - amountNoVat can not be null for supplier invoice
- invalid value - amountNoVat can not be null for supplier credit/debit note
- invalid value - amountNoVat must be positive value
- invalid value - amountVat can not be more than 99999999.9999
- invalid value - amountVat can not be null for supplier invoice
- invalid value - amountVat can not be null for supplier credit/debit note
- invalid value - amount Vat must be greater or equal than amount no vat
- invalid value - total can not be more than 99999999.9999
- invalid value - total can not be null for supplier invoice
- invalid value - lang must be char(2)
- invalid value - invoice date invalid
- invalid value - invoiceDate must not be null for supplier invoices
- invalid value - delivery date invalid
- invalid value - deliverydate invalid
- invalid value - invoice date and delivery date must be equal
- invalid value - invoicing date invalid
- invalid value - delivery status value can be : 'none','waiting','sending','sent','error' or 'misc'
- invalid value - invoice due date invalid
- invalid value - invoiceDueDate must not be null for supplier invoices
- invalid value - InvoiceDueDateDays must be greater then 0
- invalid value - payment date is not valid
- invalid value - invoice period start date invalid
- invalid value - invoice period end date invalid
- invalid value - reminder status value can be one of: 'enabled','disabled','open','closed' or 'misc'
- invalid value - supplierInvNumber can not be null for supplier invoice
- invalid value - supplierInvNumber can not be longer than 100 characters
- invalid value - supplierInvNumber expected
- invalid value - status can be 'draft' or 'approved'
Request
Responses
- 200
- 400
- 401
- 404
- 409
- 500
Invoice successfully created
Bad Request - Invalid input data or validation failed
Not Authorized, Not Authenticated
Not Found - Related resource not found
Conflict - Business rule violation
Internal Server Error