Previously invoiced tasks now show as unbilled

Hello!

Each month I create a new invoice via the web UI for all the unbilled tasks on a particular project. When I did it this month, I found many previously-invoiced tasks were included on the new invoice. I am trying to figure out how / why this happened so I can fix it.

On 5th October, a few days after I created last month’s invoice, I decided to change the income category of all the tasks on all the invoices for the project. I did it using my Ruby API client like this:

desired_category = user.freeagent.category('008').url.to_s
id = ->(uri) { uri.to_s[/\d+$/] }

user.freeagent.invoices(contact: 12345,
                        nested_invoice_items: true,
                        sort: '-created_at',
                        auto_paginate: true).each do |invoice|
  items = invoice.invoice_items.select { |item| item.category.to_s != desired_category }
  next if items.empty?

  user.freeagent.update_invoice(
    id[invoice.url],
    invoice_items: items.map { |item|
      {
        id:        id[item.url],
        category:  desired_category,
        item_type: item.item_type  # need to specify because blank == "No unit"
      }
    }
  )
end

Is it possible that updating invoice items’ categories could have somehow reset the associated tasks’ billed_on_invoice attribute? I had assumed that you only need to specify the attributes which are changing (the docs say “…containing elements…that should be updated”).

Many thanks!

Yours,
Andrew


I can give an example of a task / timeslip which I included on an invoice last month which no longer has a billed_on_invoice value set, if it helps.

Hi Andrew,

I’ve just tried reproducing the issue you encountered, but I’m afraid I wasn’t able to :thinking: If you wouldn’t mind sharing some examples of timeslips that no longer show as billed on an invoice (even though they have in the past), that would definitely help our investigation.

Best wishes,

Ewa

Hi Ewa,

Thanks for trying to reproduce this! I’ll send you a private message with some IDs.

Best wishes,
Andrew