I did some research about this matter and this is what i found. I have a new purchace receipt 000101. It has 2 lines with the following information: [CODE] { "landedCost": [], "receiptType": "PoReceipt", "receiptNbr": "000101", "hold": false, "status": "Balanced", "date": "2021-03-01T00:00:00", "postPeriod": "202103", "supplier": { "internalId": 2475, "number": "50002", "name": "Golftukku Oy" }, "location": { "id": "OLETUS", "name": "Ensisijainen paikka" }, "currency": "EUR", "exchangeRate": 1.00000000, "createBill": false, "totalQty": 4.000000, "controlQty": 4.000000, "vatExemptTotal": 0.0000, "vatTaxableTotal": 40.0000, "totalAmt": 49.6000, "controlTotal": 49.6000, "lastModifiedDateTime": "2021-03-01T08:42:57.893", "branchNumber": { "number": "1", "name": "ISV Partner DEVOCA Oy" }, "lines": [ { "allocations": [ { "lineNbr": 2, "itemId": "104 ", "location": { "id": "1A1", "name": "1A1" }, "lotSerialNumber": "", "quantity": 2.000000, "uom": "KPL", "description": "Titleist NXT Tour XXY" } ], "lineNbr": 1, "branchNumber": { "number": "1", "name": "ISV Partner DEVOCA Oy" }, "inventory": { "number": "104", "description": "Titleist NXT Tour XXY" }, "lineType": "GoodsForInventory", "warehouse": { "id": "2 ", "description": "Vantaa" }, "location": { "id": "1A1", "name": "1A1" }, "transactionDescription": "Titleist NXT Tour XXY", "uom": "KPL", "orderQty": 2.000000, "openQty": 0.000000, "receiptQty": 2.000000, "unitCost": 10.000000, "extCost": 20.0000, "discountPercent": 0.000000, "discountAmount": 0.0000, "manualDiscount": true, "discountCode": {}, "amount": 20.0000, "taxCategory": { "number": "01", "description": "Alv korkea%" }, "actualAccount": { "type": "E", "number": "4000", "description": "Ostot" }, "actualSub": { "id": "00", "description": "Ei mitään" }, "project": { "id": "X", "description": "Non-Project Code." }, "expirationDate": "0001-01-01T00:00:00", "lotSerialNumber": "", "poOrderType": "RegularOrder", "poOrderNbr": "000094", "poOrderLineNbr": 1 }, { "allocations": [ { "lineNbr": 4, "itemId": "105 ", "location": { "id": "1A1", "name": "1A1" }, "lotSerialNumber": "", "quantity": 2.000000, "uom": "KPL", "description": "Titleist NXT Distance" } ], "lineNbr": 3, "branchNumber": { "number": "1", "name": "ISV Partner DEVOCA Oy" }, "inventory": { "number": "105", "description": "Titleist NXT Distance" }, "lineType": "GoodsForInventory", "warehouse": { "id": "2 ", "description": "Vantaa" }, "location": { "id": "1A1", "name": "1A1" }, "transactionDescription": "Titleist NXT Distance", "uom": "KPL", "orderQty": 2.000000, "openQty": 0.000000, "receiptQty": 2.000000, "unitCost": 10.000000, "extCost": 20.0000, "discountPercent": 0.000000, "discountAmount": 0.0000, "manualDiscount": true, "discountCode": {}, "amount": 20.0000, "taxCategory": { "number": "01", "description": "Alv korkea%" }, "actualAccount": { "type": "E", "number": "4000", "description": "Ostot" }, "actualSub": { "id": "00", "description": "Ei mitään" }, "project": { "id": "X", "description": "Non-Project Code." }, "expirationDate": "0001-01-01T00:00:00", "lotSerialNumber": "", "poOrderType": "RegularOrder", "poOrderNbr": "000094", "poOrderLineNbr": 2 } ], "metadata": { "totalCount": 1 } } [/CODE] As you can see it has line 1 with allocation lineNbr 2 and line 3 with allocation lineNbr 4. If I try to update it by updating the original allocations and inserting new ones I get the same error as previously. I tried to update just the first line (lineNbr 1) to keep things simple: [CODE] { "lines": [{ "operation": "Update", "lineNbr": { "value": 1 }, "allocations": [{ "operation": "Update", "lineNbr": { "value": 2 }, "quantity": { "value": 1 }, "uom": { "value": "KPL" }, "location": { "value": "1A1" }, "lotSerialNumber": { "value": "" }, "expirationDate": { "value": null } }, { "operation": "Insert", "lineNbr": { "value": 5 }, "quantity": { "value": 1 }, "uom": { "value": "KPL" }, "location": { "value": "1A2" }, "lotSerialNumber": { "value": "" }, "expirationDate": { "value": null } }], "locationId": { "value": null } }], "hold": { "value": true } } [/CODE] API answer: [CODE] 400 Bad request { "message": "Error updating purchase receipt. Purchase Receipt Allocation Line: '2' not found. The parent line update deleted the allocation line" } [/CODE] Then I modified the JSON by removing the locationId field: [CODE] { "lines": [{ "operation": "Update", "lineNbr": { "value": 1 }, "allocations": [{ "operation": "Update", "lineNbr": { "value": 2 }, "quantity": { "value": 1 }, "uom": { "value": "KPL" }, "location": { "value": "1A1" }, "lotSerialNumber": { "value": "" }, "expirationDate": { "value": null } }, { "operation": "Insert", "lineNbr": { "value": 5 }, "quantity": { "value": 1 }, "uom": { "value": "KPL" }, "location": { "value": "1A2" }, "lotSerialNumber": { "value": "" }, "expirationDate": { "value": null } }] }], "hold": { "value": true } } [/CODE] API answer: [CODE] 400 Bad request { "message": "Error updating purchase receipt. Error: Inserting 'Purchase receipt line split' record raised at least one error. Please review the errors.\r\nError: 'Location' cannot be empty.\r\n" } [/CODE] Then I noticed that if I give the original allocation the original quantity (2) then the API accepts it [CODE] { "lines": [{ "operation": "Update", "lineNbr": { "value": 1 }, "allocations": [{ "operation": "Update", "lineNbr": { "value": 2 }, "quantity": { "value": 2 }, "uom": { "value": "KPL" }, "location": { "value": "1A1" }, "lotSerialNumber": { "value": "" }, "expirationDate": { "value": null } }, { "operation": "Insert", "lineNbr": { "value": 5 }, "quantity": { "value": 1 }, "uom": { "value": "KPL" }, "location": { "value": "1A2" }, "lotSerialNumber": { "value": "" }, "expirationDate": { "value": null } }] }], "hold": { "value": true } } [/CODE] API answer: [CODE]204 No Content[/CODE] But now of cource the receipt quantity is 3 instead of 2. I hope this is enough information to solve this issue.
... View more