Some questions about API and marking invoices as paid

Hi there,
I’m trying to update our Invoice Ninja (v4.5.50) content with data from a CSV file that is provided from our financial department. This file contains the date, the client id, the amount and the invoice number.

I want to mark the related invoices as paid via API.

So, after trial and error for several days, I would like to ask some questions to clarify how to proceed with implementing this:

Question 1:
We have the default “R” as prefix for recurring invoices. This is making me headaches, because this R is not present in the financial software. All invoice numbers are unique, so - in theory - I could abandon the R and be happy.
My question is: Can I safely remove the R prefix on /settings/invoice_settings#options or do I break something important with that?

Question 2:
I struggle a lot with the API documentation, because it seems that the one for v4 is quite incomplete. For example if I try to find on API (VERSION 4) — Invoice Ninja 4.5.50 documentation how to either mark an invoice as paid or to insert a payment (still not sure which one to use here) there is no information about that. On the other side, the documentation on Invoice Ninja API Spec seems to be for Invoice Ninja v5 only.

Nevertheless, I tried to test the v5 API documentation for bulk invoice processing on Invoice Ninja API Spec to create one:

### Test bulk processing
curl -X POST ${apiurl}/invoices/bulk \
-H "${apikey}: ${apival}" \
-H "Content-Type: application/json" \
-H "X-Requested-With: XMLHttpRequest"
-d '{ "ids":["2404247"], "action":"mark_paid"}'

but this returns the error message The POST method is not supported for this route. Supported methods: GET, HEAD, PUT, PATCH, DELETE. despite the fact that the API documentation clearly states Bulk invoice actions: POST /api/v1/invoices/bulk on the above mentioned page. When replacing POST with PUT as a test, the response is record does not exist no matter what I enter as data content.

So, I would really appreciate any hints (or other websites) with updates on how to mark invoices as paid by API. Also, if there’s a safe way to do this by SQL calls, I’m in.

Hi,

  1. It shouldn’t break anything, changing the setting would only affect recurring invoices created in the future.

  2. On this page there’s an example of using the action request parameter to archive the invoice. Try changing archive to markPaid (or mark_paid).

Hi,

thanks for the hints. I removed the “R” from the settings and will check if the next invoice cycle will run as expected.

About the API problem, I checked with the mentioned example. mark_paid does not, but markPaid works:

curl -X PUT "${apiurl}/invoices/9639?action=markPaid" \
-H "${apikey}: ${apival}" \
-H "Content-Type:application/json" \
-H "X-Requested-With: XMLHttpRequest"

but it does not only mark the invoice as paid, it also automatically archives it. Not sure if this is intended, but I can handle that (just have to tell the accounting folks that they have to add “archived” to the filter when searching for paid invoices).

Maybe you have auto-archive enabled on Settings > Workflow settings?