PUT Sale/Invoice/Item returns 37006 "Cannot update order on existing invoice" for any invoice converted from an order
Product: AccountRight (cloud company file), AccountRight API v2 (x-myobapi-version: v2)
Endpoint: PUT /accountright/{cf}/Sale/Invoice/Item/{uid}?returnBody=true
Goal: set CustomerPurchaseOrderNumber on paid invoices, nothing else changed
The PUT works on invoices that were entered or imported directly as invoices
(Order is null on GET). It fails on every invoice that was created by converting
a sales order in the AccountRight desktop app. Exact response, captured from the
API today:
HTTP 400
{
"Errors": [{
"Name": "CannotUpdateOrderOnExistingInvoice",
"Message": "Cannot update order on existing invoice",
"AdditionalDetails": "Order.UID",
"ErrorCode": 37006,
"Severity": "Error"
}]
}
What GET returns for one of these invoices:
- InvoiceType "Item", Status "Closed", BalanceDueAmount 0
- "Order": { "UID": "<guid>", "Number": "00030351", "URI": ".../Sale/Order/<guid>" }
The linked order:
- GET /Sale/Order?$filter=Number eq '00030351' returns it with
Status "ConvertedToInvoice" and OrderType "Service", although the invoice
is Item layout and the order was keyed with items.
- GET /Sale/Order/Item/<guid> returns 404.
- GET /Sale/Order/Service/<guid> returns it, with description-only lines
(no Item on any line).
- Every converted order in this file shows as Service the same way.
Payloads tried on the invoice, each built from a fresh GET with the current RowVersion:
1. Order exactly as returned (UID, Number, URI) -> 37006
2. The entire GET body sent back with nothing changed -> 37006
3. Order omitted -> 37006
4. "Order": null -> 37006
5. "Order": { "UID": "<guid>" } -> 37006
6. "Order": { "UID": "<guid>", "Number": "00030351" } -> 37006
7. "Order": { "UID": "<guid>", "URI": "<uri>" } -> 37006
8. "Order": { "Number": "00030351" } -> 400 "Order is required"
9. "Order": { "URI": "<uri>" } -> 400 "Order is required"
10. "Order": { "Number": "00030351", "URI": "<uri>" } -> 400 "Order is required"
11. "Order": {} -> 400 "Order is required"
12. "Order": { "UID": null } -> 400 validation errors
Control: payload 2 on an invoice with no order link -> 200 OK
So with the UID present the API says the order cannot be updated, and without
it the API says the order is required. Number and URI make no difference, the
UID alone is evaluated. There is no payload that satisfies both rules.
Editing the same invoices in the AccountRight desktop or browser UI works fine.
Questions:
1. Is this a known limitation for invoices converted from orders in the desktop app?
2. Is there a supported payload or endpoint for updating such an invoice via the API?
3. Would an invoice converted from an order through the API (POST Sale/Invoice/Item
with Order.UID) or through the browser "Convert to invoice" be updatable afterwards?
4. Why does the retained converted order appear as Service layout when the original
order and the invoice are Item layout?
Happy to supply the company file ID, invoice and order UIDs and request timestamps
privately.