Invoice from timesheets with items per task?

Hello,

I have found how to generate an invoice from tasks by selecting task items in the “Time spent” tab. However, this just generates a single line in the invoice.

Is it possible to generate 1 line per task?

Thanks in anticipation!
Kevin

Hello again,

So, I fixed this myself by editing the sources:
projet/activity/perweek.php
Added default note for per-week timespent entries
projet/tasks/time.php
Added per-task invoice generation, using the note from the time spent entry in the description.

I attach the patch file if anyone is interested.

per_task_invoicing.patch.txt (6.26 KB)

Kind regards,
Kevin

3 Likes

Kevin,

Thanks for the patch. I am new to Dolibarr and experimenting with it to see if it could serve my purposes. Your solution is something that solves a fundamental shortcoming in Dolibarr for me. Did you take any steps to enter it as a feature request ?

Geert

Hi kevin,

Can you submit your patch as a github PR to the official dolibarr project, so i can include it for next releases

Kevin,

I have been playing around with this patch and have the following doubt:

- in lines 38 and 39 of the patch file, you sum up spent time for all selected (and only the selected) “timespent” lines of a specific task.
- later in line 94 of the patch file:

$sql.=' WHERE fk_task = '.$taskid;
You update all timespent lines that have the same task ID with the invoice number and line ID (also the ones that were not selected in the previous step).

Should this line 94 not be

$sql.=' WHERE rowid in ('.join(',', $toselect).') AND fk_task = '.$taskid;
Otherwise you are marking some timespent lines as invoiced, but they were not taken in account during the calculation of total time.

Geert

Hi geert and eldy,

I did indeed have some bugs in my time.php - the new patch updates only those tasks that correspond to the invoiced items.

I attach the revised patch for review (applied to 10.0.3).

If you agree with the changes, I will submit a pull request.

Kind regards,
Kevin

per_task_invoicing_02.patch.txt (6.5 KB)

I added the feature request to the github repo:

To anyone else interested in this topic, today I confirmed that the “develop” branch (pre-12.0.0) fixes this problem.

It will be available in the next release, I guess.

The invoice line item is constructed from the task ID and label.

Thanks to the developers who fixed it.