---
title: "Migration from Horilla"
manual: "adsum by web-vision"
version: "main"
permalink: "https://docs.typo3.org/permalink/web-vision/adsum-monorepo:installation-migration-from-horilla@main"
source: "Installation/MigrationFromHorilla.rst"
rendered: "2026-11-07T02:01:32+00:00"
---

# Migration from Horilla {#installation-migration-from-horilla}

The package `web-vision/adsum-migration` imports the data of a Horilla installation once: companies,
organisation, employees, working time and calendar, punches, leave and opening balances. HR signs off a
reconciliation before the cut-over. Install the package for the import and remove it afterwards. All steps are
console commands on the server.

## Before you start {#before-you-start}

1.  Install the package:

    ```bash
    composer require web-vision/adsum-migration
    bin/console doctrine:migrations:migrate
    ```
1.  Create the adsum companies the Horilla companies go into; the import does not create companies.
1.  Create the sickness leave type of every company if Horilla's sickness is to become sickness reports.
1.  Create a read-only PostgreSQL role for Horilla:

    ```sql
    CREATE ROLE adsum_import LOGIN PASSWORD '...';
    GRANT CONNECT ON DATABASE horilla TO adsum_import;
    GRANT USAGE ON SCHEMA public TO adsum_import;
    GRANT SELECT ON ALL TABLES IN SCHEMA public TO adsum_import;
    ```

    The import does not run while the role may change a table it reads.
1.  Export the applied Horilla migrations of the reviewed copy into `horilla-migrations.txt` in the mapping
    directory, one `app.name` per line. The import refuses any other Horilla schema.

## Configuration {#configuration}

-   **MIGRATION_HORILLA_DSN**

    -   *Type:* string

    The connection to Horilla with the read-only role, for example
    `postgresql://adsum_import:...@horilla-db:5432/horilla?serverVersion=16`. Set it in `.env.local`.

-   **MIGRATION_SOURCE_TIMEZONE**

    -   *Type:* time zone identifier

    The time zone of Horilla's times, for example `Europe/Berlin`. No default.

-   **MIGRATION_CUTOVER_DATE**

    -   *Type:* date (`YYYY-MM-DD`)

    The day adsum becomes the system of record. Opening balances are booked on this day.

-   **MIGRATION_HISTORY_FROM**

    -   *Type:* date (`YYYY-MM-DD`)
    -   *Default:* 1 January of the cut-over year

    Punches and leave requests before this day are not imported.

-   **MIGRATION_WORKING_TIME_FROM**

    -   *Type:* date (`YYYY-MM-DD`)
    -   *Default:* `MIGRATION_HISTORY_FROM`

    The day the working-time history starts: working-time assignments begin on the later of this day and the entry
    date, so the working-time account is what adsum computes from the imported punches from here on. It must lie
    between `MIGRATION_HISTORY_FROM` and the cut-over date. Set it to the first day with punches, otherwise the
    months before count as days without work.

-   **MIGRATION_MAPPING_DIR**

    -   *Type:* path

    The directory of the mapping files described below.

-   **MIGRATION_REPORT_DIR**

    -   *Type:* path

    The directory of the import reports and reconciliation files, readable by their owner only. The
    reconciliation files contain names.

-   **MIGRATION_MEDIA_DIR**

    -   *Type:* path

    Optional: a read-only copy of Horilla's `MEDIA_ROOT`, for uploaded files such as the profile photos of the
    employees, the certificates of sick leave and the photos of asset allocations. Without it, the profile photos are
    reported as missing (`profilePhotoMissing`) and the other files as not copied (`photosNotCopied`).

-   **MIGRATION_REPORT_RETENTION_DAYS**

    -   *Type:* integer
    -   *Default:* `90`

    How long `prune-reports` keeps the files.

## Mapping files {#mapping-files}

The mapping files hold HR's decisions. The import checks them first and names every invalid entry. A YAML file that has
content but not its top-level key (`companies:`, `groups:`, `leaveTypes:`, `calendars:`, `organisation:`) is
refused with `mappingRootKeyMissing`, because it would otherwise import nothing without saying so.

