Use the original idea for Form8949, which is simpler.
[ustaxlib.git] / src / fed2019 / ScheduleD.ts
1 import Form from '../Form';
2 import Person from '../Person';
3 import TaxReturn from '../TaxReturn';
4 import { Line, AccumulatorLine, ComputedLine, sumLineOfForms } from '../Line';
5
6 import Form8949, { Form8949Box } from './Form8949';
7 import Form1099DIV from './Form1099DIV';
8 import Form1040, { FilingStatus } from './Form1040';
9
10 export default class ScheduleD extends Form<ScheduleD['_lines']> {
11 readonly name = 'Schedule D';
12
13 protected readonly _lines = {
14 // 1a not supported (Totals for all short-term transactions reported on Form 1099-B for which basis was reported to the IRS and for which you have no adjustments)
15 // 4 is not supported (Short-term gain from Form 6252 and short-term gain or (loss) from Forms 4684, 6781, and 8824)
16 // 5 is not supported (Net short-term gain or (loss) from partnerships, S corporations, estates, and trusts from Schedule(s) K-1)
17 // 6 is not supported (Short-term capital loss carryover. Enter the amount, if any, from line 8 of your Capital Loss Carryover Worksheet in the instructions)
18
19 '7': new ComputedLine((tr: TaxReturn): number => {
20 // 1-3 are computed by Form8949.
21 // 4-6 should be included.
22 const f8949 = tr.getForm(Form8949);
23 return f8949.getValue(tr, 'boxA').gainOrLoss +
24 f8949.getValue(tr, 'boxB').gainOrLoss +
25 f8949.getValue(tr, 'boxC').gainOrLoss;
26 }, 'Net short-term capital gain or (loss)'),
27
28 // 8a is not supported.
29
30 // 11 is not supported (Gain from Form 4797, Part I; long-term gain from Forms 2439 and 6252; and long-term gain or (loss) from Forms 4684, 6781, and 8824)
31 // 12 is not supported (Net long-term gain or (loss) from partnerships, S corporations, estates, and trusts from Schedule(s) K-1)
32
33 '13': new AccumulatorLine(Form1099DIV, '2a', 'Capital gain distributions'),
34
35 // 14 is not supported (Long-term capital loss carryover. Enter the amount, if any, from line 13 of your Capital Loss Carryover Worksheet in the instructions)
36
37 '15': new ComputedLine((tr: TaxReturn): number => {
38 // 11-14 should be included.
39 const f8949 = tr.getForm(Form8949);
40 return f8949.getValue(tr, 'boxD').gainOrLoss +
41 f8949.getValue(tr, 'boxE').gainOrLoss +
42 f8949.getValue(tr, 'boxF').gainOrLoss +
43 this.getValue(tr, '13');
44 }, 'Net long-term capital gain or (loss)'),
45
46 '16': new ComputedLine((tr: TaxReturn): number => {
47 return this.getValue(tr, '7') + this.getValue(tr, '15');
48 }),
49
50 '17': new ComputedLine((tr: TaxReturn): boolean => {
51 return this.getValue(tr, '15') > 0 && this.getValue(tr, '16') > 0;
52 }, 'Both ST and LT are gains'),
53
54 '18': new ComputedLine((tr: TaxReturn): number | undefined => {
55 if (!this.getValue(tr, '17'))
56 return undefined;
57 // TODO
58 return 0;
59 }, '28% Rate Gain Worksheet Value'),
60
61 // 19 is not supported (Unrecaptured Section 1250 Gain Worksheet)
62
63 '20': new ComputedLine((tr: TaxReturn): boolean | undefined => {
64 if (!this.getValue(tr, '17'))
65 return undefined;
66 const l18 = this.getValue(tr, '18');
67 const l19 = undefined; //this.getValue(tr, '19');
68 return (l18 === 0 || l18 === undefined) || (l19 === 0 || l19 === undefined);
69 }, 'Line 18 and 19 both 0 or blank?'),
70
71 '21': new ComputedLine((tr: TaxReturn): number | undefined => {
72 if (!this.getValue(tr, '17'))
73 return undefined;
74 const filingStatus = tr.getForm(Form1040).getInput('filingStatus');
75 const limit = filingStatus == FilingStatus.MarriedFilingSeparate ? -1500 : -3000;
76 return Math.min(this.getValue(tr, '16'), limit);
77 }, 'Net capital loss'),
78 };
79 };