My Products
Help

VoucherNo for each batch

by David Tandberg-Johansen

Hi,

 

I'm trying to follow the example in the documentation about creating batch and vouchers (https://docs.business.dev.visma.net/docs/howto/batch).

 

I see I can create a batch with the same VoucherNo on all the lines, but when I run the request again I get the same voucherno on the voucher line as the first batch. 

 

What should I do to get new voucherno on batch2, batch3 etc. 

 

We have tried the suggest path, but then we experience that some lines get the same voucherno and some doesn't. 

 

So please advice on how. 

 

And is it any plans for updating the documentation website? 

15 REPLIES 15
Accepted solution
David Tandberg-Johansen
CHAMPION *

by David Tandberg-Johansen

I would first like to thank the community for all input and comments.

 

Have been working with integration methods against Business for a long time, from edi files and with VBS, and now with GraphQL. There are different working methods in all the import methods.

 

In this thread my experience is that we had to think very differently than earlier methods. The solution we could do earlier also. But earlier we could send inn suggest(VBS) og look up next voucherno and set in the edi file, but then the counter for nextvoucherno was triggered

 

None of the examples in the GraphQL documentation give the solution we want, some of the suggestion in the thread give some solution.

 

Our scope of what we want to achieve, is to set the same voucherno on all the voucherlines, and we have not got it to work with the suggestion in this thread or from the documentation.

 

What we ended up as a solution is that do meet our scope:

  1. In the request for the batch, we set the voucherSeriesNo to the series we want, and set the batchProcessing on 8
  2. For the voucher import, we set no suggest and doesn't send any voucherno field
  3. All the voucherlines is imported, but no voucherno are set. 
  4. To set the voucherno:
    1. From the VBNXT ERP on the batch register screen, you can run the process assignVoucherNumber (On Norwegian: Tildel bilagsnummer). The process set the same voucherno on all the voucherline, different voucherno on each batch
    2. Send a batch_processing request with the BatchProcessing.assignVoucherNumer with the filter with the batchno you want to process. in the filter part for BatchProcessing.assignVoucherNumer where are using the operator _in and sends in an array of integer of the batchno we want to process. 

The only question i have to Visma () is what if a processing is gone wrong, do we get a error back with reference to which batch that gone wrong? because the response item we can set ar only succeeded

 

by David Tandberg-Johansen

Hi @Øyvind Ã…rseth ,

 

Do you have any input about this?

 

@David Tandberg-Johansen As far as I can see, both the alternatives described in the documentation should work. I agree that the first example is not the best, it was probably written before the suggest-option came to life. We've had more than one way of suggesting values, the deprecated one is marked as such in the documentation. The latest suggest method is here, also used in the alternatives mentioned above. 
As for sometimes having the same voucherno and sometimes not, it should depend on whether the voucherno balances or not. As long as the voucherno does not balance, the same voucherno is used on the next line. When the voucher is in balance, the next voucherno is suggested etc. I usually use this example to test batch/voucher-creation with suggested values, try it out and let me know what you think: 

mutation CreateBatch ($cid: Int, $batchId: Int = 0) {
    useCompany(no: $cid){
        batch_create(
            values: [
                {
                    voucherSeriesNo: 1,
                    valueDate: 20230926
                    description: "Test suggest"
                }])
        {   affectedRows
            items { batchNo @export(as: "batchId")}
        }
        voucher_create(
            values: [{
                batchNo: $batchId
                valueDate: null
                voucherDate: null
                voucherType: null
                voucherNo: null
                text: "first line"
                amountDomestic: 1300
                creditAccountNo:4300 },
                {
                batchNo: $batchId
                valueDate: null
                voucherDate: null
                voucherType: null
                voucherNo: null
                text: "second line"
                amountDomestic: 1300
                debitAccountNo: 4300 },
                {
                batchNo: $batchId
                valueDate: null
                voucherDate: null
                voucherType: null
                voucherNo: null
                text: "third line"
                amountDomestic: 500
                debitAccountNo: 4300 }])
        {affectedRows
        items{
            batchNo
            voucherNo
            }
        }
    }
}

 

Hi @Øyvind Ã…rseth 

 

Thank you for your reply

 

I tested your mutation and here is the response

{
  "data": {
    "useCompany": {
      "batch_create": {
        "affectedRows": 1,
        "items": [
          {
            "batchNo": 115
          }
        ]
      },
      "voucher_create": {
        "affectedRows": 3,
        "items": [
          {
            "batchNo": 115,
            "voucherNo": 10001
          },
          {
            "batchNo": 115,
            "voucherNo": 10001
          },
          {
            "batchNo": 115,
            "voucherNo": 10002
          }
        ]
      }
    }
  },
  "extensions": {
    "vbnxt-trace-id": "00000000000000007a1d6f15b66afddb"
  }
}

