Updating Invoice Items failings

Hi,

I’m trying to update some invoices to remove VAT. They’re international orders, but are incorrectly set to include VAT.

So, I’ve created a process to retrieve the invoice, remove the payment, set the invoice to draft. All good so far.

I’ve then PUT the invoice to be updated, and the invoice items have been duplicated.

I’ve found this bug report from 2013!: Update Invoice
was this fixed?
This post makes it sound like it should be possible, but due to the duplication issue, it doesn’t work: Add items to existing invoice via API

Any ideas?

Thanks,

Hi John,

When sending invoice_items with the PUT request, these items are added to the existing invoice as you’ve seen, however if you want to remove an already existing item you need to send the ID and the _destroy key (see docs here)

For example, as your PUT request body:

{
  "invoice": {
    "invoice_items": [
      { "id": 1, "_destroy": true },
      { "id": 2, "_destroy": true },
      // ... Your items with the updated attributes
    ]
  }
}

This will remove the existing ones and replace them with items with the correct attributes.

Thanks,
Jordan