Do your US Income Taxes with Python

Macrobius

Megaphoron
If you haven't got around to it, this is very quick. You need to know python programming and have access to a Linux box or Virtual Machine. I used a Chromebook with the Linux beta running and the miniconda3 python distribution, but I'm sure there are lots of ways to skin this cat. You will need the `m4` macro processor (`sudo apt-get install m4`). It wants python3 and so that must be installed.

In a clean directory or wherever you put scratch projects... two projects side by side with:

git clone https://github.com/b-k/py1040
git clone https://github.com/b-k/1040.js

The instructions for running the python are simple... keep doing make which uses m4 macros to pull the data tables from the javascript project into the python project.

Here is the text output from a hypothetical married couple with one child and 93k family income, 7k taxes withheld, and some Traditional IRA contributions.

Code:
python3 taxes.py
>>>>>>>>>> Form 1040 <<<<<<<<<
   1 |                  Wages, salaries, tips, from form W-2 | 98000
2.5 |                                      Taxable interest | 0
3.4 | Dividends qualifying for the long-term cap gains rate | 0
3.5 |                                         all dividends | 0
4.5 |                             Taxable IRA distributions | 0
5.5 |                         Taxable pension distributions | 0
   7 |                         Capital gains from Schedule D | 0
   9 |                                          Total income | 98000
10.25 |             Charitable contributions if not itemizing | 0
10.5 |    Charitable contributions if not itemizing, limited | 0
  11 |                                 Adjusted gross income | 92000
  12 |                                            Deductions | 25100
  12 |                                   Standard deductions | 25100
  13 |     20% discount on qualified business income (f8995) | 0
  15 |                                        Taxable income | 66900
16.1 |                                                   Tax | 7633
16.3 |                                  Sched 2, AMT + F8962 | 0
16.4 |                            Tax + Sched 2, AMT + F8962 | 7633
  18 |                                         Tax plus Sch2 | 7633
  19 |                     CTC and Schedule 3, other credits | 2000
  22 |                                     Tax minus credits | 5633
  23 |                    Other taxes, incl. self-employment | 0
  24 |                                             Total tax | 5633
  25 |   Federal income tax withheld from Forms W-2 and 1099 | 7000
  27 |                            Earned income credit (EIC) | 0
  28 |                           Refundable child tax credit | 0
  31 |                         Other asst credits from Sch 3 | 0
  33 |                                        Total payments | 7000
  34 |                                                Refund | 1367
  37 |                                              Tax owed | 0

>>>>>>>>>> Schedule 1 <<<<<<<<<
   1 |                                        Taxable state refunds | 0
2.1 |                                      alimony income received | 0
   3 |                                   Schedule C business income | 0
   4 |                            Sale of business property (f4797) | 0
   5 |                          Rents and royalties from Schedule E | 0
   6 |                                  Farm income from Schedule F | 0
   7 |                                    Unemployment compensation | 0
   8 |                        other income (see Sch 1 for the list) | 0
   9 |                      Schedule 1 subtotal w/o Rents/Royalties | 0
  13 |                             Health Savings Account deduction | 0
  20 |                                                IRA deduction | 6000
22.9 | >>>>>>>>>>>> Subtractions                                    | 0
  25 |               All other adjustments anywhere on Sch2 part II | 0
  26 |                                 Sum of adjustments to income | 6000
26.1 |                          Adjustments excluding student loans | 6000

>>>>>>>>>> Schedule 2 <<<<<<<<<
   1 |                              Alternative minimum tax | 0
   2 | Cv('f1040sch2_amt')+Cv('f1040sch2_credit_repayment') | 0
   2 |          Excess advance premium tax credit repayment | 0

>>>>>>>>>> Schedule 3 <<<<<<<<<
   1 |                         Foreign tax credit | 0
   2 |                    Dependent care expenses | 0
6.4 | Elderly or disabled credit from Schedule R | 0
   8 |                Total nonrefundable credits | 0

>>>>>>>>>> Schedule 8812, Child Tax Credit <<<<<<<<<
   3 |                                               CTC not used | 0
   4 |                                             $1,400 per kid | 1400
   5 |                                         Limited unused CTC | 0
   8 |                           15 percent of earned income-2500 | 14325
  11 | Social security and medicare withheld on W-2 lines 4 and 6 | 0
  15 |                                Refundable child tax credit | 0

>>>>>>>>>> CTC worksheet <<<<<<<<<
   1 |                        $2,000 per child under 17 | 2000
   5 | 5% of AGI minus a filing-status dependent number | 0
   6 |           $2,000 per child minus the subtraction | 2000
   9 |                Calculated tax minus some credits | 7633
  10 |                                 Child tax credit | 2000

I might have filled out the questionnaire wrong. It's a glorified calculator but nice work from the contributors. It makes a great baseline for troubleshooting the finer points, and even pointing to the forms that are requisite. I'm also planning to use it to do scenarios involving investments, inflation, and their tax consequences -- using lame-ass assumptions like '2021 taxes remain in force for 10 years'. But if I need to modify the code, it's all there for tweaking. The ability to do quick but accurate tax computations is better than SWGA ... Standard Wild Goose Ass calculations

If you don't like python, the graphical (javascript) version: https://b-k.github.io/1040.js/ (just shows the structure of the calc, and doesn't compute anything I think)

Anyway, nice simple calculator to check your pencil and paper work -- or your accountant's maths.
 
Last edited:
Top