-
-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
credits for child tax & other dependents tax calculation of the year 2021 #2700
Comments
@bodiyang Thanks for digging into this. Can you provide an example of a case where Tax-Calculator fails to give the correct child tax credit amount? |
Are we talking about the latest source code I sent to Martin? Is the
error present there?
Can you send a sample taxpayer that is incorrect? I will compare to TaxAct
and fix Taxsim.
Thanks for your help with this.
Dan
…On Fri, 20 Oct 2023, Bodi Yang wrote:
I've noticed an issue in Tax-Calculator's child tax credit calculation for the year 2021. (from the validation work with taxsim35 ~ many records are showing differences in child tax credit between Tax-Calc and Taxsim)
Currently, Tax-Calculator's child tax credit calculation follows the [IRS Publication 972 in 2018](chrome-extension://efaidnbmnnnibpcajpcglclefindmkaj/https://www.irs.gov/pub/irs-prior/p972--2018.pdf), as in [calcfunctions.py](https://github.com/PSLmodels/Tax-Calculator/blob/master/taxcalc/calcfunctions.py#L2401). The years before 2020 all follows IRS Publication 972.
Since 2021, child tax credit has been changed to follow [IRS Sch 8812 in 2021](chrome-extension://efaidnbmnnnibpcajpcglclefindmkaj/https://www.irs.gov/pub/irs-prior/f1040s8--2021.pdf). The tax logic is also changed for the year 2021, while to be noticed only for the year 2021. Year 2022's child tax credit still follows IRS Sch 8812, but the tax logic is the same as the years before 2020 which are under Publication 972, as can be seen in [IRS Sch 8812 in 2022](chrome-extension://efaidnbmnnnibpcajpcglclefindmkaj/https://www.irs.gov/pub/irs-pdf/f1040s8.pdf)
As a result, the child tax credit calculation is correct for all the years except 2021. Tax logic has to be rewritten for the year 2021, following [2021 IRS Sch 8812](chrome-extension://efaidnbmnnnibpcajpcglclefindmkaj/https://www.irs.gov/pub/irs-prior/f1040s8--2021.pdf)
--
Reply to this email directly or view it on GitHub:
#2700
You are receiving this because you are subscribed to this thread.
Message ID: ***@***.***>
|
Of course Jason and Daniel, I'll gather some sample records with different characters and attach the comparison of calculations from Tax-calculator, Taxsim and IRS Tax Forms (issues noticed so far: not including the child age at 18 (taxcalc); a rounding rule to the next $1,000 (probably in taxsim); ... ) Bodi |
One record will probably suffice.
Dan
…On Sat, 21 Oct 2023, Bodi Yang wrote:
Of course Jason and Daniel, I'll gather some sample records with different characters and attach the comparison of calculations from Tax-calculator, Taxsim and IRS Tax Forms
(issues noticed so far: not including the child age at 18 (taxcalc & taxsim); rounding to the next $1,000 (taxsim); ... )
--
Reply to this email directly or view it on GitHub:
#2700 (comment)
You are receiving this because you commented.
Message ID: ***@***.***>
|
case record: taxsimid 58 year 2021. state 0. mstat 1 page 62 sage 0 depx 4 dep13 4 dep17 4 dep18 4 pwages 177,000 swages 0 non_refundable_child_odep_credit is $8,775 from taxsim; $8,000 from tax-calculator I've tried to manually calculated the child tax credit and credit for other dependents, the result is $8,750 from Sch 8812 of the year 2021; $8,000 from Publication 972 in 2018 ~ my thought:
|
Can you send along your calculation? That is, the filled in form 8812?
Thanks.
I am working on this now.
Dan
…On Mon, 23 Oct 2023, Bodi Yang wrote:
case record:
taxsimid 18 year 2021. state 0. mstat 1 page 51 sage 0 depx 5 dep13 1 dep17 1 dep18 3 pwages 8000 swages 0
non_refundable_child_odep_credit is $5,000 from taxsim; $4,000 from tax-calculator
I've tried to manually calculated the child tax credit and credit for other dependents,
the results are
- $9,800 from Sch 8812 of the year 2021;
- $800 from Publication 972 in 2018 ~ note on this: the child tax & other dependents credit is non-refundable, so it is capped by the iitax. if there is no cap, the result would be $4,000. $800 = min (iitax = $800, child tax & other dependdents credit = $4,000)
Based on this calculation, **Tax-Calculator follows the 2018 Publication 972** instead of the 2021 tax form, while I didn't check how taxsim get thte $5,000
--
Reply to this email directly or view it on GitHub:
#2700 (comment)
You are receiving this because you commented.
Message ID: ***@***.***>
|
@bodiyang, I see that Tax-Calculator gives a CTC amount of $8775 for this filer (the same at TAXSIM-35), if you add together It may be good to add these together in |
In any case, the point about the rounding may still be an issue. I'll let you and Dan settle that, but will be following the discussion. |
@feenberg this is the calculation by tax form of the case record, with the result $8,750 taxsim looks like not considering the $1,000 rounding rule in line 5 worksheet Bodi |
Is this webpage perhaps relevant to the 2021 taxpayer?
https://www.irs.gov/pub/irs-pdf/p972.pdf
I have attached the worksheet for Line 5 of Form 8812 as prepared by
TaxAct, which seems to agree with the Taxsim calculation. If I have
entered the wrong data, or you disagree with the calculation, can you send
me your version of the 8812 worksheet? It will help a lot for me to
understand what the difference is.
I did add code to stop the smoothing which can be turned on by setting
opt1 to 88 and opt1v to 1. I use that option to turn off smoothing when it
causes difficulties, but I haven't gone through all the code looking for
places it could be used.
…On Mon, 23 Oct 2023, Bodi Yang wrote:
case record:
taxsimid 18 year 2021. state 0. mstat 1 page 51 sage 0 depx 5 dep13 1
dep17 1 dep18 3 pwages 8000 swages 0
non_refundable_child_odep_credit is $5,000 from taxsim; $4,000 from
tax-calculator
I've tried to manually calculated the child tax credit and credit for
other dependents, the results are - $9,800 from Sch 8812 of the year
2021; - $800 from Publication 972 in 2018 ~ note on this: the child tax
& other dependents credit is non-refundable, so it is capped by the
iitax. if there is no cap, the result would be $4,000. $800 = min
(iitax = $800, child tax & other dependdents credit = $4,000)
Based on this calculation, **Tax-Calculator follows the 2018 Publication
972** instead of the 2021 tax form, while I didn't check how taxsim get
thte $5,000
--
Reply to this email directly or view it on GitHub:
#2700 (comment)
You are receiving this because you commented.
Message ID: ***@***.***>
|
I woke up and realized that I didn't look at the rest of form 8812 - no
doubt there is more. I don't have TaxAct at home - I'll look again in the
morning.
Sorry for the over-confidence.
Dan
…On Mon, 23 Oct 2023, Daniel Feenberg wrote:
Is this webpage perhaps relevant to the 2021 taxpayer?
https://www.irs.gov/pub/irs-pdf/p972.pdf
I have attached the worksheet for Line 5 of Form 8812 as prepared by TaxAct,
which seems to agree with the Taxsim calculation. If I have entered the wrong
data, or you disagree with the calculation, can you send me your version of
the 8812 worksheet? It will help a lot for me to understand what the
difference is.
I did add code to stop the smoothing which can be turned on by setting opt1
to 88 and opt1v to 1. I use that option to turn off smoothing when it causes
difficulties, but I haven't gone through all the code looking for places it
could be used.
On Mon, 23 Oct 2023, Bodi Yang wrote:
> case record:
>
> taxsimid 18 year 2021. state 0. mstat 1 page 51 sage 0 depx 5 dep13 1 dep17
> 1 dep18 3 pwages 8000 swages 0
>
> non_refundable_child_odep_credit is $5,000 from taxsim; $4,000 from
> tax-calculator
>
>
> I've tried to manually calculated the child tax credit and credit for other
> dependents, the results are - $9,800 from Sch 8812 of the year 2021; - $800
> from Publication 972 in 2018 ~ note on this: the child tax & other
> dependents credit is non-refundable, so it is capped by the iitax. if there
> is no cap, the result would be $4,000. $800 = min (iitax = $800, child tax
> & other dependdents credit = $4,000)
>
> Based on this calculation, **Tax-Calculator follows the 2018 Publication
> 972** instead of the 2021 tax form, while I didn't check how taxsim get
> thte $5,000
>
> --
> Reply to this email directly or view it on GitHub:
> #2700 (comment)
> You are receiving this because you commented.
>
> Message ID: ***@***.***>
|
This record should be good. taxsimid 18 year 2021. state 0. mstat 1 page 51 sage 0 depx 5 dep13 1 dep17 1 dep18 3 pwages 8000 swages 0 non_refundable_child_odep_credit is $5,000 from taxsim Just had another check dep18 = 3 in taxsim actually represent the EITC qualifying child (under age 19), not the child under the age of 18. So dep18 = 3 should not be taken consideration into the child tax credit calculation. So for this record, the total number of child under the age of 18 is only 1 (dep 17 = 1). The child tax credit calculation should be $5,000 then. But the other example do have an issue, please refer to my comment above about the rounding rule. Another notice is to use 2021 form 8812 for the calculation, with instructions. I think the link you sent above is the IRS 2022 form 8812. The 2021 form and 2022 form are different. ~ tax logic of 2022 is same with all years before 2020; 2021 tax logic is an outlier Bodi |
It turns out the Form 8812 doesn't reduce the Line 5 amount below 8,750,
so I return to the thought that Taxsim was right. I have attached the
updated taxsim.f that allows the smoothing to be turned off. It doesn't
affect this result, but will affect others. It also has numerous
improvements to the state calculations.
Daniel Feenberg
On Tue, 24 Oct 2023, Bodi Yang wrote:
> Is this webpage perhaps relevant to the 2021 taxpayer? https://www.irs.gov/pub/irs-pdf/p972.pdf I have attached the worksheet for Line 5 of Form 8812 as prepared by TaxAct, which seems to agree with the Taxsim calculation. If I have entered the wrong data, or you disagree with the calculation, can you send me your version of the 8812 worksheet? It will help a lot for me to understand what the difference is. I did add code to stop the smoothing which can be turned on by setting opt1 to 88 and opt1v to 1. I use that option to turn off smoothing when it causes difficulties, but I haven't gone through all the code looking for places it could be used.
> [?](#)
> On Mon, 23 Oct 2023, Bodi Yang wrote: case record: taxsimid 18 year 2021. state 0. mstat 1 page 51 sage 0 depx 5 dep13 1 dep17 1 dep18 3 pwages 8000 swages 0 non_refundable_child_odep_credit is $5,000 from taxsim; $4,000 from tax-calculator I've tried to manually calculated the child tax credit and credit for other dependents, the results are - $9,800 from Sch 8812 of the year 2021; - $800 from Publication 972 in 2018 ~ note on this: the child tax & other dependents credit is non-refundable, so it is capped by the iitax. if there is no cap, the result would be $4,000. $800 = min (iitax = $800, child tax & other dependdents credit = $4,000) Based on this calculation, **Tax-Calculator follows the 2018 Publication 972** instead of the 2021 tax form, while I didn't check how taxsim get thte $5,000 -- Reply to this email directly or view it on GitHub: [#2700 (comment)](#2700 (comment)) You are receiving this becau!
se you commented. Message ID: ***@***.***>
A notice is to use [2021 form 8812](https://www.irs.gov/pub/irs-prior/f1040s8--2021.pdf) for the calculation, with [instructions](https://www.irs.gov/pub/irs-prior/i1040s8--2021.pdf). I think the link you sent above is the IRS 2022 form 8812. The 2021 form and 2022 form are different. ~ tax logic of 2022 is same with all years before 2020; 2021 tax logic is an outlier
--
Reply to this email directly or view it on GitHub:
#2700 (comment)
You are receiving this because you were mentioned.
Message ID: ***@***.***>
program taxsim
c common calc needs to be extended
compilation date compdate
implicit double precision(a-h,o-z)
parameter(nx=47)
dimension cccage(1960:2023),eicage(1960:2023),ctcage(1960:2023)
logical last,isexe,agevars,depvars
integer list(nx),nuse,isgn
character(len=1024) line
cftp character(len=64) arg
character(len=16) vars(2,nx),dnames(nx)
common/ssa/ficavars(31)
common/state/t(18)
common/calc/s(18)
common /psubr/ xndx,amtpi,almnpx,egtrra,almzbr,almst,enders,
&gjtrra,ratmul,cgmul,amtmul,tipra,wilhlc,extnd(0:100)
common/fsrates/ficar,frate,srate
common/comexe/isexe,agevars,depvars
common/nrecc/nrec
common/newshr/comnew(255)
common/comold/d(255)
common/dindiv/data(255)
common/xcom/x(nx)
data cccage/4*12.,8*13.,17*15.,35*13./
data eicage/15*100.,49*19./
data ctcage/38*0.,26*17./
data last/.false./
data vars/
& "taxsimid" ,"P", "year" ,"P", "state" ,"P","mstat" ,"P",
5 "page" ,"P", "sage" ,"P", "depx" ,"P","dep13" ,"P",
9 "dep17" ,"P", "dep18" ,"P", "pwages" ," ","swages" ," ",
3 "dividends","P", "intrec" ," ", "stcg" ," ","ltcg" ," ",
7 "otherprop"," ", "nonprop" ," ", "pensions","P","gssi" ,"P",
1 "ui" ,"P", "transfers","P", "rentpaid","P","proptax" ,"P",
5 "otheritem","P", "childcare","P", "mortgage","P","scorp" ," ",
9 "pbusinc" ," ", "pprofinc" ," ", "sbusinc" ," ","sprofinc"," ",
3 "idtl" ,"P", "mtr" ,"P", "pui" ,"P","sui" ,"P",
7 "dep6" ,"P", "dep19" ,"P", "opt1" ,"P","opt1v" ," ",
1 "opt2" ,"P", "opt2v" ," ", "age1" ,"P","age2" ,"P",
5 "age3" ,"P", "psemp" ," ", "ssemp" ," "/
cftp call getarg(1,arg)
cftp if(arg.ne.'') open(5,file=arg)
nrec = 0
if(isexe) then
do 1 i=0,100
extnd(i) = 0.
1 continue
do 2 i=1,255
d(i) =0.d0
data(i) = 0.d0
comnew(i) = 0.d0
2 continue
else
endif
data(3) = 1.d0
data(96) = -1.d0
mtr = 85
if(isexe) call begin(line,list,nuse,nx,vars,dnames)
100 continue
c If data is http web form, skip reading values
if(x(1).lt.0)then
write(*,*) 'Input line (131 chars):'
write(*,*) line(1:131)
write(*,*) 'Becomes:'
write(*,*) (i,' ',vars(1,i),"=",int(x(i)),i=1,nx)
endif
if(x(33).ne.5.and.isexe) then
read(5,'(a)',end=999,err=992) line
if(line.eq." ") goto 100
if(line(1:2).eq.'--') goto 999
if(line(1:3).eq.'eod') goto 999
read(line,*,end=998,err=993) (x(list(i)),i=1,nuse)
endif
data(255) = 1.
data(100) = x(1)
data(70) = 0.d0
data(101) = x(2)
lawyr = int(data(101))
data(103) = x(2)
data(3) = 1.d0
data(7) = 1.d0
data(8) = x(7)
data(105) = 0.
if(x(4).eq.1.or.x(4).eq.3) then
if(x(7).eq.0) then
data(2) = 1.d0
else
data(2) = 4.d0
endif
elseif(x(4).eq.2) then
data(2) = 2.d0
data(7) = 2.d0
elseif(x(4).eq.33) then
data(2) = 1.d0
elseif(x(4).eq.66.or.x(4).eq.6) then
data(2) = 6.d0
data(3) = 2.d0
elseif(x(4).eq.8) then
data(2) = 1.d0
data(7) = 0.d0
data(105) = 1.d0
elseif(x(4).eq.0) then
data(2) = 0.
elseif(x(4).eq.5) then
data(2) = 5.
else
write(*,*) 'Bad mstat',x(4),"x=",x
stop 4
endif
data(9) = 0.
if(x(5).ge.65) data(9) = 1.d0
if(x(6).ge.65) data(9) = data(9) + 1.d0
do ii=203,209
data(ii)=0.d0
enddo
data(205) = max(x(5),x(6))
data(206) = min(x(5),x(6))
data(17) = 0.d0
if(x(11).ge.0) then
data(85) = x(11)
else
data(17) = x(11)
data(85) = 0.d0
endif
if(x(12).ge.0) then
data(86) = x(12)
else
data(17) = data(17) + x(12)
data(86) = 0.d0
endif
data(11) = data(85) + data(86)
data(17) = x(46)+x(47)
data(216) = x(47)
data(12) = 0.d0
data(24) = 0.d0
data(200) = 1.d0
data(201) = 0.d0
if(data(11).ne.0) then
data(201)=data(86)/data(11)
data(200) = x(7)/data(11)
endif
data(12) = x(13) + .001d0
data(176) = data(12)
data(14) = x(14)
data(68) = x(15)
data(70) = x(16)
data(79) = x(17)
data(30) = -x(18)
data(20) = x(19)
data(91) = x(20)
data(180) = x(36)
data(82) = max(x(21),x(35)+x(36))
data(41) = x(22)
data(160) = x(23)
data(51) = x(24)
data(54) = x(25)
data(64) = x(26)
data(56) = x(27)
data(210) = x(37)
if(agevars) then
do 6 ii=43,45
data(200+ii)=x(ii)
if(x(ii).gt.0) then
if(x(ii).lt.6.d0) data(210)=data(210)+1.d0
if(x(ii).lt.cccage(lawyr)) data(207)=data(207)+1.d0
if(x(ii).lt.eicage(lawyr)) data(203)=data(203)+1.d0
if(x(ii).lt.ctcage(lawyr)) data(208)=data(208)+1.d0
if(x(ii).ge.eicage(lawyr)) data(209)=data(209)+1.d0
endif
6 continue
elseif(depvars) then
data(207) = x(8)
data(208) = x(9)
data(203) = x(10)
data(209) = data(8)-data(203)
else
data(207)=data(8)
data(203)=data(8)
data(208)=data(8)
endif
data(213) = x(28)
data(211) = x(29)
data(212) = x(30)
data(214) = x(31)
data(215) = x(32)
if(x(39).gt.0) extnd(int(x(39)))=x(40)
if(x(41).gt.0) extnd(int(x(41)))=x(42)
if(extnd(89).gt.0) then
data(6) = 0.d0
data(211) = x(3)
data(212) = x(23)
data(160) = 0.d0
data(79) = x(17) + data(211) + data(212)
endif
idtl = int(x(33))
if(idtl.ge.10) then
last=.true.
idtl=idtl-10
endif
if(x(34).ne.0) mtr = int(x(34))
data(159) = data(11) + data(12) + data(19) + data(20)
& + data(93) + data(82) + data(91) + data(41)
& + data(14) + data(211) + data(213) + data(214)
& + data(215)+ data(212)
& + data(79) + max(data(68)+data(70),0.d0)
call check(lawyr,idtl,mtr,x,nx,data,vars)
c FICA tax and rate
do 111 i=1,31
ficavars=0.
111 continue
call sstax(data,lawyr)
fica = comnew(75)
if(data(2).eq.0) fica = 0.d0
if(mtr.eq.85) then
ficar = comnew(148)
elseif(mtr.eq.86) then
ficar = comnew(149)
elseif(mtr.eq.11) then
ficar = comnew(150)
else
ficar = 0.
endif
ficar = ficar*100
c -1 is a special state code meaning do all states
if(x(3).eq.-1) then
is=1
if=51
elseif(x(3).eq.-3.d0) then
is=1
if=10
else
is=int(x(3))
if=is
endif
diff = .01d0
if(extnd(52).ne.0d0) diff=extnd(52)
datmtr = data(mtr)
data85 = data(85)
data86 = data(86)
dat159 = data(159)
data11 = data(11)
data(93) = 1.d0
do 11 istate=is,if
nrec=nrec+1
data(mtr) = datmtr
data(11) = data85 + data86
data(85) = data85
data(86) = data86
data(159) = dat159
data(6) = istate
call tcalc (data,lawyr)
if(data(100).lt.-2) then
write(90,900)(data(i),i=1,220),
& (comnew(i),i=1,220)
900 format(22(10f12.2/)///22(10f12.2/)///)
write(90,*)
&'hy rent agi exemp stded xitded taxinc pcred c
&hcr earncr credit rt'
write(90,'(a96)')
write(90,'(12f8.0)') s
write(90,'(27/)')
endif
do 8 i=1,255
d(i) = comnew(i)
8 continue
s(1) = dat159
do 9 i=1,18
t(i) = s(i)
9 continue
fold = comnew(1)
agiold = comnew(2)
tiold=comnew(29)
sold = comnew(74)
if(extnd(89).gt.0) sold=comnew(181)
frate = 0.
srate = 0.
do 10 isgn=1,-1,-2
if(mtr .ne.0) then
if(idtl.eq.5) then
fdiff = isgn*1.d0
else
fdiff = isgn*diff
endif
data(mtr) = datmtr + fdiff
if(mtr.lt.47.or.mtr.gt.63)data(159) = dat159 + fdiff
if(mtr.eq.11) then
if(data11.ne.0) then
data(85) = data85 + fdiff*(data85/data11)
data(86) = data86 + fdiff*(data86/data11)
else
data(85) = fdiff/2.d0
data(86) = fdiff/2.d0
endif
endif
data(11) = data(85) + data(86)
call tcalc(data,lawyr)
if(data(100).lt.-1) then
write(*,*) 'isgn=',isgn, 'data='
write(*,'(21(11f10.3/)//)') (data(i),i=1,210)
write(*,*) ' comnew='
write(*,'(21(11f10.3/)//)') (d(i),i=1,210)
write(*,'(6f11.3)') s
endif
tinew=comnew(29)
s(1) = data(159)
fnew = comnew(1)
snew = comnew(74)
frate =100.d0*(fnew - fold)/fdiff
srate =100.d0*(snew - sold)/fdiff
ftan = comnew(72)
if(abs(frate).lt.100.and.abs(srate).lt.25) goto 12
endif
10 continue
12 continue
srate = twn(srate,-99.d0,999.d0)
frate = twn(frate,-99.d0,999.d0)
if(isexe) call out
& (mtr,idtl,x,fold,sold,fica,frate,srate,ficar,data)
data(mtr) = datmtr
11 continue
if(idtl.eq.6) then
write(*,1000) (data(i),i=1,220),(comnew(i),i=1,220)
1000 format(22(10f9.0/)///22(10f9.2/)/)
endif
if(last) goto 999
if(idtl.eq.5) goto 999
goto 100
998 continue
if(nrec.gt.0) then
write(*,*)'TAXSIM:Insufficient values in record '
& ,nrec+1
if(i.ne.nuse)write(*,*)'TAXSIM: ',nuse,' items expected '
& ,'but',i,'were found. At or near record ',x(1)
write(*,*) 'TAXSIM:Last good read was record ',data(100),
& ' state ', data(6), ' for year ',data(101), 'nrec',nrec
write(*,*) (x(ii),ii=1,nuse)
endif
992 stop 992
993 write(*,*)'TAXSIM:Conversion error at record:',nrec+1
write(*,*)'TAXSIM:Record:','"',trim(line),'"'
stop 993
999 continue
if(nrec.eq.0) then
write(*,*) 'TAXSIM: No records read. Communication problem?'
endif
call stop
end
subroutine stop
logical isexe,agevars,depvars
common/comexe/isexe,agevars,depvars
if(isexe) then
stop
else
return
endif
end
subroutine check(lawyr,idtl,mtr,x,nx,data,vars)
implicit double precision(a-h,o-z)
dimension x(nx),data(255)
character(len=20) states(0:55)
common /psubr/ xndx,amtpi,almnpx,egtrra,almzbr,almst,enders,
&gjtrra,ratmul,cgmul,amtmul,tipra,wilhlc,extnd(0:100)
common/newshr/comnew(255)
character(len=8) mslab(8)
common/nrecc/nrec
common/cstates/states
character(len=16) vars(2,nx)
data mslab/'Single','Joint',' ','HoH',3*' ','Separate'/
if(idtl.eq.5) then
write(*,*) lawyr
write(*,*)'NBER TAXSIM Model v35 (compdate) With TCJA'
lawyr=-99
call statax(data,lawyr,comnew)
write(*,*)'State law coded through',lawyr
write(*,*)'Later state laws extrapolated from that year.'
iext1 = int(x(4))
if(mtr.eq.85) then
write(*,*) 'Marginal tax rate wrt taxpayer earnings.'
elseif(mtr.eq.17) then
write(*,*) 'Marginal tax rate wrt non-wage income.'
elseif(mtr.eq.86) then
write(*,*) 'Marginal tax rate wrt spouse earning.'
elseif(mtr.eq.70) then
write(*,*) 'Marginal rate wrt long-term gains.'
elseif(mtr.eq.56) then
write(*,*) 'Marginal rate wrt Mortgage Interest Paid.'
elseif(mtr.eq.56) then
write(*,*) 'Marginal rate wrt Other deductions.'
else
write(*,*) 'Marginal rate not requested.'
endif
endif
ierr=0
lawyr=int(data(101))
if(idtl.lt.0d0.or.idtl.gt.15.d0) then
write(*,*) 'TAXSIM: Debug Flag out of bounds : ',idtl
write(*,*) 'TAXSIM: (should not occur)'
ierr=1
endif
if((mtr.lt.11.or.mtr.gt.99).and.mtr.ne.0.d0) then
write(*,*) 'TAXSIM: Request for marginal rate on a code'
ierr=2
endif
if(int(abs(data(2))).ge.7.or.int(abs(data(2))).eq.5) then
write(*,*) 'TAXSIM: Bad value for mstat',data(2)
ierr=3
endif
if(lawyr.ge.1998) then
if(data(207).gt.data(208)) then
write(*,*) 'TAXSIM: More CCC elegible than CTC elegible'
& ,data(207),data(208),lawyr
ierr=5
endif
if(data(208).gt.data(203)) then
write(*,*) 'TAXSIM: More CTC elegible than EIC elegible'
& ,data(208),data(203)
ierr=6
endif
endif
if(data(203).gt.data(8)) then
write(*,*) 'TAXSIM: More EIC eligible than depx value ',
& int(data(203)),int(data(8))
ierr=7
endif
if(data(8).gt.15.or.data(208).gt.25) then
write(*,*) 'TAXSIM: More than 25 dependents:',data(8)
ierr=8
endif
do 100 ii=43,45
if(x(ii).lt.0..or.x(ii).gt.114) then
write(*,*) 'TAXSIM: Improbable dependent age: ',
& 'age',ii-42,'=',sngl(x(ii)),'not in 0-114.'
ierr=42
endif
100 continue
if(data(8).ne.int(data(8))) then
write(*,*) 'TAXSIM: depx must be an integer:',data(8)
ierr=9
endif
if(x(5).lt.0.or.x(5).gt.114) then
write(*,*) 'TAXSIM: Unbelievable primary age:',x(5)
ierr=10
endif
if(x(6).lt.0.or.x(6).gt.114) then
write(*,*) 'TAXSIM: Unbelievable spouse age:',x(6)
ierr=11
endif
if(x(3).ne.int(x(3))) then
write(*,*) 'TAXSIM: State code must be integer.',x(3)
ierr=13
endif
if(x(2).lt.1960d0.or.x(2).gt.2023d0) then
write(*,*) 'TAXSIM: Federal tax calculator available',
& ' 1960 - 2023 only.'
ierr=14
endif
if(x(2).ne.int(x(2))) then
write(*,*) 'TAXSIM: Tax law year must be integer.',x(2)
ierr=15
endif
if(data(6).ne.0.d0.and.
& (x(2).lt.1977)) then
write(*,*) 'TAXSIM: State tax calculator available 1977+ only'
ierr=16
endif
if(x(3).lt.-1.or.x(3).gt.51) then
write(*,*) 'TAXSIM: ',x(3),' is not a valid SOI state code'
write(*,*) 'TAXSIM: See http://taxsim.nber.org/statesoi.html'
ierr=18
endif
if(x(4).ne.2d0) then
if(x(11)*x(12).ne.0) then
c if(x(12)+abs(x(31))+abs(x(32))+x(36)+abs(x(47)).ne.0d0) then
write(*,*) 'TAXSIM: Secondary wage ',x(12)
write(*,*) 'TAXSIM: Secondary SE ' ,x(47)
write(*,*) 'TAXSIM: Secondary QBI,SSBI ',x(31),x(32)
write(*,*) 'TAXSIM: Secondary UI',x(36)
write(*,*) 'TAXSIM: Non-joint return with spousal income'
write(*,*) 'TAXSIM: Separate filers report only own income'
ierr=17
write(*,*) '11*12',x(11)*x(12),x(11),x(12)
endif
endif
if(x(4).ne.2.d0.and.x(6).gt.0d0) then
write(*,*) 'TAXSIM: Non-joint return with non-zero sage'
write(*,*) 'TAXSIM: Ages ',x(6)
ierr=19
endif
do 10 i=4,nx
if(x(i).lt.0.and.vars(2,i).eq."P") then
ierr=-1
goto 17
endif
10 continue
17 continue
if(ierr.eq.-1) then
c9 write(*,*) 'TAXSIM: Disallowed negative value:', x(i)
write(*,*) 'TAXSIM: Item in error :',i,vars(1,i),x(i)
endif
if(ierr.ne.0) then
c8 write(*,*) 'TAXSIM: Record ID :',x(1)
write(*,*) 'TAXSIM: Logical Record Number :',nrec
write(*,*) 'TAXSIM: Law Year :',x(2)
write(*,*) 'TAXSIM: State id :',x(3)
write(*,*) 'TAXSIM: Data record, as converted:',
& (int(x(ii)),ii=1,32)
write(*,*) 'TAXSIM: Abandoning processing :',ierr
write(*,*) 'TAXSIM: Taxsim35 version of : compdate'
endif
if(idtl.eq.5) then
write(*,*)
write(*,*) 'Input Data: '
write(*,3) ' 1. Record ID: ', x(1)
write(*,2) ' 2. Tax Year: ', x(2)
ii=int(x(3))
write(*,4) ' 3. State Code: ',
& x(3),states(max(0,ii))
ms = int(data(2))
1 format(a31,f11.2,1x,a8)
write(*,1) ' 4. Marital Status: ', x(4),mslab(ms)
write(*,2) ' 5-6. Age (Txpyr/Spouse): ', x(5),x(6)
write(*,2) ' 7. Dependent Exemptions: ', x(7)
write(*,2) ' Dependent Ages ',
& (sngl(data(i)),i=243,245)
write(*,2) ' 8-10. #deps for CCC/CTC/EIC: ', data(207),
& data(208),data(203)
write(*,2) '11-12. Wages (Txpyr/Spouse): ', x(11),x(12)
write(*,2) '11a12a Self-employment income:',x(46),x(47)
if(extnd(89).gt.0) write(*,*) 'Not including business income'
write(*,2) ' 13. Dividend Income: ', x(13)
write(*,2) ' 14. Interest Received: ', x(14)
write(*,2) ' 15. Short Term Gains: ', x(15)
write(*,2) ' 16. Long Term Gains: ', x(16)
write(*,2) ' 17. Other Property: ', x(17)
write(*,2) ' 18. Other Non-Property: ', x(18)
write(*,2) ' 19. Taxable Pensions: ', x(19)
write(*,2) ' 20. Gross Social Security: ', x(20)
write(*,2) ' 21. Tot/Txpy/Spouse UI : ', x(21),x(35),x(36)
write(*,2) ' 22. Non-taxable Transfers: ', x(22)
write(*,2) ' 23. Rent Paid: ', x(23)
write(*,2) ' 24. Property Taxes Paid: ', x(24)
write(*,2) ' 25. Other Itemized Deds: ', x(25)
write(*,2) ' 26. Child Care Expenses: ', x(26)
write(*,2) ' 27. Mortgage Interest: ', x(27)
write(*,2) ' 28. S-Corp profits: ', x(28)
write(*,2) '29 31. Txpy/Spouse QBI w/o PO:', x(29),x(31)
write(*,2) '30 32. Txpy/Spouse SSTB w PO:', x(30),x(32)
if(x(40).gt.0) write(*,2)
& ' 39/40. opt1/value: ',x(39),x(40)
if(x(42).gt.0) write(*,2)
& ' 41/42. opt2/value: ',x(41),x(42)
write(*,*) ' '
endif
if(ierr.ne.0) stop 1
return
2 format( a31,4f11.2 )
3 format( a31,2f13.0 )
4 format( a31,f13.0,a16)
end
subroutine tcalc(data,lawyr)
implicit double precision(a-h,o-z)
dimension data(255)
common /psubr/ xndx,amtpi,almnpx,egtrra,almzbr,almst,enders,
&gjtrra,ratmul,cgmul,amtmul,tipra,wilhlc,extnd(0:100)
common/newshr/comnew(255)
if(data(2).eq.0.) return
c Compulsory itemization
if(extnd(51).eq.0.or.extnd(51).eq.2) then
data(4) = -1
call tcalc2(data,lawyr)
taxitm = comnew(1) + comnew(74)
endif
c Compulsory standard deduction
if(extnd(51).eq.0.or.extnd(51).eq.1) then
data(4) = -2
call tcalc2(data,lawyr)
taxstd = comnew(1) + comnew(74)
endif
c If itemization is better, use it
if(extnd(51).eq.0.d0) then
if(taxitm.lt.taxstd) then
data(04) = -1
call tcalc2(data,lawyr)
else
data(50) = 0.
endif
endif
return
end
subroutine tcalc2(data,lawyr)
implicit double precision(a-h,o-z)
common/calc/st(18)
dimension data(255)
common/newshr/comnew(255)
common /psubr/ xndx,amtpi,almnpx,egtrra,almzbr,almst,enders,
&gjtrra,ratmul,cgmul,amtmul,tipra,wilhlc,extnd(0:100)
data(50)=0.
lawst = lawyr + int(extnd(79))
c100 format(17(10f8.2/)/18(10f8.2/)////)
iters=3
if(extnd(91).ne.0.d0) iters=int(extnd(91))
do 10 i=1,iters
if(data(100).lt.-1) write(*,*) "interation",i
call nlaw(data,lawyr)
comnew(74) = 0.
do 20 ii=1,18
st(ii) = 0.
20 continue
if(data(6).ne.0) then
call statax(data,lawst,comnew)
if(iters.gt.1) then
data(50)=max(saletx(data,lawst),comnew(74),0.d0)
endif
endif
if(data(100).le.-3) then
write(90,*) 'data and comnew after iter i=',i
write(90,1)(data(j),j=1,210),(comnew(j),j=1,180)
write(90,'(12f10.2)') st
endif
10 continue
c11 continue
do 112 i=1,31
ficavars=0.
112 continue
call sstax(data,lawyr)
if(data(100).le.-2)write(*,1)(data(i),i=1,210),(comnew(i),i=
& 1,180)
1 format(21(10f10.2/)///18(10f10.2/)///)
if(data(100).eq.-19)write(19,*)data
if(data(100).eq.-19)write(19,*)comnew
return
end
subroutine out(mtr,idtl,x,fold,sold,fica,frate,srate,ficar,data)
implicit double precision(a-h,o-z)
dimension data(255),x(27)
character(len=20) states(0:55)
character(len=30) x0,x1
character(len=1024) line
character(len=62) lab1
character(len=256) lab2
character(len=4) statenum(0:51)
character(len=8) lab3(16)
common/newshr/c(255)
common/calc/s(18)
common/state/t(18)
common/comold/d(255)
common/nrecc/nrec
common/cstates/states
common/cfica/tr(4,2),xoasdi,th(4,2),hins,
& eoa(2),ehi(2)
common /psubr/ xndx,amtpi,almnpx,egtrra,almzbr,almst,enders,
&gjtrra,ratmul,cgmul,amtmul,tipra,wilhlc,extnd(0:100)
c 1 2 3 4 5 6 7 8 9 10 11
c23456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012
data lab1/
& 'taxsimid,year,state,fiitax,siitax,fica,frate,srate,ficar,tfica'/
data lab2/',v10,v11,v12,v13,v14,v15,v16,v17,v18,v19,v20,v21,v22,v2
&3,v24,v25,v26,v27,v28,v29,credits,v30,v31,v32,v33,v34,v35,v36,v37,
&v38,v39,v40,v41,staxbc,srebate,senergy,sctc,qbid,v43,v44,v45,cd
&ate'/
data statenum/"00 ",
& "01al","02ak","03az","04ar","05ca","06co","07ct","08de","09dc",
& "10fl","11ga","12hi","13id","14il","15in","16ia","17ks","18ky",
& "19la","20me","21md","22ma","23mi","24mn","25ms","26mo","27mt",
& "28ne","29nv","30nh","31nj","32nm","33ny","34nc","35nd","36oh",
& "37ok","38or","39pa","40ri","41sc","42sd","43tn","44tx","45ut",
& "46vt","47va","48wa","49wv","50wi","51wy"/
data lab3/ ' 2L',' siitax',' agi',' exemp',' stded',
& ' xitem',' taxinc',' ptax',' chcr',' eic',' credits'
& ,' rate',' staxbc','srebate','senergy','sctc'/
if(x(3).gt.0.and.idtl.eq.6) then
write(*,'(22(10f8.0/))')(data(i),i=1,220)
write(*,'(22(10f8.0/))')(c(i),i=1,220)
endif
spec1c=0.d0
spec2c=0.d0
spec1d=0.d0
spec2d=0.d0
if(extnd(23).ne.0.d0) then
spec1c=c(195)
spec1d=d(195)
endif
if(data(6).ne.0) then
s(12) = s(12)*100.
t(12) = t(12)*100.
else
s(12) = 0.
t(12) = 0.
endif
d148=d(148)*100
d149=d(149)*100
tfica=d(190)
lawyr = int(data(101))
write(x0,'(f20.0)') x(1)
lenx1=1
x1=" "
do 1 i=1,30
if(x0(i:i).ne.' ') then
x1(lenx1:lenx1)=x0(i:i)
lenx1=lenx1+1
endif
1 continue
if(idtl.eq.0) then
if(nrec.eq.1) write(*,"( a62)") lab1
write(line,213) x1(1:lenx1),lawyr,int(data(6)),
& fold,sold ,fica ,frate,srate,ficar,tfica," //"
call putlin(line,1024)
elseif(idtl.eq.2) then
if(nrec.eq.1) write(*,"(a259)") lab1//lab2
write(line,200)
& x1,int(data(101)),int(data(6)),fold,sold,
& fica,frate,srate,ficar,tfica,
1 d( 2), d( 78), d( 79), d( 3),
& d( 83), d( 39), d( 34), d( 24), d( 29),
2 d( 28), d(174), d( 51), d( 81), d( 93),
& d( 53), d( 59), d( 69), d( 70), d( 52),
3 d( 75), d( 75), (s(i ),i=1,16), d(181),d(173),
4 d(180),d(186),",compdate //"
c leave "le n" to avoid false editor search matches
le n = 1024
call putlin(line,1024)
elseif(idtl.eq.5) then
if(d(24).lt.d(177).and.d(26).eq.1) then
write(*,*)
write(*,*) 'This taxpayer reduced the sum of federal and'
write(*,*) 'and state income tax by itemizing, despite'
write(*,*) 'having few deductions to claim. '
write(*,*)
endif
write(*,*) 'Basic Output: '
write(*,6) ' 1. Record ID: ', x1
write(*,3) ' 2. Year: ', int(x(2))
write(*,5) ' 3. State (SOI code): ', int(data(6)),
& states(min(55,int(data(6))))
write(*,2) ' 4. Federal IIT Liability: ', fold
write(*,2) ' 5. State IIT Liability: ', sold
write(*,2) ' 6. SS Payroll Tax Liability: ', fica
if(mtr.eq.85) then
write(*,*) 'Marginal Rates wrt Earner'
elseif(mtr.eq.86) then
write(*,*) 'Marginal Rates wrt Secondary Earner'
elseif(mtr.eq.11) then
write(*,*) 'Marginal Rates wrt Weighted Average Earnings'
elseif(mtr.eq.17) then
write(*,*) 'Marginal Rates wrt Other Income'
elseif(mtr.eq.70) then
write(*,*) 'Marginal Rates wrt Long-term Gains.'
elseif(mtr.eq.56) then
write(*,*) 'Marginal Rates wrt Mortgage and Other Deductions'
else
write(*,*) 'No marginal rates requested'
endif
write(*,2) ' 7. Federal Marginal Rate: ', frate
write(*,2) ' 8. State Marginal Rate: ', srate
if(mtr.eq.11) then
write(*,2) ' 9. Weighted Payroll Tax Rate:', ficar
elseif(mtr.eq.85) then
write(*,2) ' 9. Taxpayer SS Rate: ', d148
elseif(mtr.eq.86) then
write(*,2) ' 9. Spouse SS Rate: ', d149
else
write(*,2) ' 9. No SS Tax on Other Income:', 0.
endif
write(*,2) ' '
write(*,*) 'Federal Tax Calculation: Base
&+$1'
write(*,2) ' 10. Federal AGI ', d(2),c( 2)
write(*,2) ' 11. UI in AGI 1979+ ', d(78),c(78)
write(*,2) ' 12. Social Security in AGI 84+', d(79),c(79)
write(*,2) ' 13. Zero Bracket Amount ', d( 3),c( 3)
write(*,2) ' 14. Personal Exemptions ', d(83),c(83)
write(*,2) ' 15. Exemption Phaseout 1991+ ', d(39),c(39)
write(*,2) ' 16. Deduction Phaseout 1991+ ', d(34),c(34)
write(*,2) ' 17. Deductions allowed ', d(24),c(24)
write(*,2) ' QBI deduction ', d(181),c(181)
write(*,2) ' 18. Federal Taxable Income ', d(29),c(29)
write(*,2) ' 19. Federal Regular Tax ', d(28),c(28)
if(data(101).eq.2000.)
& write(*,21) ' (Excludes 2001 Rate Reduction Credit)'
if(data(101).eq.2001)
& write(*,21) ' (Includes 2001 Rate Reduction Credit)'
write(*,2) ' 20. Exemption Surtax 1988-96 ', d(174),c(174)
write(*,2) ' 21. General Tax Credit 1975-8 ', d(51),c(51)
if(int(data(208)).eq.0) then
write(*,2) ' 22. Child Tax Credit*17/22 98+', d(81),c(81)
else
write(*,2) ' 22. Child Tax Credit ', d(81),c(81)
endif
if(lawyr.eq.2009.or.lawyr.eq.2010) then
write(*,2) ' Make Work Pay Crdt 2009-10', d(94),c(94)
endif
write(*,2) ' 23 Refundable Part ', d(93),c(93)
write(*,2) ' 24. Child Care Credit 1076+ ', d(53),c(53)
write(*,2) ' 25. Earned Income Credit 1975+', d(59),c(59)
write(*,2) ' 26. Alternative Min Income: ', d(69),c(69)
write(*,2) ' 27. AMT ', d(70),c(70)
if(lawyr.eq.2008) then
write(*,2) ' 2008 Recovery Rebate ',d(202),c(202)
endif
if(lawyr.eq.2006.and.d(86)+c(86).gt.0)
& write(*,2) ' Telephone Tax Refund ', d(86),c(86)
write(*,2) ' 28. Income Tax Before Credits ', d(52),c(52)
write(*,2) ' Total Credits ', d(58),c(58)
write(*,2) ' 29. FICA ', d(75),c(75)
write(*,2) ' Taxpayer share of FICA ',d(190),c(190)
if(data(6).ne.0) then
write(*,2)
write(*,*) 'State Tax Calculation: '
write(*,2) ' 30. Household Income ',t(1),s(1)
write(*,2) ' 31. Imputed Rent ',t(2),s(2)
write(*,2) ' 32. AGI ',t(3),s(3)
write(*,2) ' 33. Exemptions ',t(4),s(4)
write(*,2) ' 34. Standard Deduction ',t(5),s(5)
write(*,2) ' 35. Itemized Deductions ',t(6),s(6)
write(*,2) ' 36. Taxable Income ',t(7),s(7)
write(*,2) ' Tax before credits ',t(13),s(13)
write(*,2) ' 37. Property Tax Credit ',t(8),s(8)
write(*,2) ' 38. Child Care Credit ',t(9),s(9)
write(*,2) ' 39. EIC ',t(10),s(10)
write(*,2) ' Energy|Fuel Credit ',t(15),s(15)
write(*,2) ' Child Tax Credit ',t(16),s(16)
write(*,2) ' 40. Total Credits ',t(11),s(11)
write(*,2) ' 41. Bracket Rate ',t(12),s(12)
write(*,2) ' State Tax after Credits ',d(74),c(74)
endif
if(lawyr.eq.2022) then
write(*,*) ' '
write(*,2) ' Rebate (excluded above) ',t(14),s(14)
endif
if(lawyr.gt.2018) then
write(*,*) ' '
write(*,*) 'TCJA 2018+'
write(*,2) ' 42. QBI Deduction ',d(181),c(181)
endif
if(lawyr.ge.2013) then
write(*,*) ' '
write(*,*) 'Additional Medicare Taxes 2013+'
write(*,2) ' 43. Net Investment Income Tax ',d(173),c(173)
write(*,2) ' 44. Medicare Tax on Earnings ',d(180),c(180)
endif
write(*,*) ' '
if(lawyr.eq.2020) then
write(*,*) 'CARES act 2020 only '
write(*,2) ' 45. CARES Recovery Rebates ',d(186),c(186)
endif
if(spec1d.ne.0.or.spec1c.ne.0)
& write(*,2) ' 46. Optional returned value #1 ',spec1d,spec1c
if(spec2d.ne.0.or.spec2c.ne.0)
& write(*,2) ' 47. Optional returned value #2 ',spec2d,spec2c
write(*,*)
write(*,*) 'Decomposition of FICA taxes - OASDI'
write(*,*) ' taxpayer spouse'
write(*,*) 'wages ',int(tr(1,1)),int(tr(1,2))
write(*,*) 'se combined ',int(tr(2,1))
write(*,*) 'businc ',int(tr(3,1)),int(tr(3,2))
write(*,*) 'profinc ',int(tr(3,1)),int(tr(4,2))
write(*,4) ' marginal rate',(100*eoa(i),i=1,2)
write(*,*)
write(*,*)'Decomposition of Fica taxes - Health Insurance'
write(*,*) ' taxpayer spouse'
write(*,*) 'wages ',int(th(1,1)),int(th(1,2))
write(*,*) 'se combined ',int(th(2,1))
write(*,*) 'businc ',int(th(3,1)),int(th(3,2))
write(*,*) 'profinc ',int(th(4,1)),int(th(4,2))
write(*,4) ' marginal rate ',(100*ehi(i),i=1,2)
4 format(a14,5x,2f11.2)
write(*,*)
write(*,*) 'Decomposition of Federal Marginal Rate'
write(*,*) ' (taxpayer earned income)'
write(*,2)
write(*,*) 'Regular Income Tax'
write(*,2) ' Bracket rate from X,Y or Z ', d( 66)
write(*,2) ' Deduction Phaseout: ', d(102)
write(*,2) ' Exemption Phaseout: ', d(104)
write(*,2) ' Social Security Phasein: ', d(106)
write(*,2) ' Child Tax Credit: ', d(114)
write(*,2) ' Child Care Credit: ', d(116)
write(*,2) ' Refundable Part of CTC: ', d(144)
write(*,2) ' Earned Income Credit: ', d(118)
write(*,2) ' Surtax on 15% bracket: ', d(130)
write(*,2) ' Exemption Surtax: ', d(132)
write(*,2) ' Unemployment Insurance: ', d(134)
write(*,2) ' Max Tax on Earned Income: ', d(140)
write(*,2) ' Elderly Credit: ', d( 54)
write(*,2) ' Dependent Care Credit: ', d( 53)
write(*,2) ' Percentage Std Deduction: ', d(138)
write(*,2) ' Medicare tax on Unearned Income:', d(167)
write(*,2) ' Cares Recovery Rebates: ', d(187)
write(*,2)
write(*,*) 'Alternative Minimum Income Tax '
write(*,2) ' AMT Bracket Rate ', d(99)*100
write(*,2)' AMT Phaseout ',d(99)*100.d0*(d(9)-1.d0)
write(*,2)
if(d(119).eq.0) then
write(*,*) 'Only Regular Tax Relevant'
else
write(*,*) 'Only AMT Rate Relevant'
endif
write(*,2) ' Total Marginal Rate: ', d( 72)
write(*,2) ' FICA w Medicare (t,s): ', d148,d149
elseif(idtl.eq.6) then
if(mod(nrec,10).eq.1)write(*,'(18a8)') lab3
write(*,100) statenum(int(data(6))),int(c(74)),
& (int(s(i)),i=3,15)
endif
100 format(a8,14i8)
2 format( 3x,a31,f11.2,1x,f11.2)
6 format( 3x,a32,a30)
21 format( 3x,a43)
3 format( 3x,a31,i11)
5 format( 3x,a31,i11,8x,a20)
213 format(a14,",",2(i8,","),6(f14.2,","),f14.2," ",a2)
200 format(a,",",2(i0 ,","),47( f0 .2,","), f0 .2,a8)
return
end
subroutine begin(a,list,nuse,nx,vars,dnames)
implicit double precision(a-z)
integer nx,i,j,list(nx),nuse,iostat,isget,ispost
c nnames number of known vars in names
c dnames list of names in data first line
c nlist max number of vars in data
c x(i) = z(list(i)) converts ith data element into appropriate place in x
c z(0) must be zero for this to work for missing data elements
character(len=16) dnames(nx)
character(len=1024) a,b
character(len=16) vars(2,nx)
character(len=1) c
logical isexe,agevars,depvars
common/comexe/isexe,agevars,depvars
namelist /nml/
& taxsimid, year , state , mstat , page,
6 sage , depx , dep13 , dep17 , dep18,
1 pwages , swages, divide, intrec, stcg,
6 ltcg , otherp, nonpro, pensio, gssi,
2 ui , transf, rentpa, propta, otheri,
6 childc , mortga, scorp , pbusin, pprofi,
3 sbusin , sprofi, idtl, mtr, pui,
6 sui , dep6 , dep19 , opt1, opt1v,
4 opt2 , opt2v , age1 , age2, age3,
6 psemp , ssemp
common/xcom/
& taxsimid, year , state , mstat , page,
6 sage , depx , dep13 , dep17 , dep18,
1 pwages , swages, divide, intrec, stcg,
6 ltcg , otherp, nonpro, pensio, gssi,
2 ui , transf, rentpa, propta, otheri,
6 childc , mortga, scorp , pbusin, pprofi,
3 sbusin , sprofi, idtl, mtr, pui,
6 sui , dep6 , dep19 , opt1, opt1v,
4 opt2 , opt2v , age1 , age2, age3,
6 psemp , ssemp
data ispost/0/
b=" "
do 1 i=1,nx
dnames(i) = " "
list(i) = 0
1 continue
a=' '
nuse=nx
i=0
2 continue
read(5,'(a1024)',end=999,err=998) a
if(a.eq." ") goto 2
c Skip prelimary data, "get" or "multipart form/data".
i=index(a,":")+index(a,"essage")+index(a,"---")
c write(*,*) i
ispost=max(i,ispost)
if(i.gt.0) goto 2
isget=index(a,"&")
c Write HTTP header, if appropriate
c Here for http "get" (will always have ampersands).
c Collect one data record into namelist.
agevars=.false.
depvars=.false.
if(index(a,'&').gt.0) then
b(1:6) = ' $nml '
do 3 i=1,1017
b(i+6:i+6)=a(i:i)
if(a(i:i).eq.'&') b(i+6:i+6)=','
if(a(i:i).eq.' ') then
b(i+7:i+7) = '/'
goto 4
endif
3 continue
4 continue
read(b,nml)
if(age1+age2+age3.gt.0) agevars=.true.
write(*,'("Content-type: text/plain")')
write(*,'("Content-Disposition: inline"//)')
write(*,*) b
elseif(index(a,"mstat").gt.0.and.index(a,"year").gt.0) then
c Here for CSV file using http "multipart form/data". Collect only
c variable list from first line of csv. Write csv header.
read(a,*,end=7,iostat=iostat) dnames
7 continue
c delete UTF-8 BOM
if(dnames(1)(1:1).eq.char(239))dnames(1)=dnames(1)(4:16)
do 9 i=1,nx
if(dnames(i).eq.' ') goto 99
do 8 j=1,nx
if(dnames(i)(1:3).eq."age") agevars=.true.
if(dnames(i)(1:3).eq."dep".and.
& dnames(i)(1:4).ne."depx") depvars=.true.
if(dnames(i).eq.vars(1,j)) list(i) = j
8 continue
if(list(i).eq.0) then
write(*,*) "TAXSIM: ERROR ",dnames(i),
& " is not a taxsim35 input variable."
do 11 j=1,16
c=dnames(i)(j:j)
if(c.ge.' '.and.c.le.'~') goto 11
write(*,*) "TAXSIM: Name with unprintable character"
write(*,'(a22,z2)') "TAXSIM: Hex value is:",c
11 continue
stop 901
endif
9 continue
c10 continue
99 continue
nuse = i-1
else
write(*,*) 'TAXSIM: Need at least mstat and year'
write(*,*) 'a(1:131)='
write(*,*) a(1:131)
stop 25
endif
return
998 stop 998
999 stop 999
cflush
end
subroutine putlin(a,n)
c remove spaces from a and write to standard out.
character(len=1024) a
character(len=8) format
format=" "
j=0
do 10 i=1,n
if(a(i:i).ne." ") then
if(a(i:i).eq."/") goto 20
j=j+1
a(j:j)=a(i:i)
endif
10 continue
20 continue
format(1:2)="(a"
format(7:7)=")"
write(format(3:6),'(i4)') j
write(*,format) a(1:j)
return
end
block data dllexe
implicit double precision(a-h,o-z)
logical isexe,agevars,depvars
common/comdll/dll
common/comold/d(255)
common/dindiv/data(255)
common/comexe/isexe,agevars,depvars
common/newshr/comnew(255)
data isexe/.true./
data comnew/255*0./
data d/255*0./
end
block data staten
character(len=20) states
common/cstates/states(0:55)
data states/' ',
& 'Alabama' ,'Alaska' ,'Arizona' ,'Arkansas',
& 'California' ,'Colorado' ,'Connecticut' ,'Delaware',
& 'DC' ,'Florida' ,'Georgia' ,'Hawaii',
& 'Idaho' ,'Illinois' ,'Indiana' ,'Iowa',
& 'Kansas' ,'Kentucky' ,'Louisiana' ,'Maine',
& 'Maryland' ,'Massachusetts' ,'Michigan' ,'Minnesota',
& 'Mississippi' ,'Missouri' ,'Montana' ,'Nebraska',
& 'Nevada' ,'New Hampshire' ,'New Jersey' ,'New Mexico',
& 'New York' ,'North Carolina','NorthDakota' ,'Ohio',
& 'Oklahoma' ,'Oregon' ,'Pennsylvania','Rhode Island',
& 'South Carolina','South Dakota' ,'Tennessee' ,'Texas',
& 'Utah' ,'Vermont' ,'Virginia' ,'Washington',
& 'West Virginia' ,'Wisconsin' ,'Wyoming' , 4*' '/
end
double precision function sern(d)
implicit double precision(a-h,o-z)
dimension d(255)
if(d(2).eq.2.and.d(85)+d(86).gt.0.d0) then
sern=min(d(85),d(86))
else
sern=d(11)
endif
return
end
integer function itwn(i,imin,imax)
itwn=min(imax,max(i,imin))
return
end
subroutine statax(data,lawyr,comnew)
implicit double precision (A-H,O-Z)
parameter(lastat=2022)
common /psubr/ xndx,amtpi,almnpx,egtrra,almzbr,almst,enders,
&gjtrra,ratmul,cgmul,amtmul,tipra,wilhlc,extnd(0:100)
common/calc/hy,rent,agi,exemp,stded,xitded,taxinc,pcred,chcr,
& earncr,credit,rt,taxbc,rebate,energy,ctc,ylow,amt
common /xndxac/ xndxa(1981:2023)
dimension data(255),comnew(255)
dimension ds(255),coms(255)
c DO NOT FORGET TO UPDATE parameter(lastat) EVERY YEAR
agi=0.
exemp =0.
stded =0.
xitded=0.
taxinc=0.
pcred =0.
chcr =0.
earncr=0.
credit=0.
rt =0.
taxbc =0.
rebate=0.
energy=0.
ctc =0.
ylow =0.
amt =0.
stax=0.
rt=0.
hy=data(159)
rent=data(160)
comnew(74)=0.
id=int(abs(data(6)))
if(lawyr.eq.-99) then
lawyr=lastat
return
endif
if(lawyr.lt.1977) then
write(*,*)
& 'TAXSIM: State Tax Calculator available for years 1977+'
return
endif
if(id.le.0.or.id.gt.51) return
flate = 1.
law = lawyr
if(extnd(21).gt.0) law = int(extnd(21))
if(law.gt.lastat) then
flate = xndxa(law)/xndxa(lastat)
law = lastat
endif
do 100 i=1,255
ds(i) = data(i)
coms(i) = comnew(i)
100 continue
do 200 i=11,99
ds(i) = data(i)/flate
ds(i+100) = data(i+100)/flate
200 continue
do 300 i=1,98
if(i.ne.26.and.i.ne.65.and.i.ne.72.and.i.ne.73)
& coms(i) = comnew(i)/flate
300 continue
i=int(data(i))
select case(i)
case(1)
call altax(ds,coms,stax,law)
case(2)
call aktax(ds,coms,stax,law)
case(3)
call aztax(ds,coms,stax,law)
case(4)
call artax(ds,coms,stax,law)
case(5)
call catax(ds,coms,stax,law)
case(6)
call cotax(ds,coms,stax,law)
case(7)
call cttax(ds,coms,stax,law)
case(8)
call detax(ds,coms,stax,law)
case(9)
call dctax(ds,coms,stax,law)
case(11)
call gatax(ds,coms,stax,law)
case(12)
call hitax(ds,coms,stax,law)
case(13)
call idtax(ds,coms,stax,law)
case(14)
call iltax(ds,coms,stax,law)
case(15)
call intax(ds,coms,stax,law)
case(16)
call iatax(ds,coms,stax,law)
case(17)
call kstax(ds,coms,stax,law)
case(18)
call kytax(ds,coms,stax,law)
case(19)
call latax(ds,coms,stax,law)
case(20)
call metax(ds,coms,stax,law)
case(21)
call mdtax(ds,coms,stax,law)
case(22)
call matax(ds,coms,stax,law)
case(23)
call mitax(ds,coms,stax,law)
case(24)
call mntax(ds,coms,stax,law)
case(25)
call mstax(ds,coms,stax,law)
case(26)
call motax(ds,coms,stax,law)
case(27)
call mttax(ds,coms,stax,law)
case(28)
call netax(ds,coms,stax,law)
case(30)
call nhtax(ds,coms,stax,law)
case(31)
call njtax(ds,coms,stax,law)
case(32)
call nmtax(ds,coms,stax,law)
case(33)
call nytax(ds,coms,stax,law)
case(34)
call nctax(ds,coms,stax,law)
case(35)
call ndtax(ds,coms,stax,law)
case(36)
call ohtax(ds,coms,stax,law)
case(37)
call oktax(ds,coms,stax,law)
case(38)
call ortax(ds,coms,stax,law)
case(39)
call patax(ds,coms,stax,law)
case(40)
call ritax(ds,coms,stax,law)
case(41)
call sctax(ds,coms,stax,law)
case(43)
call tntax(ds,coms,stax,law)
case(45)
call uttax(ds,coms,stax,law)
case(46)
call vttax(ds,coms,stax,law)
case(47)
call vatax(ds,coms,stax,law)
case(49)
call wvtax(ds,coms,stax,law)
case(50)
call witax(ds,coms,stax,law)
case default
stax=0.d0
end select
comnew(74) = stax*flate
return
end
c
c Subroutines from Statutil
c
recursive double precision function socsec(data,comnew,law)
implicit double precision (A-H,O-Z)
dimension data(255),comnew(255),rate(1977:2025),ceil(1977:2029)
data rate
* / .0585d0,.0605d0,.0613d0,.0613d0,
* .0665d0,.0670d0,.0670d0,.0700d0,.0705d0,
* .0715d0,.0715d0,.0751d0,.0751d0,21*.0765d0,
* 2*.0565d0,13*.0765d0/
data ceil
* / 16500.d0, 17700.d0, 22900.d0, 25900.d0,
* 29700.d0, 32400.d0, 35700.d0, 37800.d0, 39600.d0,
* 42000.d0, 43800.d0, 45000.d0, 48000.d0, 51300.d0,
* 53400.d0, 55500.d0, 57600.d0, 60600.d0, 61200.d0,
* 62700.d0, 65400.d0, 68400.d0, 72600.d0, 76200.d0,
* 80400.d0, 84900.d0, 87000.d0, 87900.d0, 90000.d0,
* 94200.d0, 97500.d0,102000.d0,106800.d0,106800.d0,
* 106800.d0,110100.d0,113700.d0,117000.d0,118500.d0,
* 118500.d0,127200.d0,128700.d0,132900.d0,137700.d0,
* 142800.d0,147000.d0,153600.d0,159300.d0,165300.d0,
* 171300.d0,177300.d0,183600.d0,190200.d0/
c actual amounts through 2022 (03.21.2022)
mst = int(data(2))
if(mst.eq.2) then
fica = (min(data(85),ceil(law))+min(data(86),ceil(law)))*
& rate(law)
if(data(85).gt.ceil(law))
& fica = fica + (data(85)-ceil(law))*.0145
if(data(86).gt.ceil(law))
& fica = fica + (data(86)-ceil(law))*.0145
else
fica = min(data(11),ceil(law))*rate(law)
if(data(11).gt.ceil(law))
& fica = fica + (data(11)-ceil(law))*.0145
endif
c socsec = fica + data(43)+data(44)
c c175 = setax in sstax
socsec = fica + comnew(175)+data(44)
c Additional 0.9% Medicare Tax on Earned Income
if(law.ge.2013) socsec = socsec + comnew(180)
return
end
double precision function xjobs(data,law)
implicit double precision (A-H,O-Z)
dimension data(255),rate1(1977:1994),rate2(1977:1994)
data rate1/10*.5d0,3*.4d0,5*0.0d0/
data rate2/10*.25d0,8*0.0d0/
amt1=0.
amt2=0.
xjobs=0.
if(law.le.1986) then
amt1=data(37)*2/3
amt2=amt1/2
xjobs=min(12000.0d0,(amt1/rate1(law))+(amt2/rate2(law)))
elseif(law.ge.1987.and.law.le.1989) then
amt1=data(37)
amt2=0.
xjobs=min(6000.0d0,(amt1/rate1(law)))
elseif(law.ge.1990) then
xjobs=0.
endif
return
end
c
recursivesubroutine look(table,y,ntab,n,statax,aif,data2,rt,data)
implicit double precision (A-H,O-Z)
common/times/z,p,txrate,h
dimension table(2,ntab),data(255)
integer d2,d209
d209 = int(data(209))
d2 = int(data2)
c negative data2 is signal that separate filing is allowed.
h=0.
c ntab=25
call look2(table,y,ntab,n,statax,aif,dabs(data2),rt,data)
if(d2.eq.-2) then
yh= max(data(85),data(86))+(y-data(11))/2.
yw=y-yh
h=2
call look2(table,yw,ntab,n,taxw,aif,1.0d0,rt,data)
h=1
call look2(table,yh,ntab,n,taxh,aif,1.0d0,rt,data)
if(taxw+taxh.gt.statax.and.d209.eq.2) then
continue
endif
statax=min(statax,taxw+taxh)
endif
return
end
subroutine look2(table,y,ntab,n,statax,aif,data2,rt,data)
implicit double precision (A-H,O-Z)
c aif=annual inflation factor if indexed,otherwise 1.
common/times/z,p,txrate,h
common/x/ct
c data2=marital status if joint filing is allowed,otherwise 0.
dimension table(2,ntab),data(255)
integer d2
d2 = int(data2)
c This line is in here to avoid unused variable errors
n = n
ajnt=1.
if(d2.eq.2.or.d2.eq.5)ajnt=2
y1=max(y/aif/ajnt,0.0d0)
statax=0.
rt=0.
yleft=y1
rate=table(2,1)/100.
if(y1.lt.table(1,1)) goto 99
statax=table(1,1)*table(2,1)/100.
do 10 i=2,ntab
if(table(1,i).lt.table(1,i-1).or.table(2,i).lt..1) then
if(table(2,i).gt.0) then
d101 = data(101)
d100 = data(100)
c write(*,*) 'TAXSIM:in look2',
c & table(1,i),table(1,i-1),table(2,i),d101,data(6),d100
endif
endif
yleft=y1-table(1,i-1)
rate=table(2,i)/100.
if(y1.lt.table(1,i)) goto 99
statax=statax+(table(1,i)-table(1,i-1))*rate
10 continue
yleft=y1-table(1,ntab)
99 continue
if(data(100).lt.-3)
& write(*,*)'a',int(statax),int(yleft),int(yleft*rate)
& ,int(yleft*rate+statax),int(y1)
statax=aif*ajnt*(yleft*rate+statax)
c calculating marginal tax rate
rt=rate
return
end
subroutine badlook2(table,y,ntab,n,statax,aif,data2,rt,data)
implicit double precision (A-H,O-Z)
c aif=annual inflation factor if indexed,otherwise 1.
common/times/z,p,txrate,h
common/x/ct
common/xcom/x(47)
c data2=marital status if income splitting is allowed,otherwise 0.
dimension table(2,ntab),data(255)
integer d2
d2 = int(data2)
c This line is in here to avoid unused variable errors
n = n
ajnt=1.
if(d2.eq.2.or.d2.eq.5)ajnt=2
y1=max(y/aif/ajnt,0.0d0)
if(x(3).gt.0.and.x(1).lt.-2)
& write(*,*)'y,aif,y1',int(y),sngl(aif),int(y1),int(ajnt)
statax=0.
rt=0.
yleft=y1
rate=table(2,1)/100.
if(y1.lt.table(1,1)) goto 99
statax=table(1,1)*table(2,1)/100.
do 10 i=2,ntab
if(table(1,i).lt.table(1,i-1).or.table(2,i).lt..1) then
if(table(2,i).gt.0) then
d101 = data(101)
d100 = data(100)
write(*,*) 'TAXSIM: in look2',
& table(1,i),table(1,i-1),table(2,i),d101,data(6),d100
endif
endif
yleft=y1-table(1,i-1)
rate=table(2,i)/100.
if(y1.lt.table(1,i)) goto 99
statax=statax+(table(1,i)-table(1,i-1))*rate
incr=int((table(1,i)-table(1,i-1))*rate)
if(x(3).gt.0..and.x(1).lt.-1)
& write(*,*)'i rs',int(table(1,i)),'-',
& int(table(1,i-1)),'*'
& ,rate,incr,int(statax)
10 continue
|
I saw your comment "It turns out the Form 8812 doesn't reduce the Line 5 amount below 8,750" I'm referring to the 2021 Form 8812 Instruction -- (at page 4) Line 5 Worksheet -- line 9. Subtract line 8 from Schdule8812 line 3 * if more than zero ....enter the next multiple of $1,000 would be easier to refer to my manual calculation for details. This is where the rounding rule got applied: Bodi |
I agree, attached is the worksheet for line 5 which shows 65,000 on line
9.
The taxsim.f file I sent you is no good. I'll send a working one if you
like. Can you remove the one I just sent from github? That would be
helpful.
Thanks
dan
…On Tue, 24 Oct 2023, Bodi Yang wrote:
@feenberg
I saw your comment "It turns out the Form 8812 doesn't reduce the Line 5 amount below 8,750"
~ just want to make sure we are talking about the same $1,000 rounding rule. There are two rounding rule appearances in the form: one in **form 8812** Part 1-A line 9, the other one is in **Form 8812 Instruction** -- (at page 4) Line 5 Worksheet -- line 9
I'm referring to the 2021 Form 8812 Instruction -- (at page 4) Line 5 Worksheet -- line 9. Subtract line 8 from Schdule8812 line 3 * if more than zero ....enter the next multiple of $1,000
would be easier to refer to [my manual calculation](#2700 (comment)) for details.
This is where the rounding rule got applied:
line 5 Worksheet -- line 9: 177000 - 112500 = 64500; then apply the rounding rule 64500 -> 65000
Bodi
--
Reply to this email directly or view it on GitHub:
#2700 (comment)
You are receiving this because you were mentioned.
Message ID: ***@***.***>
|
Of course Dan. I think you may need to remove the previous taxsim.f from your git account. I can't do it on my side |
Relates to Issue #2701 |
Resolved via PR #2704 |
There is an issue in child tax credit calculation for the year 2021. (noticed from the validation work with taxsim35 ~ many records are showing differences in child tax credit between Tax-Calc and Taxsim, as documented in PR 2698 )
Currently, Tax-Calculator's child tax credit calculation follows the IRS Publication 972, as in calcfunctions.py. The years before 2020 all follows IRS Publication 972.
Since 2021, child tax credit has been changed to follow IRS Sch 8812 in 2021. The tax logic is also changed for the year 2021, while to be noticed only for the year 2021. Year 2022's child tax credit still follows IRS Sch 8812, but the tax logic is the same as the years before 2020 which are under Publication 972, as can be seen in IRS Sch 8812 in 2022
As a result, the child tax credit calculation is correct for all the years except 2021. Tax logic has to be rewritten for the year 2021, following IRS Sch 8812 in 2021
The text was updated successfully, but these errors were encountered: