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.

2 Likes

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"

3 Likes

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

2 Likes

Disheartening to see that a year later, we still don’t have a Xero Create Invoice node that has the basic feature of supporting multiple line items :thinking: Has everyone been using a custom HTTP request? Surely multiple line items isn’t an edge case in this instance?

Could anyone let us know if this is a feature that’s likely to be implemented? I’ve been a Zapier user for a few years and just dipping my toe into n8n. How responsive are the devs to this kind of thing? :pray:

1 Like

This drove me absolutely mental too! Nothing in the documentation about this imortant bit of info :-1:

Hey @gruffvaughan,

There are a few nodes where we should probably add this as an option as it still seems odd to me that we don’t have it, This is something that will happen but we do have to prioritise our feature requests and also work on our roadmap and this is one of those things that has slipped. I will see if I can fit this in early next year though.

1 Like

Appreciate that @Jon :ok_hand:

I went ahead and tackled the problem manually and it certainly was more complex than I initially anticipated. I’ve made some good progress, but I’m yet to tackle discounted line items, which adds a whole new layer of complexity :sweat:

Doesn’t help that this is my first go at an n8n workflow, but I’m getting there :pray:

1 Like

Looks good, I love the use of sticky notes as well.

Id too love to have multiple order lines for xero. I’ve seen this issue asked a few times on multiple threads. Im quite shocked it’s not a thing.

It is pretty common if you’re hooking up an ecommerce store to xero to send multiple order items + shipping items + discount codes etc.

While you can add all 3, and that works, you just cant process more than 1 product which is silly.

I’ve also tried the HTTP request with no luck.

Please add this feature! it just makes sooo much sense to loop over the items in an array.