From 3ede4858621cb8bf155bc892f40722fec04cea16 Mon Sep 17 00:00:00 2001 From: Zak Patterson Date: Sun, 2 Jan 2022 11:06:03 -0600 Subject: [PATCH 1/4] Improve error log directory name --- src/forms/tests/TestKit.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/forms/tests/TestKit.ts b/src/forms/tests/TestKit.ts index 48165c045..faae9ec98 100644 --- a/src/forms/tests/TestKit.ts +++ b/src/forms/tests/TestKit.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ -import fc, { Parameters } from 'fast-check' +import fc, { date, Parameters } from 'fast-check' import { Information } from 'ustaxes/core/data' import Form from 'ustaxes/core/irsForms/Form' import { run } from 'ustaxes/core/util' @@ -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( From 8bea48de4e7ba5422bc1c4a9492e0f8eeecf5175 Mon Sep 17 00:00:00 2001 From: Zak Patterson Date: Sun, 2 Jan 2022 11:06:30 -0600 Subject: [PATCH 2/4] Uncomment 2020 f1040 test, showing negative value Fix negative value --- src/forms/Y2020/irsForms/F8889.ts | 2 +- src/forms/Y2020/tests/f1040.test.ts | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/forms/Y2020/irsForms/F8889.ts b/src/forms/Y2020/irsForms/F8889.ts index 2e1d20005..abc1f0186 100644 --- a/src/forms/Y2020/irsForms/F8889.ts +++ b/src/forms/Y2020/irsForms/F8889.ts @@ -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) diff --git a/src/forms/Y2020/tests/f1040.test.ts b/src/forms/Y2020/tests/f1040.test.ts index d6d3ef05b..3d0bae284 100644 --- a/src/forms/Y2020/tests/f1040.test.ts +++ b/src/forms/Y2020/tests/f1040.test.ts @@ -1,4 +1,4 @@ -import { commonTests } from '.' +import { commonTests, testKit } from '.' jest.setTimeout(40000) @@ -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) + } + }) + }) }) From c4c53acccefb7d1800d8cb04ae67f0a7fd7a7aa6 Mon Sep 17 00:00:00 2001 From: Zak Patterson Date: Sun, 2 Jan 2022 11:14:30 -0600 Subject: [PATCH 3/4] Uncomment 2021 test, fix negative value error --- src/forms/Y2021/irsForms/F8889.ts | 4 ++-- src/forms/Y2021/tests/f1040.test.ts | 34 +++++++++++++---------------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/forms/Y2021/irsForms/F8889.ts b/src/forms/Y2021/irsForms/F8889.ts index 2e1d20005..e5b5b2f09 100644 --- a/src/forms/Y2021/irsForms/F8889.ts +++ b/src/forms/Y2021/irsForms/F8889.ts @@ -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) diff --git a/src/forms/Y2021/tests/f1040.test.ts b/src/forms/Y2021/tests/f1040.test.ts index 4537f9d0e..f747b8839 100644 --- a/src/forms/Y2021/tests/f1040.test.ts +++ b/src/forms/Y2021/tests/f1040.test.ts @@ -1,4 +1,4 @@ -import { commonTests } from '.' +import { commonTests, testKit } from '.' jest.setTimeout(40000) @@ -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) + } + } + }) + }) }) From ce02a2bb7d18b188c143e419bdcf2cd9266ee8c4 Mon Sep 17 00:00:00 2001 From: Zak Patterson Date: Sun, 2 Jan 2022 12:59:50 -0500 Subject: [PATCH 4/4] Update TestKit.ts --- src/forms/tests/TestKit.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/forms/tests/TestKit.ts b/src/forms/tests/TestKit.ts index faae9ec98..ac5a2096e 100644 --- a/src/forms/tests/TestKit.ts +++ b/src/forms/tests/TestKit.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ -import fc, { date, Parameters } from 'fast-check' +import fc, { Parameters } from 'fast-check' import { Information } from 'ustaxes/core/data' import Form from 'ustaxes/core/irsForms/Form' import { run } from 'ustaxes/core/util'