My Products
Help
ummya
CONTRIBUTOR **

How to fetch invoices ,attachment and payment in Business NXT app

by ummya

Hi 

I am currently working on a new integration and am wondering how I can retrieve Customers invoices with expired due dates or may be all the invoices and the attached document with it.

https://docs.business.visma.net/docs/schema/bitflags 

in the link above i found a way to fetch credit Notes but no invoices. Any tips will be helpful. 

 

Secondly I want to create and fetch payment using graphql query.

i tried the query bellow but getting empty array as response 

query payment_object_ref_null {
useCompany(no: 386****) {
payment {
items {
paymentNo
lines: joindown_PaymentLine_via_Payment {
items {
currency: joinup_Currency {
currencyNo
bank: joinup_Bank {
name
currency: joinup_Currency {
currencyNo
}
}
}
}
}
}
}
}
}

3 REPLIES 3
Accepted solution
David Tandberg-Johansen
CHAMPION *

by David Tandberg-Johansen

Hi,

 

If you are generate the invoice from the order, you can get a PDF representing the invoice with the reeport feature.

See the documentation on reporting: https://docs.business.dev.visma.net/docs/schema/mutations/reports

Example:

mutation CreateInvoiceFromOrder($no: Int, $orderNo: String)
{
  useCompany(no: $no)
  {
    order_reports
    {
     	invoicesAndCreditNotes(
        filter:{orderNo:{_eq:$orderNo}}
        returnDocuments: true
        splitAttachments: true
        approval: true
        formNo: 203
        printDestination: PRINT_TO_PDF
      )
      {
        succeeded
        documents
        {
          name
          content
          attachments
          {
            content
          }
        }
      }
    }
  }
}

 

If you want to fetch a copy of the pdf on a later point, you have to run the the orderdocument_reports

mutation GetInvoiceCopy($no: Int, $invoiceNo: String)
{
  useCompany(no: $no)
  {
    orderDocument_reports
    {
      orderDocumentCopy(
        filter: {invoiceNo:{_eq:$invoiceNo}}
        returnDocuments: true
        splitAttachments: true
        printDestination: PRINT_TO_PDF
      )
      {
        succeeded
        documents
        {
          name
          content
          attachments
          {
            content
          }
        }
      }
    }
  }
}

 

Hope this give you a insight on how

Accepted solution
David Tandberg-Johansen
CHAMPION *

Hi again,

 

I didnt fully answer you questions

 

To answer your first question, the easiest way to retrieve invoice data that has not been paid is via the Customer ledger. You can use voucher type = 11 and paidstatus in [1,2]

The value of paidstatus is

  • 1 = open
  • 2 = partly open
  • 3 = payed, but late
  • 4 = payed, in time

Here is the query we use to get invoice, then you have to use the report mutaion in my first reply to get a PDF copy of the invoice

query GetIncoiceInfoFromCustomerTransaction($no: Int, $dueDate: Int,$pagesize: Int, $after: String) {
  useCompany(no: $no) {
    customerTransaction(
      first: $pagesize
      after: $after
      filter: 
      {
        voucherType:{_eq:11}
        dueDate: {_lt:$dueDate}
        paidStatus:{_in:[1,2]}
      }
    ) 
    {
      totalCount
      pageInfo {
        hasNextPage
        hasPreviousPage
        startCursor
        endCursor
      }
      items {
        customerNo
        invoiceNo
        voucherNo
        voucherType
        amountDomestic
        outstandingAmountDomestic
        cid
        dueDate
        crossReference
        paidStatus
        paidLast
        createdDateTime
        changedDateTime
        voucherDate
      }
    }
  }
}

 

 

ummya
CONTRIBUTOR **

Thank you very much. It worked