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

Sage Intacct settings configuration: Advanced #43934

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
a04d6e6
add basic advanced page
war-in Jun 18, 2024
5ddc8d1
add functionalities to toggles
war-in Jun 18, 2024
1f5c544
add payment account page
war-in Jun 18, 2024
f63b1ae
handle undefined bank account
war-in Jun 21, 2024
0bfe565
Merge branch 'refs/heads/main' into war-in/sage-intacct-advanced-conf…
war-in Jun 25, 2024
01ff51d
add connection type and update translations
war-in Jun 25, 2024
b4c27a2
update es translations
war-in Jun 25, 2024
6e9e9f6
add methods for each setting
war-in Jun 25, 2024
63ad64d
show `payment account` only when toggle enabled
war-in Jun 25, 2024
04ee8b0
add offline and error behaviour for auto sync
war-in Jun 28, 2024
b05cc77
Merge branch 'refs/heads/main' into war-in/sage-intacct-advanced-conf…
war-in Jun 28, 2024
b9e3e0f
fix translations
war-in Jun 28, 2024
33bfa80
handle errors
war-in Jun 28, 2024
f01c9a7
change type
war-in Jun 28, 2024
0fe287e
Merge branch 'refs/heads/main' into war-in/sage-intacct-advanced-conf…
war-in Jul 4, 2024
892f9b5
fix
war-in Jul 4, 2024
6aaac57
Merge branch 'refs/heads/main' into war-in/sage-intacct-advanced-conf…
war-in Jul 5, 2024
85f1d88
update code to match ideas from Export and Import PRs
war-in Jul 5, 2024
fd4e555
prettier
war-in Jul 5, 2024
23d112b
add case for payment account
war-in Jul 5, 2024
ab491df
fix lint
war-in Jul 5, 2024
b244a9c
offline state for auto sync toggle
war-in Jul 5, 2024
0ae9d8a
safe area padding bottom
war-in Jul 8, 2024
3f5eb43
Merge branch 'refs/heads/main' into war-in/sage-intacct-advanced-conf…
war-in Jul 8, 2024
e5f3e89
update API use
war-in Jul 8, 2024
14a677c
use correct arguments in endpoints
war-in Jul 8, 2024
7c315f9
Merge branch 'refs/heads/main' into war-in/sage-intacct-advanced-conf…
war-in Jul 9, 2024
4f3b790
address review comments
war-in Jul 9, 2024
c1ea127
include safe area padding bottom on errors
war-in Jul 9, 2024
17cdb3e
fix -1 as reimbursementaccountid
war-in Jul 9, 2024
bcabd41
Merge branch 'refs/heads/main' into war-in/sage-intacct-advanced-conf…
war-in Jul 9, 2024
b4fce17
fix translations after the merge
war-in Jul 9, 2024
efec0aa
use generic type params pattern
war-in Jul 9, 2024
207c13e
fix review comments
war-in Jul 9, 2024
39b4acf
revert integrationName in translations
war-in Jul 9, 2024
06c110f
fix translations in one more place
war-in Jul 9, 2024
094759f
split sync and autosync commands in SageIntacct.ts
war-in Jul 9, 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
13 changes: 13 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,19 @@ const CONST = {
NON_REIMBURSABLE: 'nonReimbursable',
EXPORTER: 'exporter',
REIMBURSABLE: 'reimbursable',
AUTO_SYNC: 'autoSync',
AUTO_SYNC_ENABLED: 'enabled',
IMPORT_EMPLOYEES: 'importEmployees',
APPROVAL_MODE: 'approvalMode',
SYNC: 'sync',
SYNC_REIMBURSED_REPORTS: 'syncReimbursedReports',
REIMBURSEMENT_ACCOUNT_ID: 'reimbursementAccountID',
},

SAGE_INTACCT: {
APPROVAL_MODE: {
APPROVAL_MANUAL: 'APPROVAL_MANUAL',
},
},

