From ecda0af50ef9878efb9223f3c3d7ec5b6418f952 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Mon, 19 Feb 2024 05:30:33 +0100 Subject: [PATCH 01/47] add taxRates propTypes to policy key --- src/pages/workspace/withPolicy.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pages/workspace/withPolicy.tsx b/src/pages/workspace/withPolicy.tsx index 3b10b9fb209c..f6ea9470ade7 100644 --- a/src/pages/workspace/withPolicy.tsx +++ b/src/pages/workspace/withPolicy.tsx @@ -6,6 +6,7 @@ import React, {forwardRef} from 'react'; import type {OnyxEntry} from 'react-native-onyx'; import {withOnyx} from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; +import taxPropTypes from '@components/taxPropTypes'; import {translatableTextPropTypes} from '@libs/Localize'; import type {BottomTabNavigatorParamList, CentralPaneNavigatorParamList, SettingsNavigatorParamList} from '@navigation/types'; import policyMemberPropType from '@pages/policyMemberPropType'; @@ -80,6 +81,8 @@ const policyPropTypes = { tax: PropTypes.shape({ trackingEnabled: PropTypes.bool, }), + + taxRates: taxPropTypes, }), /** The employee list of this policy */ From b5e8ed92f0e5a2fb4cceb171ec17cf251c6682d9 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Mon, 19 Feb 2024 05:33:22 +0100 Subject: [PATCH 02/47] use policy propTypes temp_confirmation list --- .../MoneyTemporaryForRefactorRequestConfirmationList.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js index ad9a14fc67bd..de8068d6c0e0 100755 --- a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js +++ b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js @@ -23,6 +23,7 @@ import * as ReceiptUtils from '@libs/ReceiptUtils'; import * as ReportUtils from '@libs/ReportUtils'; import playSound, {SOUNDS} from '@libs/Sound'; import * as TransactionUtils from '@libs/TransactionUtils'; +import {policyPropTypes} from '@pages/workspace/withPolicy'; import * as IOU from '@userActions/IOU'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -167,6 +168,10 @@ const propTypes = { /** Collection of tax rates attached to a policy */ policyTaxRates: taxPropTypes, + /* Onyx Props */ + /** The policy of the report */ + policy: policyPropTypes.policy, + /** Transaction that represents the money request */ transaction: transactionPropTypes, }; From 9c57826f92988a285ebb17ff7ec1b5f57655c6b0 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Mon, 19 Feb 2024 05:35:17 +0100 Subject: [PATCH 03/47] use policy propTypes on money request confirmation list --- src/components/MoneyRequestConfirmationList.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index cebd885e2325..4082d1a7d632 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -24,6 +24,7 @@ import * as ReceiptUtils from '@libs/ReceiptUtils'; import * as ReportUtils from '@libs/ReportUtils'; import * as TransactionUtils from '@libs/TransactionUtils'; import {iouDefaultProps, iouPropTypes} from '@pages/iou/propTypes'; +import {policyPropTypes} from '@pages/workspace/withPolicy'; import * as IOU from '@userActions/IOU'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -166,6 +167,10 @@ const propTypes = { /** Collection of tags attached to a policy */ policyTags: tagPropTypes, + /* Onyx Props */ + /** The policy of the report */ + policy: policyPropTypes.policy, + /* Onyx Props */ /** Collection of tax rates attached to a policy */ policyTaxRates: taxPropTypes, From b74b5858c6f7dd154b97c3306abf664e5317ef6f Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Mon, 19 Feb 2024 05:44:28 +0100 Subject: [PATCH 04/47] use taxRates from policy key --- ...eyTemporaryForRefactorRequestConfirmationList.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js index de8068d6c0e0..5b22d15b5aa1 100755 --- a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js +++ b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js @@ -237,6 +237,7 @@ function MoneyTemporaryForRefactorRequestConfirmationList({ onToggleBillable, payeePersonalDetails, policy, + policy: {taxRates}, policyCategories, policyID, policyTags, @@ -299,8 +300,8 @@ function MoneyTemporaryForRefactorRequestConfirmationList({ ); const formattedTaxAmount = CurrencyUtils.convertToDisplayString(transaction.taxAmount, iouCurrencyCode); - const defaultTaxKey = policyTaxRates.defaultExternalID; - const defaultTaxName = (defaultTaxKey && `${policyTaxRates.taxes[defaultTaxKey].name} (${policyTaxRates.taxes[defaultTaxKey].value}) • ${translate('common.default')}`) || ''; + const defaultTaxKey = taxRates.defaultExternalID; + const defaultTaxName = (defaultTaxKey && `${taxRates.taxes[defaultTaxKey].name} (${taxRates.taxes[defaultTaxKey].value}) • ${translate('common.default')}`) || ''; const taxRateTitle = (transaction.taxRate && transaction.taxRate.text) || defaultTaxName; const isFocused = useIsFocused(); @@ -795,10 +796,10 @@ function MoneyTemporaryForRefactorRequestConfirmationList({ { item: ( Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_TAX_RATE.getRoute(iouType, transaction.transactionID, reportID, Navigation.getActiveRouteWithoutParams()))} @@ -812,10 +813,10 @@ function MoneyTemporaryForRefactorRequestConfirmationList({ { item: ( Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_TAX_AMOUNT.getRoute(iouType, transaction.transactionID, reportID, Navigation.getActiveRouteWithoutParams()))} From bf33e31439c45bc0d5bdd462dae3f5ce9c174996 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Mon, 19 Feb 2024 05:46:04 +0100 Subject: [PATCH 05/47] remove policyTaxRates props and ONYX key --- .../MoneyTemporaryForRefactorRequestConfirmationList.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js index 5b22d15b5aa1..8d637d961aef 100755 --- a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js +++ b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js @@ -164,10 +164,6 @@ const propTypes = { /** Collection of tags attached to a policy */ policyTags: tagPropTypes, - /* Onyx Props */ - /** Collection of tax rates attached to a policy */ - policyTaxRates: taxPropTypes, - /* Onyx Props */ /** The policy of the report */ policy: policyPropTypes.policy, @@ -206,7 +202,6 @@ const defaultProps = { isDistanceRequest: false, shouldShowSmartScanFields: true, isPolicyExpenseChat: false, - policyTaxRates: {}, }; function MoneyTemporaryForRefactorRequestConfirmationList({ @@ -249,7 +244,6 @@ function MoneyTemporaryForRefactorRequestConfirmationList({ session: {accountID}, shouldShowSmartScanFields, transaction, - policyTaxRates, }) { const theme = useTheme(); const styles = useThemeStyles(); @@ -945,8 +939,5 @@ export default compose( policy: { key: ({policyID}) => `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, }, - policyTaxRates: { - key: ({policyID}) => `${ONYXKEYS.COLLECTION.POLICY_TAX_RATE}${policyID}`, - }, }), )(MoneyTemporaryForRefactorRequestConfirmationList); From 3ca147b9673cbda8857a2b0b92769b92b52c1f78 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Mon, 19 Feb 2024 06:02:10 +0100 Subject: [PATCH 06/47] use taxRates from policy key --- src/components/MoneyRequestConfirmationList.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index 4082d1a7d632..927bcb88ff3f 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -269,8 +269,9 @@ function MoneyRequestConfirmationList(props) { ); const formattedTaxAmount = CurrencyUtils.convertToDisplayString(props.transaction.taxAmount, props.iouCurrencyCode); - const defaultTaxKey = props.policyTaxRates.defaultExternalID; - const defaultTaxName = (defaultTaxKey && `${props.policyTaxRates.taxes[defaultTaxKey].name} (${props.policyTaxRates.taxes[defaultTaxKey].value}) • ${translate('common.default')}`) || ''; + const taxRates = lodashGet(props.policy, 'taxRates', {}); + const defaultTaxKey = taxRates.defaultExternalID; + const defaultTaxName = (defaultTaxKey && `${taxRates.taxes[defaultTaxKey].name} (${taxRates.taxes[defaultTaxKey].value}) • ${translate('common.default')}`) || ''; const taxRateTitle = (props.transaction.taxRate && props.transaction.taxRate.text) || defaultTaxName; const isFocused = useIsFocused(); @@ -818,7 +819,7 @@ function MoneyRequestConfirmationList(props) { @@ -835,7 +836,7 @@ function MoneyRequestConfirmationList(props) { From 8e10b1f66bfc1bc101f69dfcd553bfab087a2e38 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Mon, 19 Feb 2024 06:06:15 +0100 Subject: [PATCH 07/47] remove policyTaxRates props and ONYX key --- src/components/MoneyRequestConfirmationList.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index 927bcb88ff3f..f0144e344778 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -171,10 +171,6 @@ const propTypes = { /** The policy of the report */ policy: policyPropTypes.policy, - /* Onyx Props */ - /** Collection of tax rates attached to a policy */ - policyTaxRates: taxPropTypes, - /** Holds data related to Money Request view state, rather than the underlying Money Request data. */ iou: iouPropTypes, }; @@ -211,7 +207,6 @@ const defaultProps = { shouldShowSmartScanFields: true, isPolicyExpenseChat: false, iou: iouDefaultProps, - policyTaxRates: {}, }; function MoneyRequestConfirmationList(props) { @@ -891,9 +886,6 @@ export default compose( policy: { key: ({policyID}) => `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, }, - policyTaxRates: { - key: ({policyID}) => `${ONYXKEYS.COLLECTION.POLICY_TAX_RATE}${policyID}`, - }, iou: { key: ONYXKEYS.IOU, }, From 77347eb25d6301d17e6e7c0463cd405b11f58481 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Mon, 19 Feb 2024 06:10:34 +0100 Subject: [PATCH 08/47] get taxRates with lodashGet --- src/components/MoneyRequestConfirmationList.js | 2 +- .../MoneyTemporaryForRefactorRequestConfirmationList.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index f0144e344778..6ae082a88903 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -228,6 +228,7 @@ function MoneyRequestConfirmationList(props) { const {unit, rate, currency} = props.mileageRate; const distance = lodashGet(transaction, 'routes.route0.distance', 0); const shouldCalculateDistanceAmount = props.isDistanceRequest && props.iouAmount === 0; + const taxRates = lodashGet(props.policy, 'taxRates', {}); // A flag for showing the categories field const shouldShowCategories = props.isPolicyExpenseChat && (props.iouCategory || OptionsListUtils.hasEnabledOptions(_.values(props.policyCategories))); @@ -264,7 +265,6 @@ function MoneyRequestConfirmationList(props) { ); const formattedTaxAmount = CurrencyUtils.convertToDisplayString(props.transaction.taxAmount, props.iouCurrencyCode); - const taxRates = lodashGet(props.policy, 'taxRates', {}); const defaultTaxKey = taxRates.defaultExternalID; const defaultTaxName = (defaultTaxKey && `${taxRates.taxes[defaultTaxKey].name} (${taxRates.taxes[defaultTaxKey].value}) • ${translate('common.default')}`) || ''; const taxRateTitle = (props.transaction.taxRate && props.transaction.taxRate.text) || defaultTaxName; diff --git a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js index 8d637d961aef..1efe15a9cd92 100755 --- a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js +++ b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js @@ -232,7 +232,6 @@ function MoneyTemporaryForRefactorRequestConfirmationList({ onToggleBillable, payeePersonalDetails, policy, - policy: {taxRates}, policyCategories, policyID, policyTags, @@ -257,6 +256,7 @@ function MoneyTemporaryForRefactorRequestConfirmationList({ const {unit, rate, currency} = mileageRate; const distance = lodashGet(transaction, 'routes.route0.distance', 0); const shouldCalculateDistanceAmount = isDistanceRequest && iouAmount === 0; + const taxRates = lodashGet(policy, 'taxRates', {}); // A flag for showing the categories field const shouldShowCategories = isPolicyExpenseChat && (iouCategory || OptionsListUtils.hasEnabledOptions(_.values(policyCategories))); From 081ca79d71e29c02927a9eb9a3758ae8fb0d2119 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Mon, 19 Feb 2024 06:16:52 +0100 Subject: [PATCH 09/47] remove unused import --- src/components/MoneyRequestConfirmationList.js | 1 - .../MoneyTemporaryForRefactorRequestConfirmationList.js | 1 - 2 files changed, 2 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index 6ae082a88903..a2909ce51a7e 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -42,7 +42,6 @@ import SettlementButton from './SettlementButton'; import ShowMoreButton from './ShowMoreButton'; import Switch from './Switch'; import tagPropTypes from './tagPropTypes'; -import taxPropTypes from './taxPropTypes'; import Text from './Text'; import transactionPropTypes from './transactionPropTypes'; import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsDefaultProps, withCurrentUserPersonalDetailsPropTypes} from './withCurrentUserPersonalDetails'; diff --git a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js index 1efe15a9cd92..1cf81313214e 100755 --- a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js +++ b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js @@ -42,7 +42,6 @@ import ReceiptEmptyState from './ReceiptEmptyState'; import SettlementButton from './SettlementButton'; import Switch from './Switch'; import tagPropTypes from './tagPropTypes'; -import taxPropTypes from './taxPropTypes'; import Text from './Text'; import transactionPropTypes from './transactionPropTypes'; import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsDefaultProps, withCurrentUserPersonalDetailsPropTypes} from './withCurrentUserPersonalDetails'; From 3c26cf64c53198f1ca1a12dd9eb76f34f781bcd1 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Mon, 19 Feb 2024 06:23:10 +0100 Subject: [PATCH 10/47] use taxRates from policy key for IOURequestStepAmount --- src/pages/iou/request/step/IOURequestStepAmount.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.js b/src/pages/iou/request/step/IOURequestStepAmount.js index ec52b49d8b7a..6c8f35f8b694 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.js +++ b/src/pages/iou/request/step/IOURequestStepAmount.js @@ -83,6 +83,7 @@ function IOURequestStepAmount({ const originalCurrency = useRef(null); const iouRequestType = getRequestType(transaction); + const taxRates = lodashGet(policy, 'taxRates', {}); const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(ReportUtils.getRootParentReport(report)); const isTaxTrackingEnabled = isPolicyExpenseChat && lodashGet(policy, 'tax.trackingEnabled', policy.isTaxTrackingEnabled); @@ -130,7 +131,7 @@ function IOURequestStepAmount({ const amountInSmallestCurrencyUnits = CurrencyUtils.convertToBackendAmount(Number.parseFloat(amount)); if ((iouRequestType === CONST.IOU.REQUEST_TYPE.MANUAL || backTo) && isTaxTrackingEnabled) { - const taxAmount = getTaxAmount(transaction, policyTaxRates.defaultValue, amountInSmallestCurrencyUnits); + const taxAmount = getTaxAmount(transaction, taxRates.defaultValue, amountInSmallestCurrencyUnits); const taxAmountInSmallestCurrencyUnits = CurrencyUtils.convertToBackendAmount(Number.parseFloat(taxAmount)); IOU.setMoneyRequestTaxAmount(transaction.transactionID, taxAmountInSmallestCurrencyUnits); } From 1e88b6f4d10dd4c5bfc66dbf19bdcd0df2e28597 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Mon, 19 Feb 2024 06:27:23 +0100 Subject: [PATCH 11/47] remove policyTaxRates props and ONYX key for IOURequestStepAmount --- src/pages/iou/request/step/IOURequestStepAmount.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.js b/src/pages/iou/request/step/IOURequestStepAmount.js index 6c8f35f8b694..15bd1314a114 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.js +++ b/src/pages/iou/request/step/IOURequestStepAmount.js @@ -34,10 +34,6 @@ const propTypes = { /** The transaction object being modified in Onyx */ transaction: transactionPropTypes, - /* Onyx Props */ - /** Collection of tax rates attached to a policy */ - policyTaxRates: taxPropTypes, - /** The policy of the report */ policy: PropTypes.shape({ /** @@ -57,7 +53,6 @@ const propTypes = { const defaultProps = { report: {}, transaction: {}, - policyTaxRates: {}, policy: {}, }; @@ -73,7 +68,6 @@ function IOURequestStepAmount({ }, transaction, transaction: {currency}, - policyTaxRates, policy, }) { const {translate} = useLocalize(); @@ -186,9 +180,6 @@ export default compose( withWritableReportOrNotFound, withFullTransactionOrNotFound, withOnyx({ - policyTaxRates: { - key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY_TAX_RATE}${report ? report.policyID : '0'}`, - }, policy: { key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report ? report.policyID : '0'}`, }, From 079bac419eb2302fc2758f2f8a9fda05dd87f6e5 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Mon, 19 Feb 2024 06:29:30 +0100 Subject: [PATCH 12/47] add taxRates propTypes to policy for IOURequestStepAmount --- src/pages/iou/request/step/IOURequestStepAmount.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.js b/src/pages/iou/request/step/IOURequestStepAmount.js index 15bd1314a114..b1b18a3caff1 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.js +++ b/src/pages/iou/request/step/IOURequestStepAmount.js @@ -47,6 +47,7 @@ const propTypes = { tax: PropTypes.shape({ trackingEnabled: PropTypes.bool, }), + taxRates: taxPropTypes, }), }; From 2a248c3edd525f106228fad61a329e6bee0f23b1 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Mon, 19 Feb 2024 06:42:36 +0100 Subject: [PATCH 13/47] get policy from ONYX for IOURequestStepAmount --- .../iou/request/step/IOURequestStepTaxAmountPage.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepTaxAmountPage.js b/src/pages/iou/request/step/IOURequestStepTaxAmountPage.js index 02b0c3c38dd5..0955e3c853d8 100644 --- a/src/pages/iou/request/step/IOURequestStepTaxAmountPage.js +++ b/src/pages/iou/request/step/IOURequestStepTaxAmountPage.js @@ -1,4 +1,5 @@ import {useFocusEffect} from '@react-navigation/native'; +import lodashGet from 'lodash/get'; import React, {useCallback, useEffect, useRef} from 'react'; import {View} from 'react-native'; import {withOnyx} from 'react-native-onyx'; @@ -43,6 +44,7 @@ const propTypes = { const defaultProps = { report: {}, transaction: {}, + policy: {}, policyTaxRates: {}, }; @@ -58,6 +60,7 @@ function IOURequestStepTaxAmountPage({ transaction, transaction: {currency}, report, + policy, policyTaxRates, }) { const {translate} = useLocalize(); @@ -69,6 +72,7 @@ function IOURequestStepTaxAmountPage({ const isSaveButtonPressed = useRef(false); const originalCurrency = useRef(null); + const taxRates = lodashGet(policy, 'taxRates', {}); useEffect(() => { if (transaction.originalCurrency) { @@ -140,7 +144,7 @@ function IOURequestStepTaxAmountPage({ isEditing={isEditing} currency={currency} amount={transaction.taxAmount} - taxAmount={getTaxAmount(transaction, policyTaxRates.defaultValue)} + taxAmount={getTaxAmount(transaction, taxRates.defaultValue)} transaction={transaction} ref={(e) => (textInput.current = e)} onCurrencyButtonPress={navigateToCurrencySelectionPage} @@ -180,5 +184,8 @@ export default compose( policyTaxRates: { key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY_TAX_RATE}${report ? report.policyID : '0'}`, }, + policy: { + key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY_TAX_RATE}${report ? report.policyID : '0'}`, + }, }), )(IOURequestStepTaxAmountPage); From 614502a5f66121d17f4b3d914df0a6fb00fd1fe5 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Mon, 19 Feb 2024 06:44:05 +0100 Subject: [PATCH 14/47] remove policyTaxRates props and ONYX key for IOURequestStepTaxAmountPage --- .../iou/request/step/IOURequestStepTaxAmountPage.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepTaxAmountPage.js b/src/pages/iou/request/step/IOURequestStepTaxAmountPage.js index 0955e3c853d8..4093d6ca04bc 100644 --- a/src/pages/iou/request/step/IOURequestStepTaxAmountPage.js +++ b/src/pages/iou/request/step/IOURequestStepTaxAmountPage.js @@ -35,17 +35,12 @@ const propTypes = { /** The transaction object being modified in Onyx */ transaction: transactionPropTypes, - - /* Onyx Props */ - /** Collection of tax rates attached to a policy */ - policyTaxRates: taxPropTypes, }; const defaultProps = { report: {}, transaction: {}, policy: {}, - policyTaxRates: {}, }; const getTaxAmount = (transaction, defaultTaxValue) => { @@ -61,7 +56,6 @@ function IOURequestStepTaxAmountPage({ transaction: {currency}, report, policy, - policyTaxRates, }) { const {translate} = useLocalize(); const styles = useThemeStyles(); @@ -181,9 +175,6 @@ export default compose( withWritableReportOrNotFound, withFullTransactionOrNotFound, withOnyx({ - policyTaxRates: { - key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY_TAX_RATE}${report ? report.policyID : '0'}`, - }, policy: { key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY_TAX_RATE}${report ? report.policyID : '0'}`, }, From 108fd3e8a04585a73c013d4b91193e7707a3a73e Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Mon, 19 Feb 2024 06:47:41 +0100 Subject: [PATCH 15/47] add taxRates propTypes to policy for IOURequestStepTaxAmountPage --- src/pages/iou/request/step/IOURequestStepTaxAmountPage.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/pages/iou/request/step/IOURequestStepTaxAmountPage.js b/src/pages/iou/request/step/IOURequestStepTaxAmountPage.js index 4093d6ca04bc..3cf5b0ce148d 100644 --- a/src/pages/iou/request/step/IOURequestStepTaxAmountPage.js +++ b/src/pages/iou/request/step/IOURequestStepTaxAmountPage.js @@ -1,5 +1,6 @@ import {useFocusEffect} from '@react-navigation/native'; import lodashGet from 'lodash/get'; +import PropTypes from 'prop-types'; import React, {useCallback, useEffect, useRef} from 'react'; import {View} from 'react-native'; import {withOnyx} from 'react-native-onyx'; @@ -35,6 +36,12 @@ const propTypes = { /** The transaction object being modified in Onyx */ transaction: transactionPropTypes, + + /** The policy of the report */ + policy: PropTypes.shape({ + /** Collection of tax rates attached to a policy */ + taxRates: taxPropTypes, + }), }; const defaultProps = { From 697bc85bb228d6d2839c86f76eeb4b95a1624a41 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Mon, 19 Feb 2024 06:50:05 +0100 Subject: [PATCH 16/47] add comments for taxRates field on policy proptypes --- src/pages/workspace/withPolicy.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/workspace/withPolicy.tsx b/src/pages/workspace/withPolicy.tsx index f6ea9470ade7..76126040652b 100644 --- a/src/pages/workspace/withPolicy.tsx +++ b/src/pages/workspace/withPolicy.tsx @@ -82,6 +82,7 @@ const policyPropTypes = { trackingEnabled: PropTypes.bool, }), + /** Collection of tax rates attached to a policy */ taxRates: taxPropTypes, }), From b051dc40de616cabf8c0bb46312526d74963ca31 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Mon, 19 Feb 2024 06:52:10 +0100 Subject: [PATCH 17/47] add comments for taxRates field on policy proptypes for IOURequestStepAmount --- src/pages/iou/request/step/IOURequestStepAmount.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.js b/src/pages/iou/request/step/IOURequestStepAmount.js index b1b18a3caff1..9fdd2bea24f4 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.js +++ b/src/pages/iou/request/step/IOURequestStepAmount.js @@ -47,6 +47,8 @@ const propTypes = { tax: PropTypes.shape({ trackingEnabled: PropTypes.bool, }), + + /** Collection of tax rates attached to a policy */ taxRates: taxPropTypes, }), }; From 80ce551f54d81974cea3db352f12e362017b6ac1 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Mon, 19 Feb 2024 07:02:50 +0100 Subject: [PATCH 18/47] use taxRates from policy key for IOURequestStepTaxRatePage --- .../request/step/IOURequestStepTaxRatePage.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepTaxRatePage.js b/src/pages/iou/request/step/IOURequestStepTaxRatePage.js index edcc8c8fa592..a3258e8df9cb 100644 --- a/src/pages/iou/request/step/IOURequestStepTaxRatePage.js +++ b/src/pages/iou/request/step/IOURequestStepTaxRatePage.js @@ -1,3 +1,4 @@ +import lodashGet from 'lodash/get'; import React from 'react'; import {withOnyx} from 'react-native-onyx'; import _ from 'underscore'; @@ -31,6 +32,7 @@ const propTypes = { }; const defaultProps = { + policy: {}, policyTaxRates: {}, transaction: {}, }; @@ -44,6 +46,7 @@ function IOURequestStepTaxRatePage({ route: { params: {backTo}, }, + policy, policyTaxRates, transaction, }) { @@ -52,13 +55,13 @@ function IOURequestStepTaxRatePage({ const navigateBack = () => { Navigation.goBack(backTo); }; - - const defaultTaxKey = policyTaxRates.defaultExternalID; - const defaultTaxName = (defaultTaxKey && `${policyTaxRates.taxes[defaultTaxKey].name} (${policyTaxRates.taxes[defaultTaxKey].value}) • ${translate('common.default')}`) || ''; + const taxRates = lodashGet(policy, 'taxRates', {}); + const defaultTaxKey = taxRates.defaultExternalID; + const defaultTaxName = (defaultTaxKey && `${taxRates.taxes[defaultTaxKey].name} (${taxRates.taxes[defaultTaxKey].value}) • ${translate('common.default')}`) || ''; const selectedTaxRate = (transaction.taxRate && transaction.taxRate.text) || defaultTaxName; const updateTaxRates = (taxes) => { - const taxAmount = getTaxAmount(policyTaxRates, taxes.text, transaction.amount); + const taxAmount = getTaxAmount(taxRates, taxes.text, transaction.amount); const amountInSmallestCurrencyUnits = CurrencyUtils.convertToBackendAmount(Number.parseFloat(taxAmount)); IOU.setMoneyRequestTaxRate(transaction.transactionID, taxes); IOU.setMoneyRequestTaxAmount(transaction.transactionID, amountInSmallestCurrencyUnits); @@ -80,7 +83,7 @@ function IOURequestStepTaxRatePage({ /> @@ -98,6 +101,9 @@ export default compose( withWritableReportOrNotFound, withFullTransactionOrNotFound, withOnyx({ + policy: { + key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY_TAX_RATE}${report ? report.policyID : '0'}`, + }, policyTaxRates: { key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY_TAX_RATE}${report ? report.policyID : '0'}`, }, From f4deedf300a403ed90b65fc068f06526f8623f63 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Mon, 19 Feb 2024 07:04:57 +0100 Subject: [PATCH 19/47] remove policyTaxRates props and ONYX key for IOURequestStepTaxRatePage --- src/pages/iou/request/step/IOURequestStepTaxRatePage.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepTaxRatePage.js b/src/pages/iou/request/step/IOURequestStepTaxRatePage.js index a3258e8df9cb..1127320acb53 100644 --- a/src/pages/iou/request/step/IOURequestStepTaxRatePage.js +++ b/src/pages/iou/request/step/IOURequestStepTaxRatePage.js @@ -23,17 +23,12 @@ const propTypes = { /** Navigation route context info provided by react navigation */ route: IOURequestStepRoutePropTypes.isRequired, - /* Onyx Props */ - /** Collection of tax rates attached to a policy */ - policyTaxRates: taxPropTypes, - /** The transaction object being modified in Onyx */ transaction: transactionPropTypes, }; const defaultProps = { policy: {}, - policyTaxRates: {}, transaction: {}, }; @@ -47,7 +42,6 @@ function IOURequestStepTaxRatePage({ params: {backTo}, }, policy, - policyTaxRates, transaction, }) { const {translate} = useLocalize(); @@ -104,8 +98,5 @@ export default compose( policy: { key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY_TAX_RATE}${report ? report.policyID : '0'}`, }, - policyTaxRates: { - key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY_TAX_RATE}${report ? report.policyID : '0'}`, - }, }), )(IOURequestStepTaxRatePage); From 52e15ef631a97e977c9a5efcb14f99ee18ecc869 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Mon, 19 Feb 2024 07:18:02 +0100 Subject: [PATCH 20/47] add taxRates propTypes to policy for IOURequestStepTaxRatePage --- src/pages/iou/request/step/IOURequestStepTaxRatePage.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/pages/iou/request/step/IOURequestStepTaxRatePage.js b/src/pages/iou/request/step/IOURequestStepTaxRatePage.js index 1127320acb53..bce55fcc9849 100644 --- a/src/pages/iou/request/step/IOURequestStepTaxRatePage.js +++ b/src/pages/iou/request/step/IOURequestStepTaxRatePage.js @@ -1,4 +1,5 @@ import lodashGet from 'lodash/get'; +import PropTypes from 'prop-types'; import React from 'react'; import {withOnyx} from 'react-native-onyx'; import _ from 'underscore'; @@ -25,6 +26,12 @@ const propTypes = { /** The transaction object being modified in Onyx */ transaction: transactionPropTypes, + + /** The policy of the report */ + policy: PropTypes.shape({ + /** Collection of tax rates attached to a policy */ + taxRates: taxPropTypes, + }), }; const defaultProps = { From 401cdec7843f72410dc539a0646f8696b77f6936 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Mon, 19 Feb 2024 07:19:40 +0100 Subject: [PATCH 21/47] update policy onyx request key for IOURequestStepTaxRatePage --- src/pages/iou/request/step/IOURequestStepTaxRatePage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepTaxRatePage.js b/src/pages/iou/request/step/IOURequestStepTaxRatePage.js index bce55fcc9849..9ba525ee0890 100644 --- a/src/pages/iou/request/step/IOURequestStepTaxRatePage.js +++ b/src/pages/iou/request/step/IOURequestStepTaxRatePage.js @@ -103,7 +103,7 @@ export default compose( withFullTransactionOrNotFound, withOnyx({ policy: { - key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY_TAX_RATE}${report ? report.policyID : '0'}`, + key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report ? report.policyID : '0'}`, }, }), )(IOURequestStepTaxRatePage); From c8434b225505df10c6d07d153675ce07e9da1acc Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Mon, 19 Feb 2024 07:20:36 +0100 Subject: [PATCH 22/47] update policy onyx request key for IOURequestStepTaxAmountPage --- src/pages/iou/request/step/IOURequestStepTaxAmountPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepTaxAmountPage.js b/src/pages/iou/request/step/IOURequestStepTaxAmountPage.js index 3cf5b0ce148d..4499f7d77b17 100644 --- a/src/pages/iou/request/step/IOURequestStepTaxAmountPage.js +++ b/src/pages/iou/request/step/IOURequestStepTaxAmountPage.js @@ -183,7 +183,7 @@ export default compose( withFullTransactionOrNotFound, withOnyx({ policy: { - key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY_TAX_RATE}${report ? report.policyID : '0'}`, + key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report ? report.policyID : '0'}`, }, }), )(IOURequestStepTaxAmountPage); From 59f6200739e86583ec68abb520ad2c44e7c07d00 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Wed, 21 Feb 2024 14:02:05 +0100 Subject: [PATCH 23/47] remove tax rates types and keys --- src/ONYXKEYS.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index 5755296f3bb5..f6d4c9e8a54e 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -276,7 +276,6 @@ const ONYXKEYS = { POLICY_CATEGORIES: 'policyCategories_', POLICY_RECENTLY_USED_CATEGORIES: 'policyRecentlyUsedCategories_', POLICY_TAGS: 'policyTags_', - POLICY_TAX_RATE: 'policyTaxRates_', POLICY_RECENTLY_USED_TAGS: 'policyRecentlyUsedTags_', POLICY_REPORT_FIELDS: 'policyReportFields_', WORKSPACE_INVITE_MEMBERS_DRAFT: 'workspaceInviteMembersDraft_', @@ -462,7 +461,6 @@ type OnyxCollectionValuesMapping = { [ONYXKEYS.COLLECTION.SELECTED_TAB]: string; [ONYXKEYS.COLLECTION.PRIVATE_NOTES_DRAFT]: string; [ONYXKEYS.COLLECTION.NEXT_STEP]: OnyxTypes.ReportNextStep; - [ONYXKEYS.COLLECTION.POLICY_TAX_RATE]: string[]; }; type OnyxValuesMapping = { From 5b30df8bd5dfc87948055694bc67b9cb2e66d8b4 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Thu, 22 Feb 2024 09:45:39 +0100 Subject: [PATCH 24/47] update tax Picker Prop Types --- src/components/TaxPicker/taxPickerPropTypes.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/components/TaxPicker/taxPickerPropTypes.js b/src/components/TaxPicker/taxPickerPropTypes.js index 289b4e19aaa4..eb5c7b0f4845 100644 --- a/src/components/TaxPicker/taxPickerPropTypes.js +++ b/src/components/TaxPicker/taxPickerPropTypes.js @@ -8,14 +8,21 @@ const propTypes = { /** Callback to fire when a tax is pressed */ onSubmit: PropTypes.func.isRequired, - /* Onyx Props */ - /** Collection of tax rates attached to a policy */ - policyTaxRates: taxPropTypes, + policy: PropTypes.shape({ + /** Collection of tax rates attached to a policy */ + taxRates: taxPropTypes, + }), + + /** + * Safe area insets required for reflecting the portion of the view, + * that is not covered by navigation bars, tab bars, toolbars, and other ancestor views. + */ + insets: safeAreaInsetPropTypes.isRequired, }; const defaultProps = { selectedTaxRate: '', - policyTaxRates: {}, + policy: {}, }; export {propTypes, defaultProps}; From 7c38ea837ce1aa09097a3d785179cbf60c12481f Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Thu, 22 Feb 2024 09:52:31 +0100 Subject: [PATCH 25/47] use taxRates from policy --- src/components/TaxPicker/index.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/TaxPicker/index.js b/src/components/TaxPicker/index.js index f25a1b84bf64..71b50d7522d1 100644 --- a/src/components/TaxPicker/index.js +++ b/src/components/TaxPicker/index.js @@ -10,13 +10,15 @@ import * as TransactionUtils from '@libs/TransactionUtils'; import CONST from '@src/CONST'; import {defaultProps, propTypes} from './taxPickerPropTypes'; -function TaxPicker({selectedTaxRate, policyTaxRates, insets, onSubmit}) { +function TaxPicker({selectedTaxRate, policy, insets, onSubmit}) { const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); const {translate} = useLocalize(); const [searchValue, setSearchValue] = useState(''); - const policyTaxRatesCount = TransactionUtils.getEnabledTaxRateCount(policyTaxRates.taxes); + const taxRates = lodashGet(policy, 'taxRates', {}); + + const policyTaxRatesCount = TransactionUtils.getEnabledTaxRateCount(taxRates.taxes); const isTaxRatesCountBelowThreshold = policyTaxRatesCount < CONST.TAX_RATES_LIST_THRESHOLD; const shouldShowTextInput = !isTaxRatesCountBelowThreshold; @@ -54,10 +56,10 @@ function TaxPicker({selectedTaxRate, policyTaxRates, insets, onSubmit}) { false, false, true, - policyTaxRates, + taxRates, ); return policyTaxRatesOptions; - }, [policyTaxRates, searchValue, selectedOptions]); + }, [taxRates, searchValue, selectedOptions]); const selectedOptionKey = lodashGet(_.filter(lodashGet(sections, '[0].data', []), (taxRate) => taxRate.searchText === selectedTaxRate)[0], 'keyForList'); From c93638a28a2543afcf6cac19c05d011d4b0f7ced Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Thu, 22 Feb 2024 10:01:21 +0100 Subject: [PATCH 26/47] add missing import --- src/components/TaxPicker/taxPickerPropTypes.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/TaxPicker/taxPickerPropTypes.js b/src/components/TaxPicker/taxPickerPropTypes.js index eb5c7b0f4845..5f6f1778029e 100644 --- a/src/components/TaxPicker/taxPickerPropTypes.js +++ b/src/components/TaxPicker/taxPickerPropTypes.js @@ -1,5 +1,6 @@ import PropTypes from 'prop-types'; import taxPropTypes from '@components/taxPropTypes'; +import safeAreaInsetPropTypes from '@pages/safeAreaInsetPropTypes'; const propTypes = { /** The selected tax rate of an expense */ From 158afd9d6eed58e9cec60998e9e52aa641f9cafd Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Thu, 22 Feb 2024 10:03:07 +0100 Subject: [PATCH 27/47] update getFiltered options for taxRates --- src/libs/OptionsListUtils.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 80081061f340..dad4ef3ea4fb 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -112,7 +112,7 @@ type GetOptionsConfig = { canInviteUser?: boolean; includeSelectedOptions?: boolean; includePolicyTaxRates?: boolean; - policyTaxRates?: PolicyTaxRateWithDefault; + taxRates?: PolicyTaxRateWithDefault; transactionViolations?: OnyxCollection; }; @@ -141,7 +141,7 @@ type GetOptions = { currentUserOption: ReportUtils.OptionData | null | undefined; categoryOptions: CategorySection[]; tagOptions: CategorySection[]; - policyTaxRatesOptions: CategorySection[]; + taxRatesOptions: CategorySection[]; }; type PreviewConfig = {showChatPreviewLine?: boolean; forcePolicyNamePreview?: boolean}; @@ -1361,7 +1361,7 @@ function getOptions( includeSelectedOptions = false, transactionViolations = {}, includePolicyTaxRates, - policyTaxRates, + taxRates, }: GetOptionsConfig, ): GetOptions { if (includeCategories) { @@ -1374,7 +1374,7 @@ function getOptions( currentUserOption: null, categoryOptions, tagOptions: [], - policyTaxRatesOptions: [], + taxRatesOptions: [], }; } @@ -1388,12 +1388,12 @@ function getOptions( currentUserOption: null, categoryOptions: [], tagOptions, - policyTaxRatesOptions: [], + taxRatesOptions: [], }; } if (includePolicyTaxRates) { - const policyTaxRatesOptions = getTaxRatesSection(policyTaxRates, selectedOptions as Category[], searchInputValue); + const taxRatesOptions = getTaxRatesSection(taxRates, selectedOptions as Category[], searchInputValue); return { recentReports: [], @@ -1402,7 +1402,7 @@ function getOptions( currentUserOption: null, categoryOptions: [], tagOptions: [], - policyTaxRatesOptions, + taxRatesOptions, }; } @@ -1414,7 +1414,7 @@ function getOptions( currentUserOption: null, categoryOptions: [], tagOptions: [], - policyTaxRatesOptions: [], + taxRatesOptions: [], }; } @@ -1699,7 +1699,7 @@ function getOptions( currentUserOption, categoryOptions: [], tagOptions: [], - policyTaxRatesOptions: [], + taxRatesOptions: [], }; } @@ -1797,7 +1797,7 @@ function getFilteredOptions( canInviteUser = true, includeSelectedOptions = false, includePolicyTaxRates = false, - policyTaxRates: PolicyTaxRateWithDefault = {} as PolicyTaxRateWithDefault, + taxRates: PolicyTaxRateWithDefault = {} as PolicyTaxRateWithDefault, ) { return getOptions(reports, personalDetails, { betas, @@ -1818,7 +1818,7 @@ function getFilteredOptions( canInviteUser, includeSelectedOptions, includePolicyTaxRates, - policyTaxRates, + taxRates, }); } From 11157b79d25f36c336f068952f1cb89ea0c54321 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Thu, 22 Feb 2024 10:04:49 +0100 Subject: [PATCH 28/47] change all policyTaxRates variables to taxRates --- src/components/TaxPicker/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/TaxPicker/index.js b/src/components/TaxPicker/index.js index 71b50d7522d1..cb4436ab8b33 100644 --- a/src/components/TaxPicker/index.js +++ b/src/components/TaxPicker/index.js @@ -18,8 +18,8 @@ function TaxPicker({selectedTaxRate, policy, insets, onSubmit}) { const taxRates = lodashGet(policy, 'taxRates', {}); - const policyTaxRatesCount = TransactionUtils.getEnabledTaxRateCount(taxRates.taxes); - const isTaxRatesCountBelowThreshold = policyTaxRatesCount < CONST.TAX_RATES_LIST_THRESHOLD; + const taxRatesCount = TransactionUtils.getEnabledTaxRateCount(taxRates.taxes); + const isTaxRatesCountBelowThreshold = taxRatesCount < CONST.TAX_RATES_LIST_THRESHOLD; const shouldShowTextInput = !isTaxRatesCountBelowThreshold; @@ -38,7 +38,7 @@ function TaxPicker({selectedTaxRate, policy, insets, onSubmit}) { }, [selectedTaxRate]); const sections = useMemo(() => { - const {policyTaxRatesOptions} = OptionsListUtils.getFilteredOptions( + const {taxRatesOptions} = OptionsListUtils.getFilteredOptions( {}, {}, [], @@ -58,7 +58,7 @@ function TaxPicker({selectedTaxRate, policy, insets, onSubmit}) { true, taxRates, ); - return policyTaxRatesOptions; + return taxRatesOptions; }, [taxRates, searchValue, selectedOptions]); const selectedOptionKey = lodashGet(_.filter(lodashGet(sections, '[0].data', []), (taxRate) => taxRate.searchText === selectedTaxRate)[0], 'keyForList'); From 8e386373884899edef6bee0ccc0ae7286e6004b2 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Thu, 22 Feb 2024 10:07:01 +0100 Subject: [PATCH 29/47] pass taxRates as props --- src/pages/iou/request/step/IOURequestStepTaxRatePage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepTaxRatePage.js b/src/pages/iou/request/step/IOURequestStepTaxRatePage.js index 9ba525ee0890..0a4a533f3ed8 100644 --- a/src/pages/iou/request/step/IOURequestStepTaxRatePage.js +++ b/src/pages/iou/request/step/IOURequestStepTaxRatePage.js @@ -84,7 +84,7 @@ function IOURequestStepTaxRatePage({ /> From 591179dddde5c0f7ece8381953b282749f4932ab Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Thu, 22 Feb 2024 10:08:55 +0100 Subject: [PATCH 30/47] update taxPicker propTypes --- src/components/TaxPicker/taxPickerPropTypes.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/components/TaxPicker/taxPickerPropTypes.js b/src/components/TaxPicker/taxPickerPropTypes.js index 5f6f1778029e..06b7c00b7826 100644 --- a/src/components/TaxPicker/taxPickerPropTypes.js +++ b/src/components/TaxPicker/taxPickerPropTypes.js @@ -9,10 +9,8 @@ const propTypes = { /** Callback to fire when a tax is pressed */ onSubmit: PropTypes.func.isRequired, - policy: PropTypes.shape({ - /** Collection of tax rates attached to a policy */ - taxRates: taxPropTypes, - }), + /** Collection of tax rates attached to a policy */ + taxRates: taxPropTypes, /** * Safe area insets required for reflecting the portion of the view, @@ -23,7 +21,7 @@ const propTypes = { const defaultProps = { selectedTaxRate: '', - policy: {}, + taxRates: {}, }; export {propTypes, defaultProps}; From a76c179588cdd3ee18b466af161dcb7fe85708fc Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Thu, 22 Feb 2024 10:13:07 +0100 Subject: [PATCH 31/47] update taxPicker props --- src/components/TaxPicker/index.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/components/TaxPicker/index.js b/src/components/TaxPicker/index.js index cb4436ab8b33..94188ffb8382 100644 --- a/src/components/TaxPicker/index.js +++ b/src/components/TaxPicker/index.js @@ -10,14 +10,12 @@ import * as TransactionUtils from '@libs/TransactionUtils'; import CONST from '@src/CONST'; import {defaultProps, propTypes} from './taxPickerPropTypes'; -function TaxPicker({selectedTaxRate, policy, insets, onSubmit}) { +function TaxPicker({selectedTaxRate, taxRates, insets, onSubmit}) { const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); const {translate} = useLocalize(); const [searchValue, setSearchValue] = useState(''); - const taxRates = lodashGet(policy, 'taxRates', {}); - const taxRatesCount = TransactionUtils.getEnabledTaxRateCount(taxRates.taxes); const isTaxRatesCountBelowThreshold = taxRatesCount < CONST.TAX_RATES_LIST_THRESHOLD; From d730c2dc9588656ea69b491d5449122bea37cf9d Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Thu, 22 Feb 2024 11:11:48 +0100 Subject: [PATCH 32/47] update more policyTaxRates to taxRates only --- src/libs/OptionsListUtils.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index dad4ef3ea4fb..9f592c3485c8 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -111,7 +111,7 @@ type GetOptionsConfig = { recentlyUsedTags?: string[]; canInviteUser?: boolean; includeSelectedOptions?: boolean; - includePolicyTaxRates?: boolean; + includeTaxRates?: boolean; taxRates?: PolicyTaxRateWithDefault; transactionViolations?: OnyxCollection; }; @@ -1183,13 +1183,13 @@ type PolicyTaxRateWithDefault = { /** * Transforms tax rates to a new object format - to add codes and new name with concatenated name and value. * - * @param policyTaxRates - The original tax rates object. + * @param taxRates - The original tax rates object. * @returns The transformed tax rates object.g */ -function transformedTaxRates(policyTaxRates: PolicyTaxRateWithDefault | undefined): Record { - const defaultTaxKey = policyTaxRates?.defaultExternalID; +function transformedTaxRates(taxRates: PolicyTaxRateWithDefault | undefined): Record { + const defaultTaxKey = taxRates?.defaultExternalID; const getModifiedName = (data: PolicyTaxRate, code: string) => `${data.name} (${data.value})${defaultTaxKey === code ? ` • ${Localize.translateLocal('common.default')}` : ''}`; - const taxes = Object.fromEntries(Object.entries(policyTaxRates?.taxes ?? {}).map(([code, data]) => [code, {...data, code, modifiedName: getModifiedName(data, code), name: data.name}])); + const taxes = Object.fromEntries(Object.entries(taxRates?.taxes ?? {}).map(([code, data]) => [code, {...data, code, modifiedName: getModifiedName(data, code), name: data.name}])); return taxes; } @@ -1218,10 +1218,10 @@ function getTaxRatesOptions(taxRates: Array>): Option[] { /** * Builds the section list for tax rates */ -function getTaxRatesSection(policyTaxRates: PolicyTaxRateWithDefault | undefined, selectedOptions: Category[], searchInputValue: string): CategorySection[] { +function getTaxRatesSection(taxRates: PolicyTaxRateWithDefault | undefined, selectedOptions: Category[], searchInputValue: string): CategorySection[] { const policyRatesSections = []; - const taxes = transformedTaxRates(policyTaxRates); + const taxes = transformedTaxRates(taxRates); const sortedTaxRates = sortTaxRates(taxes); const enabledTaxRates = sortedTaxRates.filter((taxRate) => !taxRate.isDisabled); @@ -1360,7 +1360,7 @@ function getOptions( canInviteUser = true, includeSelectedOptions = false, transactionViolations = {}, - includePolicyTaxRates, + includeTaxRates, taxRates, }: GetOptionsConfig, ): GetOptions { @@ -1392,7 +1392,7 @@ function getOptions( }; } - if (includePolicyTaxRates) { + if (includeTaxRates) { const taxRatesOptions = getTaxRatesSection(taxRates, selectedOptions as Category[], searchInputValue); return { @@ -1796,7 +1796,7 @@ function getFilteredOptions( recentlyUsedTags: string[] = [], canInviteUser = true, includeSelectedOptions = false, - includePolicyTaxRates = false, + includeTaxRates = false, taxRates: PolicyTaxRateWithDefault = {} as PolicyTaxRateWithDefault, ) { return getOptions(reports, personalDetails, { @@ -1817,7 +1817,7 @@ function getFilteredOptions( recentlyUsedTags, canInviteUser, includeSelectedOptions, - includePolicyTaxRates, + includeTaxRates, taxRates, }); } From 8e2eefde56de34c7cc4c3f91c50953a67207b1b0 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Thu, 22 Feb 2024 11:13:35 +0100 Subject: [PATCH 33/47] add taxRates types to Policy --- src/types/onyx/Policy.ts | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 7d4c08374b81..a95b74878cd8 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -31,6 +31,33 @@ type DisabledFields = { reimbursable?: boolean; }; +type TaxRate = { + /** Name of the a tax rate. */ + name: string; + + /** The value of the tax rate. */ + isDisabled?: boolean; +}; + +type TaxRates = Record; + +type TaxRatesWithDefault = { + /** Name of the tax */ + name: string; + + /** Default policy tax ID */ + defaultExternalID: string; + + /** Default value of taxes */ + defaultValue: string; + + /** Default foreign policy tax ID */ + foreignTaxDefault: string; + + /** List of tax names and values */ + taxes: TaxRates; +}; + // These types are for the Integration connections for a policy (eg. Quickbooks, Xero, etc). // This data is not yet used in the codebase which is why it is given a very generic type, but the data is being put into Onyx for future use. // Once the data is being used, these types should be defined appropriately. @@ -171,6 +198,9 @@ type Policy = { trackingEnabled: boolean; }; + /** Collection of tax rates attached to a policy */ + taxRates?: TaxRatesWithDefault; + /** ReportID of the admins room for this workspace */ chatReportIDAdmins?: number; @@ -183,4 +213,4 @@ type Policy = { export default Policy; -export type {Unit, CustomUnit, Attributes, Rate}; +export type {Unit, CustomUnit, Attributes, Rate, TaxRate, TaxRates, TaxRatesWithDefault}; From ff40828c44fa15d80a00e9ac0359a2b1f0dbae5d Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Thu, 22 Feb 2024 11:15:01 +0100 Subject: [PATCH 34/47] remove policy taxRates types --- src/types/onyx/PolicyTaxRates.ts | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 src/types/onyx/PolicyTaxRates.ts diff --git a/src/types/onyx/PolicyTaxRates.ts b/src/types/onyx/PolicyTaxRates.ts deleted file mode 100644 index e2bea4a3fa44..000000000000 --- a/src/types/onyx/PolicyTaxRates.ts +++ /dev/null @@ -1,20 +0,0 @@ -type PolicyTaxRate = { - /** The name of the tax rate. */ - name: string; - - /** The value of the tax rate. */ - value: string; - - /** The code associated with the tax rate. */ - code: string; - - /** This contains the tax name and tax value as one name */ - modifiedName: string; - - /** Indicates if the tax rate is disabled. */ - isDisabled?: boolean; -}; - -type PolicyTaxRates = Record; - -export type {PolicyTaxRates, PolicyTaxRate}; From 62487657333ca52c218e6bcb49ed63ca80e4f4d2 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Thu, 22 Feb 2024 11:34:52 +0100 Subject: [PATCH 35/47] update Policy TaxRate types --- src/types/onyx/Policy.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index a95b74878cd8..34fb0e97f16c 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -36,6 +36,15 @@ type TaxRate = { name: string; /** The value of the tax rate. */ + value: string; + + /** The code associated with the tax rate. */ + code: string; + + /** This contains the tax name and tax value as one name */ + modifiedName: string; + + /** Indicates if the tax rate is disabled. */ isDisabled?: boolean; }; From aaa5d5796b1378782e630f62a556d2647423a86e Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Thu, 22 Feb 2024 11:35:53 +0100 Subject: [PATCH 36/47] export policy tax rates types from onyx types --- src/types/onyx/index.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/types/onyx/index.ts b/src/types/onyx/index.ts index 1b2ecdbdce12..9c59a89e4040 100644 --- a/src/types/onyx/index.ts +++ b/src/types/onyx/index.ts @@ -30,6 +30,7 @@ import type {PersonalDetailsList} from './PersonalDetails'; import type PersonalDetails from './PersonalDetails'; import type PlaidData from './PlaidData'; import type Policy from './Policy'; +import type {TaxRate, TaxRates, TaxRatesWithDefault} from './Policy'; import type {PolicyCategories, PolicyCategory} from './PolicyCategory'; import type {PolicyMembers} from './PolicyMember'; import type PolicyMember from './PolicyMember'; @@ -127,6 +128,9 @@ export type { SecurityGroup, Session, Task, + TaxRate, + TaxRates, + TaxRatesWithDefault, Transaction, TransactionViolation, TransactionViolations, From f81d5479cee4b5d0f0ec03cac4f2f9e61f7d8f45 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Thu, 22 Feb 2024 11:36:29 +0100 Subject: [PATCH 37/47] update OptionsListUtils TaxRate Types --- src/libs/OptionsListUtils.ts | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 9f592c3485c8..11997a712cfc 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -22,12 +22,14 @@ import type { Report, ReportAction, ReportActions, + TaxRate, + TaxRates, + TaxRatesWithDefault, Transaction, TransactionViolation, } from '@src/types/onyx'; import type {Participant} from '@src/types/onyx/IOU'; import type * as OnyxCommon from '@src/types/onyx/OnyxCommon'; -import type {PolicyTaxRate, PolicyTaxRates} from '@src/types/onyx/PolicyTaxRates'; import type DeepValueOf from '@src/types/utils/DeepValueOf'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import times from '@src/utils/times'; @@ -112,7 +114,7 @@ type GetOptionsConfig = { canInviteUser?: boolean; includeSelectedOptions?: boolean; includeTaxRates?: boolean; - taxRates?: PolicyTaxRateWithDefault; + taxRates?: TaxRatesWithDefault; transactionViolations?: OnyxCollection; }; @@ -1172,23 +1174,15 @@ function hasEnabledTags(policyTagList: Array return hasEnabledOptions(policyTagValueList); } -type PolicyTaxRateWithDefault = { - name: string; - defaultExternalID: string; - defaultValue: string; - foreignTaxDefault: string; - taxes: PolicyTaxRates; -}; - /** * Transforms tax rates to a new object format - to add codes and new name with concatenated name and value. * * @param taxRates - The original tax rates object. * @returns The transformed tax rates object.g */ -function transformedTaxRates(taxRates: PolicyTaxRateWithDefault | undefined): Record { +function transformedTaxRates(taxRates: TaxRatesWithDefault | undefined): Record { const defaultTaxKey = taxRates?.defaultExternalID; - const getModifiedName = (data: PolicyTaxRate, code: string) => `${data.name} (${data.value})${defaultTaxKey === code ? ` • ${Localize.translateLocal('common.default')}` : ''}`; + const getModifiedName = (data: TaxRate, code: string) => `${data.name} (${data.value})${defaultTaxKey === code ? ` • ${Localize.translateLocal('common.default')}` : ''}`; const taxes = Object.fromEntries(Object.entries(taxRates?.taxes ?? {}).map(([code, data]) => [code, {...data, code, modifiedName: getModifiedName(data, code), name: data.name}])); return taxes; } @@ -1196,7 +1190,7 @@ function transformedTaxRates(taxRates: PolicyTaxRateWithDefault | undefined): Re /** * Sorts tax rates alphabetically by name. */ -function sortTaxRates(taxRates: PolicyTaxRates): PolicyTaxRate[] { +function sortTaxRates(taxRates: TaxRates): TaxRate[] { const sortedtaxRates = lodashSortBy(taxRates, (taxRate) => taxRate.name); return sortedtaxRates; } @@ -1204,7 +1198,7 @@ function sortTaxRates(taxRates: PolicyTaxRates): PolicyTaxRate[] { /** * Builds the options for taxRates */ -function getTaxRatesOptions(taxRates: Array>): Option[] { +function getTaxRatesOptions(taxRates: Array>): Option[] { return taxRates.map((taxRate) => ({ text: taxRate.modifiedName, keyForList: taxRate.code, @@ -1218,7 +1212,7 @@ function getTaxRatesOptions(taxRates: Array>): Option[] { /** * Builds the section list for tax rates */ -function getTaxRatesSection(taxRates: PolicyTaxRateWithDefault | undefined, selectedOptions: Category[], searchInputValue: string): CategorySection[] { +function getTaxRatesSection(taxRates: TaxRatesWithDefault | undefined, selectedOptions: Category[], searchInputValue: string): CategorySection[] { const policyRatesSections = []; const taxes = transformedTaxRates(taxRates); @@ -1797,7 +1791,7 @@ function getFilteredOptions( canInviteUser = true, includeSelectedOptions = false, includeTaxRates = false, - taxRates: PolicyTaxRateWithDefault = {} as PolicyTaxRateWithDefault, + taxRates: TaxRatesWithDefault = {} as TaxRatesWithDefault, ) { return getOptions(reports, personalDetails, { betas, From e0dab418897252d1dc726f134ff108e278ed4a77 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Thu, 22 Feb 2024 11:44:05 +0100 Subject: [PATCH 38/47] update Tax Rates types --- src/libs/TransactionUtils.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/libs/TransactionUtils.ts b/src/libs/TransactionUtils.ts index d3eafc6554db..2988b6dc40c1 100644 --- a/src/libs/TransactionUtils.ts +++ b/src/libs/TransactionUtils.ts @@ -4,8 +4,7 @@ import Onyx from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import type {RecentWaypoint, Report, ReportAction, Transaction, TransactionViolation} from '@src/types/onyx'; -import type {PolicyTaxRate, PolicyTaxRates} from '@src/types/onyx/PolicyTaxRates'; +import type {RecentWaypoint, Report, ReportAction, TaxRate, TaxRates, Transaction, TransactionViolation} from '@src/types/onyx'; import type {Comment, Receipt, TransactionChanges, Waypoint, WaypointCollection} from '@src/types/onyx/Transaction'; import type {EmptyObject} from '@src/types/utils/EmptyObject'; import {isCorporateCard, isExpensifyCard} from './CardUtils'; @@ -578,8 +577,8 @@ function calculateTaxAmount(percentage: string, amount: number) { /** * Calculates count of all tax enabled options */ -function getEnabledTaxRateCount(options: PolicyTaxRates) { - return Object.values(options).filter((option: PolicyTaxRate) => !option.isDisabled).length; +function getEnabledTaxRateCount(options: TaxRates) { + return Object.values(options).filter((option: TaxRate) => !option.isDisabled).length; } export { From d3842c967fc8aa8c11f5e92a83046a9c286c3897 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Thu, 22 Feb 2024 11:45:50 +0100 Subject: [PATCH 39/47] fix prettier --- src/components/TaxPicker/index.js | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/src/components/TaxPicker/index.js b/src/components/TaxPicker/index.js index 94188ffb8382..be15cd546b36 100644 --- a/src/components/TaxPicker/index.js +++ b/src/components/TaxPicker/index.js @@ -36,26 +36,7 @@ function TaxPicker({selectedTaxRate, taxRates, insets, onSubmit}) { }, [selectedTaxRate]); const sections = useMemo(() => { - const {taxRatesOptions} = OptionsListUtils.getFilteredOptions( - {}, - {}, - [], - searchValue, - selectedOptions, - [], - false, - false, - false, - {}, - [], - false, - {}, - [], - false, - false, - true, - taxRates, - ); + const {taxRatesOptions} = OptionsListUtils.getFilteredOptions({}, {}, [], searchValue, selectedOptions, [], false, false, false, {}, [], false, {}, [], false, false, true, taxRates); return taxRatesOptions; }, [taxRates, searchValue, selectedOptions]); From fa62bd06df48657a73f2a3f7ed6ba029c4d8f311 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Thu, 22 Feb 2024 11:51:39 +0100 Subject: [PATCH 40/47] update OptionListUtilsTest var names --- tests/unit/OptionsListUtilsTest.js | 33 +++++++----------------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/tests/unit/OptionsListUtilsTest.js b/tests/unit/OptionsListUtilsTest.js index 00f1307ab59f..7244b7830a29 100644 --- a/tests/unit/OptionsListUtilsTest.js +++ b/tests/unit/OptionsListUtilsTest.js @@ -2063,7 +2063,7 @@ describe('OptionsListUtils', () => { const emptySearch = ''; const wrongSearch = 'bla bla'; - const policyTaxRatesWithDefault = { + const taxRatesWithDefault = { name: 'Tax', defaultExternalID: 'CODE1', defaultValue: '0%', @@ -2170,34 +2170,15 @@ describe('OptionsListUtils', () => { }, ]; - const result = OptionsListUtils.getFilteredOptions({}, {}, [], emptySearch, [], [], false, false, false, {}, [], false, {}, [], false, false, true, policyTaxRatesWithDefault); + const result = OptionsListUtils.getFilteredOptions({}, {}, [], emptySearch, [], [], false, false, false, {}, [], false, {}, [], false, false, true, taxRatesWithDefault); - expect(result.policyTaxRatesOptions).toStrictEqual(resultList); + expect(result.taxRatesOptions).toStrictEqual(resultList); - const searchResult = OptionsListUtils.getFilteredOptions({}, {}, [], search, [], [], false, false, false, {}, [], false, {}, [], false, false, true, policyTaxRatesWithDefault); - expect(searchResult.policyTaxRatesOptions).toStrictEqual(searchResultList); + const searchResult = OptionsListUtils.getFilteredOptions({}, {}, [], search, [], [], false, false, false, {}, [], false, {}, [], false, false, true, taxRatesWithDefault); + expect(searchResult.taxRatesOptions).toStrictEqual(searchResultList); - const wrongSearchResult = OptionsListUtils.getFilteredOptions( - {}, - {}, - [], - wrongSearch, - [], - [], - false, - false, - false, - {}, - [], - false, - {}, - [], - false, - false, - true, - policyTaxRatesWithDefault, - ); - expect(wrongSearchResult.policyTaxRatesOptions).toStrictEqual(wrongSearchResultList); + const wrongSearchResult = OptionsListUtils.getFilteredOptions({}, {}, [], wrongSearch, [], [], false, false, false, {}, [], false, {}, [], false, false, true, taxRatesWithDefault); + expect(wrongSearchResult.taxRatesOptions).toStrictEqual(wrongSearchResultList); }); it('formatMemberForList()', () => { From 78235614c3c739807a0b8d16c5fa772fd120db8d Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Fri, 23 Feb 2024 16:13:11 +0100 Subject: [PATCH 41/47] add policy defaults --- src/components/MoneyRequestConfirmationList.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index fb6640b38853..dcb3a701602f 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -196,6 +196,7 @@ const defaultProps = { receiptPath: '', receiptFilename: '', listStyles: [], + policy: {}, policyCategories: {}, policyTags: {}, transactionID: '', From 7332edeb9d5b9f5c0d4c81725f8041c700c294c2 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Fri, 23 Feb 2024 16:13:54 +0100 Subject: [PATCH 42/47] add policy defaults --- .../MoneyTemporaryForRefactorRequestConfirmationList.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js index d338985253cb..9881c23ac366 100755 --- a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js +++ b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js @@ -189,6 +189,7 @@ const defaultProps = { receiptPath: '', receiptFilename: '', listStyles: [], + policy: {}, policyCategories: {}, policyTags: {}, transactionID: '', From d6f8cb7df73a30b4060abd437275c497a4414a3f Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Fri, 23 Feb 2024 16:17:44 +0100 Subject: [PATCH 43/47] add comments to ONYX Props --- src/pages/iou/request/step/IOURequestStepTaxRatePage.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/iou/request/step/IOURequestStepTaxRatePage.js b/src/pages/iou/request/step/IOURequestStepTaxRatePage.js index 0a4a533f3ed8..0cc2375b5510 100644 --- a/src/pages/iou/request/step/IOURequestStepTaxRatePage.js +++ b/src/pages/iou/request/step/IOURequestStepTaxRatePage.js @@ -27,6 +27,7 @@ const propTypes = { /** The transaction object being modified in Onyx */ transaction: transactionPropTypes, + /* Onyx Props */ /** The policy of the report */ policy: PropTypes.shape({ /** Collection of tax rates attached to a policy */ From ebd910aedcb84156956473083cedf19e3ca010ff Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Fri, 23 Feb 2024 16:19:10 +0100 Subject: [PATCH 44/47] add comments to ONYX Props --- src/pages/iou/request/step/IOURequestStepTaxAmountPage.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/iou/request/step/IOURequestStepTaxAmountPage.js b/src/pages/iou/request/step/IOURequestStepTaxAmountPage.js index 4499f7d77b17..29263d92078f 100644 --- a/src/pages/iou/request/step/IOURequestStepTaxAmountPage.js +++ b/src/pages/iou/request/step/IOURequestStepTaxAmountPage.js @@ -37,6 +37,7 @@ const propTypes = { /** The transaction object being modified in Onyx */ transaction: transactionPropTypes, + /* Onyx Props */ /** The policy of the report */ policy: PropTypes.shape({ /** Collection of tax rates attached to a policy */ From 71be744d6cc476c8bda607cbde20cd780ef7aae3 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Fri, 23 Feb 2024 16:23:41 +0100 Subject: [PATCH 45/47] update comments --- src/types/onyx/Policy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 7db309194452..d766b4c106f6 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -38,7 +38,7 @@ type TaxRate = { /** Name of the a tax rate. */ name: string; - /** The value of the tax rate. */ + /** The value of the tax rate as percentage. */ value: string; /** The code associated with the tax rate. */ From 71fd0cda3964f356a003b6c7d662fb1352ffda7e Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Fri, 23 Feb 2024 16:24:59 +0100 Subject: [PATCH 46/47] update comments --- src/types/onyx/Policy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index d766b4c106f6..23f736987563 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -57,7 +57,7 @@ type TaxRatesWithDefault = { /** Name of the tax */ name: string; - /** Default policy tax ID */ + /** Default policy tax code */ defaultExternalID: string; /** Default value of taxes */ From 1283b12e53bf82352494401b8e1a80ceb4165a4b Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Fri, 23 Feb 2024 16:26:20 +0100 Subject: [PATCH 47/47] update comments --- src/types/onyx/Policy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 23f736987563..b24f6cf272df 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -63,7 +63,7 @@ type TaxRatesWithDefault = { /** Default value of taxes */ defaultValue: string; - /** Default foreign policy tax ID */ + /** Default foreign policy tax code */ foreignTaxDefault: string; /** List of tax names and values */