Skip to content

After-calculation scripts ​

Some results need more than one calculation: holiday accruals, holiday pay and pay statistics such as the average hourly pay. Salaxy calculates them with the Finnish rules by default. When a customer has its own rules, you can replace a calculation with a script. For the big picture, see Custom payroll logic.

Beta

In production, scripts run only for customers that Salaxy has turned the feature on for. See Custom payroll logic.

These scripts are not in calc.bleConfigs. Each one is stored in its own place in the company settings, next to the rule it replaces.

MethodWhat it returnsWhere the script is storedWhen Salaxy uses it
getAccruals(calculation, calculations, holidayYear, ctx, sxy)The holiday accruals of a calculation, by monthholiday.holidayAccrualSettings[].scriptThe holiday year's holiday code is script.
getHolidayPay(calculations, holidayYear, ctx, sxy)The holiday pay of a holiday yearholiday.holidayPaySettings[].scriptThe holiday pay calculation is scriptPay.
getPayStatsResult(calculations, ctx, sxy)Pay statistics, such as the average hourly paypayStats.types[].scriptThe pay statistics type's kind is script. Only for employments that are paid by the hour.
  • calculations are the calculations of the same employment and period.
  • holidayYear is the employment's holiday year.
  • ctx holds the employment and the company settings.
  • Return undefined to make no change.

Which setting applies ​

Like the calculation scripts, each setting can be limited to a collective agreement (cbaCode) and an employee group (employeeGroup). Holiday settings can also be limited to holiday years (startYear, endYear). A setting with disabled: true is skipped.

Example ​

Pay statistics feed the price helpers: sxy.prices.averageHourlyPay() in a row type script reads the average hourly pay that the pay statistics store in the employment.

js
class AverageHourlyPay {
  getPayStatsResult(calculations, ctx, sxy) {
    // Read the hours and the pay from the rows of the calculations,
    // and return the result object of the pay statistics type.
  }
}

Each script is the source code of one class. Salaxy finds the class with the method it needs, so you do not write metadata for these scripts.

Every page is also available as Markdown: add .md to its URL — a folder page such as white-label/ is white-label/index.md. Index for LLMs: llms.txt. Questions: Support.