QUICKBOOKS_REIMBURSABLE_ACCOUNT_TYPE: {
Expand Down
8 changes: 8 additions & 0 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,14 @@ const ROUTES = {
route: 'settings/workspaces/:policyID/accounting/sage-intacct/export/nonreimbursable/credit-card-account',
getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/sage-intacct/export/nonreimbursable/credit-card-account` as const,
},
POLICY_ACCOUNTING_SAGE_INTACCT_ADVANCED: {
route: 'settings/workspaces/:policyID/accounting/sage-intacct/advanced',
getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/sage-intacct/advanced` as const,
},
POLICY_ACCOUNTING_SAGE_INTACCT_PAYMENT_ACCOUNT: {
route: 'settings/workspaces/:policyID/accounting/sage-intacct/advanced/payment-account',
getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/sage-intacct/advanced/payment-account` as const,
},
} as const;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,8 @@ const SCREENS = {
SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES: 'Policy_Accounting_Sage_Intacct_Non_Reimbursable_Expenses',
SAGE_INTACCT_DEFAULT_VENDOR: 'Policy_Accounting_Sage_Intacct_Default_Vendor',
SAGE_INTACCT_NON_REIMBURSABLE_CREDIT_CARD_ACCOUNT: 'Policy_Accounting_Sage_Intacct_Non_Reimbursable_Credit_Card_Account',
SAGE_INTACCT_ADVANCED: 'Policy_Accounting_Sage_Intacct_Advanced',
SAGE_INTACCT_PAYMENT_ACCOUNT: 'Policy_Accounting_Sage_Intacct_Payment_Account',
},
INITIAL: 'Workspace_Initial',
PROFILE: 'Workspace_Profile',
Expand Down
56 changes: 44 additions & 12 deletions src/components/SelectionScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import {isEmpty} from 'lodash';
import React from 'react';
import type {StyleProp, ViewStyle} from 'react-native';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import * as PolicyUtils from '@libs/PolicyUtils';
import type {AccessVariant} from '@pages/workspace/AccessOrNotFoundWrapper';
import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper';
import type {TranslationPaths} from '@src/languages/types';
import type * as OnyxCommon from '@src/types/onyx/OnyxCommon';
import type {ConnectionName, PolicyFeatureName} from '@src/types/onyx/Policy';
import type {ReceiptErrors} from '@src/types/onyx/Transaction';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import HeaderWithBackButton from './HeaderWithBackButton';
import OfflineWithFeedback from './OfflineWithFeedback';
import ScreenWrapper from './ScreenWrapper';
import SelectionList from './SelectionList';
import type RadioListItem from './SelectionList/RadioListItem';
Expand Down Expand Up @@ -63,6 +69,18 @@ type SelectionScreenProps = {

/** Name of the current connection */
connectionName: ConnectionName;

/** The type of action that's pending */
pendingAction?: OnyxCommon.PendingAction | null;

/** The errors to display */
errors?: OnyxCommon.Errors | ReceiptErrors | null;

/** Additional style object for the error row */
errorRowStyles?: StyleProp<ViewStyle>;

/** A function to run when the X button next to the error is clicked */
onClose?: () => void;
};

function SelectionScreen({
Expand All @@ -81,8 +99,13 @@ function SelectionScreen({
featureName,
shouldBeBlocked,
connectionName,
pendingAction,
errors,
errorRowStyles,
onClose,
}: SelectionScreenProps) {
const {translate} = useLocalize();
const styles = useThemeStyles();

const policy = PolicyUtils.getPolicy(policyID);
const isConnectionEmpty = isEmpty(policy?.connections?.[connectionName]);
Expand All @@ -95,24 +118,33 @@ function SelectionScreen({
shouldBeBlocked={isConnectionEmpty || shouldBeBlocked}
>
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
includeSafeAreaPaddingBottom={!!errors && !isEmptyObject(errors)}
testID={displayName}
>
<HeaderWithBackButton
title={translate(title)}
onBackButtonPress={onBackButtonPress}
/>
<SelectionList
onSelectRow={onSelectRow}
headerContent={headerContent}
sections={sections}
ListItem={listItem}
showScrollIndicator
shouldShowTooltips={false}
initiallyFocusedOptionKey={initiallyFocusedOptionKey}
listEmptyContent={listEmptyContent}
listFooterContent={listFooterContent}
/>
{headerContent}
<OfflineWithFeedback
pendingAction={pendingAction}
errors={errors}
errorRowStyles={[errorRowStyles]}
onClose={onClose}
style={[styles.flex1]}
contentContainerStyle={[styles.flex1]}
>
<SelectionList
onSelectRow={onSelectRow}
sections={sections}
ListItem={listItem}
showScrollIndicator
shouldShowTooltips={false}
initiallyFocusedOptionKey={initiallyFocusedOptionKey}
listEmptyContent={listEmptyContent}
listFooterContent={listFooterContent}
/>
</OfflineWithFeedback>
</ScreenWrapper>
</AccessOrNotFoundWrapper>
);
Expand Down
8 changes: 8 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2261,6 +2261,14 @@ export default {
exportPreferredExporterSubNote: 'Once set, the preferred exporter will see reports for export in their account.',
noAccountsFound: 'No accounts found',
noAccountsFoundDescription: `Add the account in Sage Intacct and sync the connection again.`,
autoSync: 'Auto-sync',
autoSyncDescription: 'Sync Sage Intacct and Expensify automatically, every day.',
inviteEmployees: 'Invite employees',
inviteEmployeesDescription:
'Import Sage Intacct employee records and invite employees to this workspace. Your approval workflow will default to manager approval and can be furthered configured on the Members page.',
syncReimbursedReports: 'Sync reimbursed reports',
syncReimbursedReportsDescription: 'When a report is reimbursed using Expensify ACH, the corresponding puchase bill will be created in the Sage Intacct account below.',
paymentAccount: 'Sage Intacct payment account',
},
netsuite: {
subsidiary: 'Subsidiary',
Expand Down
9 changes: 9 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2302,6 +2302,15 @@ export default {
exportPreferredExporterSubNote: 'Una vez configurado, el exportador preferido verá los informes para exportar en su cuenta.',
noAccountsFound: 'No se ha encontrado ninguna cuenta',
noAccountsFoundDescription: 'Añade la cuenta en Sage Intacct y sincroniza de nuevo la conexión.',
autoSync: 'Sincronización automática',
autoSyncDescription: 'Sincronice Sage Intacct y Expensify automáticamente, todos los días.',
inviteEmployees: 'Invitar a los empleados',
inviteEmployeesDescription:
'Importe los registros de empleados de Sage Intacct e invite a los empleados a este espacio de trabajo. Su flujo de trabajo de aprobación será por defecto la aprobación del gerente y se puede configurar aún más en la página Miembros.',
syncReimbursedReports: 'Sincronizar informes reembolsados',
syncReimbursedReportsDescription:
'Cuando un informe se reembolsa utilizando Expensify ACH, la factura de compra correspondiente se creará en la cuenta de Sage Intacct a continuación.',
paymentAccount: 'Cuenta de pago Sage Intacct',
},
netsuite: {
subsidiary: 'Subsidiaria',
Expand Down
11 changes: 11 additions & 0 deletions src/libs/API/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@ const WRITE_COMMANDS = {
UPDATE_NETSUITE_CUSTOM_FORM_ID_OPTIONS_NON_REIMBURSABLE: 'UpdateNetSuiteCustomFormIDOptionsNonReimbursable',
REQUEST_EXPENSIFY_CARD_LIMIT_INCREASE: 'RequestExpensifyCardLimitIncrease',
CONNECT_POLICY_TO_SAGE_INTACCT: 'ConnectPolicyToSageIntacct',
UPDATE_SAGE_INTACCT_AUTO_SYNC: 'UpdateSageIntacctAutoSync',
UPDATE_SAGE_INTACCT_IMPORT_EMPLOYEES: 'UpdateSageIntacctImportEmployees',
UPDATE_SAGE_INTACCT_APPROVAL_MODE: 'UpdateSageIntacctApprovalMode',
UPDATE_SAGE_INTACCT_SYNC_REIMBURSED_REPORTS: 'UpdateSageIntacctSyncReimbursedReports',
UPDATE_SAGE_INTACCT_SYNC_REIMBURSEMENT_ACCOUNT_ID: 'UpdateSageIntacctSyncReimbursementAccountID',
CONNECT_POLICY_TO_NETSUITE: 'ConnectPolicyToNetSuite',
CLEAR_OUTSTANDING_BALANCE: 'ClearOutstandingBalance',
UPDATE_SAGE_INTACCT_EXPORTER: 'UpdateSageIntacctExporter',
Expand Down Expand Up @@ -533,8 +538,14 @@ type WriteCommandParameters = {
[WRITE_COMMANDS.UPDATE_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES_CREDIT_CARD_CHARGE_EXPORT_DEFAULT_VENDOR]: Parameters.UpdateSageIntacctGenericTypeParams<'vendorID', string>;
[WRITE_COMMANDS.UPDATE_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES_EXPORT_ACCOUNT]: Parameters.UpdateSageIntacctGenericTypeParams<'creditCardAccountID', string>;
[WRITE_COMMANDS.UPDATE_SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES_EXPORT_VENDOR]: Parameters.UpdateSageIntacctGenericTypeParams<'vendorID', string>;
[WRITE_COMMANDS.UPDATE_SAGE_INTACCT_AUTO_SYNC]: Parameters.UpdateSageIntacctGenericTypeParams<'enabled', boolean>;
[WRITE_COMMANDS.UPDATE_SAGE_INTACCT_IMPORT_EMPLOYEES]: Parameters.UpdateSageIntacctGenericTypeParams<'enabled', boolean>;
[WRITE_COMMANDS.UPDATE_SAGE_INTACCT_APPROVAL_MODE]: Parameters.UpdateSageIntacctGenericTypeParams<'value', string>;
[WRITE_COMMANDS.UPDATE_SAGE_INTACCT_SYNC_REIMBURSED_REPORTS]: Parameters.UpdateSageIntacctGenericTypeParams<'enabled', boolean>;
[WRITE_COMMANDS.UPDATE_SAGE_INTACCT_SYNC_REIMBURSEMENT_ACCOUNT_ID]: Parameters.UpdateSageIntacctGenericTypeParams<'vendorID', string>;

[WRITE_COMMANDS.UPGRADE_TO_CORPORATE]: Parameters.UpgradeToCorporateParams;

// Netsuite parameters
[WRITE_COMMANDS.UPDATE_NETSUITE_SUBSIDIARY]: Parameters.UpdateNetSuiteSubsidiaryParams;
[WRITE_COMMANDS.CONNECT_POLICY_TO_NETSUITE]: Parameters.ConnectPolicyToNetSuiteParams;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,9 @@ const SettingsModalStackNavigator = createModalStackNavigator<SettingsNavigatorP
require<ReactComponentModule>('../../../../pages/workspace/accounting/intacct/export/SageIntacctDefaultVendorPage').default,
[SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_NON_REIMBURSABLE_CREDIT_CARD_ACCOUNT]: () =>
require<ReactComponentModule>('../../../../pages/workspace/accounting/intacct/export/SageIntacctNonReimbursableCreditCardAccountPage').default,
[SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_ADVANCED]: () => require<ReactComponentModule>('../../../../pages/workspace/accounting/intacct/advanced/SageIntacctAdvancedPage').default,
[SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_PAYMENT_ACCOUNT]: () =>
require<ReactComponentModule>('../../../../pages/workspace/accounting/intacct/advanced/SageIntacctPaymentAccountPage').default,
[SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_FREQUENCY]: () => require<ReactComponentModule>('../../../../pages/workspace/workflows/WorkspaceAutoReportingFrequencyPage').default,
[SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_MONTHLY_OFFSET]: () => require<ReactComponentModule>('../../../../pages/workspace/workflows/WorkspaceAutoReportingMonthlyOffsetPage').default,
[SCREENS.WORKSPACE.TAX_EDIT]: () => require<ReactComponentModule>('../../../../pages/workspace/taxes/WorkspaceEditTaxPage').default,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial<Record<FullScreenName, string[]>> = {
SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_NON_REIMBURSABLE_EXPENSES,
SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_DEFAULT_VENDOR,
SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_NON_REIMBURSABLE_CREDIT_CARD_ACCOUNT,
SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_ADVANCED,
SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_PAYMENT_ACCOUNT,
],
[SCREENS.WORKSPACE.TAXES]: [
SCREENS.WORKSPACE.TAXES_SETTINGS,
Expand Down
2 changes: 2 additions & 0 deletions src/libs/Navigation/linkingConfig/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,8 @@ const config: LinkingOptions<RootStackParamList>['config'] = {
[SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_NON_REIMBURSABLE_CREDIT_CARD_ACCOUNT]: {
path: ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_NON_REIMBURSABLE_CREDIT_CARD_ACCOUNT.route,
},
[SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_ADVANCED]: {path: ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_ADVANCED.route},
[SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_PAYMENT_ACCOUNT]: {path: ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_PAYMENT_ACCOUNT.route},
[SCREENS.WORKSPACE.DESCRIPTION]: {
path: ROUTES.WORKSPACE_PROFILE_DESCRIPTION.route,
},
Expand Down
6 changes: 6 additions & 0 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,12 @@ type SettingsNavigatorParamList = {
[SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_NON_REIMBURSABLE_CREDIT_CARD_ACCOUNT]: {
policyID: string;
};
[SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_ADVANCED]: {
policyID: string;
};
[SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_PAYMENT_ACCOUNT]: {
policyID: string;
};
[SCREENS.GET_ASSISTANCE]: {
backTo: Routes;
};
Expand Down
11 changes: 11 additions & 0 deletions src/libs/PolicyUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,16 @@ function getIntegrationLastSuccessfulDate(connection?: Connections[keyof Connect
return (connection as ConnectionWithLastSyncData)?.lastSync?.successfulDate;
}

function getSageIntacctBankAccounts(policy?: Policy, selectedBankAccountId?: string): SelectorType[] {
const bankAccounts = policy?.connections?.intacct?.data?.bankAccounts ?? [];
return (bankAccounts ?? []).map(({id, name}) => ({
value: id,
text: name,
keyForList: id,
isSelected: selectedBankAccountId === id,
}));
}

function getSageIntacctVendors(policy?: Policy, selectedVendorId?: string): SelectorType[] {
const vendors = policy?.connections?.intacct?.data?.vendors ?? [];
return vendors.map(({id, value}) => ({
Expand Down Expand Up @@ -761,6 +771,7 @@ export {
getSageIntacctVendors,
getSageIntacctNonReimbursableActiveDefaultVendor,
getSageIntacctCreditCards,
getSageIntacctBankAccounts,
getCustomUnit,
getCustomUnitRate,
sortWorkspacesBySelected,
Expand Down
5 changes: 5 additions & 0 deletions src/libs/actions/Policy/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,10 @@ function clearNetSuiteAutoSyncErrorField(policyID: string) {
Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, {connections: {netsuite: {config: {errorFields: {autoSync: null}}}}});
}

function clearSageIntacctErrorField(policyID: string, fieldName: string) {
Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, {connections: {intacct: {config: {errorFields: {[fieldName]: null}}}}});
}

function setWorkspaceReimbursement(policyID: string, reimbursementChoice: ValueOf<typeof CONST.POLICY.REIMBURSEMENT_CHOICES>, reimburserEmail: string) {
const policy = getPolicy(policyID);

Expand Down Expand Up @@ -3140,6 +3144,7 @@ export {
openPolicyExpensifyCardsPage,
requestExpensifyCardLimitIncrease,
getPoliciesConnectedToSageIntacct,
clearSageIntacctErrorField,
};

export type {NewCustomUnit};
Loading
Loading