Update a purchase invoice
liveChange some fields of a purchase invoice. Only sent fields change; null clears a nullable field. Send If-Match with the ETag you last saw to refuse a lost update (412).
Parameters
headers and query and pathOptional optimistic-concurrency guard for an update. Send the ETag the resource's GET returned; when the resource has changed since, the update is refused with 412 PRECONDITION_FAILED and nothing is written, so a client never overwrites a change it has not seen.
Details
* matches any current version. Weak ETags (W/"...") never match: If-Match compares strongly. Omitting the header applies the update unconditionally.
Validate and compute without storing anything: the answer is what the real request would answer (status, errors, computed totals, assigned numbers) but nothing is saved, posted or sent, and the response carries Tracken-Dry-Run: true.
Request body
application/json · requiredThe fields to change.
Most used attributes of data
The supplier as the invoice names it.
The whole new list of lines, in order.
11 attributes of each item
Net price per unit, as the supplier printed it; may be negative (a discount row). A document whose total is below zero is refused (INVOICE_TOTAL_NEGATIVE); register it as a credit note.
The line's VAT code; its rate on the invoice date is frozen on the line.
The expense or asset account. Never the organization's accounts payable or receivable control account (400 PURCHASE_LINE_CONTROL_ACCOUNT at the line), except a kept line that stays on the account it already has.
Dimension values on the line.
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.
The date to book the invoice at. Null follows date again. A posted invoice cannot move to another period.
State the rate instead of the European Central Bank's. Omitted keeps a stated rate; null returns to the bank's. Refused on a document in the book currency and on a credit note, which uses its invoice's rate (EXCHANGE_RATE_OVERRIDE_INVALID). With no bank rate for the date and none stated, 400 EXCHANGE_RATE_MISSING.
The VAT in the book currency as the seller states it, of the supply: a prepayment deduction keeps its prepayment's VAT, so the invoice's stored book_tax_total is this figure less the deducted VAT.
Details
Between 0 and twice the supply's converted VAT, else 400 BOOK_TAX_TOTAL_OUT_OF_RANGE. Omitted keeps a stated figure while the document's VAT is unchanged; null returns to the converted figure.
7 more attributes
The supplier. Changing it copies the new supplier's details unless party is sent too. A posted invoice's supplier cannot change.
The number printed on the supplier's invoice.
Reclassify a draft. Not on a posted invoice, nor on a credit note that credits one of your invoices.
One of invoice, credit_note
A VAT-free rounding added to the total, in whole cents; null means none.
Responses
errors use the error envelope| 200 | PurchaseInvoice · The updated purchase invoice. |
| 400 | The request fails validation. This operation's own codes: BOOK_TAX_TOTAL_OUT_OF_RANGE, CREDITED_INVOICE_INVALID, PURCHASE_LINE_CONTROL_ACCOUNT, TAX_CODE_NOT_FOUND. |
| 401 | No token, an expired token, or a token for another audience (UNAUTHENTICATED). |
| 402 | The organization's subscription is not active (SUBSCRIPTION_INACTIVE): the trial ended without a plan, a payment is overdue, the subscription was cancelled, or the accounting firm that paid for it stopped. context.reason says which (trial_ended, not_paid, cancelled, payer_stopped; accept values you do not know) and context.export_until the last day (ISO date) the organization's data can still be exported. Every operation is refused, reads included, except reading the current user and the organization and the data export. A retry unchanged fails the same way: an owner reopens the subscription in the app. |
| 403 | Not allowed. This operation's own codes: PERIOD_HARD_GATED. |
| 404 | Not found. This operation's own codes: INVOICE_NOT_FOUND. |
| 409 | Conflicts with the resource's state. This operation's own codes: APPROVAL_PENDING, BUSINESS_PARTNER_ARCHIVED, EXTERNAL_REF_EXISTS, EXTRA_MONTH_CONFIRM_REQUIRED, IMPORTED_INVOICE_CREDIT_NOTE_REQUIRED, IMPORTED_INVOICE_RATE_SET_SEPARATELY, INVOICE_LINES_PENDING, OPENING_INVOICE_EDIT_IN_OPENING_STATE, PERIOD_CONFIRM_REQUIRED, PREPAYMENT_INVOICE_NOT_EDITABLE, PURCHASE_INVOICE_CANCELLED, PURCHASE_INVOICE_POSTED_EDIT_REFUSED, SUPPLIER_INVOICE_NUMBER_TAKEN, WORK_MONTH_CONFIRM_REQUIRED. An API credential cannot confirm a month: a person confirms it in the app, then retry the request unchanged, with the same Idempotency-Key; context names the month, its price and currency. |
| 412 | If-Match did not match: the record changed since you read it (PRECONDITION_FAILED). |
| 429 | Rate limit exceeded (RATE_LIMITED). Wait Retry-After seconds. |
Errors this operation can return
switch oncode, never on message| Code | Status | When |
|---|---|---|
PRECONDITION_FAILED | 412 | If-Match: Send the ETag the resource's GET returned; when the resource has changed since, the update is refused with 412 PRECONDITION_FAILED and nothing is written, so a client never overwrites a change it has not seen. |
CREDITED_INVOICE_INVALID | 400 | The referenced invoice is not an issued invoice of this organization. |
TAX_CODE_NOT_FOUND | 400 | That tax code no longer exists for this organization. |
PERIOD_HARD_GATED | 403 | This period is done and your role isn't permitted to write into it. |
INVOICE_NOT_FOUND | 404 | That invoice no longer exists. |
APPROVAL_PENDING | 409 | The record is still waiting for approval. |
BUSINESS_PARTNER_ARCHIVED | 409 | That business partner is archived. |
EXTERNAL_REF_EXISTS | 409 | A record of this resource already carries the external_ref you sent. |
17 more codes
EXTRA_MONTH_CONFIRM_REQUIRED | 409 | This change falls outside the working month, so this month is billed separately. |
IMPORTED_INVOICE_CREDIT_NOTE_REQUIRED | 409 | This invoice was brought over from another accounting system together with its ledger entry. |
IMPORTED_INVOICE_RATE_SET_SEPARATELY | 409 | An imported invoice's rate is not changed by editing the invoice. |
INVOICE_LINES_PENDING | 409 | This imported invoice's lines are still being fetched from Merit. |
OPENING_INVOICE_EDIT_IN_OPENING_STATE | 409 | This invoice is an open item of the opening balances. |
PERIOD_CONFIRM_REQUIRED | 409 | This changes figures already marked done for this period. |
PREPAYMENT_INVOICE_NOT_EDITABLE | 409 | A prepayment invoice can't be edited. |
PURCHASE_INVOICE_CANCELLED | 409 | A voided purchase invoice can't be edited. |
PURCHASE_INVOICE_POSTED_EDIT_REFUSED | 409 | This purchase invoice is already booked, so its figures, dates and supplier can be changed only in Tracken. |
SUPPLIER_INVOICE_NUMBER_TAKEN | 409 | This supplier already has an invoice with this number. |
WORK_MONTH_CONFIRM_REQUIRED | 409 | This change starts the plan year's working month, so the working month must be confirmed first. |
BOOK_TAX_TOTAL_OUT_OF_RANGE | 400 | data.book_tax_total: Between 0 and twice the supply's converted VAT, else 400 BOOK_TAX_TOTAL_OUT_OF_RANGE. |
PURCHASE_LINE_CONTROL_ACCOUNT | 400 | data.lines[].account_id: Never the organization's accounts payable or receivable control account (400 PURCHASE_LINE_CONTROL_ACCOUNT at the line), except a kept line that stays on the account it already has. |
EXCHANGE_RATE_OVERRIDE_INVALID | 400 | data.exchange_rate: Refused on a document in the book currency and on a credit note, which uses its invoice's rate (EXCHANGE_RATE_OVERRIDE_INVALID). |
EXCHANGE_RATE_MISSING | 400 | data.exchange_rate: With no bank rate for the date and none stated, 400 EXCHANGE_RATE_MISSING. |
INVOICE_TOTAL_NEGATIVE | 400 | data.lines[].unit_price: A document whose total is below zero is refused (INVOICE_TOTAL_NEGATIVE); register it as a credit note. |
VALIDATION_ERROR | 400 | data.lines[].tax_amount: 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. |
Plus the general codes every operation can answer (UNAUTHENTICATED, RATE_LIMITED …): handle them once.