I intent to simulate my taxes, e.g. calculate what taxes I own when the next bill comes.
I could just use some online calculator like from comparis. However my “dream solution” would be a complete re-engineering of the tax calculation (in my case canton/city of Zurich), so I can implement it as (python) script on my bookkeeping.
Has anyone build something like this that i could use/ get inspired from?
My ideas & challanges are
obtain taxation rates (solved: for ZH available as pdf here). bonus: find a machine readable source that updates in case the numbers change
find out about all the individual calculation steps by reverse engineering my last tax declaration and some common sense
gross income & deductions
DA-1 calculation. I felt some shenanegans going on here last time. I honestly did not understand the calculation they put down to estimate my tax credit (which end much less than what I paid in the end)
wealth tax calculation (should be easy)
what is this personalsteuer of CHF 24???
for a given tax declaration, calculate the derivative of the taxes owed w.r.t. certain parameters
bonus question: has anyone had good experience with a Steuerberater in Zurich? I might be interested to get some consultation. mostly for education purpose.
I have made a Python script to systematically calculate financial advantages or disadvantages if I move to another town and/or canton.
Taxation rates can be downloaded as CSV files from the federal tax office, see the link below. The script imports them. Then I’ve made an XML file with all my personal parameters, which is read and processed. The script then produces a CSV with, among other things, the expected taxes for all towns in the new canton. It also calculates how more or less expensive the rent should be to keep costs flat.
I can give it to you, if you want.
If you use it I would appreciate if you shared with me what you make of it. Also, I am not a professional developer, so I don’t know how properly pythonic my code is. And of course, there might be bugs in there, although I checked some numbers against official tax office calculators and they seemed right.
I simply take the tax software for the current year and update the number.
Do not forget that you have to take into account many parameters other than tax rates. Depending on your situation (travel deductions, social deductions, health deductions, etc.) this could vary a lot.
that would be utmost simple logic to include, however i am not that far yet
i could imagine writing a beancount plugin that lets you whitelist accounts that are tax-deductable, and also maximum amounts etc…
thanks so much for this code snippet, i only look at it now.
may I ask where you got the infromation that this api exists, and its details? is there a swagger page? i could not find any.
in the data points, there is the " municipality" that you set to 261, which I’d guess stands for the city of zurich. where can I find this information, and the numbers for other municipalities?
also for the other enum values, where can I find info on what allowed values exist?
aha so you simply reverse engineered their page - alright, what is the worst answer i could expect
so when I have questions then threre won’t be a user manual, but just hacking this online calculator. thanks anyway for pointing out
I ended up copying & hardcoding the ESTV data into a Jupyter notebook, mostly because I use the code to calculate multiple years and it iterates many times through some parts. Accessing it online every time is too slow, and I’m too lazy / unskilled to make it collect data once only and then use a cached version… Plus, for multiple years ahead, it kind of needs the logic of when different deductions kick in or stop (e.g. children deduction, no professional expenses post fire).
But I have to say, it’s quite some spaghetti code and updates are getting increasingly painful! Getting it through the API is quite neat.