Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com), and this project adheres to [Semantic Versioning](https://semver.org).

## [1.3.1] - 16-10-2026

### Changed

- Fixed start and end date so night shifts end on the day after the roster date.

## [1.3.0] - 09-06-2026

### Changed
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ The following settings are required to connect to the API.
| BaseUrl | The URL to the API | Yes |
| HistoricalDays | - The number of days in the past from which the shifts will be imported.<br> - Will be converted to a `[DateTime]` object containing the _current date_ __minus__ the number of days specified. | Yes |
| FutureDays | - The number of days in the future from which the shifts will be imported.<br> - Will be converted to a `[DateTime]` object containing the _current date_ __plus__ the number of days specified. | Yes |
| ExcludeShiftsWithoutFunction | - When enabled, shifts without a function will not be imported. This prevents importing days off. | No |

### Remarks

Expand Down
11 changes: 10 additions & 1 deletion configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,14 @@
"description": "The number of days in the future from which the shifts will be imported.",
"required": true
}
},
{
"key": "ExcludeShiftsWithoutFunction",
"type": "checkbox",
"defaultValue": false,
"templateOptions": {
"label": "Exclude shifts without function",
"required": false
}
}
]
]
34 changes: 14 additions & 20 deletions persons.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ $Script:AuthenticationHeaders = $null
$Script:BaseUrl = $config.BaseUrl
$Script:Username = $config.Username
$Script:Password = $config.Password
$Script:ExcludeShiftsWithoutFunction = $config.ExcludeShiftsWithoutFunction

#region functions
function Resolve-IntusInplanningError {
Expand Down Expand Up @@ -300,6 +301,7 @@ try {
if ((-not($day.parts.count -eq 0)) -and ($null -eq $day.absence)) {

$rosterDate = $day.rosterDate
$rosterEndDate = $rosterDate

foreach ($part in $day.parts) {
$counter = $counter + 1
Expand All @@ -310,30 +312,19 @@ try {
$pattern = '^\d{2}:\d{2}-\d{2}:\d{2}'
$time = [regex]::Match($part.shift.uname, $pattern)
if ($time.Success) {
$times = $time.value -split '-'
$startTime = $times[0]
$endTime = $times[1]
}
else {
$startTime = '00:00'
$endTime = '00:00'
if($part.shift.uname.EndsWith('p')){
$rosterEndDate = ([datetime]$rosterDate).AddDays(1).ToString("yyyy-MM-dd")
}
}
}
else {
# Define the pattern for hhmm-hhmm
$pattern = '^\d{4}-\d{4}'
$time = [regex]::Match($part.shift.uname, $pattern)
if ($time.Success) {
$times = $time.value -split '-'
$startTimeUnformatted = $times[0]
$endTimeUnformatted = $times[1]
# Format HHMM to HH:MM
$startTime = "$($startTimeUnformatted.Substring(0, 2)):$($startTimeUnformatted.Substring(2, 2))"
$endTime = "$($endTimeUnformatted.Substring(0, 2)):$($endTimeUnformatted.Substring(2, 2))"
}
else {
$startTime = '00:00'
$endTime = '00:00'
if($part.shift.uname.EndsWith('p')){
$rosterEndDate = ([datetime]$rosterDate).AddDays(1).ToString("yyyy-MM-dd")
}
}
}

Expand All @@ -344,7 +335,10 @@ try {
else {
$functioncode = ""
$function = ""
# break # If you want to skip shifts without a function, you can uncomment this line.

if($Script:ExcludeShiftsWithoutFunction){
break
}
}

$groupExternalId = $part.group.externalId
Expand All @@ -364,8 +358,8 @@ try {
# Add the same fields as for shift. Otherwise, the HelloID mapping will fail
# The value of both the 'startAt' and 'endAt' cannot be null. If empty, HelloID is unable
# to determine the start/end date, resulting in the contract marked as 'active'.
startAt = "$($rosterDate)T$($startTime):00Z"
endAt = "$($rosterDate)T$($endTime):00Z"
startAt = "$($rosterDate)"
endAt = "$($rosterEndDate)"
}

$contracts.Add($ShiftContract)
Expand Down
Loading