Dolibarr / dolibarr

Dolibarr ERP CRM is a modern software package to manage your company or foundation's activity (contacts, suppliers, invoices, orders, stocks, agenda, accounting, ...). it's an open source Web application (written in PHP) designed for businesses of any sizes, foundations and freelancers.
https://www.dolibarr.org
GNU General Public License v3.0
5.48k stars 2.79k forks source link

Friday not taken as public holiday #15425

Closed Sekkajin closed 2 years ago

Sekkajin commented 4 years ago

Bug

Hello there,

I ran into an unwanted behavior regarding public holidays. The calculation system seems to fine overall but there's a case where it fails and I cant find the missing point in the code.

The problem is simple : if there's a friday that is a public holiday (registered in the dictionnary) that shouldnt be taken in the count as a leave, it is.

Environment

Expected and actual behavior

In the holiday form validation page, if my 8th of may is a friday and I want to take a leave from thursday to monday (monday not included), it should calculate only 1 day as a holiday since the friday is a public holiday, but the count is set to 2.

If the public holiday is a wednesday the count is properly set to 1, the problem is exclusive to fridays.

Steps to reproduce the behavior

Create new holiday form, set a starting dates with friday as a public holiday, see the count.

Attached files (Screenshots, screencasts, dolibarr.log, debugging informations…)

image

num_open_day is doing the math in htdocs/holiday/card.php

image

num_open_day comes from core/lib/date.lib.php and the math is num_between_day() - num_public_holiday()

image

The num_public_holiday function is a bit big to be screenshoted as a whole but I fail to see what's wrong in the code for fridays to be taken as a working day while it is mentionned as a public holiday in the dictionnary.

Does someone already ran into this problem ?

Thank you for your time anyway.

Sekkajin commented 4 years ago

I keep testing to find a solution to this problem and I've found that if we set the parameter "lastday" of the num_open_day function to 0, the math is done well and if you set and leave with a public holiday friday in between thursday and monday, the count is properly set to 2.

I had this parameter changed in all 6 occurences of this function in holiday/card.php. There is still a problem if you set the last day of your leave as a saturday or a sunday (which makes no sense of course but it could happen as a mistake), then the public holiday friday is still counted as a working day...

Something seems off with the inclusion of saturday/sunday as non-working day in this particular case, the math is wrong :/

DR59 commented 3 years ago

Forcing lastday to 0 may "correct" the Friday holiday issue but is not a solution as it causes leave request not including a holiday to be computed as including one day less than they actually are. Thus trying to ask for a 1 day leave, Dolibarr refuses as it considers there is no work days included.

There is definitely something to be fixed about those Friday Holidays not computed correctly if we do not want to mess up the rest of vacation leaves computing.

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 1 year with no activity. If this is a bug, please comment to confirm it is still present on latest stable version. if this is a feature request, please comment to notify the request is still relevant and not yet covered by latest stable version. This issue may be closed automatically by stale bot in 10 days (you should still be able to re-open it if required).