So as you described, the line 1 doesn't balance, therefore Business suggest the same voucherno for the next line (line 2). Since line 1 and line 2 balances out, the next line (line 3) gets a new voucherno??

 

In VBS and earlier EDI import, we had the opertunity to set the same voucherno on all lines in a batch, it seems this isn't a possibility in VBNXT?

 

We have also tried to get next voucherno as from the example for each batch we create, but the voucherserie doesn't update it self, so we get the same nextvoucherno evry time

@David Tandberg-Johansen  Yes, in this case the three lines (first and second balances) give two voucher numbers. Change the amount to balance across the three lines, and the voucher no remains the same. Normally, the balancing of voucher numbers is the desired outcome. Run a new batch, and the numbers will increment as they should. 

If you want to set the same voucher no for all vouchers in a batch without suggesting, query the next from the desired voucher series, and set it on all vouchers inside the batch. Maybe as a batched request, with the query first, and the mutation second. I don't have an example for that at the moment. 

Hi Again,

 

How can you batched a request, and add value from the query to the mutation in the request?

The export is just valid inside a query isn't

 

omelhus
PARTNER

by omelhus

You can't. Create the first line first, return the voucherNo and set the voucherno on the rest of the lines before you create them.

 

If you are able to find a better way to do this I'll be grateful, but this is the only way I've been able to do this.

by David Tandberg-Johansen

Hi @omelhus 

 

Thank you for your imput.

 

We actually can get the next voucherno by lookup in the voucherserie table, and we manage to save the vouchers with that number.

 

But when we try to import the next batch/voucher, we still get the same voucherno.

 

We can se that the nextvoucherno in the VoucherSerie table, doesn't update after saving the voucher as described above.

 

We have tried to import a batch/voucher via GraphQL OK, and in ERP manually added a voucherline to the imported batch and saved.Then the nextvoucherno in VoucherSerie table got updated

 

My theory is that there are a trigger that updates the VoucherSerie table from inside the ERP. But when trying to import without suggest, and setting the voucherno, it doesn't trigger the update.

 

It would be nice to see if someone from visma to test this, and if they can replicate it.

@Øyvind Ã…rseth 

 

There are many customers who have received orders from their auditor that the voucherno must be the same inside a batch. So we have to get a fix for this, either for us to lookup the nextvoucherno and use it, or a feature from the GraphQL API 

omelhus
PARTNER

by omelhus

You'll run into concurrency issues if you don't use the suggestion-approach. 

by David Tandberg-Johansen

Yes, it could.

We have set up a VoucherSerie that only the integration is using. No manually registerd batches on that voucherserie

 

But this just prove my point, that it must be a feature that actually work for this in the API

omelhus
PARTNER

by omelhus

But this is solved by using the suggest-feature. I don't think the nextVoucherNo updates until you release the voucher.

by David Tandberg-Johansen

Which process is responsible for releasing the Voucher?

 

We have been using the suggest feature, and we got this working ok.

 

But as described earlier in the thread, some customers have received orders from their auditor that the voucherno must be the same for each batch. So we have to find a way to so it would. 

The only thing missing, is understand which process is holding the voucher so it could be release and update the VoucherSerier table

@David Tandberg-Johansen I believe you have to update the batch to move the counter at the moment (what @omelhus also refers to I suppose). That behaviour deviates from default manual journal entry, so we should probably have a look at it. I'll get back to you after some more proper testing.  
On the "auditor's order": There is no rule that makes it mandatory to keep the same voucher number  inside a batch. Try to invoice more than one invoice at the time, and you'll see what I mean. ERPs differ to a certain degree on how numbering works and what the unique updated voucher identifier is, and auditors sometimes tell customers things for their own convenience I suspect🤔 

by David Tandberg-Johansen (Updated ‎26-09-2023 20:32 by David Tandberg-Johansen )

Thank you to set focus on this 

 

As mention earlier in the thread, when we manually add a empty voucher line with the same VoucherNo, the voucherserie table nextvoucherno is updated.

 

We don't have to update the batch. 

 

So my theory is there is a trigger issue when saving voucher through the graphql api 

omelhus
PARTNER

by omelhus

The example is wrong. You need to set voucherNo to null and it will be suggested. Not sure if you need to add it to the suggest parameter still.

 

I guess @Marius Bancila should update the example.