+ taxableInterest(tr: TaxReturn): number {
+ const value = (new AccumulatorLine(Form1099INT, '1')).value(tr) +
+ (new AccumulatorLine(Form1099INT, '3')).value(tr);
+ return value;
+ }
+
+ qualifiedDividends(tr: TaxReturn): number {
+ return this.getValue(tr, '3a');
+ }
+
+ adjustedGrossIncome(tr: TaxReturn): number {
+ return this.getValue(tr, '7b') - this.getValue(tr, '8a');
+ }
+
+ deduction(tr: TaxReturn): number {
+ let deduction = 0;
+ const schedA = tr.findForm(ScheduleA);
+ if (schedA) {
+ deduction = schedA.getValue(tr, '17');
+ if (schedA.getValue(tr, '18')) {
+ return deduction;
+ }
+ }
+
+ return Math.max(deduction, tr.constants.standardDeduction[this.filingStatus]);
+ }
+
+ qualifiedBusinessIncomeDeduction(tr: TaxReturn): number {
+ const f8995 = tr.findForm(Form8995REIT);
+ if (f8995)
+ return f8995.getValue(tr, '39');
+ return 0;
+ }
+
+ capitalGainOrLoss(tr: TaxReturn): number {
+ const schedD = tr.findForm(ScheduleD);
+ if (!schedD)
+ return 0;
+
+ const l6 = schedD.getValue(tr, '16');
+ if (l6 >= 0)
+ return l6;
+ return schedD.getValue(tr, '21');
+ }
+
+ totalIncome(tr: TaxReturn): number {
+ return sumFormLines(tr, this, ['1', '2b', '3b', '4b', '4d', '5b', '6', '7a']);
+ }
+
+ taxableIncome(tr: TaxReturn): number {
+ return clampToZero(this.getValue(tr, '8b') - this.getValue(tr, '11a'));
+ }
+
+ tax(tr: TaxReturn): number {
+ // Not supported:
+ // Form 8814 (election to report child's interest or dividends)
+ // Form 4972 (relating to lump-sum distributions)
+
+ const schedD = tr.findForm(ScheduleD);
+ // Line 18 and 19 are not undefined or 0.
+ if (schedD && !schedD.getValue(tr, '20')) {
+ // Use ScheD tax worksheet;
+ const schedDtw = tr.findForm(ScheduleDTaxWorksheet);
+ if (schedDtw)
+ return schedDtw.getValue(tr, '47');
+ }
+
+ // If there are qualified dividends, use the QDCGTW.
+ if (this.qualifiedDividends(tr) > 0) {
+ const qdcgtw = tr.getForm(QDCGTaxWorksheet);
+ return qdcgtw.getValue(tr, '27');
+ }
+
+ // Otherwise, compute just on taxable income.
+ return computeTax(this.taxableIncome(tr), tr);
+ }
+