From 08a456cf2b383386f08f48b371157a4605eb58f0 Mon Sep 17 00:00:00 2001 From: Todd Rizzolo Date: Fri, 22 Nov 2024 10:48:38 -0700 Subject: [PATCH] Add unreported assets chapter --- .../chapters/10-unreported-assets/index.js | 6 + .../unreportedAssetPages.js | 194 ++++++++++++++++++ .../income-and-asset-statement/config/form.js | 2 + .../income-and-asset-statement/helpers.js | 3 + 4 files changed, 205 insertions(+) create mode 100644 src/applications/income-and-asset-statement/config/chapters/10-unreported-assets/index.js create mode 100644 src/applications/income-and-asset-statement/config/chapters/10-unreported-assets/unreportedAssetPages.js diff --git a/src/applications/income-and-asset-statement/config/chapters/10-unreported-assets/index.js b/src/applications/income-and-asset-statement/config/chapters/10-unreported-assets/index.js new file mode 100644 index 000000000000..70b7042f77cb --- /dev/null +++ b/src/applications/income-and-asset-statement/config/chapters/10-unreported-assets/index.js @@ -0,0 +1,6 @@ +import { unreportedAssetPages } from './unreportedAssetPages'; + +export default { + title: 'Assets previously not reported information', + pages: unreportedAssetPages, +}; diff --git a/src/applications/income-and-asset-statement/config/chapters/10-unreported-assets/unreportedAssetPages.js b/src/applications/income-and-asset-statement/config/chapters/10-unreported-assets/unreportedAssetPages.js new file mode 100644 index 000000000000..4f211ab3e67c --- /dev/null +++ b/src/applications/income-and-asset-statement/config/chapters/10-unreported-assets/unreportedAssetPages.js @@ -0,0 +1,194 @@ +import React from 'react'; +import merge from 'lodash/merge'; +import { + arrayBuilderItemFirstPageTitleUI, + arrayBuilderItemSubsequentPageTitleUI, + arrayBuilderYesNoSchema, + arrayBuilderYesNoUI, + 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, + otherAssetOwnerRelationshipExplanationRequired, +} from '../../../helpers'; +import { relationshipLabels } from '../../../labels'; + +/** @type {ArrayBuilderOptions} */ +const options = { + arrayPath: 'unreportedAssets', + nounSingular: 'asset previously not reported', + nounPlural: 'assets previously not reported', + required: false, + isItemIncomplete: item => + !item?.assetOwnerRelationship || + !item.ownedPortionValue || + !item.assetType || + !item.assetLocation, // include all required fields here + maxItems: 5, + text: { + getItemName: () => 'Unreported Asset', + cardDescription: item => + item?.ownedPortionValue && ( + + ), + reviewAddButtonText: 'Add another unreported asset', + alertMaxItems: + 'You have added the maximum number of allowed unreported assets for this application. You may edit or delete an unreported asset or choose to continue the application.', + alertItemUpdated: 'Your unreported asset information has been updated', + alertItemDeleted: 'Your unreported asset information has been deleted', + cancelAddTitle: 'Cancel adding this unreported asset', + cancelAddButtonText: 'Cancel adding this unreported asset', + cancelAddYes: 'Yes, cancel adding this unreported asset', + cancelAddNo: 'No', + cancelEditTitle: 'Cancel editing this unreported asset', + cancelEditYes: 'Yes, cancel editing this unreported asset', + cancelEditNo: 'No', + deleteTitle: 'Delete this unreported asset', + deleteYes: 'Yes, delete this unreported asset', + deleteNo: 'No', + }, +}; + +/** + * Cards are populated on this page above the uiSchema if items are present + * + * @returns {PageSchema} + */ +const summaryPage = { + uiSchema: { + 'view:isAddingUnreportedAssets': arrayBuilderYesNoUI( + options, + { + title: + 'Do you or your dependents have any assets not already reported?', + labels: { + Y: 'Yes, I have an asset to report', + N: 'No, I don’t have any assets to report', + }, + }, + { + title: 'Do you have any more unreported assets to report?', + labels: { + Y: 'Yes, I have another asset to report', + N: 'No, I don’t have anymore assets to report', + }, + }, + ), + }, + schema: { + type: 'object', + properties: { + 'view:isAddingUnreportedAssets': arrayBuilderYesNoSchema, + }, + required: ['view:isAddingUnreportedAssets'], + }, +}; + +/** @returns {PageSchema} */ +const relationshipPage = { + uiSchema: { + ...arrayBuilderItemFirstPageTitleUI({ + title: 'Unreported asset', + nounSingular: options.nounSingular, + }), + assetOwnerRelationship: radioUI({ + title: 'What is the asset owner’s relationship to the Veteran?', + labels: relationshipLabels, + }), + otherAssetOwnerRelationshipType: { + 'ui:title': 'Tell us the type of relationship', + 'ui:webComponentField': VaTextInputField, + 'ui:options': { + expandUnder: 'assetOwnerRelationship', + expandUnderCondition: 'OTHER', + }, + 'ui:required': (formData, index) => + otherAssetOwnerRelationshipExplanationRequired(formData, index), + }, + }, + schema: { + type: 'object', + properties: { + assetOwnerRelationship: radioSchema(Object.keys(relationshipLabels)), + otherAssetOwnerRelationshipType: { type: 'string' }, + }, + required: ['assetOwnerRelationship'], + }, +}; + +/** @returns {PageSchema} */ +const assetTypePage = { + uiSchema: { + ...arrayBuilderItemSubsequentPageTitleUI('Unreported asset'), + assetType: textUI({ + title: 'What is the type of asset?', + hint: 'Cash, art, etc', + }), + ownedPortionValue: merge( + {}, + currencyUI('What is the value of your portion of the property?'), + { + 'ui:options': { + classNames: 'schemaform-currency-input-v3', + }, + }, + ), + assetLocation: textUI({ + title: 'Where is the asset located?', + hint: 'Financial institution, property address, etc.', + }), + }, + schema: { + type: 'object', + properties: { + assetType: textSchema, + ownedPortionValue: { type: 'number' }, + assetLocation: textSchema, + }, + required: ['assetType', 'ownedPortionValue', 'assetLocation'], + }, +}; + +export const unreportedAssetPages = arrayBuilderPages(options, pageBuilder => ({ + unreportedAssetPagesSummary: pageBuilder.summaryPage({ + title: 'Unreported assets', + path: 'unreported-assets-summary', + uiSchema: summaryPage.uiSchema, + schema: summaryPage.schema, + }), + unreportedAssetRelationshipPage: pageBuilder.itemPage({ + title: 'Unreported asset owner relationship', + path: 'unreported-assets/:index/relationship', + uiSchema: relationshipPage.uiSchema, + schema: relationshipPage.schema, + }), + unreportedAssetTypePage: pageBuilder.itemPage({ + title: 'Unreported asset type', + path: 'unreported-assets/:index/asset-type', + uiSchema: assetTypePage.uiSchema, + schema: assetTypePage.schema, + }), +})); diff --git a/src/applications/income-and-asset-statement/config/form.js b/src/applications/income-and-asset-statement/config/form.js index 1b001e98730a..2c9ad8579b51 100644 --- a/src/applications/income-and-asset-statement/config/form.js +++ b/src/applications/income-and-asset-statement/config/form.js @@ -15,6 +15,7 @@ import royaltiesAndOtherProperties from './chapters/06-royalties-and-other-prope 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'; // const { } = fullSchema.properties; @@ -67,6 +68,7 @@ const formConfig = { assetTransfers, trusts, annuities, + unreportedAssets, }, }; diff --git a/src/applications/income-and-asset-statement/helpers.js b/src/applications/income-and-asset-statement/helpers.js index ac2e5ce268eb..1efb52604afa 100644 --- a/src/applications/income-and-asset-statement/helpers.js +++ b/src/applications/income-and-asset-statement/helpers.js @@ -11,6 +11,9 @@ export const formatCurrency = num => `$${num.toLocaleString()}`; export const monthlyMedicalReimbursementAmountRequired = (form, index) => get(['trusts', index, 'monthlyMedicalReimbursementAmount'], form); +export const otherAssetOwnerRelationshipExplanationRequired = (form, index) => + get(['unreportedAssets', index, 'assetOwnerRelationship'], form) === 'OTHER'; + export const otherRecipientRelationshipExplanationRequired = ( form, index,