Forecasting Payroll Cash Flows

Overview


Forecasting payroll typically involves a set of date calculations. Different companies will have different rules for when to pay out salaries. In the examples below, we assume that salary is paid out twice a month, on the 15th and on the last day of the month. If a pay day occurs on a weekend, the pay day is moved back to the first weekday prior to the given pay day.

The calculations are done using the calendar library and the payroll library

Payroll


Create a set of date ranges. Each range represents a two week period


let cd = await import('/lib/calendar/v1.0.0/calendar.mjs');

let ranges = cd.biMonthlyRanges('2020-01', '2021-12');
					


For each employee, we calculate the payments for each date range using the forecast method of the payroll library . This code assumes that the pay date for each date range falls on the first weekday before or at the end date of the range.


let py = await import('/lib/calendar/v1.0.0/payroll.mjs');

let employees = [
  {id:'1',name:'jim', start:'2020-01-01', salary:10000},
  {id:'2',name:'jill', start:'2018-01-01', end:'2024-07-15', salary:6000}
];

let payments = py.forecast(ranges, employees, -1);
					
Try it!


Topics


Contents