My Products
Help
jakob_sdf
CONTRIBUTOR *

Validate a batch and voucher when creating them

by jakob_sdf

Hello

 

We are developing an incoming invoice integration between our system and NXT.

 

Our current flow for validating voucher errors is something like this:

1. Create batch and vouchers using batch_create and voucher_create

2. Store the batch and voucher number in our database

3. Update batch using batch_processings -> updateBatch to finalize it

4. Delete the batch if updateBatch failed to enable the user to fix the problems on our end

 

updateBatch sometimes gives us errors, such as a voucher missing orgUnit1 or orgUnit2.

However, deleting the batch to start over feels like an unneccesarily complicated and slightly risky solution.

 

Is it possible to know if it's a valid voucher in step 1, and give the user a chance to fix the problems on our end before ever creating the voucher in NXT?

Or is there another preferred way of handling these validation errors?

2 REPLIES 2

by Øyvind Årseth

Try running the processing validateBatch separately before updateBatch, it will return an array of errors (if any), similar to the message you'll get in the UI if anything mandatory is missing, like cost units on certain accounts etc. Something like this for instance: 

            "message": "Error: Batch is suspended.\nLine no. 1: Account no. 1790 is missing Avdeling."
Then you can correct before you run updateBatch again, no need to delete anything. 

by Marius Bancila (Updated ‎23-01-2025 21:12 by Marius Bancila VISMA )

What does valid voucher mean here? Can't you use the information in the error to figure out what you need to properly set?