import { Form, TaxReturn } from '../core';
import { Line, AccumulatorLine, ComputedLine, ReferenceLine, sumLineOfForms } from '../core/Line';
import { UnsupportedFeatureError } from '../core/Errors';
-import { reduceBySum } from '../core/Math';
+import { clampToZero, reduceBySum } from '../core/Math';
import Form8606 from './Form8606';
import Form8959 from './Form8959';
return this.getValue(tr, '9') + this.getValue(tr, '10');
}),
'11b': new ComputedLine((tr): number => {
- const value = this.getValue(tr, '8b') - this.getValue(tr, '11a');
- return value < 0 ? 0 : value;
+ return clampToZero(this.getValue(tr, '8b') - this.getValue(tr, '11a'));
}, 'Taxable income'),
'12a': new ComputedLine((tr): number => {
'13b': new ReferenceLine(Schedule3, '7', 'Additional credits', 0),
'14': new ComputedLine((tr): number => {
- const l12b = this.getValue(tr, '12b');
- const l13b = this.getValue(tr, '13b');
- const value = l12b - l13b;
- return value < 0 ? 0 : value;
+ return clampToZero(this.getValue(tr, '12b') - this.getValue(tr, '13b'));
}),
'15': new ReferenceLine(Schedule2, '10', undefined, 0),
}, 'Total payments'),
'20': new ComputedLine((tr): number => {
- const l16: number = this.getValue(tr, '16');
- const l19: number = this.getValue(tr, '19');
- if (l19 > l16)
- return l19 - l16;
- return 0;
+ return clampToZero(this.getValue(tr, '19') - this.getValue(tr, '16'));
}, 'Amount overpaid'),
'23': new ComputedLine((tr): number => {
- const l16 = this.getValue(tr, '16');
- const l19 = this.getValue(tr, '19');
- if (l19 < l16)
- return l16 - l19;
- return 0;
+ return clampToZero(this.getValue(tr, '16') - this.getValue(tr, '19'));
}, 'Amount you owe'),
};
};
}),
'7': new ComputedLine((tr): number => this.getValue(tr, '1a') - this.getValue(tr, '6')),
// Skip the complicated Part II matrix and just use the input value.
- '8': new Input('totalForeignTaxesPaidOrAccrued'),
+ '8': new Input('totalForeignTaxesPaidOrAccrued'),
'9': new ReferenceLine(Form1116 as any, '8'),
// 10 not supported - Carryback or carryover
'11': new ComputedLine((tr): number => this.getValue(tr, '9') /* + this.getValue(tr, '10') */),
import { Form, Person, TaxReturn } from '../core';
import { Line, AccumulatorLine, ComputedLine, InputLine, ReferenceLine } from '../core/Line';
-import { clampToZero } from '../core/Math';
+import { clampToZero, undefinedToZero } from '../core/Math';
export interface Form8606Input {
person: Person;
'7': new Input('distributionsFromAllTradSepSimpleIras'),
'8': new Input('amountConvertedFromTradSepSimpleToRoth'),
'9': new ComputedLine((tr): number => {
- let value = 0;
- value += this.getValue(tr, '6') || 0;
- value += this.getValue(tr, '7') || 0;
- value += this.getValue(tr, '8') || 0;
- return value;
+ return undefinedToZero(this.getValue(tr, '6')) +
+ undefinedToZero(this.getValue(tr, '7')) +
+ undefinedToZero(this.getValue(tr, '8'));
}),
'10': new ComputedLine((tr): number => this.getValue(tr, '5') / this.getValue(tr, '9')),
'11': new ComputedLine((tr): number => this.getValue(tr, '8') * this.getValue(tr, '10'), 'Nontaxable portion converted to Roth'),
}, 'Total basis in Traditional IRAs'),
'15a': new ComputedLine((tr): number => this.getValue(tr, '7') - this.getValue(tr, '12')),
'15b': new ComputedLine((): number => 0, 'Amount attributable to qualified disaster distributions'),
- // 15b not supported - amount on line 15a attributable
+ // 15b not supported - amount on line 15a attributable
'15c': new ComputedLine((tr): number => this.getValue(tr, '15a') - this.getValue(tr, '15b'), 'Taxable amount'),
// Part 2
'2': new ReferenceLine(Form1040, '3b', 'Ordinary dividends'),
// 3 not supported - Annuities
// 4a not supported - Rental real estate, royalties, partnerships, S corporations, trusts, etc
- // 4b not supported - Adjustment for net income or loss derived in the ordinary course of a nonsection 1411 trade or business
+ // 4b not supported - Adjustment for net income or loss derived in the ordinary course of a nonsection 1411 trade or business
// 4c not supported - 4a+4b
'5a': new ComputedLine((tr): number => {
return (new ReferenceLine(Form1040, '6')).value(tr) +