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

[Wave 8- Ecard Transactions] MoneyRequestPreview - add ECard Transactions description #29176

Merged
merged 7 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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);
grgia marked this conversation as resolved.
Show resolved Hide resolved

// 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 @@ -512,6 +512,7 @@ export default {
approve: 'Approve',
approved: 'Approved',
cash: 'Cash',
card: 'Card',
split: 'Split',
addToSplit: 'Add to split',
splitBill: 'Split bill',
Expand All @@ -522,6 +523,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 @@ -504,6 +504,7 @@ export default {
approve: 'Aprobar',
approved: 'Aprobado',
cash: 'Efectivo',
card: 'Tarjeta',
split: 'Dividir',
addToSplit: 'Añadir para dividir',
splitBill: 'Dividir factura',
Expand All @@ -514,6 +515,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 @@ -395,6 +417,9 @@ export {
isReceiptBeingScanned,
getValidWaypoints,
isDistanceRequest,
isExpensifyCardTransaction,
isPending,
isPosted,
getWaypoints,
hasMissingSmartscanFields,
getWaypointIndex,
Expand Down
Loading