Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recalculate rates on every change #673

Closed
EricDBrown1 opened this issue Apr 2, 2019 · 7 comments
Closed

Recalculate rates on every change #673

EricDBrown1 opened this issue Apr 2, 2019 · 7 comments
Labels
feature request plugin not meant to be implemented in the core, but could be a plugin
Milestone

Comments

@EricDBrown1
Copy link

Issue / Feature / Problem:
I wrote a little Plugin for tracking time with Kimai2, it uses the normal API. If I want to submit a start request (POST on api/timesheets), i have to set a customer, project and activity. Lets say the customer "Please assign", projekt "Please assign" and activity "Support" has a hourly rate of 50$. After i stop the timetrack, i go to the webpage an enter my desciption, assign my customer "Customer 1", my project "Project 2" with a hourly rate of 60$ and the activity stays on "Support". My problem is that the hourly rate is not adjusted after saving the entry, it stays still on 50$ not the 60$ from "Customer 1".

Solution 1:
After clicking save it should save the the entry with the currently set hourly rate of the selected customer / project.

Solution 2:
Also it would be really nice if i could submit a start request without setting a customer, and after closing the timetrack i would like to set the customer / project and activity.

Addition Information:
Im using Kimai v2 - 0.8.1 stable

@kevinpapst
Copy link
Member

Regarding 1: https://www.kimai.org/documentation/timesheet.html#rate-calculation
This is not a bug but the intended behavior. Remove the hourly rate from the activity and place it on the project only (or create separate activities). Setting an hourly rate on global activities is problematic.

Regarding 2: the required customer in API - are you sure? A customer should not be necessary, only a project and activity are required. I can create a timesheet entry with:

{
	"activity": 1,
	"project": 1,
	"begin": "2018-10-29 12:29",
	"end": "2018-10-29 20:37",
	"description": "sdfsdf",
	"fixedRate": null,
	"hourlyRate": 85
}

or even only:

{
	"activity": 1,
	"project": 1,
	"begin": "2018-10-29 12:29"
}

Regarding:

and after closing the timetrack i would like to set the customer / project and activity.

What is your question/problem here?

@EricDBrown1
Copy link
Author

Hey, thanks for the quick reply.

The activity has no hourly nor the fixed rate. No project and no customer. In regarding 2 you were right, i dont need a customer, the customer is automatically assigned by the project. But my problem still exists, if i stop the entry (set the end) and adjust after that the customer / project, the hourly rate for the customer / project is not applied.

See (other hourly rates than in my first post):
Normal Time directly to customer:
02.04.2019 16:29 16:30 00:01h 1.33$
Customer: Customer 1 / Project: Project 2 / Activity: Support

Customer set from "please assign" to "Customer 1" after setting the end.
02.04.2019 16:29 16.30 00:01h 0.00$
Customer: Customer 1 / Project: Project 2 / Activity: Support
Here it shouldb be 1.33$.

Time with customer set to "please assign":
02.04.2019 16:29 16.30 00:01h 0.00$
Customer: Please Assign / Project: Please Assign / Activity: Support

Regarding:

and after closing the timetrack i would like to set the customer / project and activity.

What is your question/problem here?

Setting an entry via API without setting a customer, project or activity so it is just empty.

@kevinpapst
Copy link
Member

Please provide a valid test case at the demo page. Each time someone complains about the rates no problem could be found, but only a misunderstanding of how the system works.

The customer is not associated to the timesheet entry, its only linked through the project. The customer dropdown is only available to be able to filter the project list. You should not be able to save a timesheet entry without a project.

And (this is more important): you have to delete the hourly and fixed rate from the timesheet entry if you change rate relevant fields (like the project). If you have a value in the hourly rate field of a timesheet entry, it will be used for calculation. If will not automatically be overwritten with the value from the customer, as it could have been entered manually as well.
Agains, see the documentation about how the rates are calculated: the timesheet entry config for hourly rate always wins.

Having a timesheet record without project and activity is not possible and won't be => I will not support that.

@EricDBrown1
Copy link
Author

You were right, it is a misunderstanding. I asked for a suitable solution to achieve the descriped "problem". My first intention is to give the user the permission to clear the rate filed of an timesheet entry, so its recalculated each time. This works great, but this is not best practice in my case. Could you see this as a feature request for a configuration switch to recalculate the rate for an enty each time it is saved?

@kevinpapst
Copy link
Member

Yes I could, but I wonder if there is no better way than a config switch.

@kevinpapst kevinpapst changed the title Adjust hourly rate of saved entrys Recalculate rates on every change Apr 5, 2019
@kevinpapst kevinpapst added this to the 1.0 milestone Jun 16, 2019
@kevinpapst kevinpapst added the plugin not meant to be implemented in the core, but could be a plugin label Jun 16, 2019
@kevinpapst
Copy link
Member

Should be fixed with this:
https://www.kimai.org/store/keleo-recalculate-rates-bundle.html

@lock
Copy link

lock bot commented Aug 15, 2019

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.

@lock lock bot locked and limited conversation to collaborators Aug 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature request plugin not meant to be implemented in the core, but could be a plugin
Projects
None yet
Development

No branches or pull requests

2 participants