My Products
Help
danielboylan
CONTRIBUTOR ***

When to get invoice from VBNXT

by danielboylan

Hi,

When retrieving an invoice through API, what parameters should we check to ensure to invoice is ready for sending through EDI? 

Also, is there an easy way to check if a customer has EDI invoice activated in "Grunndata Kunder - Sendemåte for dokumenter"? 

4 REPLIES 4
Accepted solution
Øyvind Årseth
VISMA

by Øyvind Årseth

Hi @danielboylan 
Assuming the ordre is not yet invoiced, you could check if the order is in a status ready for invoicing, is that matches your scenario(?)
Here's an example showing orders in status "Ready for invoice", omittting orders marked for batch invoicing.
Apart from that, it depends on what you mean by "ready for sending through EDI":

query OrdersReadyForInvoice ($cid: Int) {
    useCompany(no: $cid){
        order (filter: {
            orderStatus1: {_is_on: 1},
            orderPreferences: {_is_off: 4}}) {
            totalCount
            items {
              orderNo
              customerNo
              sumBeforeGroupDiscountDomestic
            }
        }
    }
}

I suppose you would have to query customers for a value in Document delivery method 1, something like this: 

query OrdersReadyForInvoice ($cid: Int) {
    useCompany(no: $cid){
       associate(filter: {
            customerNo: {_gt: 0},
            documentDeliveryMethod1: {_is_on: 8}}) {
            totalCount
            items {
              customerNo
              name
              documentDeliveryMethod1
            }
        }
    }
}

where "8" is the bitvalue representing EDI, if that's what you are looking for specifically. 



by Marius Bancila (Updated ‎22-09-2023 10:52 by Marius Bancila VISMA )

This is not a correct filter:

 

filter: {
            orderStatus1: {_is_on: 1},
            orderPreferences: {_is_off: 4}}

 

It has more than one value so you need to build and expression with _and and/or _or. For instance, if both of these need to be true, then write it as follows:

 

filter: { _and: [
   {orderStatus1: {_is_on: 1}},
   {orderPreferences: {_is_off: 4}}
]}

 

 However, it might be easier for you to write the filter using the flag fields:

 

filter: {_and:[
   {orderStatus1Flags: {_is_on: ReadyForInvoicesAndCreditNotes}},
   {orderPreferencesFlags: {_is_off: BatchInvoice}}
]}

 

In the GraphiQL web IDE, you can explore the documentation and see the possible flags and their numerical value for each such flags field.

You can read more about that here: https://docs.business.visma.net/docs/schema/bitflags

 

danielboylan
CONTRIBUTOR ***

Thanks for the followup Marius, I'll make sure to build bu query using "and"! 

danielboylan
CONTRIBUTOR ***

Thanks Øyvind!