Skip to content
Open
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
6 changes: 5 additions & 1 deletion src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,9 @@ const ONYXKEYS = {
/** The value that indicates whether Continuous Reconciliation should be used on the domain */
EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION: 'expensifyCard_useContinuousReconciliation_',

/** Pending action for continuous reconciliation enabled status */
EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION_PENDING_ACTION: 'expensifyCard_useContinuousReconciliationPendingAction_',

/** The selected accounting integration bank account ID for card reconciliation */
EXPENSIFY_CARD_RECONCILIATION_BANK_ACCOUNT_ID: 'expensifyCard_bankAccount_',

Expand Down Expand Up @@ -1322,7 +1325,8 @@ type OnyxCollectionValuesMapping = {
[ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_MANUAL_BILLING]: boolean;
[ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST]: OnyxTypes.WorkspaceCardsList;
[ONYXKEYS.COLLECTION.EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION]: OnyxTypes.PolicyConnectionName;
[ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION]: OnyxTypes.CardContinuousReconciliation;
[ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION]: boolean;
[ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION_PENDING_ACTION]: OnyxTypes.CardContinuousReconciliation;
[ONYXKEYS.COLLECTION.EXPENSIFY_CARD_RECONCILIATION_BANK_ACCOUNT_ID]: string;
[ONYXKEYS.COLLECTION.LAST_SELECTED_FEED]: OnyxTypes.CompanyCardFeedWithDomainID;
[ONYXKEYS.COLLECTION.LAST_SELECTED_EXPENSIFY_CARD_FEED]: OnyxTypes.FundID;
Expand Down
44 changes: 32 additions & 12 deletions src/libs/actions/Card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1512,13 +1512,21 @@ function toggleContinuousReconciliation(workspaceAccountID: number, shouldUseCon
};

const optimisticData: Array<
OnyxUpdate<typeof ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION | typeof ONYXKEYS.COLLECTION.EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION>
OnyxUpdate<
| typeof ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION
| typeof ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION_PENDING_ACTION
| typeof ONYXKEYS.COLLECTION.EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION
>
> = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION}${workspaceAccountID}`,
value: shouldUseContinuousReconciliation,
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION_PENDING_ACTION}${workspaceAccountID}`,
value: {
value: shouldUseContinuousReconciliation,
pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
},
},
Expand All @@ -1530,15 +1538,21 @@ function toggleContinuousReconciliation(workspaceAccountID: number, shouldUseCon
];

