
Py1040 – A U.S. personal income tax calculator - danso
https://github.com/b-k/py1040
======
b__k
Hi, I'm the project author.

I started writing this to do my own taxes, which are very complicated---the
project covers forms 1040, 6251, part of 8582, 1040 schedules A & E, and
several worksheets because I actually have to file all of those. [Well, I
don't have to file f6251, but I can't prove that without going through it.]

But since starting I'm thinking more and more about the value of a public
reference version of the tax code. I discuss this more here:
[https://bureauphile.wordpress.com/2016/03/19/managing-
comple...](https://bureauphile.wordpress.com/2016/03/19/managing-complexity-
encoding-the-tax-code) .

Thanks to this thread I've learned about a few other implementations of the
code, and I'll have to check them out. But I should note that the XML
documents from the IRS are not one of them. They do a good deal of error
checking, but you can't use them to solve for the bottom line. It's the lack
of a reference implementation of the tax code from the IRS that has led me and
evidently several others to roll our own.

Given a reference implementation, there are a lot of things one could do: a
what-if calculator for consumers or businesses, a policy analysis tool using
IRS SOI (statistics of income) data, still more infographics beyond the one at
[https://b-k.github.io/1040.js](https://b-k.github.io/1040.js) , tools for in-
person tax prep for all the tax clinics that pop up this time of year. In a
perfect and ideal world, IRS would pick up on all this potential utility and
would start providing a reference implementation themselves.

------
danso
Count me as one of the people who needs to pay for software to do taxes every
year...it's only something I do once a year, so not frequently enough that
personal automation would be worthwhile (even as a weekend
project)...and...the tax code to me is probably like what software
installation is to the people who pay fees to Geek Squad :p

But this from the author sounds promising:

> _By re-presenting the tax calculation as a tree, we have the ability to
> trace back what led to any surprises on the tax form, aggregate multiple
> users, and otherwise process the information in a manner that would be
> difficult or incoherent using only the form view. If your financial
> situation gives you the freedom to act on what-if scenarios, or if you are a
> tax researcher considering the situations of diverse taxpayers, the
> structures here are hopefully more amenable to your needs._

I mean, I guess that's the normal pattern of software innovation...take
something very specific, abstract it a bit, and now you have something that
opens new ways of thinking and exploring. I wasn't aware that there was XML
metadata that could be interpreted...though in retrospect...obviously there
would have to be for tax software to stay up to date, though I pictured in my
head that Turbotax and its peers just bring in hundreds of data entry persons
to pore over reams of tax code paper documents to fix up the app every year.

------
ryanprichard
If you haven't seen it, I'd also recommend looking at the excel1040[1]
spreadsheet. It's been developed for about 20 years by a single author,
AFAICT. It has numerous forms, schedules, and worksheets, and it makes
aggressive use of formulas and locked cells to ensure that calculations are
correct. The spreadsheets closely resemble the actual forms, though I don't
think people are actually mailing them in as-is.

[1]
[https://sites.google.com/site/excel1040/](https://sites.google.com/site/excel1040/)

~~~
skynetv2
PSA: i tried this out and its very basic. so basic that it doesnt even cover
dcap deductions.

------
djsumdog
Very interesting. Also interesting to see there is an official XML for such
things (which this project didn't use :-P).

When I lived in Australia, I liked that there was only one piece of tax
software. It's didn't look the prettiest, but the usability wasn't too bad and
it was officially developed by the Australian Government. You didn't have to
pay someone for tax software and it made filing very easy.

In New Zealand, taxes are automatic. You typically don't have to file and
refunds are requested via their website.

~~~
kungtotte
It's automatic here in Sweden too. They send out a document basically saying
"this is what we know about your finances and this is the resulting tax
effect" and if everything checks out then you just digitally sign it and
you're good to go.

And if you have any modifications you need to do, you can do those digitally
as well. No mess, easy-peasy.

~~~
zackelan
Similar systems have been proposed in the US as well. [0] Disappointingly but
unsurprisingly, Intuit (the makers of TurboTax, the most popular tax prep
software in the US) spent millions of dollars lobbying the federal government
to oppose return-free filing. [1]

0:
[http://www.nytimes.com/2015/04/16/technology/personaltech/tu...](http://www.nytimes.com/2015/04/16/technology/personaltech/turbotax-
or-irs-as-tax-preparer-intuit-has-a-favorite.html)

1: [http://techcrunch.com/2013/03/27/turbotax-maker-funnels-
mill...](http://techcrunch.com/2013/03/27/turbotax-maker-funnels-millions-to-
lobby-against-easier-tax-returns/)

~~~
basseq
The other opponent—surprisingly—are taxpayer advocacy groups. Automatic
returns are tied closely to data integrity. The IRS doesn't have a full
picture until all Information Returns (IRs: e.g., W-2s, 1040s, 1099s) are
submitted by employers, banks, etc., which may not happen until March in some
cases. This means that the IRS can't automatically process your return until
March/April.

Not a problem, you say? Well, consider this: tax returns in the U.S. are
closely tied to tax _refunds_ , which for many Americans, is the largest check
they receive all year. So by "fixing" this process, you're affecting real
dollars to real Americans, and disproportionately lower-income Americans. It's
a political nightmare.

Of course, the "refund" process also indicates a broken system: taxpayers are
loaning the U.S. government billions of dollars a year, tax free. And an
automatic return system would massively reduce fraud (both evasion and refund
fraud)... so...

------
sigil
Nice! I've been doing my own taxes for almost 20 years now. A few years back I
wrote a little Python program like this one, and it's made the whole process
much less onerous. Each year there are some tweaks to the tax code [1], and
some differences in my situation, but mostly things stay the same from year to
year.

My question is: why isn't there already a good opensource 1040 calculator?
Does a liability disclaimer like Py1040's not cut it? Is it the extreme
unsexiness of taxes?

[1] Unfortunately this does involve scanning through the relevant forms and
instructions for changes over the prior year -- my kingdom for a diff...

~~~
chrisseaton
I don't know why anyone bothers with tax software, let alone writing their
own. Why not just use an accountant?

I send all my documents to a local accountant and he sorts it all out once a
year for the equivalent of about a quarter of day's wages, and about an hour
of my time to sort the documents.

~~~
jedberg
Because I do a better job than the accountant.

They usually bill a fixed rate, and even if they do an hourly rate, they try
to do them quickly to get through more of them. They don't spend the hours I
do playing "what if". Sometimes certain deductions can apply in different
places for very different outcomes.

An example: You manage a property for a friend. You collect the rent and then
send it over to them minus a small fee for yourself. You can claim this one of
two ways: You can file a schedule C or a schedule E. Each has a very different
effect on your final total depending on the rest of your tax situation and the
other forms you have filed.

For example, the schedule E increases your AGI, even though you can deduct all
the rent you paid back to your friend. The schedule C does not, because only
the total counts against your AGI, not all revenue.

So now when you go to deduct your medical expenses, the 7.5% minimum is quite
different.

That's just one example of how the what-if plays into it, but only a very
expensive accountant will spend the time doing those things and/or have enough
experience to know how to do it right the first time.

That being said, I'll probably do a bake off this year again to see if the
accountant can do better than I with TurboTax.

~~~
sigil
> They don't spend the hours I do playing "what if". Sometimes certain
> deductions can apply in different places for very different outcomes.

Good point. Now you've got me thinking about what a simple optimizer could do
given the small search space of legal inputs. Why does TurboTax even require
you to play "what if"?

------
schoen
It's a nice contribution to have non-proprietary tax software, even when its
functionality is so basic.

Is Javascript in PDF sophisticated and general enough that something like this
could be ported to run inside the form itself? Like having the form itself
have a way to ask you the questions and then complete itself with the answers?

~~~
tekromancr
Haha, No. I am not even responding to the technical side. I am sure it is
_possible_ to do such a thing. Unfortunately, there are a lot of forces (one
in particular actually) at work lobbying against anything that would make it
easier to do taxes. [http://techcrunch.com/2013/03/27/turbotax-maker-funnels-
mill...](http://techcrunch.com/2013/03/27/turbotax-maker-funnels-millions-to-
lobby-against-easier-tax-returns/)

~~~
jandrese
Virginia used to have a super easy online form you could use to fill out
taxes. H&R Block bought out one of our down state representatives and had her
kill it off. It still makes me angry every year around tax time.

There is absolutely no reason the IRS couldn't run their own online tax filing
system that gets prepopulated with all of the information companies and banks
report to the IRS except that it would drive thousands of otherwise useless
middlemen out of business. There would still be accountants of course, but
only for people who have actual complicated tax returns.

------
etep
In my hazy recollection turbotax once upon a time made it easy to see their
own DAG, essentially an outline style index into their various interview
questions. Now such navigation is obscured, ostensibly for "user friendliness"
I'm sure. sigh.

------
yodsanklai
I lived in the US for a couple of years. I was very surprised that virtually
everybody told me that I needed help from a professional accountant (esp.
considering my situation was quite simple). Is it the culture or is it really
that hard?

Anyway, after a little bit of research, I think I did it correctly with no
particular problem. It was just a matter of finding the appropriate forms and
reading the documentation.

~~~
Pitarou
In many cases, it really is that hard.

------
analog31
I like the idea, and wonder how this would play as a Jupyter notebook.

------
awinter-py
I've wanted this forever!!!

That said -- when this guy is rooming with martha & bernie, intuit will send
him fruit baskets to make sure the other inmates give him a warm welcome.

When can we expect py_double_irish?

------
lintiness
i commend the effort, but us tax code is insanely complex, and i doubt a
weekend's work can make sense of it.

~~~
superuser2
Most people live in a single state, work a single job, don't itemize
deductions, and maybe have a 401k. For them the tax code is actually very
simple.

It's when you have relationships with multiple states and countries,
businesses, complex investments, and sophisticated tax minimization strategies
(taking advantage of all the deductions you can find, etc) that things get
unwieldy.

~~~
jandrese
A weekenders work can cover probably 80% of the population. This is the bread
and butter of places like H&R Block and Turbotax.

There's not really much they can do to find deductions, they're little more
than middlemen the law requires if you want to e-File.

~~~
willholloway
You can e-file for free yourself. There are digital versions of forms like the
1040, schedule c etc...

~~~
jandrese
IIRC you can only e-file for free if you can use a 1040ez, which has some
pretty severe limitations. For instance, you can't use it if you're claiming
the very common mortgage interest deduction.

~~~
bzbarsky
[https://www.freefilefillableforms.com/](https://www.freefilefillableforms.com/)
lets you e-file for free with much less stringent limitations: you have to
stick to the forms listed at
[https://www.freefilefillableforms.com/#/fd/forms.availabilit...](https://www.freefilefillableforms.com/#/fd/forms.availability)

One caveat is that it will not do as much automatic propagation of numbers as
it _could_, so you end up having to do some manual work that could be
automated away. But it will certainly let you e-file.

The second caveat is that this is basically a private organization funded by a
consortium of tax-preparation companies, which means that (1) you have to
trust them with your tax data (unlike the under-$62k thing that's run directly
by the IRS as far as I can tell) and (2) there is zero incentive for this
thing to become as good as the for-pay tax preparation software (hence the
stupid things that could be automated but aren't).

