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
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ import {useRoute} from '@react-navigation/native';
import React, {useCallback, useMemo} from 'react';
import {View} from 'react-native';

// Sage Intacct's default-vendor fields hold a raw vendor ID; sending this empty string clears the default.
const CLEAR_DEFAULT_VENDOR = '';

function DynamicSageIntacctDefaultVendorPage() {
const styles = useThemeStyles();
const {translate} = useLocalize();
Expand Down Expand Up @@ -75,14 +78,21 @@ function DynamicSageIntacctDefaultVendorPage() {
[translate, styles.pb2, styles.ph5, styles.pb5, styles.textNormal, isReimbursable],
);

// Blank vendor only has a defined meaning for the non-reimbursable credit-card-charge path. The bill and reimbursable paths handle blank differently and re-tapping to clear them is out of scope here.
const canClearByReSelecting = settingName === CONST.SAGE_INTACCT_CONFIG.NON_REIMBURSABLE_CREDIT_CARD_VENDOR;

const updateDefaultVendor = useCallback(
({value}: SelectorType) => {
if (value !== defaultVendor) {
if (value === defaultVendor) {
if (canClearByReSelecting) {
updateSageIntacctDefaultVendor(policyID, settingName, CLEAR_DEFAULT_VENDOR, defaultVendor);
}
} else {
updateSageIntacctDefaultVendor(policyID, settingName, value, defaultVendor);
}
goBack();
},
[defaultVendor, policyID, settingName, goBack],
[defaultVendor, policyID, settingName, goBack, canClearByReSelecting],
);

const listEmptyContent = useMemo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,15 @@ function QuickbooksNonReimbursableVendorSelectPage({policy, configKey, updateVen
isSelected: vendor.id === currentVendor,
})) ?? [];

// Blank vendor only has a defined meaning for the CC/DC export path (falls back to "Credit Card Misc"). For Vendor Bill export, blank falls back to the report submitter — but the user can already leave that setting disabled from the parent page, so re-tapping to clear is out of scope here.
const canClearByReSelecting = configKey === CONST.QUICKBOOKS_CONFIG.NON_REIMBURSABLE_CREDIT_CARD_DEFAULT_VENDOR;

const selectVendor = (row: CardListItem) => {
if (row.value !== currentVendor) {
if (row.value === currentVendor) {
if (canClearByReSelecting) {
updateVendor(policyID, CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE, currentVendor);
}
} else {
updateVendor(policyID, row.value, currentVendor);
}
Navigation.goBack();
Expand Down
Loading