Differents unit prices when invoicing based on timesheet

We have a project that are may require interventions out of the normal working hours. It has been agreed with the customer that at higher price will be billed in case of the need of working in such hours.

For now we have identified the following cases that will include a different price:

  • Work is out of the daily working hours. For example company works from 9:00 to 17:00 but an intervention is requested at 22:00
  • Work is requested on weekend.
  • Work is requested on festive day. As festive we have national days (i.e: Chrismas day) but also festive days that are linked to the city where the company (city local festive day).

To be able to generate the right invoices we need to:

  1. Define on the company the working hours and days. So we must add following fields: Working days (multiselection of ir.calendar.day), Working Start Time and Working End Time.
  2. A new model to define the festive days for the company. We may name it: Working Calendar, and contain the following fields: Company, Date and Name.
  3. For each timesheet line we may add a new field to define the type: Normal/Festive/Extra Hours/etc. The system should be able to compute most of the times based on previous rules, but the user should be able to review them manually later.
  4. On project, define a diferent price (or event products) for each type of work, so when generating the invoice different invoice lines will be created.

For now, it is not possible to implement point 4 as the invoice api does not manage different types of lines for the same work but it can be easly refactored.

Having say that I think all other points are also interested to be part of standard modules. For example the working calendar can be used as base for the Payroll management feature we already discussed.

Toughts?

Just create task for each kind with each price and let the employee encode timesheet on the proper task.

The problem is that we already have differnt tasks on the projects due to different nature of work and different kinds of employees.

So with your proposal, in case we have 4 tasks per project, then we must create a subtask for each type of payments which means 16 tasks for a simple task.

So this makes more complex for the user to be able to know on which task it should enter the timesheet and maximizes the number of errors.

Also it is possible that the employee entering the data does not know the billing conditions with the customer, so he may not know if it should be billed as extra price or not. So we want to relly on Tryton to do the proper computation.

Well if you have 16 different pricing for a simple task. Any way you will need to have the 16 prices recorded somewhere.

I guess it should be possible to have a job that move timesheet lines to the proper task.

Well correct naming should solve the problem.

For me the main problem with the request is that it will no more be possible to compute the forecast of invoiced amount per task (or at least in a fast way) because it can no more be timesheet hour * price.

Of course but some prices can be just computed. For example, out of office work has a 20% price increase.
Also the prices are shared between multiple projects. We have different projects for the same customer and prices are also shared by different customers.

So of course its easier to make the system compute it than manually creating multiple tasks for each project.

That can be easly solved by doing: hour * Coalesce(timesheet_price, price) where timesheet_price is the price of timesheet lines that have different prices.

Indeed for invoicing we must group by different timesheet lines, so we must already have the price (or some other model that fixes the price) stored on the line.

I just realized that information will be also usefull for Holidays dates for planned_date but also for any Human Resources module for tryton?

IYAI we implemented working calendar long time ago.

Great to know that such feature will be also usefull for others. Could you explain the use case of such module? What is the feature that you use the calendar for?

Mainly to distinguish employee hours in working days from another days, in order to prepare monthly employee information for a third party payroll software.

I have thought a bit about this. What we do now for a customer is to have a timesheet.work specific for a certain project or work order. Users adding timesheet.line to it and Tryton will compute the costprice of that line. But overtime will be added to a different timesheet.work which we allowed to be negative hours. So added all the hours together will end up with a fixed total of hours from the contract. Invoicing in this case cannot be done automatically. In short for an employee with a contract of 8 hours aday, 40 hours a week, a work week will something like:

mo: 8 hours, working at repair shop
tu: 3 hours, delivery machine to customer,
    6 hours, working at repair shop,
   -1 hour, overtime
we: 5 hours, delivery machine to customer,
    5 hours, repairs at different customers,
   -2 hours overtime
th: 8 hours, study
fr: 5 hours, working at repair shop,
    3 hours free time

As you can see, the employee made on Tuesday and Wednesday some extra hours, but took an early weekend on Friday. The thing with this is that the overtime is not calculated for the customer, which in this case it not a big problem, but in general you are missing the link why there was overtime.

So I think that there have to be new model added to the timesheet module which connects hours, employee and works.

I think this should be done on employee level because most companies work 24/7 but in shifts. Also this must be flexible. There are situations where people want a day off twice a month, or on even weeks etc. Sometime they want to work the even weeks 5 days and the odd weeks 3 days. Sometimes they have a contract for 32 hours, but they want to do it in 3 days, or an employee only wants to work on tuesday, wednesday and thursday etc. Also costprices should be defined here because some employees get 150% on saturday and 200% on sunday, but others are on a different salary scale, where there is no overtime, so all working hours are 100%.

Make this general and call it working days, each employee has specified their working days here. For example monday, tuesday, thursday and friday are working days of 8 hours. The wednesday is an off day. You can also think of the friday to be the day off.

When an employee adds more then the working hours, the system should balance the extra hours on a different timesheet.work and makes that amount negative. In a new model (timesheet.timesheet?), you can select a week number or a date range and the employee and you will see all the works and the sum of each day.

As you can see, invoicing is left out, but it shouldn’t be hard to implement the total costs.

This should be forbidden: Issue 11869: Prevent negative timesheet hours - Tryton issue tracker

This is not the goal of timesheet to manage attendance, this is for the attendance module.

The rest of the discussion if just off-topic.