0

I have an application that posts invoices to Xero.

In the Xero API spec for invoices it lists Due Date as an 'optional' field - see here: https://developer.xero.com/documentation/api/accounting/invoices

However if I exclude the invoice field from my API JSON Request, I get the following error.

"ValidationErrors": [ { "Message": "Due Date cannot be empty" }

Doesn't appear that the Xero API behaves according to the API spec.

My solution, is to capture and store the payments terms when creating/updating contacts. Here is a sample of the payments terms that are returned when using the Contacts API:

"PaymentTerms": { "Sales": { "Day": 15, "Type": "OFFOLLOWINGMONTH" } }

I will also have to use the Organisation API to return the default PaymentTerms.

I then have to build some logic in my app something to the effect of: IF MyStoredContact PaymentTerms = BLANK, THEN Use OrgPaymentTerms, ELSE Calculate DueDate from InvoiceDate using Contact PaymentTerms

This is not ideal, as I have to update my database, store additional information, testing etc.

My questions are:

  1. Is there a better way of doing this?
  2. If DueDate is a mandatory field in the invoices API, then why does this logic not already exist within Xero?

Any help would be appreciated.

As above, I tried to exclude the DueDate field from my API Request, however I get the following validation error back from Xero API:

"ValidationErrors": [ { "Message": "Due Date cannot be empty" }

Rob
  • 1

1 Answers1

0

DueDate is optional for DRAFT status but required for SUBMITTED and AUTHORISED statuses

  • Thanks for the fast response. This worked in terms of letting me submit an invoice without a DueDate. However when submitted, Xero doesn't use either the Org Default settings, or the Contact Payment Terms to calculate the DueDate. It simply shows a DueDate equal to the Invoice Date. Unless you have any other ideas, I am back to needing to implement this logic on my side in my app. Seems counter production and would be much better handled on Xero's side. Also it would be good if they updated the documentation around DueDates noting that you can't omit beyond DRAFT state. – Rob Feb 07 '23 at 07:02