Relieving the Monotony of Payroll Deductions through Automation

We receive up to $6,600 per year from the PEI Department of Education, under the School-age Autism funding program, to help cover the cost of a “community aide” for Oliver. And because of the way the program is structured, we’re expected to treat the people we hire as full-fledged employees as far as Canada Revenue is concerned. This means that every week I need to calculate their salary based on the number of hours they’ve worked, and then use the government’s Payroll Deductions Online Calculator to calculate the amount of Canada Pension Plan, Employment Insurance premiums, and federal and provincial income tax to deduct from that and remit.

The monotonous thing about this is that the inputs to this process are three things–salary, vacation pay, and date–and the outputs are four things–federal tax, provincial tax, CPP and EI. But because the government’s calculator has to work for commissioned salespeople, and clergy members, and people paid bi-weekly, and people paying union dues, every week I’m forced to wade through myriad options to put those three inputs in and get those four inputs out.

Fortunately, though, the calculator is a web application, and a relatively simple old-school one at that, meaning that it’s easy to automate.

So I hacked together a crude PHP application to do exactly that.

As a result, I can now, from the command line on my Mac, do this:

# php ./pdoc.php -d 2017-02-03 -i 180 -v 7.20
    [federalTax] => 0.00
    [provincialTax] => 2.39
    [CPP] => 5.94
    [EI] => 3.05

I pass the calculation date (2017-02-03), the income ($180) and the vacation pay ($7.20) to the script as options, and it automates the process of walking through the website, passing parameters as required to each step and then scraping the values out of the final confirmation page’s HTML.

The code isn’t pretty (or documented), but it will, I think, be useful to others who want to automate this same process.

The bureaucratic requirement to do this, by the way, is something that many families receiving this funding find onerous to the point of not applying for it; I’m currently trying to identify resources that would allow families to be relieved of this burden while, at the same time, still meeting their remittance obligations. If you have any ideas, please let me know.


Peter Rukavina's picture
Peter Rukavina on June 14, 2018 - 16:41 Permalink

I’ve updated the PHP code that scrapes payroll calculations from the CRA PDOC site to handle the updated version of their web app, as of July 1, 2018.