Skip to content
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
7 changes: 5 additions & 2 deletions src/components/ReportActionItem/MoneyRequestReceiptView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import OfflineWithFeedback from '@components/OfflineWithFeedback';
import ReceiptAudit, {ReceiptAuditMessages} from '@components/ReceiptAudit';
import ReceiptEmptyState from '@components/ReceiptEmptyState';
import useActiveRoute from '@hooks/useActiveRoute';
import useEnvironment from '@hooks/useEnvironment';
import useGetIOUReportFromReportAction from '@hooks/useGetIOUReportFromReportAction';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
Expand Down Expand Up @@ -97,6 +98,7 @@ function MoneyRequestReceiptView({
}: MoneyRequestReceiptViewProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const {environmentURL} = useEnvironment();
const {shouldUseNarrowLayout, isInNarrowPaneModal} = useResponsiveLayout();
const {getReportRHPActiveRoute} = useActiveRoute();
const parentReportID = report?.parentReportID;
Expand Down Expand Up @@ -136,6 +138,7 @@ function MoneyRequestReceiptView({
const isReportArchived = useReportIsArchived(report?.reportID);
const isEditable = !!canUserPerformWriteActionReportUtils(report, isReportArchived) && !readonly;
const canEdit = isMoneyRequestAction(parentReportAction) && canEditMoneyRequest(parentReportAction, isChatReportArchived, moneyRequestReport, policy, transaction) && isEditable;
const companyCardPageURL = `${environmentURL}/${ROUTES.WORKSPACE_COMPANY_CARDS.getRoute(report?.policyID)}`;

const canEditReceipt = isEditable && canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.RECEIPT, undefined, isChatReportArchived);

Expand Down Expand Up @@ -170,15 +173,15 @@ function MoneyRequestReceiptView({
const isReceiptFieldViolation = receiptFieldViolationNames.has(violation.name);
const isReceiptImageViolation = receiptImageViolationNames.has(violation.name);
if (isReceiptFieldViolation || isReceiptImageViolation) {
const violationMessage = ViolationsUtils.getViolationTranslation(violation, translate, canEdit);
const violationMessage = ViolationsUtils.getViolationTranslation(violation, translate, canEdit, undefined, companyCardPageURL);
allViolations.push(violationMessage);
if (isReceiptImageViolation) {
imageViolations.push(violationMessage);
}
}
}
return [imageViolations, allViolations];
}, [transactionViolations, translate, canEdit]);
}, [transactionViolations, translate, canEdit, companyCardPageURL]);