const successData: Array<
OnyxUpdate<typeof ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION | typeof ONYXKEYS.COLLECTION.EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION>
OnyxUpdate<
| typeof ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION
| typeof ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION_PENDING_ACTION
| typeof ONYXKEYS.COLLECTION.EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION
>
> = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION}${workspaceAccountID}`,
value: {
value: shouldUseContinuousReconciliation,
pendingAction: null,
},
value: shouldUseContinuousReconciliation,
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION_PENDING_ACTION}${workspaceAccountID}`,
value: null,
},
{
onyxMethod: Onyx.METHOD.MERGE,
Expand All @@ -1548,15 +1562,21 @@ function toggleContinuousReconciliation(workspaceAccountID: number, shouldUseCon
];

const failureData: Array<
OnyxUpdate<typeof ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION | typeof ONYXKEYS.COLLECTION.EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION>
OnyxUpdate<
| typeof ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION
| typeof ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION_PENDING_ACTION
| typeof ONYXKEYS.COLLECTION.EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION
>
> = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION}${workspaceAccountID}`,
value: {
value: !shouldUseContinuousReconciliation,
pendingAction: null,
},
value: !shouldUseContinuousReconciliation,
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION_PENDING_ACTION}${workspaceAccountID}`,
value: null,
},
{
onyxMethod: Onyx.METHOD.MERGE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ function CardReconciliationPage({policy, route}: CardReconciliationPageProps) {
const effectiveDomainID = Number(domainID ?? workspaceAccountID);

const [continuousReconciliation] = useOnyx(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION}${effectiveDomainID}`);
const [continuousReconciliationPendingAction] = useOnyx(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_USE_CONTINUOUS_RECONCILIATION_PENDING_ACTION}${effectiveDomainID}`);
const [currentConnectionName] = useOnyx(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_CONTINUOUS_RECONCILIATION_CONNECTION}${effectiveDomainID}`);
const [reconciliationBankAccountID] = useOnyx(`${ONYXKEYS.COLLECTION.EXPENSIFY_CARD_RECONCILIATION_BANK_ACCOUNT_ID}${effectiveDomainID}`);

Expand Down Expand Up @@ -124,11 +125,11 @@ function CardReconciliationPage({policy, route}: CardReconciliationPageProps) {
}, [policyID]);

useEffect(() => {
if (continuousReconciliation?.value !== undefined) {
if (continuousReconciliation !== undefined) {
return;
}
fetchPolicyAccountingData();
}, [continuousReconciliation?.value, fetchPolicyAccountingData]);
}, [continuousReconciliation, fetchPolicyAccountingData]);

return (
<AccessOrNotFoundWrapper
Expand All @@ -153,10 +154,10 @@ function CardReconciliationPage({policy, route}: CardReconciliationPageProps) {
shouldPlaceSubtitleBelowSwitch
switchAccessibilityLabel={translate('workspace.accounting.continuousReconciliation')}
disabled={!autoSync}
isActive={!!continuousReconciliation?.value}
isActive={!!continuousReconciliation}
onToggle={handleToggleContinuousReconciliation}
wrapperStyle={styles.ph5}
pendingAction={continuousReconciliation?.pendingAction}
pendingAction={continuousReconciliationPendingAction?.pendingAction}
/>
{!autoSync && (
<View style={[styles.renderHTML, styles.ph5, styles.mt2]}>
Expand All @@ -169,8 +170,8 @@ function CardReconciliationPage({policy, route}: CardReconciliationPageProps) {
/>
</View>
)}
<OfflineWithFeedback pendingAction={continuousReconciliation?.pendingAction}>
{!!paymentBankAccountID && !!continuousReconciliation?.value && (
<OfflineWithFeedback pendingAction={continuousReconciliationPendingAction?.pendingAction}>
{!!paymentBankAccountID && !!continuousReconciliation && (
<MenuItemWithTopDescription
style={styles.mt5}
title={bankAccountTitle}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ function WorkspaceSettlementAccountPage({route}: WorkspaceSettlementAccountPageP
}, [policyID]);

useEffect(() => {
if (!cardSettings || !hasActiveAccountingConnection || continuousReconciliation?.value !== undefined || reconciliationConnection !== undefined) {
if (!cardSettings || !hasActiveAccountingConnection || continuousReconciliation !== undefined || reconciliationConnection !== undefined) {
return;
}
fetchPolicyAccountingData();
}, [cardSettings, hasActiveAccountingConnection, continuousReconciliation?.value, reconciliationConnection, fetchPolicyAccountingData]);
}, [cardSettings, hasActiveAccountingConnection, continuousReconciliation, reconciliationConnection, fetchPolicyAccountingData]);

const eligibleBankAccountsOptions: BankAccountListItem[] = eligibleBankAccounts.map((bankAccount) => {
const bankName = (bankAccount.accountData?.addressName ?? '') as BankName;
Expand Down Expand Up @@ -124,7 +124,7 @@ function WorkspaceSettlementAccountPage({route}: WorkspaceSettlementAccountPageP
return (
<>
<Text style={[styles.mh5, styles.mv4]}>{translate('workspace.expensifyCard.settlementAccountDescription')}</Text>
{!!continuousReconciliation?.value && !!connectionParam && hasActiveAccountingConnection && (
{!!continuousReconciliation && !!connectionParam && hasActiveAccountingConnection && (
<View style={[styles.renderHTML, styles.mh5, styles.mb6]}>
<RenderHTML
html={translate(
Expand Down
3 changes: 0 additions & 3 deletions src/types/onyx/CardContinuousReconciliation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ import type {PendingAction} from './OnyxCommon';

/** Represents the continuous reconciliation status for a card. */
type CardContinuousReconciliation = {
/** The boolean value indicating if continuous reconciliation is enabled */
value: boolean;

/** Pending action for optimistic UI updates */
pendingAction?: PendingAction;
};
Expand Down
Loading