My Products
Help
Florian Haase
PARTNER

Placing POReceipts on SupplierInvoice

by Florian Haase

Hi

 

I just got a problem which can be a bit critical for us, but I dont know how to find out of this: 

 

We are collecting PurchaseReceipts on SupplierInvoices. To know which receipts are not processed yet we take all receipts with the status balanced and not on hold. We release the receipt first and than run a put on the supplierInvoice with 

"addPOReceiptLines": [
    {
      "poReceiptNumber": {
        "value": "string"
      },
      "poReceiptLineNumber": {
        "value": 0
      }
    }
  ],

 

I tested this now with 4 receipts with exactly the same content (that means I copied the same receipt 4 times). The items are non-stock. The first 3 receipts went through as expected without error.

 

But on the fourth I got: {"message":"Error updating supplier invoice. The PO Receipt Line with order number 000085 and line number 1 doesn't exist in the look-up table."}

 

So I checked in the  UI and the receipt was not placed on the invoice as the error-message says. But it was no problem to place this last receipt manually on the invoice in the UI. It was available and there was no error when I transfered it there.

 

I think it maybe could be some locking-problem in the database when releasing the receipts?

It seems like even when the API sent the return with a success-statuscode on the receipt/release the receipt was not available for the invoice endpoint yet. I have no idea how to get around the problem. This always will result in some random error situasjons. But maybe I also take wrong about the underlaying problem here?

 

Florian

 

 

 

 

14 REPLIES 14
Florian Haase
PARTNER

by Florian Haase

Just now we are running several tests about that problem. 

 

Now we updated Purchase receipt 86 - 106 and number 100 failed and 106 failed. All the others were ok. The receipts are exactly equal (copied)

 

screenshot.pngFlorian

by Magnus Johnsen

Hi,

Would you be able to tell us how long it is between it is being released and then added to the supplierInvoice? 

You be right that some receipts take longer time due, to queues/lockups, and therefore are unavailable when you try to add them. 

Florian Haase
PARTNER

by Florian Haase

Hi

 

I have no idea so far, because I don't logg between sending the release request and the Invoice update. But the invoice update happens at once I get the success-code for the Receipt-Release from the API. So between the answer from the API and sending of invoice-request its just some milliseconds.

But shouldn't the API wait with the answer until the release is finnished in the system?

 

We can place a wait between the release and the put/post of invoice but the question is how long? 

Can this take feks some milliseconds, seconds. Does it take sometimes longer or sometimes shorter?

 

Florian

Florian Haase
PARTNER

by Florian Haase

Hi

 

now we placed a wait by 500 milliseconds and it works much better. But at least we had 1 request which failed again. So the question is still how long do we have to wait if we want to be sure that this does not cause any problems....

 

 

Florian

Florian Haase
PARTNER

by Florian Haase

We run now through 65 receipts without error with a waittime by 500 ms. But still very unsure if this is safe...

 

 

Florian Haase
PARTNER

by Florian Haase

Nope....

 

screenshot.png

Florian Haase
PARTNER

by Florian Haase

I still need an answer here.- How long do we have to wait from updating the receipt to placing at on the invoice to be sure to not get in such error-situations?

 

Now we have placed a wait of 500 ms in the code. But today none av the receipts could be transfered to invoice. I wonder how we can handle this in a good way?

 

Any ideas?

 

FLorian

Florian Haase
PARTNER

by Florian Haase

The cause why nothing works today is another case, I take it in a new thread since the problem is not the same. 

by Magnus Johnsen

Hi.

As mentioned, there is no time frame that we can tell you that will work definitely. It depends on the size of the document amongst other things, just as you can see happens in the UI.

What you can do until there is a better solution in place to make sure that you know when the operation is done, is to GET the document and check the status.

If it is released add it to the invoice.

mrtnsn
CONTRIBUTOR ***

by mrtnsn

Hi Magnus,

Is it possible to use webhooks to trigger when an document is released?

by Magnus Johnsen

Hi, it depends in the document. For PurchaseOrderReceipt there is not currently any webhooks. 

Florian Haase
PARTNER

by Florian Haase

As mentioned in the other Topic we changed our implementation and place now first the lines manually on the invoice and than update the Receipt. 

 

In that way we get around this timing issue, and we also get around the problem that we can have a status where we have updated the receipt and got an errormessage when placing on it on the invoice. I think in that way we have a much better implementation, the only thing we are missing is the reference between the invoice and the receipt.

 

Florian

by Magnus Johnsen

Ok, please let us know if we can do anything else.

by Magnus Johnsen

Hi,

As in the UI, the time to release documents depends from document to document, and most likely the server load and how many sql operations that are currently in queue.

It might be a good solution to just retry the operation if it fails when it's just been released, the issue with this might be that the receipt might not be created as the response from the endpoint is just telling you that the job has started, not if it succedes or fails. 

 

There is a case in the backlog to return an error if it fails.