-
Notifications
You must be signed in to change notification settings - Fork 0
/
fullYearTaxAmount.js
194 lines (188 loc) · 4.87 KB
/
fullYearTaxAmount.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
const assert = require('node:assert')
const tp = require('../src')
const ordinaryIncome = 50_500.00
const capitalGainsIncome = 10_000.00
const agi = ordinaryIncome + capitalGainsIncome
const californiaDeduction = 5_202.00
const federalDeduction = 12_950
const federalInomeTaxes = [
[ 0, 10_275, 0.10],
[ 10_275, 41_775, 0.12],
[ 41_775, 89_075, 0.22],
[ 89_075, 170_050, 0.24],
[170_050, 215_950, 0.32],
[215_950, 539_900, 0.35],
[539_900, null, 0.37]
]
const federalCapGainsTax = [
[ 0, 41_675, 0.00],
[ 41_675, 459_750, 0.15],
[459_750, null, 0.20]
]
const federalNiit = [
[ 0, 200_000, 0.000],
[200_000, null, 0.038]
]
const californiaIncomeTax = [
[ 0, 10_099, 0.010],
[ 10_099, 23_942, 0.020],
[ 23_942, 37_788, 0.040],
[ 37_788, 52_455, 0.060],
[ 52_455, 66_295, 0.080],
[ 66_295, 338_639, 0.093],
[338_639, 406_364, 0.103],
[406_364, 677_275, 0.113],
[677_275, null, 0.123]
]
const californiaCapGainsTax = [
[ 0, 8_932, 0.010],
[ 8_932, 21_175, 0.020],
[ 21_175, 33_421, 0.040],
[ 33_421, 46_394, 0.060],
[ 46_394, 58_634, 0.080],
[ 58_634, 299_508, 0.093],
[299_508, 359_407, 0.103],
[359_407, 599_012, 0.113],
[599_012, null, 0.123]
]
describe('Full Tax Year Calculations', () => {
it('can get federal tax year values', () => {
const federalTaxBracket = tp.stackTaxBrackets(
ordinaryIncome,
tp.appendDeductionToBracket(
federalDeduction,
federalInomeTaxes,
),
tp.appendDeductionToBracket(
federalDeduction,
tp.mergeTaxBrackets(
federalCapGainsTax,
federalNiit,
)
)
)
const actualAmount = tp.taxAmount(
agi,
federalTaxBracket
)
const expectedAmount = 5_181.75
assert.equal(actualAmount, expectedAmount)
})
it('can get state tax year values', () => {
const stateTaxBrackets = tp.stackTaxBrackets(
ordinaryIncome,
tp.appendDeductionToBracket(
californiaDeduction,
californiaIncomeTax
),
tp.appendDeductionToBracket(
californiaDeduction,
californiaCapGainsTax
)
)
const actualAmount = tp.taxAmount(
agi,
stateTaxBrackets
)
const expectedAmount = 2_160.37
assert.equal(actualAmount, expectedAmount)
})
it('can combine federal and state', () => {
const federalTaxBracket = tp.stackTaxBrackets(
ordinaryIncome,
tp.appendDeductionToBracket(
federalDeduction,
federalInomeTaxes,
),
tp.appendDeductionToBracket(
federalDeduction,
tp.mergeTaxBrackets(
federalCapGainsTax,
federalNiit,
)
)
)
const stateTaxBrackets = tp.stackTaxBrackets(
ordinaryIncome,
tp.appendDeductionToBracket(
californiaDeduction,
californiaIncomeTax
),
tp.appendDeductionToBracket(
californiaDeduction,
californiaCapGainsTax
)
)
const combinedTaxBrackets = tp.mergeTaxBrackets(
federalTaxBracket,
stateTaxBrackets,
)
const actualAmount = tp.taxAmount(
agi,
combinedTaxBrackets
)
const expectedAmount = 7_342.12
assert.equal(actualAmount, expectedAmount)
})
it('can be combined a second way', () => {
const localOrdinaryIncome = 300_000
const stackedByAuthority = tp.mergeTaxBrackets(
// federal
tp.stackTaxBrackets(
localOrdinaryIncome,
tp.appendDeductionToBracket( // income taxes
federalDeduction,
federalInomeTaxes,
),
tp.appendDeductionToBracket( // capital gains taxes
federalDeduction,
tp.mergeTaxBrackets(
federalCapGainsTax,
federalNiit,
)
)
),
// state
tp.stackTaxBrackets(
localOrdinaryIncome,
tp.appendDeductionToBracket( // income taxes
californiaDeduction,
californiaIncomeTax
),
tp.appendDeductionToBracket( // capital gains taxes
californiaDeduction,
californiaCapGainsTax
)
)
)
const stackedByType = tp.stackTaxBrackets(
localOrdinaryIncome,
// income taxes
tp.mergeTaxBrackets(
tp.appendDeductionToBracket( // federal
federalDeduction,
federalInomeTaxes,
),
tp.appendDeductionToBracket( // state
californiaDeduction,
californiaIncomeTax
),
),
// capital gains taxes
tp.mergeTaxBrackets(
tp.appendDeductionToBracket( // federal
federalDeduction,
tp.mergeTaxBrackets(
federalCapGainsTax,
federalNiit,
)
),
tp.appendDeductionToBracket( // state
californiaDeduction,
californiaCapGainsTax
)
)
)
assert.deepEqual(stackedByType, stackedByAuthority)
})
})