Xero: Create Invoice with multiple orderliness

(might be similar to this ask: Multiline invoice from Google Sheets to Xero)

I have an array with order lines that I intend to send in via the Xero node as a draft Invoice. Issue is that I might have 1 or 30 order lines depending on the order.

Any easy way to programatically fix this?

Example:

[
   {
      "OrderItems":[
         {
            "SKU":"sku1",
            "Quantity":1,
            "UnitPrice":405,
            "UnitPriceVat":0
         },
         {
            "SKU":"sku2",
            "Quantity":1,
            "UnitPrice":11.95,
            "UnitPriceVat":0
         }
      ],
      "ContactID":"xxxx"
   }
]

Hi @ericsonmartin

Easiest way would be to have a split off where one workflow path handles the orderlines. You can use the item list node to split the lines, then you can process them and combine them again. After that simply merge them back into the main flow of the invoices.

Hope that makes sense.

Hi,

The node has a specific set of lines. You basically need to add more if you have more lines.

Cannot figure out how to send in an array

Hi @ericsonmartin

Ah, now I see, sorry I didn’t realise how the node works.

No Idea how you would pull this one off with the node, without doing some bizarre stuff.
I think using a manual request with the HTTP node is the easiest way to get going.

1 Like

Maybe someone that knows about this node, knows?

Manual HTTP complicates stuff with the oauth 2.0 being renewed each 30 minutes (as far as I can read)

You can use the credentials.
image

Bram,

It looks like you have tried this and I haven’t. Which I think is the opposite.

Again, I am asking if anyone knows.

The predefined scopes on oauth 2.0 for Xero are the following:

offline_access
accounting.transactions
accounting.settings
accounting.contacts

I need to create a payment for an invoice. Anyone knows how/if to extend this.

Flow:

  1. Create customer (prebuilt Xero node)
  2. Create invoice (kinda prebuilt Xero node except for the line item issues)
  3. Create Payment (no support)

I see that Zapier supports this. Perhaps we can get inspired? @jan

Hey @ericsonmartin,

At the moment the node doesn’t have support for paying invoices so we would need to create a feature request for that one, With the multi line items I can’t see a way to do it but I can see why it would be useful to have it although I am not sure why this has not come up before unless I have missed it.

I did think maybe a loop would do the job and you could create an invoice, store the ID then on the next loop just update the invoice to add new line items but it looks like the node replaces the line items which is not ideal.

At the moment the best I can suggest would be to use the HTTP Request node and create a new generic oauth option that contains the scopes required until we update the node or someone else pops in a pull request / creates a community version.

Just to be complete and share a workflow that doesn’t work as intended but shows what I was thinking

Hey @Jon, I’m also trying to work a solution for this. I noticed the following line in the Xero API instructions for Posting Invoice Updates.

Not providing an existing LineItem with it’s LineItemID will result in that line item being deleted.

I’m pretty sure this is what has been thwarting my attempts to get multi-line invoices working so far. Wondering if this may be relevant for your workflow too?

I’ve built everything with standard http requests and it works sending in the array per their documentation. No line Id is needed.

Edit, just saw that you mentioned updates. Ye, that’s correct. But to create an invoice with an item array works without line id

2 Likes

@ericsonmartin - it’s great that you have developed a solution. Is there a workflow you could share so I can see how you built it out?

Hi James,

It’s not fully done and there are some sensitive client data but more or less this approach:

  1. Check if customer exists.
  2. 2.a If found, use on Create Invoice & update customer with recent information. (it will override previous data but recent is what the client wanted)
  3. Create invoice as draft
  4. Try to Authorise the invoice (will fail if not enough inventory on any items
  5. If possible to authorise, create payment

I am formatting the data on each and then just attach the object in the HTTP request.

So far this is proof of concept but the approach seems to be valid.

Can add (thanks to @Jon) that you need to add headers on the HTTP call with "Xero-Tenant-Id"

2 Likes

Thank you very much for this comment!!
I was going crazy here hahaha

1 Like