const receiptRequiredViolation = transactionViolations?.some((violation) => violation.name === CONST.VIOLATIONS.RECEIPT_REQUIRED);
const customRulesViolation = transactionViolations?.some((violation) => violation.name === CONST.VIOLATIONS.CUSTOM_RULES);
Expand Down
7 changes: 6 additions & 1 deletion src/components/ReportActionItem/MoneyRequestView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Text from '@components/Text';
import ViolationMessages from '@components/ViolationMessages';
import {WideRHPContext} from '@components/WideRHPContextProvider';
import useActiveRoute from '@hooks/useActiveRoute';
import useEnvironment from '@hooks/useEnvironment';
import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
import useOnyx from '@hooks/useOnyx';
Expand Down Expand Up @@ -129,6 +130,7 @@ function MoneyRequestView({
const theme = useTheme();
const StyleUtils = useStyleUtils();
const {isOffline} = useNetwork();
const {environmentURL} = useEnvironment();
const {translate, toLocaleDigit} = useLocalize();
const {getReportRHPActiveRoute} = useActiveRoute();
const [lastVisitedPath] = useOnyx(ONYXKEYS.LAST_VISITED_PATH, {canBeMissing: true});
Expand Down Expand Up @@ -246,6 +248,7 @@ function MoneyRequestView({
const isReportArchived = useReportIsArchived(report?.reportID);
const isEditable = !!canUserPerformWriteActionReportUtils(report, isReportArchived) && !readonly;
const canEdit = isMoneyRequestAction(parentReportAction) && canEditMoneyRequest(parentReportAction, isChatReportArchived, moneyRequestReport, policy, transaction) && isEditable;
const companyCardPageURL = `${environmentURL}/${ROUTES.WORKSPACE_COMPANY_CARDS.getRoute(report?.policyID)}`;
const {isExpenseSplit} = getOriginalTransactionWithSplitInfo(transaction);
const isSplitAvailable = moneyRequestReport && transaction && isSplitAction(moneyRequestReport, [transaction], policy);

Expand Down Expand Up @@ -415,7 +418,7 @@ function MoneyRequestView({
// Return violations if there are any
if (field !== 'merchant' && hasViolations(field, data, policyHasDependentTags, tagValue)) {
const violations = getViolationsForField(field, data, policyHasDependentTags, tagValue);
return `${violations.map((violation) => ViolationsUtils.getViolationTranslation(violation, translate, canEdit)).join('. ')}.`;
return `${violations.map((violation) => ViolationsUtils.getViolationTranslation(violation, translate, canEdit, undefined, companyCardPageURL)).join('. ')}.`;
Comment thread
samranahm marked this conversation as resolved.
}

return '';
Expand All @@ -437,6 +440,7 @@ function MoneyRequestView({
canEditMerchant,
canEdit,
isCustomUnitOutOfPolicy,
companyCardPageURL,
],
);

Expand Down Expand Up @@ -898,6 +902,7 @@ function MoneyRequestView({
textStyle={[styles.ph0]}
isLast
canEdit={canEdit}
companyCardPageURL={companyCardPageURL}
/>
)}
</View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import ReportActionItemImages from '@components/ReportActionItem/ReportActionIte
import UserInfoCellsWithArrow from '@components/SelectionListWithSections/Search/UserInfoCellsWithArrow';
import Text from '@components/Text';
import TransactionPreviewSkeletonView from '@components/TransactionPreviewSkeletonView';
import useEnvironment from '@hooks/useEnvironment';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import useReportIsArchived from '@hooks/useReportIsArchived';
Expand All @@ -33,6 +34,7 @@ import ViolationsUtils from '@libs/Violations/ViolationsUtils';
import variables from '@styles/variables';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type {TransactionPreviewContentProps} from './types';

function TransactionPreviewContent({
Expand Down Expand Up @@ -61,6 +63,7 @@ function TransactionPreviewContent({
const theme = useTheme();
const styles = useThemeStyles();
const {translate} = useLocalize();
const {environmentURL} = useEnvironment();

const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`, {canBeMissing: true});
const isParentPolicyExpenseChat = isPolicyExpenseChat(chatReport);
Expand Down Expand Up @@ -103,7 +106,8 @@ function TransactionPreviewContent({
const firstViolation = violations.at(0);
const isIOUActionType = isMoneyRequestAction(action);
const canEdit = isIOUActionType && canEditMoneyRequest(action, isChatReportArchived, report, policy, transaction);
const violationMessage = firstViolation ? ViolationsUtils.getViolationTranslation(firstViolation, translate, canEdit) : undefined;
const companyCardPageURL = `${environmentURL}/${ROUTES.WORKSPACE_COMPANY_CARDS.getRoute(report?.policyID)}`;
const violationMessage = firstViolation ? ViolationsUtils.getViolationTranslation(firstViolation, translate, canEdit, undefined, companyCardPageURL) : undefined;

const previewText = useMemo(
() =>
Expand Down
5 changes: 5 additions & 0 deletions src/components/TransactionItemRow/TransactionItemRowRBR.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {View} from 'react-native';
import Icon from '@components/Icon';
import {DotIndicator} from '@components/Icon/Expensicons';
import RenderHTML from '@components/RenderHTML';
import useEnvironment from '@hooks/useEnvironment';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import useTheme from '@hooks/useTheme';
Expand All @@ -13,6 +14,7 @@ import {isSettled} from '@libs/ReportUtils';
import ViolationsUtils from '@libs/Violations/ViolationsUtils';
import variables from '@styles/variables';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type {Report, TransactionViolation} from '@src/types/onyx';
import type Transaction from '@src/types/onyx/Transaction';

Expand All @@ -37,9 +39,11 @@ function TransactionItemRowRBR({transaction, violations, report, containerStyles
const styles = useThemeStyles();
const {translate} = useLocalize();
const theme = useTheme();
const {environmentURL} = useEnvironment();
const [reportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transaction.reportID}`, {
canBeMissing: true,
});
const companyCardPageURL = `${environmentURL}/${ROUTES.WORKSPACE_COMPANY_CARDS.getRoute(report?.policyID)}`;
const [policyTags] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_TAGS}${report?.policyID}`, {canBeMissing: true});
const transactionThreadId = reportActions ? getIOUActionForTransactionID(Object.values(reportActions ?? {}), transaction.transactionID)?.childReportID : undefined;
const [transactionThreadActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transactionThreadId}`, {
Expand All @@ -53,6 +57,7 @@ function TransactionItemRowRBR({transaction, violations, report, containerStyles
missingFieldError,
Object.values(transactionThreadActions ?? {}),
policyTags,
companyCardPageURL,
);

return (
Expand Down
15 changes: 11 additions & 4 deletions src/components/ViolationMessages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,21 @@ import ViolationsUtils from '@libs/Violations/ViolationsUtils';
import type {TransactionViolation} from '@src/types/onyx';
import Text from './Text';

type ViolationMessagesProps = {violations: TransactionViolation[]; isLast?: boolean; containerStyle?: StyleProp<ViewStyle>; textStyle?: StyleProp<TextStyle>; canEdit: boolean};
type ViolationMessagesProps = {
violations: TransactionViolation[];
isLast?: boolean;
containerStyle?: StyleProp<ViewStyle>;
textStyle?: StyleProp<TextStyle>;
canEdit: boolean;
companyCardPageURL?: string;
};

export default function ViolationMessages({violations, isLast, containerStyle, textStyle, canEdit}: ViolationMessagesProps) {
export default function ViolationMessages({violations, isLast, containerStyle, textStyle, canEdit, companyCardPageURL}: ViolationMessagesProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const violationMessages = useMemo(
() => violations.map((violation) => [violation.name, ViolationsUtils.getViolationTranslation(violation, translate, canEdit)]),
[canEdit, translate, violations],
() => violations.map((violation) => [violation.name, ViolationsUtils.getViolationTranslation(violation, translate, canEdit, undefined, companyCardPageURL)]),
[canEdit, translate, violations, companyCardPageURL],
);

return (
Expand Down
6 changes: 3 additions & 3 deletions src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6829,14 +6829,14 @@ ${amount} für ${merchant} - ${date}`,
},
customRules: ({message}: ViolationsCustomRulesParams) => message,
reviewRequired: 'Überprüfung erforderlich',
rter: ({brokenBankConnection, email, isAdmin, isTransactionOlderThan7Days, member, rterType}: ViolationsRterParams) => {
rter: ({brokenBankConnection, isAdmin, isTransactionOlderThan7Days, member, rterType, companyCardPageURL}: ViolationsRterParams) => {
if (rterType === CONST.RTER_VIOLATION_TYPES.BROKEN_CARD_CONNECTION_530) {
return 'Kassenbon kann aufgrund einer unterbrochenen Bankverbindung nicht automatisch zugeordnet werden.';
}
if (brokenBankConnection || rterType === CONST.RTER_VIOLATION_TYPES.BROKEN_CARD_CONNECTION) {
return isAdmin
? `Kassenbon kann aufgrund einer unterbrochenen Bankverbindung, die ${email} beheben muss, nicht automatisch zugeordnet werden.`
: 'Kassenbon kann aufgrund einer unterbrochenen Bankverbindung nicht automatisch zugeordnet werden.';
? `Bankverbindung unterbrochen. <a href="${companyCardPageURL}">Jetzt wieder verbinden, um den Beleg zuzuordnen</a>`
: 'Bankverbindung unterbrochen. Bitte einen Admin bitten, sie wieder zu verbinden, um den Beleg zuzuordnen.';
}
if (!isTransactionOlderThan7Days) {
return isAdmin
Expand Down
6 changes: 4 additions & 2 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6795,12 +6795,14 @@ const translations = {
},
customRules: ({message}: ViolationsCustomRulesParams) => message,
reviewRequired: 'Review required',
rter: ({brokenBankConnection, email, isAdmin, isTransactionOlderThan7Days, member, rterType}: ViolationsRterParams) => {
rter: ({brokenBankConnection, isAdmin, isTransactionOlderThan7Days, member, rterType, companyCardPageURL}: ViolationsRterParams) => {
if (rterType === CONST.RTER_VIOLATION_TYPES.BROKEN_CARD_CONNECTION_530) {
return "Can't auto-match receipt due to broken bank connection";
}
if (brokenBankConnection || rterType === CONST.RTER_VIOLATION_TYPES.BROKEN_CARD_CONNECTION) {
return isAdmin ? `Can't auto-match receipt due to broken bank connection which ${email} needs to fix` : "Can't auto-match receipt due to broken bank connection";
return isAdmin
? `Bank connection broken. <a href="${companyCardPageURL}">Reconnect to match receipt</a>`
: 'Bank connection broken. Ask an admin to reconnect to match receipt.';
}
if (!isTransactionOlderThan7Days) {
return isAdmin ? `Ask ${member} to mark as a cash or wait 7 days and try again` : 'Awaiting merge with card transaction.';
Expand Down
7 changes: 4 additions & 3 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {CONST as COMMON_CONST} from 'expensify-common';
import CONST from '@src/CONST';
import type en from './en';
import type {ViolationsRterParams} from './params';
import type {TranslationDeepObject} from './types';

/* eslint-disable max-len */
Expand Down Expand Up @@ -6924,14 +6925,14 @@ ${amount} para ${merchant} - ${date}`,
},
customRules: ({message}) => message,
reviewRequired: 'Revisión requerida',
rter: ({brokenBankConnection, isAdmin, email, isTransactionOlderThan7Days, member, rterType}) => {
rter: ({brokenBankConnection, isAdmin, isTransactionOlderThan7Days, member, rterType, companyCardPageURL}: ViolationsRterParams) => {
if (rterType === CONST.RTER_VIOLATION_TYPES.BROKEN_CARD_CONNECTION_530) {
return 'No se puede emparejar automáticamente el recibo debido a una conexión bancaria interrumpida.';
}
if (brokenBankConnection || rterType === CONST.RTER_VIOLATION_TYPES.BROKEN_CARD_CONNECTION) {
return isAdmin
? `No se puede adjuntar recibo debido a un problema con la conexión a tu banco que ${email} necesita arreglar`
: 'No se puede adjuntar recibo debido a un problema con la conexión a tu banco';
? `Conexión bancaria interrumpida. <a href="${companyCardPageURL}">Vuelve a conectarte para emparejar el recibo</a>`
: 'Conexión bancaria interrumpida. Pide a un administrador que la vuelva a conectar para emparejar el recibo.';
}
if (!isTransactionOlderThan7Days) {
return isAdmin
Expand Down
6 changes: 3 additions & 3 deletions src/languages/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6836,14 +6836,14 @@ ${amount} pour ${merchant} - ${date}`,
},
customRules: ({message}: ViolationsCustomRulesParams) => message,
reviewRequired: 'Examen requis',
rter: ({brokenBankConnection, email, isAdmin, isTransactionOlderThan7Days, member, rterType}: ViolationsRterParams) => {
rter: ({brokenBankConnection, isAdmin, isTransactionOlderThan7Days, member, rterType, companyCardPageURL}: ViolationsRterParams) => {
if (rterType === CONST.RTER_VIOLATION_TYPES.BROKEN_CARD_CONNECTION_530) {
return "Impossible de faire correspondre automatiquement le reçu en raison d'une connexion bancaire défectueuse.";
}
if (brokenBankConnection || rterType === CONST.RTER_VIOLATION_TYPES.BROKEN_CARD_CONNECTION) {
return isAdmin
? `Impossible de faire correspondre automatiquement le reçu en raison d'une connexion bancaire défectueuse que ${email} doit corriger.`
: "Impossible de faire correspondre automatiquement le reçu en raison d'une connexion bancaire défectueuse.";
? `Connexion bancaire interrompue. <a href="${companyCardPageURL}">Reconnecter pour associer le reçu</a>`
: 'Connexion bancaire interrompue. Demandez à un administrateur de la reconnecter pour associer le reçu.';
}
if (!isTransactionOlderThan7Days) {
return isAdmin ? `Demandez à ${member} de marquer comme espèce ou attendez 7 jours et réessayez` : 'En attente de fusion avec la transaction par carte.';
Expand Down
6 changes: 3 additions & 3 deletions src/languages/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6844,14 +6844,14 @@ ${amount} per ${merchant} - ${date}`,
},
customRules: ({message}: ViolationsCustomRulesParams) => message,
reviewRequired: 'Revisione richiesta',
rter: ({brokenBankConnection, email, isAdmin, isTransactionOlderThan7Days, member, rterType}: ViolationsRterParams) => {
rter: ({brokenBankConnection, isAdmin, isTransactionOlderThan7Days, member, rterType, companyCardPageURL}: ViolationsRterParams) => {
if (rterType === CONST.RTER_VIOLATION_TYPES.BROKEN_CARD_CONNECTION_530) {
return 'Impossibile associare automaticamente la ricevuta a causa di una connessione bancaria interrotta.';
}
if (brokenBankConnection || rterType === CONST.RTER_VIOLATION_TYPES.BROKEN_CARD_CONNECTION) {
return isAdmin
? `Impossibile abbinare automaticamente la ricevuta a causa di una connessione bancaria interrotta che ${email} deve risolvere.`
: 'Impossibile associare automaticamente la ricevuta a causa di una connessione bancaria interrotta.';
? `Connessione bancaria interrotta. <a href="${companyCardPageURL}">Riconnetti per abbinarla alla ricevuta</a>`
: 'Connessione bancaria interrotta. Chiedi a un amministratore di riconnetterla per abbinare la ricevuta.';
}
if (!isTransactionOlderThan7Days) {
return isAdmin ? `Chiedi a ${member} di contrassegnarlo come contante o attendi 7 giorni e riprova` : 'In attesa di unione con la transazione della carta.';
Expand Down
6 changes: 4 additions & 2 deletions src/languages/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6777,12 +6777,14 @@ ${date} - ${merchant}に${amount}`,
},
customRules: ({message}: ViolationsCustomRulesParams) => message,
reviewRequired: 'レビューが必要です',
rter: ({brokenBankConnection, email, isAdmin, isTransactionOlderThan7Days, member, rterType}: ViolationsRterParams) => {
rter: ({brokenBankConnection, isAdmin, isTransactionOlderThan7Days, member, rterType, companyCardPageURL}: ViolationsRterParams) => {
if (rterType === CONST.RTER_VIOLATION_TYPES.BROKEN_CARD_CONNECTION_530) {
return '銀行接続が切れているため、領収書を自動照合できません。';
}
if (brokenBankConnection || rterType === CONST.RTER_VIOLATION_TYPES.BROKEN_CARD_CONNECTION) {
return isAdmin ? `${email}が修正する必要がある銀行接続の問題のため、領収書を自動マッチングできません。` : '銀行接続が切れているため、領収書を自動照合できません。';
return isAdmin
? `銀行接続が切断されています。<a href="${companyCardPageURL}">再接続して領収書を照合してください</a>`
: '銀行接続が切断されています。領収書を照合するには管理者に再接続を依頼してください。';
}
if (!isTransactionOlderThan7Days) {
return isAdmin ? `${member}に現金としてマークするように依頼するか、7日間待って再試行してください。` : 'カード取引とのマージを待機中。';
Expand Down
Loading
Loading