kimai / kimai

Kimai is a web-based multi-user time-tracking application. Works great for everyone: freelancers, companies, organizations - everyone can track their times, generate reports, create invoices and do so much more. SaaS version available at https://www.kimai.cloud
https://www.kimai.org
GNU Affero General Public License v3.0
3.15k stars 550 forks source link

add timerange filter to timesheet export api #577

Closed j0hannesr0th closed 5 years ago

j0hannesr0th commented 5 years ago

Is your feature request related to a problem? Please describe. As requested in #562 I'll create a new issue for enhancing the api. Firstly it's not possible to select the content of the users timesheets by a given timerange. Secondly everytime the request is done all the timesheet entries will be shown. There is no flag "exported already" or something like this.

Describe the solution you'd like Add a filter for timerange and once requested set "exportedAt" to current DATETIME in the database. It's very helpful for invoicing and checking reasons. Maybe you can make it possible to respect "all" or "not exported yet" flag, too.

kevinpapst commented 5 years ago

The export flag is currently only shown for single timesheet entities, but not when querying the collection (see this file: https://github.com/kevinpapst/kimai2/blob/master/config/serializer/App/Entity.Timesheet.yml).

You can already update the export flag for single timesheet entities: its used in the export module as well. Why don't you use that one?

Attached PR #639 adds a begin, end and exported flag to the timesheet collection query.

j0hannesr0th commented 5 years ago

@kevinpapst I've tested the api tonight with postman. It works - but I have a question.

At the end of every week I'm sending a csv-file to some of our big customers - they use kimai 1, too. They import the timesheet entries I exported them. Because then invoicing is much more easier for us - I just write the hours to the invoice and they can see the details in their own kimai.

So once exported I don't want to export the same entry again. That's why my script updated all entries which are in the csv-file to "exported = 1". In some cases it happens that entries aren't inside the database when I export them. Example: employee does on-site service on thursday. He can't access Kimai while he is doing on-site service so he'll add his times on friday. On friday he is ill at home. The export on friday evening is now without his times. But it doesn't matter because his times will be in the next export because I always select all timesheet entries per customer which have not been exported yet.

Now my question: do you think a mass updater for exported flag is useful for others too? Like once the api /api/timesheets?customer=1&exported=1&update_exported_to=1 is called all the entries get a mass-update at the exported flag to 1.

If you don't think it's useful for others I'll write a small script which does this job.

kevinpapst commented 5 years ago

A mass update would be useful for sure. Currently the exporter sends each entry in one request to set the export flag, which is slow for large exports and possibly error-prone. Doing a mass update in one transaction would be the right way to go. So we need to add a "patch collection" method to the timesheets API => new issue please :-)

lock[bot] commented 5 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. If you use Kimai on a daily basis, please consider donating to support further development of Kimai.