-   **`companies.yaml`**

    Per Horilla company id: `target` (the adsum company id), `timeZone` and `federalState` (for example
    `DE-BY`), the region of the company and its locations. The regions and holidays need the country package
    (`web-vision/adsum-country-de` for Germany); without it, the company is imported without region and reported with
    `regionNotInstalled`, and `statutory-holidays` skips it. Companies not listed are skipped. The optional
    `defaultLocation` is the name of a location that `locations` creates in the company; every employee without a
    location in Horilla gets it, with the warning `locationDefaulted`. The optional `dayValidation` sets the day
    validation of the company on every import, as the settings page has it: `policy` (`off`, `all` or
    `conditional`) and, optionally, `workedAboveSeconds`, `deltaAboveSeconds`, `deltaBelowSeconds` (seconds) and
    `withViolations`; for example \``dayValidation: { policy: conditional, deltaAboveSeconds: 5400, deltaBelowSeconds:
    5400 }`\` for a check of every day more than 1:30 over or short of its target. Days before the cut-over never wait
    for a manager; they count as validated, as in Horilla. The optional `planning` sets who reads the planning of the
    company, where the Planning package is installed: `planning: { visibility: company }` lets every employee read the
    planning of every person and team, `team` (the default) only their own teams. Without the Planning package the
    setting is reported (`planningNotInstalled`). The optional `features` switch features of the installed packages
    on or off on every import: `features: { workTypes: off, scheduleChanges: off }` for a company that uses neither
    work types nor schedule change requests. A feature no installed package declares is an error of the row
    (`featureUnknown`). The optional `colleagueAbsenceVisibility` (`off`, `team`, `department` or `company`)
    sets on every import whose absences colleagues see; without it the company keeps its setting (a new company starts
    with `department`). Which absence types colleagues see, the import never sets. The optional `gravatarEnabled`
    (`true` or `false`) sets on every import whether employees without a photo are shown with their Gravatar;
    without it the company keeps its setting (a new company starts with `false`).

-   **`roles.yaml`**

    `groups`: the adsum role (`hr`, `admin`) of each Horilla group; `superusers`: Horilla user names that
    become admins; the optional `people`: the roles of single people by personnel number, for those whom no group
    describes. The roles are `employee`, `hr` and `admin`; they are added to those of the groups and never
    remove one. An example:

    ```
    people:
      H7: [hr]
      PEP#32: [hr]

    ```

    A personnel number is the badge id of the employee, or the one `personnel-numbers.csv` gives it. An unknown role
    stops the import like any broken mapping entry and names the entry (`people.H7`). The stage `person-roles`
    lists every granted role with `roleGranted` and writes nothing, since the roles are granted when the account is
    created through `invite-users` or the normal invitation; a personnel number that belongs to no employee
    (`unknownPersonnelNumber`) or to several (`ambiguousPersonnelNumber`) is an error of the row and grants
    nothing. A second run changes nothing.

-   **`leave-types.yaml`**

    Per Horilla leave type id an `action`: `create`, `existing` (with `key`, the adsum leave type id),
    `sickness`, `timeOffInLieu` or `skip` (with `reason`). Several Horilla types may map to one adsum type;
    their balances are added up. With `balanceAs: carryForward` the balances of a type open as carry-over, valid
    until their own expiry in Horilla or else `validUntil` (`YYYY-MM-DD`), which is meant for the vacation types
    of earlier years. Create the adsum type and its policies, valid from the cut-over date, before
    `leave-balances`. A type without entry is created only if it is a plain yearly type in days.

-   **`personnel-numbers.csv`**

    `employeeId,personnelNumber` for employees without a usable badge id.

-   **`entry-dates.csv`**

    `employeeId,entryDate` (`YYYY-MM-DD`): the real entry date of an employee. Without an entry the import takes
    Horilla's joining date, and without that the earlier of the creation of the employee's login and the first
    attendance day, with the warning `entryDateDerived` so that HR can correct it after the go-live.

-   **`weekly-contract.csv`**

    `personnelNumber,weeklyContractSeconds`; overrides the weekly full time of the shift.

-   **`exit-dates.csv`**

    `personnelNumber,exitDate` (`YYYY-MM-DD`): the real exit date of an employee who is inactive in Horilla. Without
    an entry the import exits the person on the contract end of Horilla, else on the day of the last attendance. A row
    wins over both, and the employment of the person ends that day. A date that is no date, or a personnel number
    listed twice, stops the import like any broken mapping entry. The stage `exit-dates` reports a personnel number
    that no employee of Horilla has (`unknownPersonnelNumber`); a row for an employee who is active in Horilla changes
    nothing.

-   **`working-time-history.csv`**

    `employeeId,validFrom,validTo,model` (dates `YYYY-MM-DD`, `validTo` empty for an open end): the working-time
    periods of an employee, because Horilla knows only the current shift. `model` is a Horilla shift id (numeric) or
    the code of a working-time model that exists in the company before the import, for example a model without working
    days for a leave of absence. The rows of a listed employee replace the single assignment the import derives from
    the shift; gaps between rows stay without model. A period that begins before the entry date or
    `MIGRATION_WORKING_TIME_FROM` is cut there (`workingTimeHistoryCut`). Overlapping rows
    (`workingTimeHistoryOverlap`) or an unknown model (`workingTimeHistoryModelUnknown`) are errors and the
    employee gets no assignment. Employees that are not listed keep the derived assignment.

-   **`employment-history.csv`**

    `personnelNumber,from,employmentType,weeklyContractHours` (date `YYYY-MM-DD`, the type by its German name in the
    company, the hours as a decimal number, for example `32` or `39.5`): the employment periods of a person, because
    Horilla knows only the current work information. List the periods in order, one row each; a period lasts until the
    day before the next one and the last one stays open. The first row is the entry date. The rows of a listed person
    replace the single period the import derives from the work information and `weekly-contract.csv`; department, job
    position, job role and location are those of the current work information. A type that is unknown in the company
    (`employmentHistoryTypeUnknown`), a row dated before the one above (`employmentHistoryUnordered`) or on the same
    day (`employmentHistoryOverlap`) and a first row that is not the entry date (`employmentHistoryStart`) are
    errors, whose field names the line, and the person is not imported. The stage `employment-history` reports a
    personnel number that no employee of Horilla has (`unknownPersonnelNumber`). A second run with the same file
    changes nothing; a period added to the file is added, but a period that starts on the day of an existing one with
    other data is reported (`employmentHistoryPeriodExists`): correct it on the employee record. For a person who
    changes later in the running system, use the correction of the employment period there instead of the file.

-   **`additional-absences.csv`**

    `personnelNumber,from,to,part,leaveType,reason` (dates `YYYY-MM-DD`, `to` may stay empty for a single day,
    `part` is `full`, `firstHalf` or `secondHalf` and may stay empty for `full`; a half day is a single day,
    the leave type is its German name in the company or `sickness`): absences that were missing in Horilla, such as
    a vacation approved outside the system, a release by law or a sickness nobody reported. Every fresh import starts
    from Horilla's data again, so list them here once instead of entering them by hand after each run. The stage
    `additional-absences`, after `leave-requests` and `punches`, enters each row the way HR records an absence
    afterwards: a leave request that is approved at once without an approval step, marked as entered by HR, with the
    reason in its history, or a sickness report for `sickness`. A day before the cut-over is charged against the
    opening balance, carried-over leave first; the balance must cover it. A row with a bad date, an unknown part, no
    reason or the same entry twice stops the import like any broken mapping entry. A personnel number nobody has
    (`unknownPersonnelNumber`), a leave type the company does not have (`leaveTypeUnknown`) and a request the leave
    rules refuse, such as a day that is not in the past (`requestRefused`), are errors of that row. A row that shares
    a day, or a half of it, with a request or a sickness (`overlappingAbsence`) or with tracked time
    (`overlappingTrackedTime`) is reported and not imported. Every row that was entered is listed in the report
    (`additionalAbsenceRecorded`). A second run changes nothing, also when only the reason in the file changed.

-   **`attendance-adjustments.csv`**

    `personnelNumber,date,action,newDate,reason` (dates `YYYY-MM-DD`; put a reason with commas in quotes): decisions
    of HR about attendance records that Horilla holds on the wrong day, such as a correction entered with the date of
    the day before the work. The only action is `moveTo`: the record of the person on `date`, and its punches if
    it has any, is imported as if it belonged to `newDate`, at the same times of day, and the reason becomes the note
    of the day. The leave of the person stays as it is, so the work counts on top of a vacation day. This holds for
    `punches`, `attendance-corrections` and `attendance-without-punches` alike. The stage
    `attendance-adjustments` reports every row and writes nothing: a row that is applied is listed with
    `attendanceMoved`; a row for which Horilla holds no record of the person on `date`
    (`attendanceAdjustmentNoRecord`) or whose `newDate` already has tracked time in Horilla
    (`attendanceAdjustmentTargetBusy`) is an error of the row and not applied, and so is a personnel number nobody
    has (`unknownPersonnelNumber`) or several have (`ambiguousPersonnelNumber`). A row with an action nobody knows,
    a bad date, the same day twice, no reason or the same record twice stops the import like any broken mapping entry.
    Every fresh import starts from Horilla's data again, so list the records here once. A second run changes nothing.

-   **`organisation.yaml`**

    Optional. The company structure HR decided, which wins over Horilla's departments and reporting lines from the
    cut-over date on; what Horilla held before stays as it was, as the employment periods and reporting lines of the
    people carry it. Under the top-level key `organisation` (a misspelled key is refused) and with personnel numbers
    as the import gives them (badge ids, or `personnel-numbers.csv`):

    ```yaml
    organisation:
      validFrom: 2027-03-15
      departments:
        X-Men: { lead: H18, substitute: H4, members: [H4, H35, PEP#22] }
        Justice League: { lead: H8, members: [H15, H12] }
      withoutDepartment:
        H23: { manager: H2 }
      leadsReportTo: H2
      dropDepartments: [Design]
      planningTeams:
        FES Community Portal: { H23: 100, H10: 100 }
        X-Men: { H15: 50 }
    ```

    `validFrom` is optional: the day the file applies from, at most the cut-over date (a later day, or a value that
    is no date, stops the import with `mappingInvalid`). It lets you check the new structure in a rehearsal before
    the cut-over; what Horilla held before that day stays, and the cut-over date for openings and leave does not
    change. Leave it out for the real cut-over: then the file applies from the cut-over date. The day is reported once
    (`organisationValidFrom`). Where this text says cut-over date for the structure, it means this day when it is
    given. If you change it, the next run applies the structure from the new day.

    `departments` lists each department with its `lead` (who becomes its head and belongs to it), an optional
    `substitute` and its `members`. A member reports to the lead of the department, a lead to `leadsReportTo` (a
    lead who is that person keeps the manager Horilla has), and the department and manager of everybody apply from the
    cut-over date, or from the entry date of somebody who enters later. A department the company lacks is created. The
    substitute is a permanent substitute of the lead, without end date, for the approvals of the lead.
    `withoutDepartment` gives people without department a manager; the model needs a department for everybody, so they
    keep the one they have (`withoutDepartmentKept`). A department of `dropDepartments`, and one whose name Horilla
    spells differently from the file (`Justice Leage` for `Justice League`, reported with `departmentMisspelled`),
    is archived, not deleted, once nobody works in it any more; while somebody does, the row is an error
    (`departmentNotEmpty`). Somebody who left before the cut-over does not count; the employment of everybody who left
    in Horilla ends on the day they left. `planningTeams` lists the share in percent of each member per team, where
    the Planning package is installed; a team named like a department of the file also holds its lead and members with
    100 %, unless the team gives them another share. The team is created in the company of its members, with its members
    from the cut-over date. Without the Planning package every team is reported (`planningNotInstalled`) and nothing
    is written.

    The stage `organisation` runs after `reporting-lines`, and before `leave-requests`, so that the requests still
    waiting are submitted to the managers of the file. It reports a person nobody has (`unknownPersonnelNumber`) or
    several have (`ambiguousPersonnelNumber`), a person who would sit in two departments or in a department and in
    none (`personInTwoDepartments`), a person who leads two departments and is a member of neither
    (`leadOfTwoDepartmentsWithoutMembership`: add the person to the members of one of them),
    one who has left before the cut-over (`notEmployedAtCutover`), a manager who is
    not imported (`managerNotImported`) or of another company (`managerOfOtherCompany`), and a team member of
    another company than the team (`teamMemberOfOtherCompany`), each as an error of its row. Every change against
    Horilla is listed with the info `departmentCreated`, `departmentLeadChanged`, `departmentChanged` and
    `managerChanged` (the field names old and new), `substituteSet`, `departmentArchived` and
    `planningShareSet`. If the employment of a person already has a period that starts on the cut-over date, which
    cannot be changed, the change starts on the next day (`changeStartsAfterCutover`). A later change of Horilla does
    not take back what the file decided for a person. Every fresh import starts from Horilla again, so keep the file. A
    second run changes nothing, and a dry run writes nothing.

-   **`leave-balances-confirmed.csv`**

    `personnelNumber,leaveTypeId,days,seconds`: leave balances confirmed by HR; they replace Horilla's.

-   **`leave-requests-not-taken.csv`**

    `requestId`: the Horilla ids of undecided leave requests from before the cut-over that HR knows were not taken
    (see the leave requests below); they are imported as withdrawn and charge nothing.

-   **`working-time-opening.csv`**

    `personnelNumber,seconds`: the working-time account of every active employee at the cut-over date. Leave the file
    empty when `MIGRATION_WORKING_TIME_FROM` is before the cut-over date, because the account then comes from the
    imported punches; a value is refused with `historyAlreadyCounted`.

-   **`apprenticeship-settings.yaml`**

    Optional, where the Apprenticeship package is installed. Per Horilla company id `schoolDayCountsAsWholeDay`
    (`true` or `false`): whether a school day of an apprentice counts as a full working day, set on the company
    that `companies.yaml` maps it to before the punches, so that the first calculation of an imported day knows it.
    A company that is not mapped is skipped (`companyNotMapped`); without the file the stage says so with an info
    line (`noApprenticeshipSettingsFile`).

## Cut-over {#cut-over}

1.  Check the source:

    ```bash
    bin/console app:migration:horilla:preflight
    ```
1.  Rehearse with a dry run; it writes only its reports:

    ```bash
    bin/console app:migration:horilla:run-all --dry-run
    ```

    Every stage reports counts and one line per issue (source id, field, reason). Correct Horilla or the mapping
    files and repeat. A row the target refuses is reported as `targetRefused`; its field names the reason, the short
    name of the exception class or, for a failed validation, the property path and the message key. The exception is
    in the log as a warning.

    The dry run reports what the real run does: a company listed in `companies.yaml` stands for the adsum company
    named by its `target`, and a leave type with the action `existing` or `sickness` for the adsum type it
    names, also for the stages after them.
1.  The import handles the messages it causes (recalculated attendance days, account bookings, violations, lateness,
    leave effects) itself, inside the run, and puts none of them on a queue. The workers can keep running. When the
    database ends a batch in a deadlock with another process, the import tries it again; if the batch still fails, the
    stage ends as failed with the issue `targetLocked` and the database error, and a repeated run continues after
    the last committed batch. At the end of a run, and of `delta`, the closed weeks are evaluated for the rules over a
    period, such as the average working time; the first evaluation of a person announces nothing, and what a later one
    finds notifies nobody. `app:attendance:evaluate-periods` starts the same evaluation by hand.
1.  After every update of the code, clear the cache of the environment you import in; a kernel that is not in debug mode
    does not notice changed code and keeps running on the old container, which ends in errors such as a constructor
    with too few arguments:

    ```bash
    bin/console --no-debug cache:clear
    ```
1.  Import, with `APP_ENV=prod` or `--no-debug`. A kernel in debug mode remembers every query, which slows a long
    import down and makes the process grow by gigabytes; the commands warn when they find debug mode:

    ```bash
    bin/console --no-debug app:migration:horilla:run-all
    ```

    The run stops after a stage with errors unless `--continue` is given. Run a single stage with
    `app:migration:horilla:import <stage>`. Repeating a run continues where it stopped and imports nothing twice.

    The stage `profile-photos` runs after `employees` and sets the profile photo of Horilla
    (`employee_profile`, read from [MIGRATION_MEDIA_DIR](https://docs.typo3.org/permalink/web-vision/adsum-monorepo:confval-env-migration-media-dir@main)) as the photo of the
    employee, with the checks of an upload: a JPEG (also `.jfif`), PNG or WebP image of at most 5 MB and 4096 pixels
    per side. A missing file (`profilePhotoMissing`) or one the checks refuse (`profilePhotoRefused`) is a warning;
    the employee keeps the photo they have. A photo that changed in Horilla replaces the imported one on the next run
    or the delta import. A photo takes precedence over Gravatar.

    Horilla keeps a job role below its job position, so two roles of different positions may share a name; adsum
    keeps names unique per company. A role whose name (trimmed, upper and lower case alike) an adsum role of the
    company already has is mapped onto that role and reported with the warning `jobRoleMerged`; the employees who
    use it get that role.

    Horilla stores fractions of a second, adsum records one punch of an action per second and employee. Of two
    clock-ins of an employee within the same second, and likewise of two clock-outs, only the first is imported (by
    the fraction of a second, then by the lower activity id); the later one is skipped and reported with the warning
    `duplicatePunchMerged`, whose field names the activity of the first. A clock-in and a clock-out in the same
    second are different actions and both stay.
    If the activities of such a double click have clock-outs, the first clock-in pairs with the earliest of them and the
    other clock-outs are skipped with the same warning, whose field names the activity whose clock-out was kept.
    An activity of the double click without clock-out takes part like the others, also when later activities follow it.

    An activity whose clock-out lies before its clock-in is handled like an activity without clock-out, but reported
    with the warning `outNotAfterIn`; it needs no acceptance.

    An activity that lasts longer than 16 hours, or whose clock-out lies after the next clock-in of the person, is a
    clock-out Horilla closed much later. It is imported with the clock-out set so that the day ends at its planned
    working time: the clock-in plus the working time planned for that day less what the earlier activities of that day
    add up to (as they are imported), at least the clock-in itself when the day has reached its time (on a day without
    planned time the end of the day), at most one second before the next clock-in, and reported with the warning
    `clockOutCut`, whose field is the clock-out of Horilla. The cut never crosses midnight: it is at most the last
    second of the clock-in's day in the time zone of the person. A day without planned time (a weekly day off, a
    holiday) gets no invented time: the clock-out is the last second of that day and the activity is reported with the
    warning `clockOutCutNoTarget` instead, for HR to correct. Activities that overlap are cut the same way and are no
    longer refused. The punches after such an activity are imported as usual. An activity whose clock-out lies on a
    later day than its clock-in and at most ten minutes before the next clock-in of the person is a clock-out that
    Horilla closed when the person clocked in again. It is cut like the others, whatever its length, and gets the reason
    `closedByNextClockIn` in the notice, on the attendance day and in the list of the cut days; on a day without
    planned time the reason stays `noTargetEndOfDay`. An activity within one day, or with a real gap before the next
    clock-in such as a night shift, is imported as it is. On a day an absence reduces, the planned time is the target
    that is left after the absence: a day of vacation or sickness is cut at the clock-in, a half day at the clock-in
    plus half the target less the earlier work. For that the stage `punches` runs after `leave-requests`. Only a day
    whose scheduled target is zero keeps the end of the day. An activity belongs to the day it starts on, so activities
    that are each plausible can add up to more than a day: the clock-out of the activity that would take the day above
    24 hours is cut where the day reaches 24 hours (`clockOutCut`). The activity that takes a day above 16 hours gets
    the warning `longDay`, whose field is the date, for HR to check the day. The import records what follows from the
    imported days (violations of the working time rules, lateness, missing punches, balances below zero), but none of it
    sends a notification or an e-mail. The notifications of the cut days below are the only ones. The cut-over date is
    also the history boundary of the company: whatever path a later recalculation takes, nobody is notified about a day
    before it, while the facts stay recorded. Each person with a cut day gets one in-app notification per day, naming
    the day and the time the clock-out was set to, so that they can check it and correct it after the go-live. Unlike
    the records of the import, these notifications are sent; they are the only messages of an import that wait on the
    queue for the workers.

    An approved leave request for which adsum counts no days, because it lies on days off, on holidays or before the
    working-time model starts, or because the model has no day schedule, is imported all the same: it keeps its Horilla
    dates and status, takes nothing from the leave account and is reported with the warning `zeroQuantityImported`.
    A request that is only requested and counts no days stays refused (`requestRefused`). The file
    `weekly-contract.csv` sets the weekly contract time only, never the days of the week; a shift of Horilla without
    day schedule therefore gives no working days.

    A request that was never decided in Horilla and ends before the cut-over counts as taken, because nobody decides it
    any more and the person was away. It is imported as approved by the import (the request shows that it was taken over
    undecided) and charged against the carry-over first, then against the rest of the balance, whichever Horilla leave
    type it was filed under. What the balance does not cover is booked all the same, so the balance goes below zero,
    and the request is reported with the warning `undecidedOverdrawn` for HR to resolve; nothing is raised
    automatically. Every other such request is reported as `undecidedTakenOver`. A request still undecided after the
    cut-over stays pending. HR checks the list of these requests (see the go-live check) before the final import and
    enters each request that was not taken into `leave-requests-not-taken.csv`; it is then imported as withdrawn
    (`undecidedNotTaken`) and charges nothing.

    Horilla lets people book the free half of a half-day holiday, usually the afternoon of 24 and 31 December. adsum
    would count such a half day as nothing and leave the working half absent. The import therefore moves a half-day
    request of a single day that lies on the free half of a half-day holiday of the person to the working half, when
    the person tracked no time in Horilla on that day (no activity, no attendance record with worked time): it charges
    0.5 days and completes the day, and the report lists it with the info `halfDayMovedToWorkingHalf`. With tracked
    time the request stays as it is. Only the import does this; the request form of adsum is unchanged.

    Horilla applies an attendance request to its day record only, never to the activities, so the punches alone would
    lose every correction. The stage `attendance-corrections` imports them on top of the punches. An approved request
    becomes an approved correction of its day with origin `migration`: the corrected clock-in and clock-out replace
    the first clock-in and the last clock-out of the day (see below), the replaced punches stay in the history, and a
    day without punches gets the pair. The approver of Horilla is named as the decider when that person was imported;
    otherwise nobody is named. Each one is reported with the warning `correctionApplied`, whose field is the Horilla
    attendance id. A request that is still waiting becomes an open correction that the approvers of adsum decide; it
    stays quiet until the migrated approvals are released (see below). It meets the punches of its day like an approved
    one, with the worked time that was requested, so that the approver sees that worked time in the preview and
    approving gives it. A request without any requested data is skipped as `noRequestedData`. A request without usable
    times is reported with `correctionDataInvalid`, also a waiting one without clock-out, since a correction needs
    both. An approved request whose clock-in and clock-out equal those of the day's activities to the minute is skipped
    as `correctionMatchesPunches`, provided its worked time is missing or equals, within a minute, what the punches
    give; with another worked time it is a correction like any other, and the rules below for the worked time apply. A
    validated day record, or an approved request without requested data, whose clock-out equals to the minute the
    clock-out Horilla recorded for an activity the import cut that day only mirrors the forgotten clock-out: it is not
    imported, the information `recordMirrorsCutClockOut` names it, and the cut stays in the list of the cut days for
    HR. A record with another clock-out is a correction as before. The reason of the correction is the description of
    the person, as written. That the correction was taken over is its origin `migration`, which the approvals and the
    lists of corrections show as "Imported from Horilla" in the language of the reader. The delta import brings requests
    decided or made in Horilla later; an open correction that Horilla has decided meanwhile is withdrawn.

    An approved request changes only what it changed in Horilla: the first clock-in and the last clock-out of the day.
    The punches between stay, so the breaks of the day still count as breaks; a clock-in or clock-out that equals the
    corrected one to the minute is not replaced either. The day is listed with the information
    `correctionKeptPunches`. Where the corrected times do not fit the punches (a clock-in after the end of the first
    activity, overlapping activities), the corrected pair replaces all punches of the day, listed as
    `correctionReplacedPunches`. If the worked time of the request (`attendance_worked_hour`) is lower by a minute
    or more than the day that results, for example because of a punch of one second, the difference becomes one break in
    the longest work interval and the day ends at the worked time of Horilla (information `correctionBreakAdded`,
    warning `correctionBreakNotPlaceable` when the difference does not fit that interval). A worked time that is
    missing, zero or unreadable leaves the day as it is and is reported with `attendanceWorkedHoursMissing`. The
    approved worked time is the worked time of the day: where the punches that stay give less than it by more than a
    minute, for example because a punch is missing that the request repaired, the corrected clock-in and clock-out
    replace all punches of the day, with one break of the difference in the middle of the span (information
    `correctionReplacedPunches`). A worked time that is higher even than the corrected pair keeps the whole span of
    the pair and is reported with `attendanceWorkedHoursExceedSpan`; the field of both is `attendance_worked_hour`.
    An approved request without requested data on a day with an activity over midnight, which the import cut, is a
    correction as well, and so is a validated attendance record without requested data whose day has activities, whether
    it belongs to an update request or has a request flag, and whatever became of the request, since a validated record
    counts as confirmed: the clock-in, clock-out and worked time of its attendance record are the correction, under the
    same rules. A worked time above 24 hours, or above the span of the pair by more than the span, is not used: the day
    stays as it is, without a break, and is reported with `attendanceWorkedHoursImplausible`. If the attendance record
    of an approved request says another clock-in or clock-out, the record moved on after the approval, and its final
    values are the correction instead of the requested data (information `correctionUsesFinalRecord`); a worked time
    that differs alone does not count. The next run replaces the days that an earlier import took over as one interval
    from the first clock-in to the last clock-out.

    The import builds the days from the attendance activities only, but Horilla keeps a day a second time as an
    attendance record, and some records have no activity at all: HR entered or edited them by hand. The stage
    `attendance-without-punches` imports such a record with worked time as the clock-in and clock-out of its day, as a
    correction with origin `migration` and a reason that names the previous system. A record that Horilla did not
    validate becomes an approved correction too; its reason says that the previous system did not confirm it. Each is
    listed with the information `attendanceWithoutPunches`, whose field is `attendance_date`. A clock-out that makes
    the day longer than 16 hours is cut like that of a punch (`clockOutCut`). A record before the entry date of the
    person is reported with `attendanceBeforeEntry` and not imported, one without clock-in or clock-out with
    `attendanceTimesMissing` or `outNotAfterIn`. A validated record whose day has activities with other times and
    that is not such a correction is not applied, but reported with `attendanceDiffersFromPunches`, whose field holds
    the times of the record and of the punches, so that HR decides. A record with a request, and a validated record of
    an update request, belongs to `attendance-corrections`.

    A person often entered such a day by hand with the break already taken off, so Horilla's worked time
    (`attendance_worked_hour`, also written without the leading zero as `9:45`) is lower than the span from
    clock-in to clock-out. The imported day gets Horilla's worked time: the difference becomes one break in the middle
    of the span, starting on a whole minute. A worked time that is missing or zero leaves the span as it is and is
    reported with `attendanceWorkedHoursMissing`, one that is longer than the span with
    `attendanceWorkedHoursExceedSpan`; the field of both is `attendance_worked_hour`. Days that an earlier import
    took over as the whole span are corrected by the next run.

    An employee who is their own reporting manager in Horilla, as the top person usually is, is imported without a
    manager and reported with the warning `selfManagerDropped`; their requests then go to HR. Employees who report to
    each other, directly or over several steps, stay an error (`reportingCycle`) and are imported without manager.
1.  During the parallel run, import what changed in Horilla, as often as needed:

    ```bash
    bin/console --no-debug app:migration:horilla:delta
    ```

    The delta import handles its messages itself as well. `--full-scan` compares every row. A punch that a correction
    replaced stays replaced: the delta does not create it again, and reports the row as skipped with
    `punchVoidedByCorrection`. When a run ends, the
    balances and the leave days on the attendance days are final; no worker has to catch up first.
1.  Reconcile and let HR sign off:

    ```bash
    bin/console app:migration:horilla:reconcile
    bin/console app:migration:horilla:signoff --by=hr@example.com --employee=<id> --note="..."
    ```

    Besides the rows per month, the report has a row `workedDay` for every day whose worked time differs from the
    worked hours Horilla validated for it (`attendance_worked_hour`), classified like its month; a correction that
    did not come over shows up here with its day.
    `--only-classification=<defect>` signs off every employee whose differences all have that classification.
    Accept an issue that cannot be fixed with `app:migration:horilla:accept-issue <issue id> --note="..."`.
    An accepted error no longer stops the stages that need the stage it came from, and the next run of that stage keeps
    the acceptance, with its note, for the same row, field and reason, shown as `(accepted)`. If the row changed in
    Horilla in the meantime, or the reason or field differs, the issue is open again.
1.  After the last working day in Horilla, freeze the import (with a last delta):

    ```bash
    bin/console app:migration:horilla:freeze --confirm
    bin/console app:migration:horilla:reconcile
    ```
1.  Check the cut-over; the command fails until every check passes:

    ```bash
    bin/console app:migration:horilla:go-live-check
    ```

    `openAttendanceCorrections` is information and never fails: it lists the Horilla ids of the attendance requests
    that were imported as open corrections and that nobody has decided in adsum yet. They wait for the approvers of
    adsum, who can decide them after the go-live; until the invitations are sent a request whose approver has no account
    waits for HR as the fallback.

    `undecidedLeaveRequests` is information too: one line per undecided request from before the cut-over that the
    import took over as taken, with the Horilla id, the personnel number, the period, the days and the word
    `overdrawn` when the balance did not cover it. A request that counts no days, because it lies on days off, shows
    `0 d, no working days in the period`.

    `unvalidatedAttendance` is information too: one line per day that the import took from an attendance record
    without punches that Horilla had not validated, with the personnel number, the day, the times and
    `nicht bestätigt im Altsystem / not confirmed in the previous system`, so that HR can check these days. A record
    that Horilla validates later leaves the list.

    `unbookedHalfHolidays` is information too: one line (personnel number and day) for each day of a half-day holiday,
    such as the afternoon of 24 and 31 December, on which an employed person booked nothing and tracked no time. These
    days stay as the import found them, with the working half of the day missing its hours, so that HR can check them.

    `clockOutCutDays` is information as well: it lists, per employee, the days on which the import cut a clock-out;
    `clockOutCutNoTargetDays` lists those of them on a day without planned time, which HR has to correct. A
    person without a user account is told of these days once the person gets one. The notice opens the attendance day,
    which shows the clock-out of Horilla next to the cut time. `app:migration:horilla:cut-clock-outs` lists these days
    for HR with the clock-out of Horilla, the cut time, the reason and the kind: the days that may be real long days
    come first, then the clock-outs most likely forgotten (the original lies within an hour of the first clock-in or
    planned start of the next day with work, or more than two days after the clock-in), each with the path of its
    attendance day. The column `Correction` shows `open` for a day with a request of Horilla that waits, `invalid`
    for a day whose request of Horilla the import refused (`correctionDataInvalid`; `clockOutCutDays` names the
    refused request with the day, and HR decides what the real end was), and `replaced` for a day on which an approved
    correction took the place of the cut; these come last and are not listed in `clockOutCutDays`.
1.  Go live: invite the employees and release pending requests to their approvers:

    ```bash
    bin/console app:migration:horilla:invite-users --language=de
    bin/console app:migration:horilla:release-approvals
    ```

    An active employee with an inactive Horilla user gets an account block (stage `account-blocks`, reason
    "Other", note "Imported from Horilla"), effective as soon as the invitation creates the account. HR lifts it in
    adsum. Archived employees get no block.

## Data of installed packages {#data-of-installed-packages}

Installed packages add their own stages to `run-all`.

### Assets {#assets}

With `web-vision/adsum-assets` installed:

-   **`asset-categories` and `asset-batches`**

    Go into their Horilla company, with the name as English and German text. With several companies: the first
    (`inSeveralCompanies`); with none: the only company, otherwise reported (`withoutCompany`). Categories have
    no custodians; HR gets their notifications until custodians are assigned.

-   **`assets`**

    Every asset becomes one unit; the tracking id becomes its serial number, and it gets a number of the company's
    scheme. `Not-Available` becomes "out of service". A batch of another company is dropped
    (`batchOfOtherCompany`). Expiry notices are sent only for dates after the import.

-   **`asset-allocations`**

    Every assignment becomes an allocation, without notifications. Returns keep their day, condition (as notes)
    and status; a requested return stays requested. Of two open assignments of one unit, the older ends when the
    newer began (`duplicateOpenAllocation`). Later returns in Horilla are taken over on the next run.
    Photos are copied from [MIGRATION_MEDIA_DIR](https://docs.typo3.org/permalink/web-vision/adsum-monorepo:confval-env-migration-media-dir@main); a missing file
    (`photoMissing`) or one that is not a JPEG, PNG or PDF of at most 10 MB (`photoRefused`) is reported and
    left out.

-   **`asset-requests`**

    Waiting requests get their approvers from the current rules and reach them with `release-approvals`. Approved
    requests become fulfilled without an allocation; rejected ones stay rejected. Later decisions in Horilla are
    taken over on the next run.

-   **`asset-reports`**

    Reports come with their date and documents, copied like the photos (`documentMissing`,
    `documentRefused`, `documentsNotCopied`). They belong to no allocation; a report without title gets its
    date as title.

-   **`asset-fines`**

    Horilla's payroll loans of type `fine` with an asset, also without the payroll package. A fine is charged to
    the employee's allocation of the asset that began by the fine's day (`allocationNotFound` if none), regardless
    of the company's fine setting. Payroll is not notified.

### Directory login {#directory-login}

With `web-vision/adsum-ldap` installed:

-   **`identity-providers`**

    Horilla's LDAP settings become a disabled `ldap` sign-in provider "LDAP (Horilla)" in every imported company,
    with server, bind DN and base DN, but without the bind password. An admin enters the password, tests the
    connection and enables the provider. A plain `ldap://` server is set to StartTLS. Later runs do not change the
    provider.

## Switching the import off {#switching-the-import-off}

1.  After the retention period, delete the files:

    ```bash
    bin/console app:migration:horilla:prune-reports
    ```

    Runs, issues, reconciliation lines and sign-offs stay in the database.
1.  Remove `MIGRATION_HORILLA_DSN` from `.env.local` and drop the read-only role in Horilla.
1.  Remove the package; its tables stay:

    ```bash
    composer remove web-vision/adsum-migration
    ```
