# Explain payroll variances

You have read access to your payroll software, a team chat and a
table you can read and write. Run this for **[the pay month you are
about to validate, e.g. 2026-11]** on **[one dossier, or every
dossier your key reaches]**.

## 0. Set up (skip if you're already connected)

If you don't already have live tool access for this, connect it
first. This prompt is only as real as the tools behind it:

1. Get a Tulina account: book a demo at https://tulina.ai/book.
2. Add Tulina's MCP server to your assistant: https://mcp.tulina.ai/mcp
3. In Tulina, connect your own API keys for the tools this
   prompt uses: your payroll software and your team chat.

Once connected, your assistant has real tool access and the rest of
this prompt runs as written.

## 0b. Already on Tulina? Three things around the run

An account and the MCP server are not the whole setup. Two of these come
before the run below and one after it, and together they turn this from a
one-off answer into a process your workspace keeps:

1. **Activate this process's connectors first.** Call
   `oto_connector(op="list")`, match it against the tools named in step 3
   above, and `oto_connector(op="select", name="...")` every one that
   isn't active yet. Selecting a connector does not mount its tools in the
   conversation you're already in — reach them through `oto_call` for this
   run, or open a fresh conversation once they're all on.
2. **Attach the work to an existing project.** `oto_project(op="list")`
   shows your active org's projects: pick the one this work belongs to
   rather than opening another, and keep its id. The project is where this
   process, the tables it writes to and the connectors it uses hang
   together.
3. **When the run is done, save it as a process — with its graph.** Write
   the body with `oto_procedure(op="set", ...)`, then attach it with
   `oto_project(op="link", project_id=..., target_type="procedure",
   target_ref="<your slug>")`. The body has to carry a drawing: read
   `oto_guide(op="read", slug="procedure-flowchart")` and follow it
   exactly — ONE untagged fenced block in that grammar, opening with the
   trigger and a quoted example of what you'd type to start a run. Tulina
   parses that drawing back into the graph it renders as the process's
   default view, which is what makes it come out in the same style as
   every other process in the app; a drawing the grammar can't read falls
   back to raw characters instead. Saving a process needs org-admin
   rights — without them, hand the finished body to someone who has them.

## 1. List the dossiers and the open month

- List the dossiers your key reaches (`silae_dossier`, op `list`). A
  dossier you expected and do not see may simply sit outside the API
  access configuration behind your subscription key: report it, do not
  guess.
- For each dossier in scope, read its open pay period (op
  `current_period`). Review the month you were given; if it differs from
  the open period, say so in the report rather than silently switching.
- Pay months are written `AAAA-MM`. The comparison month is the one
  before, **[the month under review minus one]**.
- Every call targets one dossier. With several Silae accounts stored
  (one per firm or per client), target each with `_account="<name>"`
  and walk them yourself: no tool loops over accounts on its own.
- Do not run between 1am and 5am: Silae refreshes its platforms then.
- On a portfolio of many dossiers, run the reads of steps 2 and 3 as a
  script or recipe and keep the model for step 4. Reading every payslip
  one call at a time through the model costs far more than the review is
  worth.

## 2. Compare headcount with last month

- List the employees active in the month under review (`silae_employee`,
  `periode="[month]"`), then those active in the comparison month. Key
  both lists on the matricule.
- In both lists, not in the previous one: an **entry**. In the previous
  one only: an **exit**. Both explain a variance on the dossier total,
  and an entry or exit inside the month usually explains a partial
  payslip on its own.
- For every employee present in the month, read their jobs (op `jobs`)
  to get each `identifiant_emploi`. An intermittent can hold several jobs
  in a month, and each job has its own payslips.

## 3. Compare each payslip with last month

- A payslip is addressed by matricule + `identifiant_emploi` + month +
  `indice_periode`. List the payslips of each job for both months
  (`silae_payslip`, op `indices`). An index above 0 is a supplementary
  payslip (a profit-sharing or a correction, for example): it is a
  variance in itself, flag it.
- Read the header of each payslip for both months (op `header`): gross,
  net, taxable net, deduction totals and hours.
- Flag the payslip when **[your variance threshold, e.g. 5 % or €150 on
  gross or net]** is crossed, or when hours changed.
- For a flagged payslip only, read its lines for both months (op
  `lines`, `line_filters` with `exclure_lignes_neutres` set, and `zone`
  `pay` then `contributions`). Match lines on their code, then list the
  lines that appeared, vanished or changed amount, and on contribution
  lines any change of rate or base. Keep the DUCS code beside each.
- A line present this month and absent last month: read the same month
  a year earlier before calling it new. An annual bonus explains itself
  there.

## 4. Give each variance a probable cause

For every flagged payslip, write one probable cause from what steps 2
and 3 actually show, and nothing else:

- **Entry or exit** in the month (partial period).
- **Hours**: the header's hours moved, overtime or reduced time.
- **Absence**: an absence line appeared on the pay zone.
- **One-off element**: a bonus or allowance line present this month
  only, or recurring at this time of year.
- **Regularisation**: a line correcting an earlier period.
- **Rate or base change** on a contribution line, the same for every
  employee of the dossier (a rate update) or for one only.
- **Supplementary payslip** (index above 0).

A variance with no cause the data supports is marked **to confirm with
the payroll manager**, with the lines that moved. Never call a variance
an error: a correct payslip can move a lot, and deciding is the payroll
manager's job.

## 5. Log every variance against its payslip

- One batch write to **[your payroll review table]**, keyed on dossier
  + matricule + `identifiant_emploi` + month + `indice_periode`, so a
  re-run merges onto the same rows. Columns: the gross and net of both
  months, the variance, the lines that moved, the probable cause or
  *to confirm*, and an empty decision column for the reviewer.
- Identify employees by matricule only. Names, social security numbers
  and addresses stay in the payroll software.

## 6. Post the monthly summary

Post one message to **[your payroll channel]**: dossiers reviewed,
payslips compared, variances flagged, how many have a probable cause,
how many are to confirm, and the dossiers with the most to confirm.
**Counts and dossier names only**: never an employee's name, social
security number or pay in the channel.

## 7. Review and validate the month

The payroll manager opens the table, starts with the rows to confirm,
fills in the decision column and validates the month in the payroll
software. Nothing in this process changes a payslip.

## Rules

- Read-only on the payroll side: never enter a variable element,
  a bonus or hours, never validate a payslip.
- No personal data in the chat or in the summary.
- A probable cause is never presented as a finding of error.

## Output

A short report: the month reviewed, dossiers and payslips compared,
entries and exits, variances flagged, explained and to confirm,
supplementary payslips, any dossier missing from the key's reach, and
the link to the review table.
