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

Offline and errors pattern in Quickbooks Online integration #46511

Merged
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
263743b
Initial refactor of import pages
zfurtak Jul 30, 2024
362d521
Merge branch 'main' into @zfurtak/qbo-error-messages
zfurtak Jul 30, 2024
ab278cb
Adjusted import pages and refactored advanced page
zfurtak Jul 30, 2024
2f73caa
Further refactor
zfurtak Jul 31, 2024
a98872e
Export pages refactor
zfurtak Aug 1, 2024
cabe722
Merge branch 'main' into @zfurtak/qbo-error-messages
zfurtak Aug 1, 2024
4a2c570
Add error/offline patterns and refactor advanced pages
zfurtak Aug 2, 2024
5de6c69
Adding missing patterns
zfurtak Aug 2, 2024
ee86a23
Merge branch 'main' into @zfurtak/qbo-error-messages
zfurtak Aug 5, 2024
93c42d1
Revert max_request_retry value
zfurtak Aug 5, 2024
def4201
Adjustments
zfurtak Aug 6, 2024
0cff3d9
Adjustments
zfurtak Aug 6, 2024
c109a1d
Adjusted to review
zfurtak Aug 7, 2024
e609478
Added needed conditions
zfurtak Aug 7, 2024
0b181b3
Merge branch 'main' into @zfurtak/qbo-error-messages
zfurtak Aug 7, 2024
26a9448
Adjust error patterns
zfurtak Aug 7, 2024
a5e667a
Fix console errors
zfurtak Aug 7, 2024
0ca45ed
Adjusted to review
zfurtak Aug 7, 2024
1600fe6
Style fix
zfurtak Aug 7, 2024
f95c601
Merge branch 'main' into @zfurtak/qbo-error-messages
zfurtak Aug 8, 2024
21d34d0
Rerun the checks
zfurtak Aug 8, 2024
893c8b1
Added missing setting
zfurtak Aug 8, 2024
a765f9b
Adjust code to react compiler
zfurtak Aug 8, 2024
12c81e2
Merge branch 'main' into @zfurtak/qbo-error-messages
zfurtak Aug 13, 2024
3c54077
Fix react compiler errors
zfurtak Aug 13, 2024
ce308ed
Remove opacity from empty list
zfurtak Aug 14, 2024
ee8a820
Merge branch 'main' into @zfurtak/qbo-error-messages
zfurtak Aug 14, 2024
650192a
Remove opacity from empty list
zfurtak Aug 14, 2024
1449d8a
Merge branch 'main' into @zfurtak/qbo-error-messages
zfurtak Aug 26, 2024
e5faeb4
Merge branch 'main' into @zfurtak/qbo-error-messages
zfurtak Aug 27, 2024
9664819
Merge main
zfurtak Sep 4, 2024
14875d2
Merge main
zfurtak Sep 4, 2024
5e556ff
Added generic types for oldSettingValue
zfurtak Sep 4, 2024
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
8 changes: 6 additions & 2 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1337,21 +1337,25 @@ const CONST = {
},
QUICKBOOKS_ONLINE: 'quickbooksOnline',

