Common expressions
Description

Using Report Designer you can add expressions to reports and other documents to calculate values.

Let's take a look at some of the most commonly used expressions on Sage 50 Payroll reports.

Cause
Resolution

Common expressions

To add the processing month and year to the subject line of an email payslip

CompanyDetails.Name + " payslip for " + DateTimeToFormattedString (DateParameters.ProcessDate, "MMMM/yy")

To calculate the total value of all non-statutory payment or deduction types

Payments

CurrentPay.PreTaxPay + CurrentPay.PstTaxPay

Deductions

CurrentPay.PreTaxDed + CurrentPay.PstTaxDed

To show the age of an employee

Age in years and months

CString((TotalMonths(Employees.DateOfBirth, Now()) - ((DateTimeToFormattedString(NOW(), "dd"))<(DateTimeToFormattedString(Employees.DateOfBirth, "dd"))?2:1)) / 12) + " yrs, " + CString((TotalMonths(Employees.DateOfBirth, Now()) - ((DateTimeToFormattedString(NOW(), "dd"))<(DateTimeToFormattedString(Employees.DateOfBirth, "dd"))?2:1)) % 12) + " mths"

Age in years

(DateParameters.ProcessDate - Employees.DateOfBirth) / 365.25

Age in months

(DateParameters.ProcessDate - Employees.DateOfBirth) / 30.4375

If you want to ensure the age rounds down to the previous year rather than up, you can also use the following expression:

Age in years

Floor((DateParameters.ProcessDate - Employees.DateOfBirth) / 365.25)

To show an employee's length of service in years and months

Service in years and months

CString((TotalMonths(Employees.WorkStartDate, Now()) - ((DateTimeToFormattedString(NOW(), "dd"))<(DateTimeToFormattedString(Employees.WorkStartDate, "dd"))?2:1)) / 12) + " yrs, " + CString((TotalMonths(Employees.WorkStartDate, Now()) - ((DateTimeToFormattedString(NOW(), "dd"))<(DateTimeToFormattedString(Employees.WorkStartDate, "dd"))?2:1)) % 12) + " mths"

Service in years

CInt(TotalWholeMonths(Employees.WorkStartDate, DateParameters.ProcessDate)) / CInt(12)

Service in months

CInt(TotalWholeMonths(Employees.WorkStartDate, DateParameters.ProcessDate)) % 12

To show an employee's total holiday entitlement

Holidays calculated in days

Employees.HolDaysBF + Employees.HolDaysCF + Employees.EmployeeEntitlement

Holidays calculated in hours

Employees.HolHoursBF + Employees.HolHoursCF + Employees.EmployeeEntitlement

To show the holidays remaining for an employee


Holidays calculated in days

(Employees.HolDaysBF + Employees.HolDaysCF + Employees.EmployeeEntitlement) - (Employees.HolDaysTaken + Employees.HolDaysBookedThisPayPeriod)

Holidays calculated in hours

(Employees.HolHoursBF + Employees.HolHoursCF + Employees.EmployeeEntitlement) - (Employees.HolHoursTaken + Employees.HolHoursBookedThisPayPeriod)

To show an employee's projected yearly salary based on their current monthly payment type

First, you need to know the number assigned to the payment type in your custom report setting. You can check this within Company > Custom Reports.

You can then create the following expression, replacing Total1 with the required total for your payment type:

PaymentAnalysis.Total1 * 12

To show an employee's total holiday entitlement including any holidays brought forward from a previous year

Holidays calculated in days

Employees.HolDaysBF + Employees.EmployeeEntitlement

Holidays calculated in hours

Employees.HolHoursBF + Employees.EmployeeEntitlement

To show an employees' holiday fund values accrued and carried forward

To show an accrued fund

CurrentPay.HolidayFundAccrued + CurrentPay.HolidayFundAccruedHol

To show a fund carried forward to the next pay period

Employees.HolidayFund + CurrentPay.HolidayFundAccrued + CurrentPay.HolidayFundAccruedHol - CurrentPay.HolidayFundPaid - CurrentPay.HolidayFundPaidHol

To show an employee's title, forename and surname with spaces

Employees.Title + " " + Employees.Forename + " " + Employees.Surname

To show an employee's first forename, excluding any second forename

Substring(Employees.Forename,0,IndexOf(Employees.Forename," ")) + " "

You can use this within a larger expression, for example: "Dear " + Substring(Employees.Forename,0,IndexOf(Employees.Forename," ")) + ","

To include employer's pension contributions on a payslip layout

Current values

CurrentPay.EmployerPensCur + CurrentPay.EmployerPensHol

YTD values including the current period

Employees.PensnEmployerTD + CurrentPay.EmployerPensCur + CurrentPay.EmployerPensHol

[BCB:19:UK - Sales message :ECB]
Steps to duplicate
Related Solutions