+
+export interface CapitalLossCarryoverWorksheetInput {
+ priorYearTaxableIncome: number;
+ priorYearSchedDGainOrLoss: number; // This is the value reported on F1040.
+ priorYearNetShortTermGainOrLoss: number;
+ priorYearNetLongTermGainOrLoss: number;
+};
+
+export class CapitalLossCarryoverWorksheet extends Form<CapitalLossCarryoverWorksheetInput> {
+ readonly name = 'Capital Loss Carryover Worksheet';
+
+ readonly lines = {
+ '1': new InputLine<CapitalLossCarryoverWorksheetInput>('priorYearTaxableIncome'),
+ '2': new ComputedLine((tr): number => Math.abs(this.getInput('priorYearSchedDGainOrLoss')), 'Prior year net loss as a positive amount'),
+ '3': new ComputedLine((tr): number => clampToZero(sumFormLines(tr, this, ['1', '2']))),
+ '4': new ComputedLine((tr): number => Math.min(this.getValue(tr, '2'), this.getValue(tr, '3'))),
+ '5': new ComputedLine((tr): number => {
+ const stgl = this.getInput('priorYearNetShortTermGainOrLoss');
+ if (stgl > 0)
+ return 0;
+ return Math.abs(stgl);
+ }, 'Prior year short-term capital loss as a positive amount'),
+ '6': new ComputedLine((tr): number => clampToZero(this.getInput('priorYearNetLongTermGainOrLoss'))),
+ '7': new ComputedLine((tr): number => sumFormLines(tr, this, ['4', '6'])),
+ '8': new ComputedLine((tr): number => {
+ const l5 = this.getValue(tr, '5');
+ if (l5 <= 0)
+ return 0;
+ return clampToZero(l5 - this.getValue(tr, '7'))
+ }, 'Short-term capital loss carryover'),
+ '9': new ComputedLine((tr): number => {
+ const ltgl = this.getInput('priorYearNetLongTermGainOrLoss');
+ if (ltgl > 0)
+ return 0;
+ return Math.abs(ltgl);
+ }, 'Prior year long-term capital loss as a positive amount'),
+ '10': new ComputedLine((tr): number => clampToZero(this.getInput('priorYearNetShortTermGainOrLoss'))),
+ '11': new ComputedLine((tr): number => clampToZero(this.getValue(tr, '4') - this.getValue(tr, '5'))),
+ '12': new ComputedLine((tr): number => sumFormLines(tr, this, ['10', '11'])),
+ '13': new ComputedLine((tr): number => {
+ const l9 = this.getValue(tr, '9');
+ if (l9 <= 0)
+ return 0;
+ return clampToZero(l9 - this.getValue(tr, '12'));
+ }, 'Long-term capital loss carryover'),
+ };
+};