From 6f5aa5f3b56bcb8b9f94b517a8b4e35aafedfc54 Mon Sep 17 00:00:00 2001 From: jeet-dhandha Date: Sat, 2 Sep 2023 04:05:52 +0530 Subject: [PATCH 1/5] updated amount, merchant, currency for distance request --- .../MoneyRequestConfirmationList.js | 8 +++++--- src/libs/actions/IOU.js | 11 +++++++---- .../iou/steps/MoneyRequestConfirmPage.js | 19 ++++++++++++++----- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index 51467d4012e5..d40cf350a971 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -290,6 +290,8 @@ function MoneyRequestConfirmationList(props) { return [...selectedParticipants, OptionsListUtils.getIOUConfirmationOptionsFromPayeePersonalDetail(payeePersonalDetails)]; }, [selectedParticipants, props.hasMultipleParticipants, payeePersonalDetails]); + const distanceMerchant = useMemo(() => DistanceRequestUtils.getDistanceMerchant(distance, unit, rate, currency, translate), [distance, unit, rate, currency, translate]); + /** * @param {Object} option */ @@ -337,10 +339,10 @@ function MoneyRequestConfirmationList(props) { Log.info(`[IOU] Sending money via: ${paymentMethod}`); onSendMoney(paymentMethod); } else { - onConfirm(selectedParticipants); + onConfirm(selectedParticipants, distanceMerchant); } }, - [selectedParticipants, onSendMoney, onConfirm, props.iouType], + [selectedParticipants, onSendMoney, onConfirm, props.iouType, distanceMerchant], ); const footerContent = useMemo(() => { @@ -457,7 +459,7 @@ function MoneyRequestConfirmationList(props) { {props.isDistanceRequest ? ( { - IOU.createDistanceRequest(props.report, selectedParticipants[0], trimmedComment, props.iou.created, props.iou.transactionID); + (selectedParticipants, trimmedComment, distanceMerchant) => { + IOU.createDistanceRequest( + props.report, + selectedParticipants[0], + trimmedComment, + props.iou.created, + props.iou.transactionID, + props.iou.amount, + props.iou.currency, + distanceMerchant, + ); }, - [props.report, props.iou.created, props.iou.transactionID], + [props.report, props.iou.created, props.iou.transactionID, props.iou.amount, props.iou.currency], ); const createTransaction = useCallback( - (selectedParticipants) => { + (selectedParticipants, distanceMerchant) => { const trimmedComment = props.iou.comment.trim(); // IOUs created from a group report will have a reportID param in the route. @@ -189,7 +198,7 @@ function MoneyRequestConfirmPage(props) { } if (isDistanceRequest) { - createDistanceRequest(selectedParticipants, trimmedComment); + createDistanceRequest(selectedParticipants, trimmedComment, distanceMerchant); return; } From 208c222ac4070fc26eed38a8cba19bac2ccdbb78 Mon Sep 17 00:00:00 2001 From: jeet-dhandha Date: Sat, 2 Sep 2023 04:24:43 +0530 Subject: [PATCH 2/5] fix: checking of report id as sometimes its coming in number type --- src/libs/TransactionUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/TransactionUtils.js b/src/libs/TransactionUtils.js index 39ec2082d84a..472de65c4507 100644 --- a/src/libs/TransactionUtils.js +++ b/src/libs/TransactionUtils.js @@ -264,7 +264,7 @@ function getLinkedTransaction(reportAction = {}) { } function getAllReportTransactions(reportID) { - return _.filter(allTransactions, (transaction) => transaction.reportID === reportID); + return _.filter(allTransactions, (transaction) => `${transaction.reportID}` === `${reportID}`); } /** From 78fcfcdcb1676180dc9ba3bdd10b3ba107301700 Mon Sep 17 00:00:00 2001 From: jeet-dhandha Date: Sat, 2 Sep 2023 05:43:49 +0530 Subject: [PATCH 3/5] updated distant merchat to use IOU's set merchant function --- src/components/MoneyRequestConfirmationList.js | 8 ++++++-- src/pages/iou/steps/MoneyRequestConfirmPage.js | 10 +++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index d40cf350a971..7dddbc28aeaf 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -292,6 +292,10 @@ function MoneyRequestConfirmationList(props) { const distanceMerchant = useMemo(() => DistanceRequestUtils.getDistanceMerchant(distance, unit, rate, currency, translate), [distance, unit, rate, currency, translate]); + useEffect(() => { + IOU.setMoneyRequestMerchant(distanceMerchant); + }, [distanceMerchant]); + /** * @param {Object} option */ @@ -339,10 +343,10 @@ function MoneyRequestConfirmationList(props) { Log.info(`[IOU] Sending money via: ${paymentMethod}`); onSendMoney(paymentMethod); } else { - onConfirm(selectedParticipants, distanceMerchant); + onConfirm(selectedParticipants); } }, - [selectedParticipants, onSendMoney, onConfirm, props.iouType, distanceMerchant], + [selectedParticipants, onSendMoney, onConfirm, props.iouType], ); const footerContent = useMemo(() => { diff --git a/src/pages/iou/steps/MoneyRequestConfirmPage.js b/src/pages/iou/steps/MoneyRequestConfirmPage.js index 04a174ef1b91..72d5ef4c06b5 100644 --- a/src/pages/iou/steps/MoneyRequestConfirmPage.js +++ b/src/pages/iou/steps/MoneyRequestConfirmPage.js @@ -143,7 +143,7 @@ function MoneyRequestConfirmPage(props) { * @param {String} trimmedComment */ const createDistanceRequest = useCallback( - (selectedParticipants, trimmedComment, distanceMerchant) => { + (selectedParticipants, trimmedComment) => { IOU.createDistanceRequest( props.report, selectedParticipants[0], @@ -152,14 +152,14 @@ function MoneyRequestConfirmPage(props) { props.iou.transactionID, props.iou.amount, props.iou.currency, - distanceMerchant, + props.iou.merchat, ); }, - [props.report, props.iou.created, props.iou.transactionID, props.iou.amount, props.iou.currency], + [props.report, props.iou.created, props.iou.transactionID, props.iou.amount, props.iou.currency, props.iou.merchat], ); const createTransaction = useCallback( - (selectedParticipants, distanceMerchant) => { + (selectedParticipants) => { const trimmedComment = props.iou.comment.trim(); // IOUs created from a group report will have a reportID param in the route. @@ -198,7 +198,7 @@ function MoneyRequestConfirmPage(props) { } if (isDistanceRequest) { - createDistanceRequest(selectedParticipants, trimmedComment, distanceMerchant); + createDistanceRequest(selectedParticipants, trimmedComment); return; } From dc7e128c5efdfe227aa60929e4711b2960b31df1 Mon Sep 17 00:00:00 2001 From: jeet-dhandha Date: Sat, 2 Sep 2023 05:58:57 +0530 Subject: [PATCH 4/5] update merchant --- src/pages/iou/steps/MoneyRequestConfirmPage.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/iou/steps/MoneyRequestConfirmPage.js b/src/pages/iou/steps/MoneyRequestConfirmPage.js index 72d5ef4c06b5..15cb7632714e 100644 --- a/src/pages/iou/steps/MoneyRequestConfirmPage.js +++ b/src/pages/iou/steps/MoneyRequestConfirmPage.js @@ -152,10 +152,10 @@ function MoneyRequestConfirmPage(props) { props.iou.transactionID, props.iou.amount, props.iou.currency, - props.iou.merchat, + props.iou.merchant, ); }, - [props.report, props.iou.created, props.iou.transactionID, props.iou.amount, props.iou.currency, props.iou.merchat], + [props.report, props.iou.created, props.iou.transactionID, props.iou.amount, props.iou.currency, props.iou.merchant], ); const createTransaction = useCallback( From e4cdc493f60b98470ecee128f7f4e7c8b79623b0 Mon Sep 17 00:00:00 2001 From: jeet-dhandha Date: Sat, 2 Sep 2023 06:21:18 +0530 Subject: [PATCH 5/5] add comment --- src/libs/TransactionUtils.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libs/TransactionUtils.js b/src/libs/TransactionUtils.js index 472de65c4507..c26a13f07bf5 100644 --- a/src/libs/TransactionUtils.js +++ b/src/libs/TransactionUtils.js @@ -264,6 +264,9 @@ function getLinkedTransaction(reportAction = {}) { } function getAllReportTransactions(reportID) { + // `reportID` from the `/CreateDistanceRequest` endpoint return's number instead of string for created `transaction`. + // For reference, https://github.com/Expensify/App/pull/26536#issuecomment-1703573277. + // We will update this in a follow-up Issue. According to this comment: https://github.com/Expensify/App/pull/26536#issuecomment-1703591019. return _.filter(allTransactions, (transaction) => `${transaction.reportID}` === `${reportID}`); }