Skip to content

Commit

Permalink
add mark as cash button
Browse files Browse the repository at this point in the history
  • Loading branch information
BrtqKr committed May 8, 2024
1 parent 8463360 commit 00b7a54
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/components/MoneyReportHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function MoneyReportHeader({
const [isConfirmModalVisible, setIsConfirmModalVisible] = useState(false);

const transactionIDs = TransactionUtils.getAllReportTransactions(moneyRequestReport?.reportID).map((transaction) => transaction.transactionID);
const haveAllPendingRTERViolation = TransactionUtils.haveAllPendingRTERViolation(transactionIDs);
const hasAllPendingRTERViolations = TransactionUtils.hasAllPendingRTERViolations(transactionIDs);

const cancelPayment = useCallback(() => {
if (!chatReport) {
Expand All @@ -121,13 +121,13 @@ function MoneyReportHeader({

const shouldDisableApproveButton = shouldShowApproveButton && !ReportUtils.isAllowedToApproveExpenseReport(moneyRequestReport);

const shouldShowSettlementButton = !ReportUtils.isInvoiceReport(moneyRequestReport) && (shouldShowPayButton || shouldShowApproveButton) && !haveAllPendingRTERViolation;
const shouldShowSettlementButton = !ReportUtils.isInvoiceReport(moneyRequestReport) && (shouldShowPayButton || shouldShowApproveButton) && !hasAllPendingRTERViolations;

const shouldShowSubmitButton = isDraft && reimbursableSpend !== 0 && !haveAllPendingRTERViolation;
const shouldShowSubmitButton = isDraft && reimbursableSpend !== 0 && !hasAllPendingRTERViolations;
const shouldDisableSubmitButton = shouldShowSubmitButton && !ReportUtils.isAllowedToSubmitDraftExpenseReport(moneyRequestReport);
const isFromPaidPolicy = policyType === CONST.POLICY.TYPE.TEAM || policyType === CONST.POLICY.TYPE.CORPORATE;
const shouldShowNextStep = !ReportUtils.isClosedExpenseReportWithNoExpenses(moneyRequestReport) && isFromPaidPolicy && !!nextStep?.message?.length;
const shouldShowAnyButton = shouldShowSettlementButton || shouldShowApproveButton || shouldShowSubmitButton || shouldShowNextStep;
const shouldShowAnyButton = shouldShowSettlementButton || shouldShowApproveButton || shouldShowSubmitButton || shouldShowNextStep || hasAllPendingRTERViolations;
const bankAccountRoute = ReportUtils.getBankAccountRoute(chatReport);
const formattedAmount = CurrencyUtils.convertToDisplayString(reimbursableSpend, moneyRequestReport.currency);
const [nonHeldAmount, fullAmount] = ReportUtils.getNonHeldAndFullAmount(moneyRequestReport, policy);
Expand Down Expand Up @@ -212,7 +212,7 @@ function MoneyReportHeader({
shouldShowBackButton={shouldUseNarrowLayout}
onBackButtonPress={onBackButtonPress}
// Shows border if no buttons or next steps are showing below the header
shouldShowBorderBottom={!(shouldShowAnyButton && shouldUseNarrowLayout) && !(shouldShowNextStep && !shouldUseNarrowLayout) && !haveAllPendingRTERViolation}
shouldShowBorderBottom={!(shouldShowAnyButton && shouldUseNarrowLayout) && !(shouldShowNextStep && !shouldUseNarrowLayout) && !hasAllPendingRTERViolations}
shouldShowThreeDotsButton
threeDotsMenuItems={threeDotsMenuItems}
threeDotsAnchorPosition={styles.threeDotsPopoverOffsetNoCloseButton(windowWidth)}
Expand Down Expand Up @@ -250,7 +250,7 @@ function MoneyReportHeader({
</View>
)}
</HeaderWithBackButton>
{haveAllPendingRTERViolation && (
{hasAllPendingRTERViolations && (
<MoneyRequestHeaderStatusBar
title={
<Icon
Expand Down
13 changes: 13 additions & 0 deletions src/components/MoneyRequestHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type {Policy, Report, ReportAction, ReportActions, Session, Transaction, TransactionViolations} from '@src/types/onyx';
import type {OriginalMessageIOU} from '@src/types/onyx/OriginalMessage';
import Button from './Button';
import ConfirmModal from './ConfirmModal';
import HeaderWithBackButton from './HeaderWithBackButton';
import Icon from './Icon';
Expand Down Expand Up @@ -90,6 +91,7 @@ function MoneyRequestHeader({
const isActionOwner = typeof parentReportAction?.actorAccountID === 'number' && typeof session?.accountID === 'number' && parentReportAction.actorAccountID === session?.accountID;
const isPolicyAdmin = policy?.role === CONST.POLICY.ROLE.ADMIN;
const isApprover = ReportUtils.isMoneyRequestReport(moneyRequestReport) && moneyRequestReport?.managerID !== null && session?.accountID === moneyRequestReport?.managerID;
const hasAllPendingRTERViolations = TransactionUtils.hasAllPendingRTERViolations([transaction?.transactionID ?? '']);

const deleteTransaction = useCallback(() => {
if (parentReportAction) {
Expand Down Expand Up @@ -244,6 +246,17 @@ function MoneyRequestHeader({
danger
/>
)}
{hasAllPendingRTERViolations && (
<View style={[styles.ph5, styles.pb3, styles.borderBottom]}>
<Button
medium
success
text={translate('iou.markAsCash')}
style={[styles.w100, styles.pr0]}
onPress={() => {}}
/>
</View>
)}
</View>
<ConfirmModal
title={translate('iou.deleteExpense')}
Expand Down
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,7 @@ export default {
deleteReceipt: 'Delete receipt',
pendingMatchWithCreditCard: 'Receipt pending match with credit card.',
pendingMatchWithCreditCardDescription: 'Receipt pending match with credit card. Marks as cash to ignore and request payment.',
markAsCash: 'Mark as cash',
routePending: 'Route pending...',
receiptScanning: 'Receipt scanning…',
receiptScanInProgress: 'Receipt scan in progress.',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ export default {
deleteReceipt: 'Eliminar recibo',
pendingMatchWithCreditCard: 'Recibo pendiente de conciliar con la tarjeta de crédito.',
pendingMatchWithCreditCardDescription: 'Recibo pendiente de conciliar con tarjeta de crédito. Marcar como efectivo para ignorar y solicitar pago.',
markAsCash: 'Marcar como efectivo',
routePending: 'Ruta pendiente...',
receiptIssuesFound: (count: number) => `${count === 1 ? 'Problema encontrado' : 'Problemas encontrados'}`,
fieldPending: 'Pendiente...',
Expand Down
4 changes: 2 additions & 2 deletions src/libs/TransactionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ function hasPendingRTERViolation(transactionViolations?: TransactionViolations |
/**
* Check if there is pending rter violation in transactionViolations.
*/
function haveAllPendingRTERViolation(transactionIds: string[]): boolean {
function hasAllPendingRTERViolations(transactionIds: string[]): boolean {
const transactionsWithRTERViolations = transactionIds.map((transactionId) => hasPendingRTERViolation(getTransactionViolations(transactionId, allTransactionViolations)));
return transactionsWithRTERViolations.length !== 0 && transactionsWithRTERViolations.every((value) => value === true);
}
Expand Down Expand Up @@ -750,7 +750,7 @@ export {
areRequiredFieldsEmpty,
hasMissingSmartscanFields,
hasPendingRTERViolation,
haveAllPendingRTERViolation,
hasAllPendingRTERViolations,
hasPendingUI,
getWaypointIndex,
waypointHasValidAddress,
Expand Down

0 comments on commit 00b7a54

Please sign in to comment.