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

Connect to sage intacct #43661

Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
75fd912
add connect to sage intacct button
SzymczakJ Jun 12, 2024
2baa77a
add intacct prerequisites screen
SzymczakJ Jun 12, 2024
c223592
fix IntacctPrerequisitesPage styling
SzymczakJ Jun 13, 2024
f17c09f
add EnterSageIntacctCredentialsPage screen
SzymczakJ Jun 13, 2024
78e810d
add ExistingConnectionsPage
SzymczakJ Jun 17, 2024
9464001
add spanish translations
SzymczakJ Jun 17, 2024
b3867f7
Merge branch 'main' into @szymczak/connect-to-sage-intacct
SzymczakJ Jun 17, 2024
fd12010
clean up code
SzymczakJ Jun 17, 2024
b28456e
fix type errors
SzymczakJ Jun 17, 2024
096f9dd
fix typo
SzymczakJ Jun 17, 2024
f6c0528
fix error names
SzymczakJ Jun 17, 2024
dc01b0b
fix PR comments
SzymczakJ Jun 17, 2024
720e8a4
fix types
SzymczakJ Jun 18, 2024
8f448b1
clean up DateUtils
SzymczakJ Jun 18, 2024
530a407
fix type errors
SzymczakJ Jun 18, 2024
93b5aa0
fix translations
SzymczakJ Jun 18, 2024
277f574
fix translations
SzymczakJ Jun 18, 2024
722ceed
fix eslint
SzymczakJ Jun 18, 2024
aa1ed19
fix PR comments
SzymczakJ Jun 19, 2024
1d85d00
fix ComputerIllustration style
SzymczakJ Jun 19, 2024
7f1d7a4
Merge branch 'main' into @szymczak/connect-to-sage-intacct
SzymczakJ Jun 19, 2024
29266a5
fix PErmissions.ts
SzymczakJ Jun 19, 2024
518dbce
fix Permissions.ts
SzymczakJ Jun 19, 2024
3a55954
Merge branch 'main' into @szymczak/connect-to-sage-intacct
SzymczakJ Jun 24, 2024
7fccce5
connect to BE
SzymczakJ Jun 25, 2024
9db4670
add sync stage translations
SzymczakJ Jun 25, 2024
5f37695
Merge branch 'main' into @szymczak/connect-to-sage-intacct
SzymczakJ Jun 26, 2024
88bf2cd
fix PR comments
SzymczakJ Jun 27, 2024
cd814a9
Merge branch 'main' into @szymczak/connect-to-sage-intacct
SzymczakJ Jun 27, 2024
73c4418
fix lint and typecheck
SzymczakJ Jun 27, 2024
ef45f0e
fix lint
SzymczakJ Jun 27, 2024
5ca6e4f
fix lint
SzymczakJ Jun 27, 2024
6349f17
fix not showing avatars
SzymczakJ Jun 27, 2024
ed9e7f8
add displayNames to match standard
SzymczakJ Jun 27, 2024
4d05367
merge main
SzymczakJ Jun 28, 2024
984447a
clean up sage intacct modules
SzymczakJ Jun 28, 2024
3c0f992
fix lint
SzymczakJ Jun 28, 2024
173fcd8
add key prop to stop console errors
SzymczakJ Jun 28, 2024
510c45e
fix navigation loop
SzymczakJ Jun 28, 2024
a84a85d
Merge branch 'main' into @szymczak/connect-to-sage-intacct
SzymczakJ Jun 28, 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
216 changes: 216 additions & 0 deletions assets/images/computer.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions assets/images/integrationicons/sage-intacct-icon-square.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,8 @@ const CONST = {
ONFIDO_TERMS_OF_SERVICE_URL: 'https://onfido.com/terms-of-service/',
LIST_OF_RESTRICTED_BUSINESSES: 'https://community.expensify.com/discussion/6191/list-of-restricted-businesses',
TRAVEL_TERMS_URL: `${USE_EXPENSIFY_URL}/travelterms`,
EXPENSIFY_PACKAGE_FOR_SAGE_INTACCT: `${USE_EXPENSIFY_URL}/tools/integrations/downloadPackage`,
HOW_TO_CONNECT_TO_SAGE_INTACCT: 'https://help.expensify.com/articles/expensify-classic/integrations/accounting-integrations/Sage-Intacct#how-to-connect-to-sage-intacct',

// Use Environment.getEnvironmentURL to get the complete URL with port number
DEV_NEW_EXPENSIFY_URL: 'https://dev.new.expensify.com:',
Expand Down Expand Up @@ -1786,6 +1788,7 @@ const CONST = {
// Here we will add other connections names when we add support for them
QBO: 'quickbooksOnline',
XERO: 'xero',
SAGE_INTACCT: 'intacct',
},
SYNC_STAGE_NAME: {
STARTING_IMPORT_QBO: 'startingImportQBO',
Expand Down
3 changes: 3 additions & 0 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,8 @@ const ONYXKEYS = {
NEW_CHAT_NAME_FORM_DRAFT: 'newChatNameFormDraft',
SUBSCRIPTION_SIZE_FORM: 'subscriptionSizeForm',
SUBSCRIPTION_SIZE_FORM_DRAFT: 'subscriptionSizeFormDraft',
SAGE_INTACCT_CREDENTIALS_FORM: 'sageIntacctCredentialsForm',
SAGE_INTACCT_CREDENTIALS_FORM_DRAFT: 'sageIntacctCredentialsFormDraft',
},
} as const;

Expand Down Expand Up @@ -545,6 +547,7 @@ type OnyxFormValuesMapping = {
[ONYXKEYS.FORMS.WORKSPACE_TAX_VALUE_FORM]: FormTypes.WorkspaceTaxValueForm;
[ONYXKEYS.FORMS.NEW_CHAT_NAME_FORM]: FormTypes.NewChatNameForm;
[ONYXKEYS.FORMS.SUBSCRIPTION_SIZE_FORM]: FormTypes.SubscriptionSizeForm;
[ONYXKEYS.FORMS.SAGE_INTACCT_CREDENTIALS_FORM]: FormTypes.SageIntactCredentialsForm;
};

type OnyxFormDraftValuesMapping = {
Expand Down
12 changes: 12 additions & 0 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,18 @@ const ROUTES = {
route: 'settings/workspaces/:policyID/accounting/quickbooks-online/import/taxes',
getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-online/import/taxes` as const,
},
POLICY_ACCOUNTING_SAGE_INTACCT_PREREQUISITES: {
route: 'settings/workspaces/:policyID/accounting/sage-intacct/prerequisites',
getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/sage-intacct/prerequisites` as const,
},
POLICY_ACCOUNTING_ENTER_SAGE_INTACCT_CREDENTIALS: {
SzymczakJ marked this conversation as resolved.
Show resolved Hide resolved
route: 'settings/workspaces/:policyID/accounting/sage-intacct/enter-credentials',
getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/sage-intacct/enter-credentials` as const,
},
POLICY_ACCOUNTING_EXISTING_SAGE_INTACCT_CONNECTIONS: {
SzymczakJ marked this conversation as resolved.
Show resolved Hide resolved
route: 'settings/workspaces/:policyID/accounting/sage-intacct/exisitng-connections',
SzymczakJ marked this conversation as resolved.
Show resolved Hide resolved
getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/sage-intacct/exisitng-connections` as const,
SzymczakJ marked this conversation as resolved.
Show resolved Hide resolved
},
} as const;

/**
Expand Down
3 changes: 3 additions & 0 deletions src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,9 @@ const SCREENS = {
XERO_EXPORT_PREFERRED_EXPORTER_SELECT: 'Workspace_Accounting_Xero_Export_Preferred_Exporter_Select',
XERO_BILL_PAYMENT_ACCOUNT_SELECTOR: 'Policy_Accounting_Xero_Bill_Payment_Account_Selector',
XERO_EXPORT_BANK_ACCOUNT_SELECT: 'Policy_Accounting_Xero_Export_Bank_Account_Select',
SAGE_INTACCT_PREREQUISITES: 'Policy_Accounting_Sage_Intacct_Prerequisites',
ENTER_SAGE_INTACCT_CREDENTIALS: 'Policy_Enter_Sage_Intacct_Credentials',
EXISTING_SAGE_INTACCT_CONNECTIONS: 'Policy_Existing_Sage_Intacct_Connections',
},
INITIAL: 'Workspace_Initial',
PROFILE: 'Workspace_Profile',
Expand Down
138 changes: 138 additions & 0 deletions src/components/ConnectToSageIntacctButton/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
import React, {useRef, useState} from 'react';
import type {View} from 'react-native';
import {useOnyx} from 'react-native-onyx';
import Button from '@components/Button';
import ConfirmModal from '@components/ConfirmModal';
import * as Expensicons from '@components/Icon/Expensicons';
import PopoverMenu from '@components/PopoverMenu';
import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import {removePolicyConnection} from '@libs/actions/connections';
import Navigation from '@libs/Navigation/Navigation';
import {getPoliciesConnectedToSageIntacct} from '@libs/PolicyUtils';
import type {AnchorPosition} from '@styles/index';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type {PolicyConnectionName} from '@src/types/onyx/Policy';

type ConnectToSageIntacctButtonProps = {
policyID: string;
shouldDisconnectIntegrationBeforeConnecting?: boolean;
integrationToDisconnect?: PolicyConnectionName;
};

function ConnectToSageIntacctButton({policyID, shouldDisconnectIntegrationBeforeConnecting, integrationToDisconnect}: ConnectToSageIntacctButtonProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const {isOffline} = useNetwork();
const currentIntegration = translate('workspace.accounting.integrationName', integrationToDisconnect);
const integrationToConnect = translate('workspace.accounting.integrationName', CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT);

const [isDisconnectModalOpen, setIsDisconnectModalOpen] = useState(false);

const [policies] = useOnyx(ONYXKEYS.COLLECTION.POLICY);
const hasPoliciesConnectedToSageIntacct = !!getPoliciesConnectedToSageIntacct(policies);
const {isSmallScreenWidth} = useWindowDimensions();
const [isReuseConnectionsPopoverOpen, setIsReuseConnectionsPopoverOpen] = useState(false);
const [reuseConnectionPopoverPosition, setReuseConnectionPopoverPosition] = useState<AnchorPosition>({horizontal: 0, vertical: 0});
const threeDotsMenuContainerRef = useRef<View>(null);
const connectionOptions = [
{
icon: Expensicons.LinkCopy,
text: translate('workspace.intacct.createNewConnection'),
onSelected: () => {
Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_PREREQUISITES.getRoute(policyID));
setIsReuseConnectionsPopoverOpen(false);
},
},
{
icon: Expensicons.Copy,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be enabled if hasPoliciesConnectedToSageIntacct is false?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modal containing these options will pop up only when hasPoliciesConnectedToSageIntacct is true.

text: translate('workspace.intacct.reuseExitingConnection'),
onSelected: () => {
Navigation.navigate(ROUTES.POLICY_ACCOUNTING_EXISTING_SAGE_INTACCT_CONNECTIONS.getRoute(policyID));
setIsReuseConnectionsPopoverOpen(false);
},
},
];

return (
<>
<Button
onPress={() => {
if (shouldDisconnectIntegrationBeforeConnecting && integrationToDisconnect) {
setIsDisconnectModalOpen(true);
return;
}
if (!hasPoliciesConnectedToSageIntacct) {
Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_PREREQUISITES.getRoute(policyID));
return;
}
if (!isSmallScreenWidth) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a little confused on why do we need this?

Copy link
Contributor Author

@SzymczakJ SzymczakJ Jun 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we have big screen, instead of drawer
Screenshot 2024-06-27 at 10 57 26
there is a pop up:
Screenshot 2024-06-27 at 10 57 41
and that's why we need to set these x and y coords(and there is no need to do this when the screen is small 😄 )

threeDotsMenuContainerRef.current?.measureInWindow((x, y, width, height) => {
setReuseConnectionPopoverPosition({
horizontal: x + width,
vertical: y + height,
});
});
}
setIsReuseConnectionsPopoverOpen(true);
}}
text={translate('workspace.accounting.setup')}
style={styles.justifyContentCenter}
small
isDisabled={isOffline}
ref={threeDotsMenuContainerRef}
/>
<PopoverMenu
isVisible={isReuseConnectionsPopoverOpen}
onClose={() => {
setIsReuseConnectionsPopoverOpen(false);
}}
withoutOverlay
menuItems={connectionOptions}
onItemSelected={(item) => {
if (!item?.onSelected) {
return;
}
item.onSelected();
}}
anchorPosition={reuseConnectionPopoverPosition}
anchorAlignment={{horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.RIGHT, vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.TOP}}
anchorRef={threeDotsMenuContainerRef}
/>
{shouldDisconnectIntegrationBeforeConnecting && isDisconnectModalOpen && integrationToDisconnect && (
<ConfirmModal
title={translate('workspace.accounting.disconnectTitle', currentIntegration)}
isVisible
onConfirm={() => {
removePolicyConnection(policyID, integrationToDisconnect);
setIsDisconnectModalOpen(false);
if (!hasPoliciesConnectedToSageIntacct) {
Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_PREREQUISITES.getRoute(policyID));
return;
}
if (!isSmallScreenWidth) {
threeDotsMenuContainerRef.current?.measureInWindow((x, y, width, height) => {
setReuseConnectionPopoverPosition({
horizontal: x + width,
vertical: y + height,
});
});
}
setIsReuseConnectionsPopoverOpen(true);
}}
onCancel={() => setIsDisconnectModalOpen(false)}
prompt={translate('workspace.accounting.disconnectPrompt', integrationToConnect, currentIntegration)}
confirmText={translate('workspace.accounting.disconnect')}
cancelText={translate('common.cancel')}
danger
/>
)}
</>
);
}

export default ConnectToSageIntacctButton;
2 changes: 2 additions & 0 deletions src/components/Icon/Expensicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ import ImageCropSquareMask from '@assets/images/image-crop-square-mask.svg';
import Inbox from '@assets/images/inbox.svg';
import Info from '@assets/images/info.svg';
import QBOSquare from '@assets/images/integrationicons/qbo-icon-square.svg';
import SageIntacctSquare from '@assets/images/integrationicons/sage-intacct-icon-square.svg';
import XeroSquare from '@assets/images/integrationicons/xero-icon-square.svg';
import InvoiceGeneric from '@assets/images/invoice-generic.svg';
import Invoice from '@assets/images/invoice.svg';
Expand Down Expand Up @@ -348,6 +349,7 @@ export {
Workflows,
Workspace,
XeroSquare,
SageIntacctSquare as IntacctSquare,
Zoom,
Twitter,
Youtube,
Expand Down
58 changes: 28 additions & 30 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,8 @@ export default {
shared: 'Shared',
drafts: 'Drafts',
finished: 'Finished',
companyID: 'Company ID',
userID: 'User ID',
},
location: {
useCurrent: 'Use current location',
Expand Down Expand Up @@ -2171,6 +2173,16 @@ export default {
noAccountsFound: 'No accounts found',
noAccountsFoundDescription: 'Add the account in Xero and sync the connection again.',
},
intacct: {
sageIntacctSetup: 'Sage Intacct setup',
prerequisitesTitle: 'Before you connect...',
downloadExpensifyPackage: 'Download the Expensify package for Sage Intacct',
followSteps: 'Follow the steps in our How-to: Connect to Sage Intacct instructions',
enterCredentials: 'Enter your Sage Intacct credentials',
createNewConnection: 'Create new connection',
reuseExitingConnection: 'Reuse existing connection',
SzymczakJ marked this conversation as resolved.
Show resolved Hide resolved
existingConnections: 'Existing connections',
},
type: {
free: 'Free',
control: 'Control',
Expand Down Expand Up @@ -2391,6 +2403,19 @@ export default {
subtitle: 'Connect to your accounting system to code transactions with your chart of accounts, auto-match payments, and keep your finances in sync.',
qbo: 'Quickbooks Online',
xero: 'Xero',
intacct: 'Sage Intacct',
integrationName: (integration?: ConnectionName): string => {
switch (integration) {
case CONST.POLICY.CONNECTIONS.NAME.QBO:
return 'Quickbooks Online';
case CONST.POLICY.CONNECTIONS.NAME.XERO:
return 'Xero';
case CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT:
return 'Sage Intacct';
default:
return 'Integration';
}
},
setup: 'Connect',
lastSync: 'Last synced just now',
import: 'Import',
Expand All @@ -2399,17 +2424,7 @@ export default {
other: 'Other integrations',
syncNow: 'Sync now',
disconnect: 'Disconnect',
disconnectTitle: (integration?: ConnectionName): string => {
switch (integration) {
case CONST.POLICY.CONNECTIONS.NAME.QBO:
return 'Disconnect QuickBooks Online';
case CONST.POLICY.CONNECTIONS.NAME.XERO:
return 'Disconnect Xero';
default: {
return 'Disconnect integration';
}
}
},
disconnectTitle: (integration?: string): string => `Disconnect ${integration}`,
syncError: (integration?: ConnectionName): string => {
switch (integration) {
case CONST.POLICY.CONNECTIONS.NAME.QBO:
Expand All @@ -2434,25 +2449,8 @@ export default {
[CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE]: 'Not imported',
[CONST.INTEGRATION_ENTITY_MAP_TYPES.REPORT_FIELD]: 'Imported, displayed as report fields',
},
disconnectPrompt: (integrationToConnect?: ConnectionName, currentIntegration?: ConnectionName): string => {
switch (integrationToConnect) {
case CONST.POLICY.CONNECTIONS.NAME.QBO:
return 'Are you sure you want to disconnect Xero to set up QuickBooks Online?';
case CONST.POLICY.CONNECTIONS.NAME.XERO:
return 'Are you sure you want to disconnect QuickBooks Online to set up Xero?';
default: {
switch (currentIntegration) {
case CONST.POLICY.CONNECTIONS.NAME.QBO:
return 'Are you sure you want to disconnect QuickBooks Online?';
case CONST.POLICY.CONNECTIONS.NAME.XERO:
return 'Are you sure you want to disconnect Xero?';
default: {
return 'Are you sure you want to disconnect this integration?';
}
}
}
}
},
disconnectPrompt: (integrationToConnect?: string, currentIntegration?: string): string =>
`Are you sure you want to disconnect ${currentIntegration} to set up ${integrationToConnect}?`,
enterCredentials: 'Enter your credentials',
connections: {
syncStageName: (stage: PolicyConnectionSyncStage) => {
Expand Down
Loading
Loading