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

Fix/issue 29899 #30232

Merged
merged 22 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
d77413d
fix: adding condition to change amount and merchant to TBD, when a tr…
Tony-MK Oct 24, 2023
15ee5ce
fix: adding condition to change amount and merchant to TBD, when a tr…
Tony-MK Oct 24, 2023
12fb96c
fix: adding condition return the pending map when the transaction's w…
Tony-MK Oct 24, 2023
1f5b971
fix: formatting amount and merchant displays, if the report has one o…
Tony-MK Oct 24, 2023
796de4b
refactor: making the changes look prettier
Tony-MK Oct 24, 2023
3c6662f
refactor: making the changes a bit prettier
Tony-MK Oct 24, 2023
45124ff
refactor: making ReceiptUtils.ts look prettier
Tony-MK Oct 24, 2023
717b517
Update src/libs/ReceiptUtils.ts
Tony-MK Oct 25, 2023
13ee066
Update src/components/ReportActionItem/ReportPreview.js
Tony-MK Oct 25, 2023
8b78cc5
fix: reverting line due to typescript checks
Tony-MK Oct 26, 2023
7748f18
fix: Adding regex constant for matching the first space in a distance…
Tony-MK Oct 26, 2023
f1c3c55
refactor: Replacing raw regex with constant from CONST.ts
Tony-MK Oct 26, 2023
0c0fe0d
refactor: Replacing raw regex with constant from CONST.ts
Tony-MK Oct 26, 2023
0e7faea
‌‌refactor: Replacing raw regex with constant from CONST.ts
Tony-MK Oct 26, 2023
6c50d5e
fix: reverting line
Tony-MK Oct 26, 2023
9e49f7f
Merge branch 'Expensify:main' into fix/issue-29899
Tony-MK Oct 26, 2023
3520b63
fix: reverting line
Tony-MK Oct 27, 2023
06a21ce
Merge branch 'Expensify:main' into fix/issue-29899
Tony-MK Oct 27, 2023
7bf9309
Merge branch 'Expensify:main' into fix/issue-29899
Tony-MK Oct 27, 2023
41aaea3
Merge branch 'Expensify:main' into fix/issue-29899
Tony-MK Oct 28, 2023
17598cd
Merge branch 'Expensify:main' into fix/issue-29899
Tony-MK Nov 1, 2023
62fc922
Merge branch 'Expensify:main' into fix/issue-29899
Tony-MK Nov 7, 2023
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
8 changes: 6 additions & 2 deletions src/components/ReportActionItem/MoneyRequestPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ function MoneyRequestPreview(props) {

const receiptImages = hasReceipt ? [ReceiptUtils.getThumbnailAndImageURIs(props.transaction)] : [];

const hasPendingWaypoints = lodashGet(props.transaction, 'pendingFields.waypoints', null);

const getSettledMessage = () => {
if (isExpensifyCardTransaction) {
return props.translate('common.done');
Expand Down Expand Up @@ -222,7 +224,7 @@ function MoneyRequestPreview(props) {

const getDisplayAmountText = () => {
if (isDistanceRequest) {
return requestAmount ? CurrencyUtils.convertToDisplayString(requestAmount, props.transaction.currency) : props.translate('common.tbd');
return requestAmount && !hasPendingWaypoints ? CurrencyUtils.convertToDisplayString(requestAmount, props.transaction.currency) : props.translate('common.tbd');
}

if (isScanning) {
Expand Down Expand Up @@ -305,7 +307,9 @@ function MoneyRequestPreview(props) {
</View>
{shouldShowMerchant && (
<View style={[styles.flexRow]}>
<Text style={[styles.textLabelSupporting, styles.mb1, styles.lh20, styles.breakWord]}>{requestMerchant}</Text>
<Text style={[styles.textLabelSupporting, styles.mb1, styles.lh20, styles.breakWord]}>
{hasPendingWaypoints ? requestMerchant.replace(/.+?(?=\s)/, props.translate('common.tbd')) : requestMerchant}
</Text>
</View>
)}
<View style={[styles.flexRow, styles.mt1]}>
Expand Down
5 changes: 3 additions & 2 deletions src/components/ReportActionItem/MoneyRequestView.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ function MoneyRequestView({report, betas, parentReport, policyCategories, should
transactionMerchant === '' || transactionMerchant === CONST.TRANSACTION.UNKNOWN_MERCHANT || transactionMerchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT;
const isDistanceRequest = TransactionUtils.isDistanceRequest(transaction);
let formattedTransactionAmount = transactionAmount ? CurrencyUtils.convertToDisplayString(transactionAmount, transactionCurrency) : '';
if (isDistanceRequest && !formattedTransactionAmount) {
const hasPendingWaypoints = lodashGet(transaction, 'pendingFields.waypoints', null);
if (isDistanceRequest && (!formattedTransactionAmount || hasPendingWaypoints)) {
formattedTransactionAmount = translate('common.tbd');
}
const formattedOriginalAmount = transactionOriginalAmount && transactionOriginalCurrency && CurrencyUtils.convertToDisplayString(transactionOriginalAmount, transactionOriginalCurrency);
Expand Down Expand Up @@ -206,7 +207,7 @@ function MoneyRequestView({report, betas, parentReport, policyCategories, should
<OfflineWithFeedback pendingAction={lodashGet(transaction, 'pendingFields.waypoints') || lodashGet(transaction, 'pendingAction')}>
<MenuItemWithTopDescription
description={translate('common.distance')}
title={transactionMerchant}
title={hasPendingWaypoints ? transactionMerchant.replace(/.+?(?=\s)/, translate('common.tbd')) : transactionMerchant}
Tony-MK marked this conversation as resolved.
Show resolved Hide resolved
interactive={canEdit && !isSettled}
shouldShowRightIcon={canEdit && !isSettled}
titleStyle={styles.flex1}
Expand Down
21 changes: 14 additions & 7 deletions src/components/ReportActionItem/ReportPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,24 @@ function ReportPreview(props) {
const lastThreeTransactionsWithReceipts = transactionsWithReceipts.slice(-3);
const lastThreeReceipts = _.map(lastThreeTransactionsWithReceipts, (transaction) => ReceiptUtils.getThumbnailAndImageURIs(transaction));
const hasNonReimbursableTransactions = ReportUtils.hasNonReimbursableTransactions(props.iouReportID);
const hasOnlyOneReceiptRequest = numberOfRequests === 1 && hasReceipts;
const previewSubtitle = hasOnlyOneReceiptRequest
? TransactionUtils.getMerchant(transactionsWithReceipts[0])
: props.translate('iou.requestCount', {
count: numberOfRequests,
scanningReceipts: numberOfScanningReceipts,
});
let formattedMerchant = numberOfRequests === 1 && hasReceipts ? TransactionUtils.getMerchant(transactionsWithReceipts[0]) : null;
const hasPendingWaypoints = formattedMerchant && hasOnlyDistanceRequests && _.every(transactionsWithReceipts, (transaction) => lodashGet(transaction, 'pendingFields.waypoints', null));
if (hasPendingWaypoints) {
formattedMerchant = formattedMerchant.replace(/.+?(?=\s)/, props.translate('common.tbd'));
Tony-MK marked this conversation as resolved.
Show resolved Hide resolved
}
const previewSubtitle =
formattedMerchant ||
props.translate('iou.requestCount', {
count: numberOfRequests,
scanningReceipts: numberOfScanningReceipts,
});

const shouldShowSubmitButton = isReportDraft && reimbursableSpend !== 0;

const getDisplayAmount = () => {
if (hasPendingWaypoints) {
Tony-MK marked this conversation as resolved.
Show resolved Hide resolved
return props.translate('common.tbd');
}
if (totalDisplaySpend) {
return CurrencyUtils.convertToDisplayString(totalDisplaySpend, props.iouReport.currency);
}
Expand Down
20 changes: 11 additions & 9 deletions src/libs/ReceiptUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,19 @@ function getThumbnailAndImageURIs(transaction: Transaction, receiptPath: string

const hasEReceipt = transaction?.hasEReceipt;

if (hasEReceipt) {
return {thumbnail: null, image: ROUTES.ERECEIPT.getRoute(transaction.transactionID), transaction};
}
if (!Object.hasOwn(transaction?.pendingFields ?? {}, 'waypoints')) {
Tony-MK marked this conversation as resolved.
Show resolved Hide resolved
if (hasEReceipt) {
return {thumbnail: null, image: ROUTES.ERECEIPT.getRoute(transaction.transactionID), transaction};
}

// For local files, we won't have a thumbnail yet
if (isReceiptImage && (path.startsWith('blob:') || path.startsWith('file:'))) {
return {thumbnail: null, image: path};
}
// For local files, we won't have a thumbnail yet
if (isReceiptImage && (path.startsWith('blob:') || path.startsWith('file:'))) {
return {thumbnail: null, image: path};
}

if (isReceiptImage) {
return {thumbnail: `${path}.1024.jpg`, image: path};
if (isReceiptImage) {
return {thumbnail: `${path}.1024.jpg`, image: path};
}
}

const {fileExtension} = FileUtils.splitExtensionFromFileName(filename) as FileNameAndExtension;
Expand Down
Loading