QUICK_BOOKS_CONFIG: {
SYNC_CLASSES: 'syncClasses',
QUICKBOOKS_CONFIG: {
ENABLE_NEW_CATEGORIES: 'enableNewCategories',
SYNC_CLASSES: 'syncClasses',
SYNC_CUSTOMERS: 'syncCustomers',
SYNC_LOCATIONS: 'syncLocations',
SYNC_TAX: 'syncTax',
EXPORT: 'export',
EXPORTER: 'exporter',
EXPORT_DATE: 'exportDate',
NON_REIMBURSABLE_EXPENSES_ACCOUNT: 'nonReimbursableExpensesAccount',
NON_REIMBURSABLE_EXPENSES_EXPORT_DESTINATION: 'nonReimbursableExpensesExportDestination',
REIMBURSABLE_EXPENSES_ACCOUNT: 'reimbursableExpensesAccount',
REIMBURSABLE_EXPENSES_EXPORT_DESTINATION: 'reimbursableExpensesExportDestination',
NON_REIMBURSABLE_BILL_DEFAULT_VENDOR: 'nonReimbursableBillDefaultVendor',
NON_REIMBURSABLE_EXPENSE_EXPORT_DESTINATION: 'nonReimbursableExpensesExportDestination',
NON_REIMBURSABLE_EXPENSE_ACCOUNT: 'nonReimbursableExpensesAccount',
RECEIVABLE_ACCOUNT: 'receivableAccount',
AUTO_SYNC: 'autoSync',
ENABLED: 'enabled',
SYNC_PEOPLE: 'syncPeople',
AUTO_CREATE_VENDOR: 'autoCreateVendor',
REIMBURSEMENT_ACCOUNT_ID: 'reimbursementAccountID',
Expand Down
1 change: 1 addition & 0 deletions src/components/SelectionScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ function SelectionScreen<T = string>({
pendingAction={pendingAction}
style={[styles.flex1]}
contentContainerStyle={[styles.flex1]}
shouldDisableOpacity={!sections.length}
>
<SelectionList
onSelectRow={onSelectRow}
Expand Down
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2203,6 +2203,7 @@ export default {
accountsPayable: 'Accounts payable',
accountsPayableDescription: 'Choose where to create vendor bills.',
bankAccount: 'Bank account',
notConfigured: 'Not configured',
bankAccountDescription: 'Choose where to send checks from.',
creditCardAccount: 'Credit card account',
companyCardsLocationEnabledDescription:
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2231,6 +2231,7 @@ export default {
accountsPayable: 'Cuentas por pagar',
accountsPayableDescription: 'Elige dónde crear las facturas de proveedores.',
bankAccount: 'Cuenta bancaria',
notConfigured: 'No configurado',
bankAccountDescription: 'Elige desde dónde enviar los cheques.',
creditCardAccount: 'Cuenta de la tarjeta de crédito',
companyCardsLocationEnabledDescription:
Expand Down
62 changes: 30 additions & 32 deletions src/libs/actions/connections/QuickbooksOnline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ function updateQuickbooksOnlineEnableNewCategories(policyID: string, settingValu
connections: {
[CONST.POLICY.CONNECTIONS.NAME.QBO]: {
config: {
[CONST.QUICK_BOOKS_CONFIG.ENABLE_NEW_CATEGORIES]: settingValue ?? null,
[CONST.QUICKBOOKS_CONFIG.ENABLE_NEW_CATEGORIES]: settingValue ?? null,
pendingFields: {
[CONST.QUICK_BOOKS_CONFIG.ENABLE_NEW_CATEGORIES]: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
[CONST.QUICKBOOKS_CONFIG.ENABLE_NEW_CATEGORIES]: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
},
errorFields: {
[CONST.QUICK_BOOKS_CONFIG.ENABLE_NEW_CATEGORIES]: null,
[CONST.QUICKBOOKS_CONFIG.ENABLE_NEW_CATEGORIES]: null,
},
},
},
Expand All @@ -52,12 +52,12 @@ function updateQuickbooksOnlineEnableNewCategories(policyID: string, settingValu
connections: {
[CONST.POLICY.CONNECTIONS.NAME.QBO]: {
config: {
[CONST.QUICK_BOOKS_CONFIG.ENABLE_NEW_CATEGORIES]: settingValue ?? null,
[CONST.QUICKBOOKS_CONFIG.ENABLE_NEW_CATEGORIES]: !settingValue ?? null,
pendingFields: {
[CONST.QUICK_BOOKS_CONFIG.ENABLE_NEW_CATEGORIES]: null,
[CONST.QUICKBOOKS_CONFIG.ENABLE_NEW_CATEGORIES]: null,
},
errorFields: {
[CONST.QUICK_BOOKS_CONFIG.ENABLE_NEW_CATEGORIES]: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'),
[CONST.QUICKBOOKS_CONFIG.ENABLE_NEW_CATEGORIES]: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'),
},
},
},
Expand All @@ -74,12 +74,11 @@ function updateQuickbooksOnlineEnableNewCategories(policyID: string, settingValu
connections: {
[CONST.POLICY.CONNECTIONS.NAME.QBO]: {
config: {
[CONST.QUICK_BOOKS_CONFIG.ENABLE_NEW_CATEGORIES]: settingValue ?? null,
pendingFields: {
[CONST.QUICK_BOOKS_CONFIG.ENABLE_NEW_CATEGORIES]: null,
[CONST.QUICKBOOKS_CONFIG.ENABLE_NEW_CATEGORIES]: null,
},
errorFields: {
[CONST.QUICK_BOOKS_CONFIG.ENABLE_NEW_CATEGORIES]: null,
[CONST.QUICKBOOKS_CONFIG.ENABLE_NEW_CATEGORIES]: null,
},
},
},
Expand All @@ -91,7 +90,7 @@ function updateQuickbooksOnlineEnableNewCategories(policyID: string, settingValu
const parameters: UpdateQuickbooksOnlineGenericTypeParams = {
policyID,
settingValue: JSON.stringify(settingValue),
idempotencyKey: String(CONST.QUICK_BOOKS_CONFIG.ENABLE_NEW_CATEGORIES),
idempotencyKey: String(CONST.QUICKBOOKS_CONFIG.ENABLE_NEW_CATEGORIES),
};
API.write(WRITE_COMMANDS.UPDATE_QUICKBOOKS_ONLINE_ENABLE_NEW_CATEGORIES, parameters, {optimisticData, failureData, successData});
}
Expand All @@ -105,12 +104,12 @@ function updateQuickbooksOnlineAutoCreateVendor(policyID: string, settingValue:
connections: {
[CONST.POLICY.CONNECTIONS.NAME.QBO]: {
config: {
[CONST.QUICK_BOOKS_CONFIG.AUTO_CREATE_VENDOR]: settingValue ?? null,
[CONST.QUICKBOOKS_CONFIG.AUTO_CREATE_VENDOR]: settingValue ?? null,
pendingFields: {
[CONST.QUICK_BOOKS_CONFIG.AUTO_CREATE_VENDOR]: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
[CONST.QUICKBOOKS_CONFIG.AUTO_CREATE_VENDOR]: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
},
errorFields: {
[CONST.QUICK_BOOKS_CONFIG.AUTO_CREATE_VENDOR]: null,
[CONST.QUICKBOOKS_CONFIG.AUTO_CREATE_VENDOR]: null,
},
},
},
Expand All @@ -127,12 +126,12 @@ function updateQuickbooksOnlineAutoCreateVendor(policyID: string, settingValue:
connections: {
[CONST.POLICY.CONNECTIONS.NAME.QBO]: {
config: {
[CONST.QUICK_BOOKS_CONFIG.AUTO_CREATE_VENDOR]: settingValue ?? null,
[CONST.QUICKBOOKS_CONFIG.AUTO_CREATE_VENDOR]: !settingValue ?? null,
pendingFields: {
[CONST.QUICK_BOOKS_CONFIG.AUTO_CREATE_VENDOR]: null,
[CONST.QUICKBOOKS_CONFIG.AUTO_CREATE_VENDOR]: null,
},
errorFields: {
[CONST.QUICK_BOOKS_CONFIG.AUTO_CREATE_VENDOR]: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'),
[CONST.QUICKBOOKS_CONFIG.AUTO_CREATE_VENDOR]: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'),
},
},
},
Expand All @@ -149,12 +148,11 @@ function updateQuickbooksOnlineAutoCreateVendor(policyID: string, settingValue:
connections: {
[CONST.POLICY.CONNECTIONS.NAME.QBO]: {
config: {
[CONST.QUICK_BOOKS_CONFIG.AUTO_CREATE_VENDOR]: settingValue ?? null,
pendingFields: {
[CONST.QUICK_BOOKS_CONFIG.AUTO_CREATE_VENDOR]: null,
[CONST.QUICKBOOKS_CONFIG.AUTO_CREATE_VENDOR]: null,
},
errorFields: {
[CONST.QUICK_BOOKS_CONFIG.AUTO_CREATE_VENDOR]: null,
[CONST.QUICKBOOKS_CONFIG.AUTO_CREATE_VENDOR]: null,
},
},
},
Expand All @@ -166,14 +164,15 @@ function updateQuickbooksOnlineAutoCreateVendor(policyID: string, settingValue:
const parameters: UpdateQuickbooksOnlineGenericTypeParams = {
policyID,
settingValue: JSON.stringify(settingValue),
idempotencyKey: String(CONST.QUICK_BOOKS_CONFIG.AUTO_CREATE_VENDOR),
idempotencyKey: String(CONST.QUICKBOOKS_CONFIG.AUTO_CREATE_VENDOR),
};
API.write(WRITE_COMMANDS.UPDATE_QUICKBOOKS_ONLINE_AUTO_CREATE_VENDOR, parameters, {optimisticData, failureData, successData});
}

function updateQuickbooksOnlineReimbursableExpensesAccount<TConnectionName extends ConnectionNameExceptNetSuite, TSettingName extends keyof Connections[TConnectionName]['config']>(
policyID: string,
settingValue: Partial<Connections[TConnectionName]['config'][TSettingName]>,
newSettingValue: Partial<Connections[TConnectionName]['config'][TSettingName]>,
oldSettingValue: Partial<Connections[TConnectionName]['config'][TSettingName]>,
) {
const optimisticData: OnyxUpdate[] = [
{
Expand All @@ -183,12 +182,12 @@ function updateQuickbooksOnlineReimbursableExpensesAccount<TConnectionName exten
connections: {
[CONST.POLICY.CONNECTIONS.NAME.QBO]: {
config: {
[CONST.QUICK_BOOKS_CONFIG.REIMBURSABLE_EXPENSES_ACCOUNT]: settingValue ?? null,
[CONST.QUICKBOOKS_CONFIG.REIMBURSABLE_EXPENSES_ACCOUNT]: newSettingValue ?? null,
pendingFields: {
[CONST.QUICK_BOOKS_CONFIG.REIMBURSABLE_EXPENSES_ACCOUNT]: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
[CONST.QUICKBOOKS_CONFIG.REIMBURSABLE_EXPENSES_ACCOUNT]: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
},
errorFields: {
[CONST.QUICK_BOOKS_CONFIG.REIMBURSABLE_EXPENSES_ACCOUNT]: null,
[CONST.QUICKBOOKS_CONFIG.REIMBURSABLE_EXPENSES_ACCOUNT]: null,
},
},
},
Expand All @@ -205,12 +204,12 @@ function updateQuickbooksOnlineReimbursableExpensesAccount<TConnectionName exten
connections: {
[CONST.POLICY.CONNECTIONS.NAME.QBO]: {
config: {
[CONST.QUICK_BOOKS_CONFIG.REIMBURSABLE_EXPENSES_ACCOUNT]: settingValue ?? null,
[CONST.QUICKBOOKS_CONFIG.REIMBURSABLE_EXPENSES_ACCOUNT]: oldSettingValue ?? null,
pendingFields: {
[CONST.QUICK_BOOKS_CONFIG.REIMBURSABLE_EXPENSES_ACCOUNT]: null,
[CONST.QUICKBOOKS_CONFIG.REIMBURSABLE_EXPENSES_ACCOUNT]: null,
},
errorFields: {
[CONST.QUICK_BOOKS_CONFIG.REIMBURSABLE_EXPENSES_ACCOUNT]: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'),
[CONST.QUICKBOOKS_CONFIG.REIMBURSABLE_EXPENSES_ACCOUNT]: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'),
},
},
},
Expand All @@ -227,12 +226,11 @@ function updateQuickbooksOnlineReimbursableExpensesAccount<TConnectionName exten
connections: {
[CONST.POLICY.CONNECTIONS.NAME.QBO]: {
config: {
[CONST.QUICK_BOOKS_CONFIG.REIMBURSABLE_EXPENSES_ACCOUNT]: settingValue ?? null,
pendingFields: {
[CONST.QUICK_BOOKS_CONFIG.REIMBURSABLE_EXPENSES_ACCOUNT]: null,
[CONST.QUICKBOOKS_CONFIG.REIMBURSABLE_EXPENSES_ACCOUNT]: null,
},
errorFields: {
[CONST.QUICK_BOOKS_CONFIG.REIMBURSABLE_EXPENSES_ACCOUNT]: null,
[CONST.QUICKBOOKS_CONFIG.REIMBURSABLE_EXPENSES_ACCOUNT]: null,
},
},
},
Expand All @@ -243,8 +241,8 @@ function updateQuickbooksOnlineReimbursableExpensesAccount<TConnectionName exten

const parameters: UpdateQuickbooksOnlineGenericTypeParams = {
policyID,
settingValue: JSON.stringify(settingValue),
idempotencyKey: String(CONST.QUICK_BOOKS_CONFIG.REIMBURSABLE_EXPENSES_ACCOUNT),
settingValue: JSON.stringify(newSettingValue),
idempotencyKey: String(CONST.QUICKBOOKS_CONFIG.REIMBURSABLE_EXPENSES_ACCOUNT),
};
API.write(WRITE_COMMANDS.UPDATE_QUICKBOOKS_ONLINE_REIMBURSABLE_EXPENSES_ACCOUNT, parameters, {optimisticData, failureData, successData});
}
Expand Down
86 changes: 1 addition & 85 deletions src/libs/actions/connections/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function createErrorFields<TConnectionName extends ConnectionNameExceptNetSuite,
}, {});
}

function updatePolicyXeroConnectionConfig<TConnectionName extends ConnectionNameExceptNetSuite, TSettingName extends keyof Connections[TConnectionName]['config']>(
function updatePolicyConnectionConfig<TConnectionName extends ConnectionNameExceptNetSuite, TSettingName extends keyof Connections[TConnectionName]['config']>(
policyID: string,
connectionName: TConnectionName,
settingName: TSettingName,
Expand Down Expand Up @@ -142,89 +142,6 @@ function updatePolicyXeroConnectionConfig<TConnectionName extends ConnectionName
};
API.write(WRITE_COMMANDS.UPDATE_POLICY_CONNECTION_CONFIG, parameters, {optimisticData, failureData, successData});
}

function updatePolicyConnectionConfig<TConnectionName extends ConnectionNameExceptNetSuite, TSettingName extends keyof Connections[TConnectionName]['config']>(
policyID: string,
connectionName: TConnectionName,
settingName: TSettingName,
settingValue: Partial<Connections[TConnectionName]['config'][TSettingName]>,
) {
const optimisticData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
value: {
connections: {
[connectionName]: {
config: {
[settingName]: settingValue ?? null,
pendingFields: {
[settingName]: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
},
errorFields: {
[settingName]: null,
},
},
},
},
},
},
];

const failureData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
value: {
connections: {
[connectionName]: {
config: {
[settingName]: settingValue ?? null,
pendingFields: {
[settingName]: null,
},
errorFields: {
[settingName]: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'),
},
},
},
},
},
},
];

const successData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
value: {
connections: {
[connectionName]: {
config: {
[settingName]: settingValue ?? null,
pendingFields: {
[settingName]: null,
},
errorFields: {
[settingName]: null,
},
},
},
},
},
},
];

const parameters: UpdatePolicyConnectionConfigParams = {
policyID,
connectionName,
settingName: String(settingName),
settingValue: JSON.stringify(settingValue),
idempotencyKey: String(settingName),
};
API.write(WRITE_COMMANDS.UPDATE_POLICY_CONNECTION_CONFIG, parameters, {optimisticData, failureData, successData});
}

/**
* This method returns read command and stage in progres for a given accounting integration.
*
Expand Down Expand Up @@ -433,7 +350,6 @@ function copyExistingPolicyConnection(connectedPolicyID: string, targetPolicyID:
export {
removePolicyConnection,
updatePolicyConnectionConfig,
updatePolicyXeroConnectionConfig,
updateManyPolicyConnectionConfigs,
getSynchronizationErrorMessage,
syncConnection,
Expand Down
Loading
Loading