Home Forums Support API – How do I "pull" invoices between specific dates?

This topic contains 5 replies, has 2 voices, and was last updated by  brackenhill_mob 2 weeks, 2 days ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #17868

    brackenhill_mob
    Participant

    I’ve now got my bespoke accounts system pulling data from IN. Very happy 🙂

    However it pulls every invoice since the beginning!

    So how do I

    a) pull invoices from a specific date/invoice number?
    As I add invoices into the system (and every client has a monthly recurring retainer too) I want to be able to pull new ones not already in the accounts system

    b) pull invoices between specific dates?
    My account sometimes asks for this 🙁

    The documentation for API calls is a little sparse for my needs 😉

    I’m hoping I don’t need to make multiple curl calls (one for each invoice) to achieve this!

    Thanks

    #17872

    Hillel Coren
    Keymaster

    You can use the reports to filter invoices between a set of dates but it isn’t supported in the API.

    If you’re a developer it shouldn’t be too hard to add, we’d most likely merge a pull request.

    #17883

    brackenhill_mob
    Participant

    This is something I need/want in the API.

    I’m intrigued now as to how do accounts packages (Xero, Quickbooks etc) do this? Do they take every invoice and filter at there end? If so, doesn’t this get really slow as the number of invoices gets large?

    “If you’re a developer it shouldn’t be too hard to add, we’d most likely merge a pull request.”

    I was a developer 20 years ago, and I’ve written a bunch of Perl scripts to integrate InvoiceNinja into my accounts system (LibreOffice spreadsheets) which works. If you point me in the direction I need to look, I could probably hack something together to achieve what i want and then make it available to you/everyone if they want to include it in their systems.

    Interestingly since your reply, I’ve been playing around and discovered that if I pull invoices using updated_at I get the invoice with that timestamp pulls every one created after that date so I can actually work with this if i have to (my Perl script just drops the matching row). If this isn’t the intended behaviour, please don’t change it unless you have to 😉

    Tangential to this topic, but how do you combine the optional settings? I want to pass per_page and updated_at at the same time.

    #17884

    Hillel Coren
    Keymaster

    Here’s the relevant part of the code:

    https://github.com/invoiceninja/invoiceninja/blob/master/app/Http/Controllers/InvoiceApiController.php#L59

    That’s the intended behavior, you can see the list of options here:

    https://invoice-ninja.readthedocs.io/en/latest/api.html#optional-settings

    You can add multiple params to the query string. ie, /api/v1/clients?page=2&per_page=100

    #17985

    brackenhill_mob
    Participant

    Thanks Hillel – very helpful. As this is the intended behaviour, I’ll code for this until I’ve got time to delve into the inner workings of the app.

    On the params questions, this doesn’t work for me so I’ve opened a new topic here in case others are having the same issue.

    #17992

    brackenhill_mob
    Participant

    Can you mark this one as [SOLVED] too please?

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.

Posted in: