lnNgyn1 / PeriodInsertBundle

A Kimai plugin which generates entries for a given time-period.
MIT License
5 stars 0 forks source link

Feature request: Disallow overlapping time entries #4

Closed mpermperpisang closed 1 month ago

mpermperpisang commented 1 month ago

Hi First I want to say thank you so much for this awesome plugin It really helps me to manage my freelancers

The thing is when I'm trying to insert time range but at the specific date has already input some activity, it still work The expectation is, we dont want to overlap the time entries from any entry point

Will it be possible to disallow or showing some error message when at the same day has already have other activity?

Thank you :)

lnNgyn1 commented 1 month ago

Hi, thanks for opening this issue! Yes, I think it definitely would be possible to disallow overlapping time entries. I'm not sure whether or not to make that feature a requirement. I see two options: period inserts must have no overlapping time entries (so you have to make sure the period insert is correct beforehand), or period inserts go through with any overlapping time entries being excluded. The first option makes it a requirement. Which option did you have in mind? I'm thinking it would be better to make this feature into a toggle, similar to the select days feature.

lnNgyn1 commented 1 month ago

Just to clarify: by overlapping time entry, do you mean an entry with the same user and activity on the same day? I'm considering the case where someone can have multiple time entries on the same day but with different activities.

mpermperpisang commented 1 month ago

on my case when someone request sick leave / annual leave or any leave they have, they shouldnt have activity like work from office, @lnNgyn1

lnNgyn1 commented 1 month ago

Okay, it seems like you have two separate activities: one for sick leave and one for work from office. I will implement the first option and have that apply to any activity so that any period insert with an overlapping time entry will show an error message. I'll start working on it as soon as I can and let you know when I've added the feature.

mpermperpisang commented 1 month ago

thank you so much :)

lnNgyn1 commented 1 month ago

@mpermperpisang I've updated the plugin to disallow overlapping time entries if it is not allowed by the time tracking system settings. Submitting a period insert with an overlapping time entry will show an error message with the date of the first/earliest overlapping time entry found. Let me know if you have any problems or suggestions!

Working on this feature also gave me the opportunity to revisit and refactor the plugin. For reference, here are the other notable changes I made:

mpermperpisang commented 1 month ago

awesome i'll re-check it and update to you once i'm doing a testing

^_^

mpermperpisang commented 1 month ago

first i inputed the annual leave

Screenshot 2024-10-01 at 19 26 34

then i input the period to work from office *overlapping is disable

Screenshot 2024-10-01 at 19 27 06

i checked the Calendar menu *there are 2 activities

Screenshot 2024-10-01 at 19 27 19

i also tried to enable overlapping *and there are 3 activities as a result

Screenshot 2024-10-01 at 19 28 43

did I do it wrong? or what do your expectation of the feature? thank you @lnNgyn1

my expectation is like here *there is an error You already have an entry for this time.

Screenshot 2024-10-01 at 19 33 23 Screenshot 2024-10-01 at 19 34 48
lnNgyn1 commented 1 month ago

Oh, I wasn't aware that Kimai already had an allow overlapping time entries option. I'll work on using that instead.

The Allow overlapping time entries option should not be outside of the Extended settings menu. I ran into a similar issue in my installation. To fix it, you need to restart your Kimai installation. On Docker, I ran the command docker restart kimai-container. You may also need to clear the cache. The error is a popup message after you submit the form, instead showing up on the form itself.

lnNgyn1 commented 1 month ago

@mpermperpisang I updated the plugin to incorporate the time tracking system settings. It now checks for the Allow time entries in the future, Allow time entries with an empty duration, and Allow overlapping time entries options. It also takes into account the timetracking mode, so selecting the [Duration] configurable fixed start-time, only duration can be changed mode will hide the begin time field from the period insert page. So, the Allow overlapping time entries option is no longer under the Extended settings menu. Let me know if you have any problems or suggestions!

I still need to implement the Allow overbooking of stored budgets option, but the updated plugin should resolve your issue!

mpermperpisang commented 1 month ago

it works now, @lnNgyn1 🙌🙌🙌

Screenshot 2024-10-03 at 12 10 26
lnNgyn1 commented 1 month ago

@mpermperpisang Yay, I'm glad it worked!

By the way, I've updated the plugin again! It now applies the Allow overbooking of stored budgets option and the [Time-clock] user can start and stop records, but not edit the times or duration timetracking mode. Since period inserts are not allowed in the [Time-clock] timetracking mode, the page will hide the period insert form and show the message Period Insert is not allowed in the [Time-clock] timetracking mode.

I also fixed two minor bugs from the release you installed:

The latest release should have all the changes I mentioned. If you run into any problems, let me know!

lnNgyn1 commented 1 month ago

Another bug: code did not check if Allow overbooking of stored budgets option was enabled. Commit fac6404 fixed this issue. Latest release has been updated.