Kitz Forum
Chat => Tech Chat => Topic started by: chenks on July 19, 2019, 03:44:12 PM
-
so i've been using the gov.uk website for a bit to calcaulate holiday entitlements for starters and leavers - https://www.gov.uk/calculate-your-holiday-entitlement/y
it all works fine, however i though it would be handy to have the actual calculation formula sitting offline rather than having to use the website all the time. they don't seem to want to give out the formula though. has anyone ever managed to work out what it is? or a way to scrape it from the sit?
-
Have a look at https://www.nidirect.gov.uk/articles/holiday-entitlements and perhaps https://www.nibusinessinfo.co.uk/content/know-how-much-holiday-give-your-staff
-
hmmm think you may have missed the point of the post.
it's not that i don't know that it's 5.6 weeks per year (or 28 days). it's what the formula is for working out what an entitlement is for a part year based on a specific start date etc.
the gov.uk gives you the number after you've asked all the questions, what i'm trying to scrape is what that actual formula is.
ie guys starts on 14 may 2019, holiday year starts on 1 jan 2019, works 5 days a week = 17.8 days (round up to 18).
-
Without calculating it myself, I think one of the links above answers this:
The holiday entitlement of 5.6 weeks is equivalent to 12.07 per cent of hours worked. The 12.07 per cent figure is 5.6 weeks' holiday, divided by 46.4 weeks (52 weeks - 5.6 weeks) and multiplied by 100 = 12.07 per cent.
-
i don't think it does.
-
You don't say whether the staff are full or part time, but this basic PowerShell script should work for both and point you in the right direction.
$ww = 5 # Number of days worked per week (max 5)
$he = $ww * 5.6 # Calculate entitlement
$d1 = '2019-05-14' # Start date
$d2 = '2019-12-31' # End date /end of year
$ts = New-TimeSpan -Start $d1 -End $d2
$weeks = $ts.Days / 7
[math]::round($he / 52 * $weeks, 1)
Kevin
-
Try this one https://www.moorepay.co.uk/blog/holiday-entitlement-calculations-made-easy/
-
You don't say whether the staff are full or part time, but this basic PowerShell script should work for both and point you in the right direction.
$ww = 5 # Number of days worked per week (max 5)
$he = $ww * 5.6 # Calculate entitlement
$d1 = '2019-05-14' # Start date
$d2 = '2019-12-31' # End date /end of year
$ts = New-TimeSpan -Start $d1 -End $d2
$weeks = $ts.Days / 7
[math]::round($he / 52 * $weeks, 1)
Kevin
it would be all full time, but some are on 28 days (incl bank holidays) and some are on 33 days (incl bank holidays), but yeah all based on a 5 day working week.
-
Try this one https://www.moorepay.co.uk/blog/holiday-entitlement-calculations-made-easy/
that pages seems to base everything on someone starting on the 1st of each month or leaving at the end of each month, however if a person starts or leaves mid-month you must included the days for those part-months (as per government website). you are also not allowed to round down at any time, must always keep it as it is or round up (in reality it's always going to be rounded up unless it comes out as a full or half number).
-
it would be all full time, but some are on 28 days (incl bank holidays) and some are on 33 days (incl bank holidays), but yeah all based on a 5 day working week.
Sorry for the brief response but I'm pressed for time.
for 28 days use 5.6
for 33 days use 6.6
Hope that makes sense.
-
You don't say whether the staff are full or part time, but this basic PowerShell script should work for both and point you in the right direction.
$ww = 5 # Number of days worked per week (max 5)
$he = $ww * 5.6 # Calculate entitlement
$d1 = '2019-05-14' # Start date
$d2 = '2019-12-31' # End date /end of year
$ts = New-TimeSpan -Start $d1 -End $d2
$weeks = $ts.Days / 7
[math]::round($he / 52 * $weeks, 1)
Kevin
yeah that seems to give the same result as the gov website based on the various date starts i've tested.
now, would that also be able to tell me how many days they have accrued to date? ie it has the start date and the current date and works out how many days accrued so far?
-
Yes, by putting in the holiday year start date or employees start date and the current date would give you entitlement to date.
You've probably worked it out already but just
- calculate the weeks worked so far
- divide their entitlement by 52 then times by the weeks worked
Kevin
-
i don't think that's quite right (unless i've mucked up the formula)
i just tried that formula based on someone leaving on 2nd august
gov website says 11.8 days, this formula gave 16.4 days
PS C:\Users\grays> $ww = 5 # Number of days worked per week (max 5)
>> $he = $ww * 5.6 # Calculate entitlement
>> $d1 = '2019-01-01' # Start date
>> $d2 = '2019-08-02' # End date /end of year
>> $ts = New-TimeSpan -Start $d1 -End $d2
>> $weeks = $ts.Days / 7
>> [math]::round($he / 52 * $weeks, 1)
16.4
(https://i.ibb.co/wrdhv70/Capture.jpg)
-
The .gov site deducts bank holidays.
The basic script I provided just calculates entitlement based on weeks worked. It's up to you to deduct bank holidays/days taken.
Kevin
-
does it deduct them? i can't see where it states that they are deducted.
the gov website uses 28 days as the base for the calculation.
banks holidays are included in the 28 (and 33 days) for the purposes of any calculations we do.
if people want the bank holidays off they have to take them as part of their holiday entitlement.
-
Sorry for the delay – finally got home from work and had time for a quick look and read your reply properly.
Based on your input of:
Employment start date – 1 January 2019
Leave year start – 2 August 2019
I’m surprised the site gave you any answer.
Another way of looking at it is 28 / 52 * weeks worked
Kevin
-
i think the website results has displayed those two fields in the wrong place!
i suppose the question i'm asking is why is it divided by "weeks worked".
shouldn't it be "days worked", as unless you leave at the end of a full week then the calculation may end up being short?
not everyone starts at the beginning of a week and leaves at the end of a week.