Write off invoice at specified date

Hi,
If I write of an invoice with for example
response = requests.put(url=urltodelete+"/transitions/mark_as_cancelled", headers=header,timeout=mytimeout)

This works for writing it off now.

But if I want to specify a date to write invoices off, because they need to be written off in the previous financial year for example, I can’t see how to do this programatically.
I have too many to manually do this.
I’ve tried
response = requests.put(url=urltodelete+"/transitions/mark_as_cancelled?written_off_date=2020-03-31", headers=header,timeout=mytimeout)

This writes it off but on todays date.

Please help
Thank you

Hi @jimgoodman

I’ve looked into your issue and we don’t allow a written off date to be send in the cancelled the invoice, but you can still change the written_off_date by updating the invoice once you have cancelled it.

So for example if you first cancel like this


curl -v -XPUT "https://api.freeagent.com/v2/invoices/${INVOICE_ID}/transitions/mark_as_cancelled" \
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
-H "Content-type: application/json" \
-H "Accept: application/json"

Then you can update the invoices written off date like this


curl -v -XPUT "https://api.freeagent.com/v2/invoices/{INVOICE_ID}" \
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
-H "Content-type: application/json" \
-H "Accept: application/json" \
--data @- << EOH
{
"invoice":{
  "written_off_date":"2021-04-01"
  }
}
EOH

Hope that helps

Regards

Colin Gemmell (FreeAgent)

Hi,
It most certainly does help.
Thank you very much for your fast reply.
Much appreciated.
Kind regards,
James :blush:

Thanks for sharing this info this is useful keep it up.