# Initial problem: High tax on consultants in Sweden

As with many other startups it all started with having a problem myself.

Back in 2017 I was lucky enough to get a great consulting opportunity because of a massive layoff. Being a consultant involves sending monthly invoices, so I created a small company (AB: aktiebolag) here in Sweden. I hired an accountant and started working hard. Revenue began to arrive at a steady rate.

As in most other countries the revenue of my company does not translate directly to net income. After a few emails with my accountant I had to realize how complex the Swedish tax rules are and how seriously they impact the net income I can achieve from my business.

It turned out that my biggest cost is the tax by far. Consultants have to pay both the income tax as an employee and the payroll tax as an employer. There is no family taxation, income tax is calculated individually. Dividend rules are complex and there is profit tax on all revenue not spent by the end of the financial year.

It turned out accountants have the software for the "forward" tax calculation, but cannot tell how to wisely choose the numbers we still have control over. Widespread practice is to just set an arbitrary salary and accept the tax hit later.

"Only Skatteverket knows the final tax to pay."

(Skatteverket is the tax office in Sweden.)

I did not accept this situation, since I would like to control my situation as much as possible, while still staying within the legal limits. I looked around for software solving my problem.

For income tax there are online calculators available, but my case was more complex with the small business involved. I needed a tax forecasting tool covering both the business and the personal income taxes with all the complex dividend rules considered.

What does a software developer do in such a situation?

Yes, your guess is right. I ended up implementing the whole tax calculation in a Python script. The first version was more of a hack giving a rough estimate, but still better than nothing.

I put the whole "forward" calculation into a few embedded loops to search the problem space for the global optimum of highest net income while keeping the total cost constant. This optimum is the same as paying the least on taxes, the two definitions are equivalent. Also plotted the results to visualize the solution space. Here we go, finally some usable results.

To my positive surprise I could save a significant amount this way. All I had to do is choosing the right salaries for me and my wife, then paying out the rest of the revenue according to the dividend rules after the financial year is closed.

It worked well for me in 2018, but what other consultants can do? Running my Python script? Not too straightforward solution.

This is how the idea of OptiTax, an online business income forecasting tool was born.

Today's Top Milestones