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

New: add configuration to choose if holiday are updated at the end of month #29438

Open
wants to merge 29 commits into
base: develop
Choose a base branch
from

Conversation

YannisHoareau
Copy link
Contributor

If the configuration is selected, the holiday balance is not updated when clicked on approve, it is now updated at the end of the month, when the balance get increased.
If a leave period gets cancelled, only the already consummated days are credited again in balance.

YannisHoareau and others added 24 commits April 18, 2024 16:36
…ustRaosha/dolibarr into new-holiday-update-at-the-end-of-month
…ustRaosha/dolibarr into new-holiday-update-at-the-end-of-month
// Get month of last update
$lastUpdate = $this->getConfCP('lastUpdate', $newdateforlastupdate);
$monthLastUpdate = $lastUpdate[4].$lastUpdate[5];
$lastUpdate = strtotime($this->getConfCP('lastUpdate', dol_print_date($now, '%Y%m%d%H%M%S')));
Copy link
Member

@eldy eldy May 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of strtotime is forbidden because it does not deal correctly the timezone.
You can use dol_stringtotime()


// If month date is not same than the one of last update (the one we saved in database), then we update the timestamp and balance of each open user,
// catching up to the current month if a gap is detected
while (date('Ym', $lastUpdate) < date('Ym', $now)) {
Copy link
Member

@eldy eldy May 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of date() function is forbidden because it does not deal correctly the timezone.
You can use dol_print_date
PS: to avoid call to a function inside the while (function()). You should set 2 variables, for example $yearmonth = ... and $yearmonthnow = ... and then do
while (yearmonth < $yearmonthnow)

@eldy eldy added the PR to fix or conflict to solve PR needs to be fixed to be integrated (except for conflicts, a comment describes the fix to do) label May 10, 2024
return 1;
} else {
//updating the date of the last monthly balance update
$lastUpdate = strtotime('+1 month', strtotime(date('Ym01His', $lastUpdate)));
Copy link
Member

@eldy eldy May 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strtotime is forbidden as it does not deal correctly the timezone and daylight times.

// We add a log for each user
$this->addLogCP($user->id, $userCounter['rowid'], $langs->trans('HolidaysMonthlyUpdate'), $newSolde, $userCounter['type']);
// We add a log for each user when its balance gets increased
$this->addLogCP($user->id, $userCounter['rowid'], $langs->trans('HolidayMonthlyCredit'), $newSolde, $userCounter['type']);
Copy link
Member

@eldy eldy May 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the goal of adding the translation key HolidayMonthlyCredit compared to HolidayMonthlyUpdate ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goal is to be more understandable when reading the logs of the update because update could mean increasing or decreasing. Now, the user would know if his balance is credited or debited.

@YannisHoareau
Copy link
Contributor Author

@eldy any new feedback for this feature ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR to fix or conflict to solve PR needs to be fixed to be integrated (except for conflicts, a comment describes the fix to do)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants