My Products
Help
jakob_sdf
CONTRIBUTOR *

Error: Voucher no. XXXXXX is used before

by jakob_sdf

Hello

 

We are trying to add a voucher to an existing batch through the api, but are getting the error "Voucher no. XXXXXX is used before". 

 

We need to use the same voucher number, and adding a voucher with the same number works in the ui, see below.

 

How do we make it work using the api?

 

Here is our request.

 

mutation add_voucher {
  useCompany(no: 2860985) {
    voucher_create(
      values: [{
	batchNo: 27
	voucherNo: 2191594
	lineNo: 4
	voucherType: 26
	valueDate: 20240930
	voucherDate: 20240930
	debitAccountNo : 4011 # material
	amountInCurrency: 4154
	orgUnit1: 2
	orgUnit2: 219890
      }]
    ) {
      affectedRows
      items {
        batchNo
        voucherNo
        voucherDate
        valueDate
      }
    }
  }
}

 

 

Works in the ui:

 

jakob_sdf_1-1727772896042.png

 

jakob_sdf_3-1727773402452.png

3 REPLIES 3

by Øyvind Årseth

@jakob_sdf I am not able to reproduce the issue when I test with your mutation, so a little hard to tell based on the given info. The mutation in itself works just fine, but I would skip the lineNo from the input, as it is not necessary when you create new vouchers. 
No need to use the insert row option in the UI, you can just start in the first column (Ver.nr.) on the new line, the insert-options are meant for inserting line in between the exisiting. 

jakob_sdf
CONTRIBUTOR *

by jakob_sdf

We actually get the same error (but in swedish) when we start in the first column as you described. But using the insert option it works. Still haven't got it to work in the api.

Could it be some configuration in the customer's NXT that causes this error?

jakob_sdf_0-1727876110550.png

 

by Øyvind Årseth

Yes, check if the voucher no. control is enabled in the company information table.Voucherno_control.png