From 8286a9b772c9b0fd953502cf7a019ba56a9714b1 Mon Sep 17 00:00:00 2001 From: 0xmiroslav Date: Wed, 10 May 2023 14:49:17 +0200 Subject: [PATCH] show individual split amount on Bill Split IOU Previews --- .../MoneyRequestConfirmationList.js | 4 ++-- src/components/ReportActionItem/IOUPreview.js | 21 ++++++++++++++----- src/languages/en.js | 1 + src/languages/es.js | 1 + src/libs/IOUUtils.js | 6 +++--- src/libs/actions/IOU.js | 4 ++-- tests/unit/IOUUtilsTest.js | 12 +++++------ 7 files changed, 31 insertions(+), 18 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index b122ab19f70e..586d98934291 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -139,7 +139,7 @@ class MoneyRequestConfirmationList extends Component { * @returns {Array} */ getParticipantsWithAmount(participants) { - const iouAmount = IOUUtils.calculateAmount(participants, this.props.iouAmount); + const iouAmount = IOUUtils.calculateAmount(participants.length, this.props.iouAmount); return OptionsListUtils.getIOUConfirmationOptionsFromParticipants(participants, CurrencyUtils.convertToDisplayString(iouAmount, this.props.iou.selectedCurrencyCode)); } @@ -168,7 +168,7 @@ class MoneyRequestConfirmationList extends Component { const formattedUnselectedParticipants = this.getParticipantsWithoutAmount(unselectedParticipants); const formattedParticipants = _.union(formattedSelectedParticipants, formattedUnselectedParticipants); - const myIOUAmount = IOUUtils.calculateAmount(selectedParticipants, this.props.iouAmount, true); + const myIOUAmount = IOUUtils.calculateAmount(selectedParticipants.length, this.props.iouAmount, true); const formattedMyPersonalDetails = OptionsListUtils.getIOUConfirmationOptionsFromMyPersonalDetail( this.props.currentUserPersonalDetails, CurrencyUtils.convertToDisplayString(myIOUAmount, this.props.iou.selectedCurrencyCode), diff --git a/src/components/ReportActionItem/IOUPreview.js b/src/components/ReportActionItem/IOUPreview.js index 202689085d97..407716b93995 100644 --- a/src/components/ReportActionItem/IOUPreview.js +++ b/src/components/ReportActionItem/IOUPreview.js @@ -26,6 +26,7 @@ import {showContextMenuForReport} from '../ShowContextMenuContext'; import * as OptionsListUtils from '../../libs/OptionsListUtils'; import Button from '../Button'; import * as CurrencyUtils from '../../libs/CurrencyUtils'; +import * as IOUUtils from '../../libs/IOUUtils'; const propTypes = { /** Additional logic for displaying the pay button */ @@ -199,11 +200,21 @@ const IOUPreview = (props) => { - {!isCurrentUserManager && props.shouldShowPendingConversionMessage && ( - {props.translate('iou.pendingConversionMessage')} - )} - - {Str.htmlDecode(lodashGet(props.action, 'originalMessage.comment', ''))} + + + {!isCurrentUserManager && props.shouldShowPendingConversionMessage && ( + {props.translate('iou.pendingConversionMessage')} + )} + {Str.htmlDecode(lodashGet(props.action, 'originalMessage.comment', ''))} + + {props.isBillSplit && !_.isEmpty(participantEmails) && ( + + {props.translate('iou.amountEach', { + amount: CurrencyUtils.convertToDisplayString(IOUUtils.calculateAmount(participantEmails.length - 1, requestAmount), requestCurrency), + })} + + )} + {isCurrentUserManager && !props.shouldHidePayButton && props.iouReport.stateNum === CONST.REPORT.STATE_NUM.PROCESSING && (