My Products
Help
MarcusHedlund
CONTRIBUTOR *

Potential invalid validation (Purchase receipt)

by MarcusHedlund (Updated ‎20-09-2023 14:11 by MarcusHedlund )

Im creating a purchase receipt via the API. I then want to add purchase order lines.

This works some of the time and some of the times I get an error that ExpirationDate is missing. 

 

So instead of just population the Lines property with the lines I want from the purchase order I also populate the allocation property with the required data. Then i start to get errors that some lines contain unassigned location and/or lot/serial number. Im not sure what that means, but im posting correct values in the request.

 

The main issue as I see it is the first ExpirationDate missing error, not sure why that is thrown, and only in some cases. I have not figured out when its thrown and when its not.

 

Side note: If i manually add the same lines in the initial post request that create the purchase receipt, it works fine. 

 

The first request with only lines:

 

POST: https://integration.visma.net/API/controller/api/v1/PurchaseReceipt/2500577/action/addpurchaseorderlines
Headers: {
    Accept: application/json
    Authorization: <hidden>
    Accept-Encoding: gzip    Accept-Encoding: deflate
    Request-Id: |mC569LrL59w=.887f20fa_4.
    Content-Type: application/json; charset=utf-8
    Content-Length: 73
}
{"purchaseOrderLines":[{"orderNbr":"2300132","lines":[{"lineNbr":"1"}]}]}
Response: 400 Bad Request
Headers: {
    Date: Tue, 19 Sep 2023 14:51:13 GMT
    Server: Nginx
    Strict-Transport-Security: max-age=31536000; includeSubDomains    Strict-Transport-Security: max-age=31536000; includeSubDomains
    ipp-request-id: 9aab4b0a-dc05-4587-9e4a-dc1c3ffc9041
    X-Content-Type-Options: application/json
    Pragma: no-cache
    X-Handled-By: Visma-PX.Export/AuthenticationManagerModule
    Referrer-Policy: origin-when-cross-origin
    VnfInstanceId: ERP_SE_DEMO_0017
    Cache-Control: no-cache
    X-XSS-Protection: 1;mode=block
    Set-Cookie: <crumbs>;  path=/;  secure;  expires=Mon, 18-Sep-2023 14:51:10 GMT;  HttpOnly
    Connection: close
    Transfer-Encoding: chunked
    Content-Type: application/json; charset=utf-8
    Expires: -1
}
{"message":"Error adding purchase orders to receipt: Error: Inserting  'Purchase receipt line split' record raised at least one error. Please review the errors.\r\nError: 'Expiration date' cannot be empty.\r\n"}

 

 

The second request with lines and allocations. 

 

POST: https://integration.visma.net/API/controller/api/v1/PurchaseReceipt/2500589/action/addpurchaseorderlines
Headers: {
    Accept: application/json
    Authorization: <hidden>
    Accept-Encoding: gzip    Accept-Encoding: deflate
    Request-Id: |CAUmqwPHhLw=.cf51796f_5.
    Content-Type: application/json; charset=utf-8
    Content-Length: 292
}
{"purchaseOrderLines":[{"orderNbr":"2300132","lines":[{"lineNbr":"1"}],"allocations":[{"operation":"Insert","lineNbr":{"value":1},"location":{"value":"1"},"lotSerialNumber":{"value":"000000"},"quantity":{"value":500.00},"expirationDate":{"value":"2026-09-19T08:23:55.5486531+02:00"}}]}]}
Response: 500 Internal Server Error
Headers: {
    Date: Wed, 20 Sep 2023 06:24:00 GMT
    Server: Nginx
    Strict-Transport-Security: max-age=31536000; includeSubDomains    Strict-Transport-Security: max-age=31536000; includeSubDomains
    ipp-request-id: 171c594a-3636-41d0-9cef-19b86d0a4925
    X-Content-Type-Options: application/json
    Pragma: no-cache
    X-Handled-By: Visma-PX.Export/AuthenticationManagerModule
    Referrer-Policy: origin-when-cross-origin
    VnfInstanceId: ERP_SE_DEMO_0017
    Cache-Control: no-cache
    X-XSS-Protection: 1;mode=block
    Set-Cookie: <crumbs>;  path=/;  secure;  expires=Tue, 19-Sep-2023 06:23:58 GMT;  HttpOnly
    Connection: close
    Transfer-Encoding: chunked
    Content-Type: application/json; charset=utf-8
    Expires: -1
}
{"message":"VismaId: 171c594a-3636-41d0-9cef-19b86d0a4925. Error adding purchase orders to receipt: Sales order error: One or more lines contain unassigned location and/or lot/serial number."}

 

 

2 REPLIES 2
Accepted solution
Magnus Johnsen
VISMA

by Magnus Johnsen (Updated ‎21-09-2023 14:51 by Magnus Johnsen VISMA )

Hi,

This is most likely because the items that you are trying to add have a Lot/serial Class that requires certain information depending on how the class is set up.

 

You can find what class the item has via the inventory endpoint/window, and then the lot/serialclass via the ui(ScreenId=IN2070PL) or the endpoint:

2023-09-20 15_15_56-.png2023-09-20 15_18_02-Visma.net Integrations Documentation - Brave.png

Could you send us an example setup that does not work? If so we can test it on our end and investigate it.

Thank you.

MarcusHedlund
CONTRIBUTOR *

Hi, 

 

That seems to be exactly whats happening, that also explains why some orders works and some dont. 

Thank you.