My Products
Help
tomkui
CONTRIBUTOR **

API: Problems with updating allocations on purchaceReceipt

by tomkui (Updated ‎25-02-2021 12:07 by tomkui )

Hello!

I'm trying to update allocations on purchaseReceipt to match where the items were really placed in the warehouse.
The problem I'm having seems to happen only on receipts that have multiple lines.

 

Example 1.
Purchase receipt 000087 has only one line. The one line is allocated for location 1A1 with quantity of 2.
I want to put the items as following: 1 to 1A1 and 1 to 1A2.

 

I update it with the following JSON:
PUT https://integration.visma.net/API/controller/api/v1/purchaseReceipt/000087

[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": 2
},
"quantity": {
"value": 1
},
"uom": {
"value": "KPL"
},
"location": {
"value": "1A2"
},
"lotSerialNumber": {
"value": ""
},
"expirationDate": {
"value": null
}
}],
"locationId": {
"value": null
}
}],
"hold": {
"value": true
}
}
[/CODE]

This goes successfully to the API and does not cause any problems.

 

Example 2.

Purchase receipt 000090 has 2 lines. The both lines are allocated for location 1A1 with quantity of 2.
I want to split them both as in Example 1: 1 to 1A1 and 1 to 1A2.

I try to update it with:
PUT https://integration.visma.net/API/controller/api/v1/purchaseReceipt/000090
[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": 2
},
"quantity": {
"value": 1
},
"uom": {
"value": "KPL"
},
"location": {
"value": "1A2"
},
"lotSerialNumber": {
"value": ""
},
"expirationDate": {
"value": null
}
}],
"locationId": {
"value": null
}
}, {
"operation": "Update",
"lineNbr": {
"value": 3
},
"allocations": [{
"operation": "Update",
"lineNbr": {
"value": 4
},
"quantity": {
"value": 1
},
"uom": {
"value": "KPL"
},
"location": {
"value": "1A1"
},
"lotSerialNumber": {
"value": ""
},
"expirationDate": {
"value": null
}
}, {
"operation": "Insert",
"lineNbr": {
"value": 4
},
"quantity": {
"value": 1
},
"uom": {
"value": "KPL"
},
"location": {
"value": "1A2"
},
"lotSerialNumber": {
"value": ""
},
"expirationDate": {
"value": null
}
}],
"locationId": {
"value": null
}
}],
"hold": {
"value": true
}
}
[/CODE]

 

The API answer:
[CODE] 400 Bad Request [/CODE]
[CODE]
{
"message": "Error updating purchase receipt. Purchase Receipt Allocation Line: '2' not found. The parent line update deleted the allocation line"
}
[/CODE]

 

I have tried this in the UI and I can split the allocations on all the lines.
I cannot reproduce this problem using the UI.

7 REPLIES 7
Accepted solution
Yıldırım
VISMA

by Yıldırım

This issue has been planned to be fixed in 8.48 version. Visma.net Financials API updates for version 8.48.0 (May 2021)

by Magnus Johnsen

Please get the receipt and doublecheck what lines are created. Please also be aware that all line numbers share the same incremated series.

 

So you would need to:

Update line 1, and to and insert it in line 3 and 4. 

tomkui
CONTRIBUTOR **

by tomkui

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.

by Magnus Johnsen

Hi,

I've had a look at this, and to just start with lets review example 1.

If the purchaseReceipt just has been created, normally if you have a look at it in the UI, it will not have any allocation lines.

However when getting the receipt, the API will tell you that there is an allocation, this is an "internal" kind of preallocation of the required allocations.

 

So in this example, where 1 line has 2 items that you want to split to two different locations you should update line 1(this is the only real line, the second line "dissapears" as you change the allocation for line 1).

 

This is the JSON what you would use:

 

{
"lines": [{
"allocations": [{
"operation": "insert",
"lineNbr": {
"value": 2
},
"quantity": {
"value": 1
},
"lotSerialNumber": {
"value": "AllocationLine1"
},
"location": {
"value": 1
}
},
{
"operation": "insert",
"lineNbr": {
"value": 3
},
"quantity": {
"value": 1
},
"lotSerialNumber": {
"value": "AllocationLine2"
},
"location": {
"value": 2
}
}
],
"operation": "Update",
"lineNbr": {
"value": 1
}
}
]
}

You would in the case of the lines being inserted not specify the line number, this is done automatically. It's only when changing the, updating or deleting you need to specify them.
 
This is the result in the UI:
2021-03-04 09_57_31-Purchase receipts.png
 
When you have several lines, it helps knowing where the receiptlines are so that you can update them and then insert the lines you need for your allocation.
Please try this, and if it still doesn't help, please let us know!
tomkui
CONTRIBUTOR **

by tomkui

Thank you very much for your answer.


We went it thru and did everything according to your advice.
However we are not able to get this feature working as it should.
And I think that just by sending messages will not solve this.
So for this reason we would like to have a brief web meeting where we could show you the issue and where we could learn your solution for it.
What would be suitable times for web meeting?

by Magnus Johnsen (Updated ‎19-03-2021 09:30 by Magnus Johnsen VISMA )

We have sent you an email, please have a look at it and let us know. 

tomkui
CONTRIBUTOR **

by tomkui

I checked and line numbers are okay but the issue is still remaining.