Skip to content

Commit

Permalink
Merge pull request #29176 from Expensify/georgia-cardTransactions-Mon…
Browse files Browse the repository at this point in the history
…eyRequestPreview

[Wave 8-  Ecard Transactions] MoneyRequestPreview - add ECard Transactions description
  • Loading branch information
marcochavezf authored Oct 11, 2023
2 parents 0b6aee0 + 2e88f25 commit 227d61c
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/components/ReportActionItem/MoneyRequestPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ function MoneyRequestPreview(props) {
const isScanning = hasReceipt && TransactionUtils.isReceiptBeingScanned(props.transaction);
const hasFieldErrors = TransactionUtils.hasMissingSmartscanFields(props.transaction);
const isDistanceRequest = TransactionUtils.isDistanceRequest(props.transaction);
const isSettled = ReportUtils.isSettled(props.iouReport);
const isExpensifyCardTransaction = TransactionUtils.isExpensifyCardTransaction(props.transaction);
const isSettled = ReportUtils.isSettled(props.iouReport.reportID);

// Show the merchant for IOUs and expenses only if they are custom or not related to scanning smartscan
const shouldShowMerchant =
Expand All @@ -174,6 +175,9 @@ function MoneyRequestPreview(props) {
const receiptImages = hasReceipt ? [ReceiptUtils.getThumbnailAndImageURIs(props.transaction.receipt.source, props.transaction.filename || '')] : [];

const getSettledMessage = () => {
if (isExpensifyCardTransaction || isDistanceRequest) {
return props.translate('common.done');
}
switch (lodashGet(props.action, 'originalMessage.paymentType', '')) {
case CONST.IOU.PAYMENT_TYPE.EXPENSIFY:
return props.translate('iou.settledExpensify');
Expand All @@ -199,13 +203,19 @@ function MoneyRequestPreview(props) {
return props.translate('iou.split');
}

if (isExpensifyCardTransaction) {
let message = props.translate('iou.card');
if (TransactionUtils.isPending(props.transaction)) {
message += ` • ${props.translate('iou.pending')}`;
}
return message;
}

let message = props.translate('iou.cash');
if (ReportUtils.isControlPolicyExpenseReport(props.iouReport) && ReportUtils.isReportApproved(props.iouReport) && !ReportUtils.isSettled(props.iouReport)) {
message += ` • ${props.translate('iou.approved')}`;
} else if (props.iouReport.isWaitingOnBankAccount) {
message += ` • ${props.translate('iou.pending')}`;
} else if (ReportUtils.isSettled(props.iouReport.reportID)) {
message += ` • ${props.translate('iou.settledExpensify')}`;
}
return message;
};
Expand Down
2 changes: 2 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ export default {
approve: 'Approve',
approved: 'Approved',
cash: 'Cash',
card: 'Card',
split: 'Split',
addToSplit: 'Add to split',
splitBill: 'Split bill',
Expand All @@ -523,6 +524,7 @@ export default {
pay: 'Pay',
viewDetails: 'View details',
pending: 'Pending',
posted: 'Posted',
deleteReceipt: 'Delete receipt',
receiptScanning: 'Receipt scan in progress…',
receiptMissingDetails: 'Receipt missing details',
Expand Down
2 changes: 2 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ export default {
approve: 'Aprobar',
approved: 'Aprobado',
cash: 'Efectivo',
card: 'Tarjeta',
split: 'Dividir',
addToSplit: 'Añadir para dividir',
splitBill: 'Dividir factura',
Expand All @@ -515,6 +516,7 @@ export default {
pay: 'Pagar',
viewDetails: 'Ver detalles',
pending: 'Pendiente',
posted: 'Contabilizado',
deleteReceipt: 'Eliminar recibo',
receiptScanning: 'Escaneo de recibo en curso…',
receiptMissingDetails: 'Recibo con campos vacíos',
Expand Down
25 changes: 25 additions & 0 deletions src/libs/TransactionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {format, parseISO, isValid} from 'date-fns';
import CONST from '../CONST';
import ONYXKEYS from '../ONYXKEYS';
import DateUtils from './DateUtils';
import {isExpensifyCard} from './CardUtils';
import * as NumberUtils from './NumberUtils';
import {RecentWaypoint, ReportAction, Transaction} from '../types/onyx';
import {Receipt, Comment, WaypointCollection} from '../types/onyx/Transaction';
Expand Down Expand Up @@ -277,6 +278,27 @@ function isDistanceRequest(transaction: Transaction): boolean {
return type === CONST.TRANSACTION.TYPE.CUSTOM_UNIT && customUnitName === CONST.CUSTOM_UNITS.NAME_DISTANCE;
}

function isExpensifyCardTransaction(transaction: Transaction): boolean {
if (!transaction.cardID) {
return false;
}
return isExpensifyCard(transaction.cardID);
}

function isPending(transaction: Transaction): boolean {
if (!transaction.status) {
return false;
}
return transaction.status === CONST.TRANSACTION.STATUS.PENDING;
}

function isPosted(transaction: Transaction): boolean {
if (!transaction.status) {
return false;
}
return transaction.status === CONST.TRANSACTION.STATUS.POSTED;
}

function isReceiptBeingScanned(transaction: Transaction): boolean {
return [CONST.IOU.RECEIPT_STATE.SCANREADY, CONST.IOU.RECEIPT_STATE.SCANNING].some((value) => value === transaction.receipt.state);
}
Expand Down Expand Up @@ -404,6 +426,9 @@ export {
isReceiptBeingScanned,
getValidWaypoints,
isDistanceRequest,
isExpensifyCardTransaction,
isPending,
isPosted,
getWaypoints,
hasMissingSmartscanFields,
getWaypointIndex,
Expand Down

0 comments on commit 227d61c

Please sign in to comment.