to get a personalized navigation.
to get a personalized navigation.
Hey,
I've already discussed this with Øyvind and Suzdar, but it might be an issue worth tracking in the community.
Current behavior
When I create a batch I expect the voucher number (voucherNo) to be automatically set by the API, based on the provided voucherSeriesNo set on the batch. In the current implementation in the API the nextVoucherNo on voucherSeries won't even increment after I've created a new line using voucher_create. I can then continue to register multiple vouchers using the same voucherNo via the API. When I go to "Bilagsregistrering" in the UI and press + the number increases and I get an when I try to add a new voucher with the same number.
Expected behavior
TLDR: Work like VBS.
When I create a batch I also provide the voucherSeriesNo the vouchers for that batch should automatically set the voucherNo for each line based on that series. This is exactly what happens if you use the sample from the SDK with VBS.
Snippet from SDK
Solved! Go to Solution.
May I ask what is the status on this one? Marius Bancila comments that a way of having VB NXT setting next VoucherNo is added to the backlog - but that comment was from May 2022.
Are there any news around this?
This works using my solution or with suggest:.
Tested your solution - got it to work. I was just under the impression it would be a more integrated solution reducing number of steps needed to be taken to create a voucher.
Thanx for replying!
You should be able to do this.
mutation CreateVoucherLines($cid: Int!, $lines: [Voucher_Insert_Input!]!) {
useCompany(no: $cid) {
voucher_create(values: $lines, suggest: { voucherNo: true }) {
affectedRows
items {
batchNo
voucherNo
voucherDate
}
}
}
}
We have now support for suggesting values in production. Please check the documentation here: https://docs.business.visma.net/docs/schema/mutations/inserts#suggested-values
So it turns out that this was solvable with a processing called assignVoucherNumber all along.
mutation AssignVoucherNumberAndFinishBatch($cid: Int!, $batchNo: Int!, $updateBatch: Boolean = false) {
useCompany(no: $cid) {
batch_processings {
assignVoucherNumber(filter: { batchNo: { _eq: $batchNo } }) {
succeeded
}
updateBatch(filter: { batchNo: { _eq: $batchNo } }) @include(if: $updateBatch) {
succeeded
voucherJournalNo
}
}
}
}
I do understand the hassle. I have added this issue to our backlog.
I am thinking of the following solution (that preserves backward compatibility with existing schema and does not affect existing code):
mutation create_voucher($cid : Int!,
$bno : Int!,
$cno : Int!,
$valuedt : Int!)
{
useCompany(no : $cid)
{
voucher_create(values: {
batchNo : $bno
debitAccountNo : 1930
creditAccountNo: $cno
customerNo : $cno
amountDomestic : 100
valueDate : $valuedt
suggestValues {
voucherNo
voucherDate
}
})
{
affectedRows
items
{
batchNo
voucherNo
voucherDate
valueDate
}
}
}
}
Let me know what you think.
I think it would be better as a parameter for voucher_create instead of a property on Voucher_Insert.
mutation create_voucher($cid: Int!, $bno: Int!, $cno: Int!, $valuedt: Int!) {
useCompany(no: $cid) {
voucher_create(
values: {
batchNo: $bno
debitAccountNo: 1930
creditAccountNo: $cno
customerNo: $cno
amountDomestic: 100
valueDate: $valuedt
}
suggestValues: { voucherNo: { type: DEFAULT } }
) {
affectedRows
items {
batchNo
voucherNo
voucherDate
valueDate
}
}
}
}
This way SuggestValueInInterval also could be implemented with a type: INTERVAL, start: N, end: N+X and thus fix my issues with creating customers and suppliers as well.
The approach with a second argument, suggestValues, as you have shown, implies that this specification applies to all the objects passed to the values argument. If you add more than one record at a time (keep in mind this is generic, not voucher related) for all objects added the same specification is used. I supposed that should be fine. SuggestValue could be called before setting a specific value if one is provided within the object in values.
In my opinion "SuggestValue" should be default for all properties where it's available, unless it's provided in the object. Does the model contain information about what fields have SuggestValue available?
I've no opinion on how or where to implement this functionality, but I agree that SuggestValue is missed dearly. As Ole points out, one would expect VB to handle this, without the need of getting and setting the nextVoucherNo in voucherSeries.
Batch and voucher are two entities. When you create a batch (batch_create), there is no voucher that is created. You need to explicitly use voucher_create. That is no different than what you do in VBS. There you also have to call AddRow() explicitly on the batch and voucher table. What you do in VBS is you say JoinTable but we don't have that in GraphQL. I think the part you are complaining about is:
voucherLineRow.SuggestValue((long)C.Voucher.VoucherNo);
voucherLineRow.SuggestValue((long)C.Voucher.VoucherDate);
We don't actually have this in GraphQL so far because VoucherNo and VoucherDate are not primary key columns. We call SuggestValue automatically for all primary keys that don't have a value given explicitly, but these do are not primary keys. Therefore, for this to work, we need to find a way to request an automatic value.
Yes, I'm using voucher_create to create the lines after I've created the batch.
You have two options here. Either you can set SuggestValue for the columns by default and let the user override them afterwards, or you can take an argument with array of fields to suggest values for.
If you first run SuggestValue and then SetIntergerValue afterwards it won't suggest a value but use the value that's set by SetIntegerValue.
If you have the time we can setup a google meet and I can show you how this is a major issue.
Copyright © 2022 Visma.com. All rights reserved.