AddOnBase

[POST] .../v1/docinvoice/addonbase

Creates an invoice from a source document. Use this method when the invoice must be generated from an already posted DocWholeSale or DocWholeSaleReturn document and its operation rows must be copied into InvoiceOperation records automatically. The request body must contain document_type_id and document_id; code and date are optional, omitted or 0 date uses the current timestamp, corrected_date and corrected_code are used for DocWholeSaleReturn corrective invoices and attached_user_id defaults to the current request user for DocWholeSale source documents. Source DocWholeSale creates an Outcome invoice and copies corrected source data from the source document; source DocWholeSaleReturn creates a Corrective invoice and uses corrected source data from the request, while both workflows require a matching contract direction when the source document has a contract. The response currently returns InsertResult with new_id equal to 1 as the success marker instead of the created invoice ID; missing body, invalid source document, unposted source document, contract mismatch, denied access, tariff restriction, database or transaction failures are returned as HTTP 200 ErrorResult business errors.

Request Parameters

Name Type Required Description
attached_user_id Int64 Optional Responsible user ID. If omitted or 0, the API uses the current request user.
code String Optional Invoice code. If omitted, the API generates the next invoice number. Maximum length is 50 characters.
corrected_code String Optional Code of the corrected source document. Used for corrective invoices created from return source documents. Maximum length is 50 characters.
corrected_date Int64 Optional Date of the corrected source document as Unix time in seconds. Used for corrective invoices created from return source documents.
date Int64 Optional Invoice date as Unix time in seconds. If omitted or 0, the API uses the current timestamp.
description String Optional Additional description. Maximum length is 300 characters.
document_id Int64 Required ID of the document that the invoice is created from.
document_type_id Int64 Required ID of the document type that the invoice is created from.

Request Example

{
  "document_type_id": 49,
  "document_id": 5601,
  "code": "INV-0009101",
  "date": 1767225600,
  "description": "Invoice generated from wholesale shipment",
  "attached_user_id": 5
}

Response Parameters

Name Type Description
ok Boolean Indicates whether the request completed successfully.
result Insert Created record result.

Response Example

{
  "ok": true,
  "result": {
    "new_id": 1
  }
}