Item Purchase Order Validation Errors
I am trying to POST a new item purchase order but am encountering validation errors I am unable to interpret. The payload below is being sent to /Purchase/Order/Item using the POST method.
{
"Lines": [
{
"BillQuantity": 2.0,
"ReceivedQuantity": 0,
"UnitPrice": 769.5,
"DiscountPercent": 0.0,
"Total": 1539.0,
"Item": {
"UID": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
},
"TaxCode": {
"UID": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
},
"Type": "Transaction",
"Description": "My description",
"RowVersion": "1"
}
],
"OrderDeliveryStatus": "Print",
"Number": "000005",
"Date": "2024-11-08T08:22:26.6152102+10:00",
"SupplierInvoiceNumber": "",
"Supplier": {
"UID": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
},
"IsTaxInclusive": false,
"IsReportable": false,
"Subtotal": 0,
"TotalTax": 0,
"TotalAmount": 0,
"AppliedToDate": 0,
"BalanceDueAmount": 0,
"Status": "Open",
"OrderType": "Item"
}
and the response received is:
{
"Errors": [
{
"Name": "ValidationError",
"Message": "BusinessLine_AccountRequired",
"AdditionalDetails": "AccountId:(PurchaseOrderItemLine)",
"ErrorCode": 4242,
"Severity": "Error",
"LearnMore": null
},
{
"Name": "ValidationError",
"Message": "PurchaseOrderLine_ItemBoughtOrInventoriedRequired",
"AdditionalDetails": "ItemId:(PurchaseOrderItemLine)",
"ErrorCode": 4305,
"Severity": "Error",
"LearnMore": null
}
],
"Information": "Warning, error messages have not been finalised in this release and may change"
}
The item purchase order page doesn't mention an account field or an inventory required field, and the SDK objects don't have them either. I'm unsure what I'm supposed to here also since the API errors page doesn't identify these errors.
For context, I don't have background in being a MYOB user. I would greatly appreciate any help here.
Hi mdaniels , a couple of suggestions:
Line RowVersion is not required for a new transaction
ReceivedQuantity is not required for an order
OrderType is not a valid element (posting to Purchase/Order/Item)
I would put the date in as "Date": "2024-11-08T00:00:00" as MYOB only ever displays the date.
imo SubTotal, TotalTax and TotalAmount should have correct values
The second error suggests that the item definition in MYOB is missing or incomplete - the item must be ticked as "I buy" or "I inventory" to be included on a purchase transaction. (And the item must pre-exist).
The first error may be due to one or more of the above.