Skip to content

Commit

Permalink
Merge pull request #36407 from shahinyan11/issues/34418
Browse files Browse the repository at this point in the history
Fix displaying edited amount in IOU preview for scan failed receipt
  • Loading branch information
techievivek authored Mar 12, 2024
2 parents d1a7dca + 64259b3 commit 59c98ce
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import ControlSelection from '@libs/ControlSelection';
import * as CurrencyUtils from '@libs/CurrencyUtils';
import * as DeviceCapabilities from '@libs/DeviceCapabilities';
import * as IOUUtils from '@libs/IOUUtils';
import * as Localize from '@libs/Localize';
import * as OptionsListUtils from '@libs/OptionsListUtils';
import * as ReceiptUtils from '@libs/ReceiptUtils';
import * as ReportActionsUtils from '@libs/ReportActionsUtils';
Expand Down Expand Up @@ -152,12 +151,25 @@ function MoneyRequestPreviewContent({
}

let message = translate('iou.cash');
if (hasViolations && transaction) {
if (shouldShowRBR && transaction) {
const violations = TransactionUtils.getTransactionViolations(transaction.transactionID, transactionViolations);
if (violations?.[0]) {
const violationMessage = ViolationsUtils.getViolationTranslation(violations[0], translate);
const isTooLong = violations.filter((v) => v.type === 'violation').length > 1 || violationMessage.length > 15;
message += ` • ${isTooLong ? translate('violations.reviewRequired') : violationMessage}`;
const violationsCount = violations.filter((v) => v.type === 'violation').length;
const isTooLong = violationsCount > 1 || violationMessage.length > 15;
const hasViolationsAndFieldErrors = violationsCount > 0 && hasFieldErrors;

return `${message}${isTooLong || hasViolationsAndFieldErrors ? translate('violations.reviewRequired') : violationMessage}`;
}

const isMerchantMissing = TransactionUtils.isMerchantMissing(transaction);
const isAmountMissing = TransactionUtils.isAmountMissing(transaction);
if (isAmountMissing && isMerchantMissing) {
message += ` • ${translate('violations.reviewRequired')}`;
} else if (isAmountMissing) {
message += ` • ${translate('iou.missingAmount')}`;
} else {
message += ` • ${translate('iou.missingMerchant')}`;
}
} else if (ReportUtils.isPaidGroupPolicyExpenseReport(iouReport) && ReportUtils.isReportApproved(iouReport) && !ReportUtils.isSettled(iouReport?.reportID)) {
message += ` • ${translate('iou.approved')}`;
Expand All @@ -180,10 +192,6 @@ function MoneyRequestPreviewContent({
return translate('iou.routePending');
}

if (!isSettled && TransactionUtils.hasMissingSmartscanFields(transaction)) {
return Localize.translateLocal('iou.receiptMissingDetails');
}

return CurrencyUtils.convertToDisplayString(requestAmount, requestCurrency);
};

Expand Down
2 changes: 2 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,8 @@ export default {
routePending: 'Route pending...',
receiptScanning: 'Scan in progress…',
receiptMissingDetails: 'Receipt missing details',
missingAmount: 'Missing amount',
missingMerchant: 'Missing merchant',
receiptStatusTitle: 'Scanning…',
receiptStatusText: "Only you can see this receipt when it's scanning. Check back later or enter the details now.",
receiptScanningFailed: 'Receipt scanning failed. Enter the details manually.',
Expand Down
2 changes: 2 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,8 @@ export default {
routePending: 'Ruta pendiente...',
receiptScanning: 'Escaneo en curso…',
receiptMissingDetails: 'Recibo con campos vacíos',
missingAmount: 'Falta importe',
missingMerchant: 'Falta comerciante',
receiptStatusTitle: 'Escaneando…',
receiptStatusText: 'Solo tú puedes ver este recibo cuando se está escaneando. Vuelve más tarde o introduce los detalles ahora.',
receiptScanningFailed: 'El escaneo de recibo ha fallado. Introduce los detalles manualmente.',
Expand Down

0 comments on commit 59c98ce

Please sign in to comment.