Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add discontinued incomes section #33264

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,304 @@
import React from 'react';
import merge from 'lodash/merge';
import {
arrayBuilderItemFirstPageTitleUI,
arrayBuilderItemSubsequentPageTitleUI,
arrayBuilderYesNoSchema,
arrayBuilderYesNoUI,
currentOrPastDateUI,
currentOrPastDateSchema,
radioUI,
radioSchema,
textUI,
textSchema,
} from '~/platform/forms-system/src/js/web-component-patterns';
import currencyUI from 'platform/forms-system/src/js/definitions/currency';
import { VaTextInputField } from 'platform/forms-system/src/js/web-component-fields';
import { arrayBuilderPages } from '~/platform/forms-system/src/js/patterns/array-builder';
import {
formatCurrency,
otherRecipientRelationshipExplanationRequired,
recipientNameRequired,
showRecipientName,
} from '../../../helpers';
import { incomeFrequencyLabels, relationshipLabels } from '../../../labels';

/** @type {ArrayBuilderOptions} */
const options = {
arrayPath: 'discontinuedIncomes',
nounSingular: 'discontinued income',
nounPlural: 'discontinued incomes',
required: false,
isItemIncomplete: item =>
!item?.recipientRelationship ||
!item.payer ||
!item.incomeType ||
!item.incomeFrequency ||
!item.incomeLastReceivedDate ||
!item.grossAnnualAmount, // include all required fields here
maxItems: 5,
text: {
getItemName: () => 'Discontinued income',
cardDescription: item =>
item?.grossAnnualAmount && (
<ul className="u-list-no-bullets vads-u-padding-left--0 vads-u-font-weight--normal">
<li>
Income relationship:{' '}
<span className="vads-u-font-weight--bold">
{relationshipLabels[item.recipientRelationship]}
</span>
</li>
<li>
Income type:{' '}
<span className="vads-u-font-weight--bold">{item.incomeType}</span>
</li>
<li>
Gross annual amount:{' '}
<span className="vads-u-font-weight--bold">
{formatCurrency(item.grossAnnualAmount)}
</span>
</li>
</ul>
),
reviewAddButtonText: 'Add another discontinued income',
alertMaxItems:
'You have added the maximum number of allowed discontinued incomes for this application. You may edit or delete an discontinued income or choose to continue the application.',
alertItemUpdated: 'Your discontinued income information has been updated',
alertItemDeleted: 'Your discontinued income information has been deleted',
cancelAddTitle: 'Cancel adding this discontinued income',
cancelAddButtonText: 'Cancel adding this discontinued income',
cancelAddYes: 'Yes, cancel adding this discontinued income',
cancelAddNo: 'No',
cancelEditTitle: 'Cancel editing this discontinued income',
cancelEditYes: 'Yes, cancel editing this discontinued income',
cancelEditNo: 'No',
deleteTitle: 'Delete this discontinued income',
deleteYes: 'Yes, delete this discontinued income',
deleteNo: 'No',
},
};

/**
* Cards are populated on this page above the uiSchema if items are present
*
* @returns {PageSchema}
*/
const summaryPage = {
uiSchema: {
'view:isAddingDiscontinuedIncomes': arrayBuilderYesNoUI(
options,
{
title:
'Did you or your dependents receive income that has stopped or is no longer being received within the last calendar year?',
labels: {
Y: 'Yes, I have a discontinued income to report',
N: 'No, I don’t have any discontinued incomes to report',
},
},
{
title: 'Do you have any more discontinued incomes to report?',
labels: {
Y: 'Yes, I have another discontinued income to report',
N: 'No, I don’t have anymore discontinued incomes to report',
},
},
),
},
schema: {
type: 'object',
properties: {
'view:isAddingDiscontinuedIncomes': arrayBuilderYesNoSchema,
},
required: ['view:isAddingDiscontinuedIncomes'],
},
};

/** @returns {PageSchema} */
const relationshipPage = {
uiSchema: {
...arrayBuilderItemFirstPageTitleUI({
title: 'Discontinued income relationship',
nounSingular: options.nounSingular,
}),
recipientRelationship: radioUI({
title: 'What is the income recipient’s relationship to the Veteran?',
labels: relationshipLabels,
}),
otherRecipientRelationshipType: {
'ui:title': 'Tell us the type of relationship',
'ui:webComponentField': VaTextInputField,
'ui:options': {
expandUnder: 'recipientRelationship',
expandUnderCondition: 'OTHER',
},
'ui:required': (formData, index) =>
otherRecipientRelationshipExplanationRequired(
formData,
index,
'discontinuedIncomes',
),
},
recipientName: {
'ui:title': 'Tell us the income recipient’s name',
'ui:webComponentField': VaTextInputField,
'ui:options': {
hint: 'Only needed if child, parent, custodian of child, or other',
expandUnder: 'recipientRelationship',
expandUnderCondition: showRecipientName,
},
'ui:required': (formData, index) =>
recipientNameRequired(formData, index, 'discontinuedIncomes'),
},
},
schema: {
type: 'object',
properties: {
recipientRelationship: radioSchema(Object.keys(relationshipLabels)),
otherRecipientRelationshipType: { type: 'string' },
recipientName: textSchema,
},
required: ['recipientRelationship'],
},
};

/** @returns {PageSchema} */
const incomePayerPage = {
uiSchema: {
...arrayBuilderItemSubsequentPageTitleUI('Discontinued income payer'),
payer: textUI({
title: 'Income payer name',
hint: 'Name of business, financial institution, etc.',
}),
},
schema: {
type: 'object',
properties: {
payer: textSchema,
},
required: ['payer'],
},
};

