Skip to content

Commit

Permalink
Merge pull request #3 from zakpatterson/f8889-review
Browse files Browse the repository at this point in the history
F8889 review - fix negative values
  • Loading branch information
ctSkennerton committed Jan 2, 2022
2 parents 75fedb8 + ce02a2b commit 709d1f7
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/forms/Y2020/irsForms/F8889.ts
Expand Up @@ -245,7 +245,7 @@ export default class F8889 extends Form {
l14c = (): number => this.l14a() - (this.l14b() ?? 0)
l15 = (): number =>
this.hsas.reduce((total, hsa) => hsa.qualifiedDistributions + total, 0)
l16 = (): number => this.l14c() - this.l15()
l16 = (): number => Math.max(0, this.l14c() - this.l15())
l17a = (): boolean => false
// TODO: add in logic for when line 17a is true
l17b = (): number | undefined => Math.round(this.l16() * 0.2)
Expand Down
26 changes: 13 additions & 13 deletions src/forms/Y2020/tests/f1040.test.ts
@@ -1,4 +1,4 @@
import { commonTests } from '.'
import { commonTests, testKit } from '.'

jest.setTimeout(40000)

Expand All @@ -13,16 +13,16 @@ beforeAll(() => {
describe('f1040', () => {
commonTests.run()

// it('should never produce higher tax than income', async () => {
// await testKit.with1040Assert(async (forms) => {
// const f1040 = commonTests.findF1040OrFail(forms)
// expect(f1040).not.toBeUndefined()
// // tax is less than taxable income
// if (f1040?.l15() ?? 0 > 0) {
// expect(f1040?.l24() ?? 0).toBeLessThan(f1040?.l15() ?? 0)
// } else {
// expect(f1040?.l24() ?? 0).toEqual(0)
// }
// })
// })
it('should never produce higher tax than income', async () => {
await testKit.with1040Assert(async (forms) => {
const f1040 = commonTests.findF1040OrFail(forms)
expect(f1040).not.toBeUndefined()
// tax is less than taxable income
if (f1040?.l15() ?? 0 > 0) {
expect(f1040?.l24() ?? 0).toBeLessThan(f1040?.l15() ?? 0)
} else {
expect(f1040?.l24() ?? 0).toEqual(0)
}
})
})
})
4 changes: 2 additions & 2 deletions src/forms/Y2021/irsForms/F8889.ts
Expand Up @@ -242,10 +242,10 @@ export default class F8889 extends Form {
l14a = (): number =>
this.hsas.reduce((total, hsa) => hsa.totalDistributions + total, 0)
l14b = (): number | undefined => undefined
l14c = (): number => this.l14a() - (this.l14b() ?? 0)
l14c = (): number => Math.max(0, this.l14a() - (this.l14b() ?? 0))
l15 = (): number =>
this.hsas.reduce((total, hsa) => hsa.qualifiedDistributions + total, 0)
l16 = (): number => this.l14c() - this.l15()
l16 = (): number => Math.max(0, this.l14c() - this.l15())
l17a = (): boolean => false
// TODO: add in logic for when line 17a is true
l17b = (): number | undefined => Math.round(this.l16() * 0.2)
Expand Down
34 changes: 15 additions & 19 deletions src/forms/Y2021/tests/f1040.test.ts
@@ -1,4 +1,4 @@
import { commonTests } from '.'
import { commonTests, testKit } from '.'

jest.setTimeout(40000)

Expand All @@ -13,22 +13,18 @@ beforeAll(() => {
describe('f1040', () => {
commonTests.run()

// TODO: revisit this test. Commented it out because it will fail
// under certain seemingly legit circumstances. For example, if there
// is no income from W2 or 1099 but an excess distribution from a HSA
// is done, then there will be more tax than income.
// it('should never produce higher tax than income', async () => {
// await testKit.with1040Assert(async (forms) => {
// const f1040 = commonTests.findF1040(forms)
// expect(f1040).not.toBeUndefined()
// if (f1040 !== undefined) {
// // tax is less than taxable income
// if (f1040.l15() ?? 0 > 0) {
// expect(f1040.l24() ?? 0).toBeLessThan(f1040.l15() ?? 0)
// } else {
// expect(f1040.l24() ?? 0).toEqual(0)
// }
// }
// })
// })
it('should never produce higher tax than income', async () => {
await testKit.with1040Assert(async (forms) => {
const f1040 = commonTests.findF1040(forms)
expect(f1040).not.toBeUndefined()
if (f1040 !== undefined) {
// tax is less than taxable income
if (f1040.l15() ?? 0 > 0) {
expect(f1040.l24() ?? 0).toBeLessThan(f1040.l15() ?? 0)
} else {
expect(f1040.l24() ?? 0).toEqual(0)
}
}
})
})
})
6 changes: 5 additions & 1 deletion src/forms/tests/TestKit.ts
Expand Up @@ -37,7 +37,11 @@ export default class TestKit {
try {
const builder = this.builder.build(info)
const pdfs = await builder.f1040Pdfs()
const saveDirName = `Errors ${new Date().getUTCHours()}:${new Date().getMinutes()}:${new Date().getSeconds()}`
const today = new Date()
const dateStr = `${today.getFullYear()}-${
today.getMonth() + 1
}-${today.getDate()}`
const saveDirName = `Errors ${dateStr} ${today.toLocaleTimeString()}`
const saveDir = path.resolve(logsDir, saveDirName)
await fs.mkdir(saveDir, { recursive: true })
await run(pdfs).fold(
Expand Down

0 comments on commit 709d1f7

Please sign in to comment.