Fix invoice period calculation

Currently, the end time of the period was always the creation time of
the invoice (due to the initialisation), as it is generally by definition
later than any of the task periods.