SalesInvoiceCreateRequest
RequestSent in requests. Its values are closed: anything not listed is refused.
Attributes
2A new draft sales invoice, credit note or prepayment invoice. A credit note names the issued invoice it credits in credits_invoice_id; without lines it credits all of it. An invoice from a quote names the quote in from_quote_id and takes the quote's lines. Nothing is numbered or posted until issue.
22 attributes of data
Document kind; omitted means invoice (or credit_note with credits_invoice_id).
One of invoice, credit_note
Document date. Required, except with from_quote_id or a credit note without lines, which are dated as the app dates them (today).
The date the document is booked at -- its ledger entry, the period checked and the VAT return. Omitted or null books at date.
Document currency (ISO 4217): the book currency, EUR, or another currency the company has activated. Omitted, EUR.
The rate to book a foreign-currency document at, in ExchangeRate's direction. Omitted: the European Central Bank's rate of the supply date, else the posting date, else the invoice date.
Details
Sent: used as given and recorded as a manual rate. A credit note takes its invoice's rate, and a document in the book currency has the rate 1; any other value is refused (EXCHANGE_RATE_OVERRIDE_INVALID), as is a rate that is not positive. On an issued create linked to an imported transaction (transaction_id) it is the source system's rate: the document ties to that journal at it, within a cent per VAT group, and keeps it as an imported rate; omitted there, the rate is the one the journal was booked at.
The customer. Its name, codes, address and e-mail are printed on the document unless party says otherwise.
The customer as printed, for a one-off customer or to override the contact's details.
5 attributes of party
Register code (a company), or a person's personal code.
The lines, in order. Optional only with credits_invoice_id or from_quote_id.
13 attributes of each item
Quantity, up to 10 fraction digits. A negative quantity is a return and must name the invoice it returns against in credited_invoice_id (INVOICE_LINE_REFERENCE_REQUIRED); a price reduction keeps a positive quantity and a negative unit_price.
Net price per unit, up to 10 fraction digits. May be negative (a discount at the time of sale). A document totalling below zero is refused with INVOICE_TOTAL_NEGATIVE: it is a credit note.
An existing line of this document to keep; omit for a new line (INVOICE_LINE_NOT_FOUND otherwise).
Dimension values on the line, at most one per dimension.
The issued sales invoice this row corrects -- a return, or a price cut of an earlier sale (KMS § 29 lg 7). Required on a row with a negative quantity (INVOICE_LINE_REFERENCE_REQUIRED); one that names no issued invoice of this organization is CREDITED_INVOICE_INVALID.
The line's VAT as the document states it. Kept only on a historical create -- one that links its imported transaction_id, or is dated before the organization's opening date; the document's VAT is then these figures, not the ones its codes derive.
Details
On any other write it may only repeat the VAT the line derives (a read sent back), and is not stored; another figure is 400 VALIDATION_ERROR by pointer. A line with no VAT rate states none; the VAT sits on the line value's side of zero.
Whole-cent rounding added to the total, outside every VAT figure (ROUNDING_AMOUNT_INVALID otherwise). Omitted or null is 0.
Create a credit note for this issued invoice. Without lines the credit note copies all of it, at its frozen rates.
Make the invoice from this accepted quote; the quote's lines are taken and lines may not be sent. Edit the draft afterwards.
draft (the default) registers a draft; issued creates a historical document a migration brings over: it links the imported transaction that booked it (transaction_id, required), keeps its number, dates and stated line VAT, posts and sends nothing, and reads origin: import.
One of draft, issued
With status: issued: the imported transaction (origin: import, posted by no document) that booked this document, dated on its posting date, whose receivable (sales) or payable (purchases) lines name this contact or none and move exactly its total in its direction (an invoice debits a receivable and credits a payable, a credit note the reverse).
Details
400 INVOICE_TRANSACTION_NOT_LINKABLE otherwise. The transaction is only linked, never changed. Refused (400 INVOICE_TRANSACTION_NOT_LINKABLE) as well: a transaction any lines of which carry a VAT code (the return would count them beside the invoice), whose VAT accounts do not move the invoice's VAT, that an imported payment already holds, or a document with no total. A document in another currency than the book currency ties in book figures: at the rate sent as exchange_rate (the source system's), its receivable or payable and VAT legs within a cent per VAT group of the converted total and VAT; without one, at the rate the journal booked (its receivable or payable over the total), its VAT legs likewise. Its rate and book figures are then read off that journal. A link into a period marked done is 409 PERIOD_CONFIRM_REQUIRED, and into a filed VAT return's period 409 INVOICE_TRANSACTION_VAT_PERIOD_FILED. Needs the ledger:write scope besides invoices:write (403 INSUFFICIENT_SCOPE).
With status: issued, required: the document's own number. Unique among the organization's sales documents (409 DOCUMENT_NUMBER_TAKEN). A number in the organization's own format for its date takes its place in that series, so the next issued invoice continues after it.
An Estonian reference (7-3-1 check digit) or an RF creditor reference (400 PAYMENT_REFERENCE_INVALID otherwise). With status: issued, the reference the invoice was issued with, so a later bank payment citing it is matched to it: several open invoices of the same contact may share one (a customer's own reference), and an open invoice of another contact carrying it is 409 PAYMENT_REFERENCE_TAKEN with its existing_id.
Details
On a draft it is the draft's typed reference, unique in the organization (409 PAYMENT_REFERENCE_TAKEN) and printed when the draft is issued; a credit note carries none.
Your own id for the document, unique per organization; on_conflict resolves a create against it.
The invoice's other recipients besides the payer (co-owners), in print order: each is printed under the customer, e-mailed the invoice and reached by reminders, and the receivable stays on contact_id. Each a contact of the organization, listed once, not the customer. Their printed details are taken from the contact.
What a create does when a record of the same resource already holds the sent external_ref. error: 409 EXTERNAL_REF_EXISTS with existing_id. return: 200 with the existing record, unchanged.
One of error, return, update
Details
update: apply the sent fields to it as a PATCH would and answer 200; refused like a PATCH when the record is no longer editable.