/** @returns {PageSchema} */
const incomeTypePage = {
uiSchema: {
...arrayBuilderItemSubsequentPageTitleUI('Discontinued income type'),
incomeType: textUI({
title: 'What is the type of income received?',
hint: 'Interest, dividends, etc',
}),
},
schema: {
type: 'object',
properties: {
incomeType: textSchema,
},
required: ['incomeType'],
},
};

/** @returns {PageSchema} */
const incomeFrequencyPage = {
uiSchema: {
...arrayBuilderItemSubsequentPageTitleUI('Discontinued income frequency'),
incomeFrequency: radioUI({
title: 'What is the frequency of the income received?',
labels: incomeFrequencyLabels,
}),
},
schema: {
type: 'object',
properties: {
incomeFrequency: radioSchema(Object.keys(incomeFrequencyLabels)),
},
required: ['incomeFrequency'],
},
};

/** @returns {PageSchema} */
const incomeDatePage = {
uiSchema: {
...arrayBuilderItemSubsequentPageTitleUI('Discontinued income date'),
incomeLastReceivedDate: currentOrPastDateUI(
'When was the income last paid?',
),
},
schema: {
type: 'object',
properties: {
incomeLastReceivedDate: currentOrPastDateSchema,
},
required: ['incomeLastReceivedDate'],
},
};

/** @returns {PageSchema} */
const incomeAmountPage = {
uiSchema: {
...arrayBuilderItemSubsequentPageTitleUI('Discontinued income amount'),
grossAnnualAmount: merge(
{},
currencyUI('What was the gross annual amount reported to the IRS?'),
{
'ui:options': {
classNames: 'schemaform-currency-input-v3',
},
},
),
},
schema: {
type: 'object',
properties: {
grossAnnualAmount: { type: 'number' },
},
required: ['grossAnnualAmount'],
},
};

export const discontinuedIncomePages = arrayBuilderPages(
options,
pageBuilder => ({
discontinuedIncomePagesSummary: pageBuilder.summaryPage({
title: 'Discontinued incomes',
path: 'discontinued-incomes-summary',
uiSchema: summaryPage.uiSchema,
schema: summaryPage.schema,
}),
discontinuedIncomeRelationshipPage: pageBuilder.itemPage({
title: 'Discontinued income relationship',
path: 'discontinued-incomes/:index/relationship',
uiSchema: relationshipPage.uiSchema,
schema: relationshipPage.schema,
}),
discontinuedIncomePayerPage: pageBuilder.itemPage({
title: 'Discontinued income payer',
path: 'discontinued-incomes/:index/payer',
uiSchema: incomePayerPage.uiSchema,
schema: incomePayerPage.schema,
}),
discontinuedIncomeTypePage: pageBuilder.itemPage({
title: 'Discontinued income type',
path: 'discontinued-incomes/:index/type',
uiSchema: incomeTypePage.uiSchema,
schema: incomeTypePage.schema,
}),
discontinuedIncomeFrequencyPage: pageBuilder.itemPage({
title: 'Discontinued income frequency',
path: 'discontinued-incomes/:index/frequency',
uiSchema: incomeFrequencyPage.uiSchema,
schema: incomeFrequencyPage.schema,
}),
discontinuedIncomeDatePage: pageBuilder.itemPage({
title: 'Discontinued income date',
path: 'discontinued-incomes/:index/date',
uiSchema: incomeDatePage.uiSchema,
schema: incomeDatePage.schema,
}),
discontinuedIncomeAmountPage: pageBuilder.itemPage({
title: 'Discontinued income amount',
path: 'discontinued-incomes/:index/amount',
uiSchema: incomeAmountPage.uiSchema,
schema: incomeAmountPage.schema,
}),
}),
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { discontinuedIncomePages } from './discontinuedIncomePages';

export default {
title: 'Discontinued incomes information',
pages: discontinuedIncomePages,
};
2 changes: 2 additions & 0 deletions src/applications/income-and-asset-statement/config/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import assetTransfers from './chapters/07-asset-transfers';
import trusts from './chapters/08-trusts';
import annuities from './chapters/09-annuities';
import unreportedAssets from './chapters/10-unreported-assets';
import discontinuedIncomes from './chapters/11-discontinued-incomes';

// const { } = fullSchema.properties;

Expand Down Expand Up @@ -69,6 +70,7 @@ const formConfig = {
trusts,
annuities,
unreportedAssets,
discontinuedIncomes,
},
};

Expand Down
6 changes: 6 additions & 0 deletions src/applications/income-and-asset-statement/labels.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ export const claimantTypeLabels = {
CUSTODIAN: 'Custodian of child beneficiary',
};

export const incomeFrequencyLabels = {
RECURRING: 'Recurring',
IRREGULAR: 'Irregular',
ONE_TIME: 'One time payment',
};

export const incomeTypeLabels = {
SOCIAL_SECURITY: 'Social Security',
PENSION_RETIREMENT: 'Pension or retirement income',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,17 @@
"assetLocation": "Global Investments LLC, Portfolio ID #987654321"
}
],
"view:isAddingDiscontinuedIncomes": true,
"discontinuedIncomes": [
{
"recipientRelationship": "VETERAN",
"payer": "Social Security Administration",
"incomeType": "Social Security",
"incomeFrequency": "RECURRING",
"incomeLastReceivedDate": "2023-05-15",
"grossAnnualAmount": 18000.0
}
],
"statementOfTruthSignature": "John Doe"
}
}
Loading
Loading