-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
New Feature: "When to export" selector for auto-sync for NetSuite #51949
Merged
Merged
Changes from 11 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
1f8b718
When to export selector for auto-sync for NetSuite
twilight2294 9be1a90
Add API
twilight2294 b394302
Fix lint errors
twilight2294 08bfaab
fix prettier
twilight2294 6f229fc
Merge branch 'Expensify:main' into issuenewpage
twilight2294 2b10591
address comments
twilight2294 7a604a9
Merge branch 'Expensify:main' into issuenewpage
twilight2294 88abfb1
Use const from expensify-common
twilight2294 1fd9e9f
Fix lint
twilight2294 7040eec
add optional chaining
twilight2294 5a77bfb
Merge branch 'Expensify:main' into issuenewpage
twilight2294 96208e2
Apply offline feedback
twilight2294 33dc114
Merge branch 'Expensify:main' into issuenewpage
twilight2294 357da49
Fix offline state
twilight2294 205ff74
Merge branch 'issuenewpage' of https://github.com/twilight2294/App in…
twilight2294 06f1170
fix wrong file push
twilight2294 4d1245b
improve code redability
twilight2294 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/libs/API/parameters/UpdateNetSuiteAccountingMethodParams.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import type {CONST as COMMON_CONST} from 'expensify-common'; | ||
import type {ValueOf} from 'type-fest'; | ||
|
||
type UpdateNetSuiteAccountingMethodParams = { | ||
policyID: string; | ||
accountingMethod: ValueOf<typeof COMMON_CONST.INTEGRATIONS.ACCOUNTING_METHOD>; | ||
}; | ||
|
||
export default UpdateNetSuiteAccountingMethodParams; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
src/pages/workspace/accounting/netsuite/advanced/NetSuiteAccountingMethodPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import {CONST as COMMON_CONST} from 'expensify-common'; | ||
import React, {useCallback, useMemo} from 'react'; | ||
import {View} from 'react-native'; | ||
import type {ValueOf} from 'type-fest'; | ||
import RadioListItem from '@components/SelectionList/RadioListItem'; | ||
import type {ListItem} from '@components/SelectionList/types'; | ||
import SelectionScreen from '@components/SelectionScreen'; | ||
import type {SelectorType} from '@components/SelectionScreen'; | ||
import Text from '@components/Text'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import * as Connections from '@libs/actions/connections/NetSuiteCommands'; | ||
import Navigation from '@navigation/Navigation'; | ||
import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; | ||
import withPolicyConnections from '@pages/workspace/withPolicyConnections'; | ||
import CONST from '@src/CONST'; | ||
import type {TranslationPaths} from '@src/languages/types'; | ||
import ROUTES from '@src/ROUTES'; | ||
|
||
type MenuListItem = ListItem & { | ||
value: ValueOf<typeof COMMON_CONST.INTEGRATIONS.ACCOUNTING_METHOD>; | ||
}; | ||
|
||
function NetSuiteAccountingMethodPage({policy}: WithPolicyConnectionsProps) { | ||
const {translate} = useLocalize(); | ||
const policyID = policy?.id ?? '-1'; | ||
const styles = useThemeStyles(); | ||
const config = policy?.connections?.netsuite?.options?.config; | ||
const accountingMethod = config?.accountingMethod ?? COMMON_CONST.INTEGRATIONS.ACCOUNTING_METHOD.CASH; | ||
const data: MenuListItem[] = Object.values(COMMON_CONST.INTEGRATIONS.ACCOUNTING_METHOD).map((accountingMethodType) => ({ | ||
value: accountingMethodType, | ||
text: translate(`workspace.netsuite.advancedConfig.accountingMethods.values.${accountingMethodType}` as TranslationPaths), | ||
alternateText: translate(`workspace.netsuite.advancedConfig.accountingMethods.alternateText.${accountingMethodType}` as TranslationPaths), | ||
keyForList: accountingMethodType, | ||
isSelected: accountingMethod === accountingMethodType, | ||
})); | ||
|
||
const headerContent = useMemo( | ||
() => ( | ||
<View> | ||
<Text style={[styles.ph5, styles.pb5]}>{translate('workspace.netsuite.advancedConfig.accountingMethods.description')}</Text> | ||
</View> | ||
), | ||
[translate, styles.pb5, styles.ph5], | ||
); | ||
|
||
const selectExpenseReportApprovalLevel = useCallback( | ||
(row: MenuListItem) => { | ||
if (row.value !== config?.accountingMethod) { | ||
Connections.updateNetSuiteAccountingMethod(policyID, row.value, config?.accountingMethod ?? COMMON_CONST.INTEGRATIONS.ACCOUNTING_METHOD.CASH); | ||
} | ||
Comment on lines
+54
to
+56
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NAB: Add a comment here explaining why we're defaulting to CASH |
||
Navigation.goBack(ROUTES.POLICY_ACCOUNTING_NETSUITE_AUTO_SYNC.getRoute(policyID)); | ||
}, | ||
[config?.accountingMethod, policyID], | ||
); | ||
|
||
return ( | ||
<SelectionScreen | ||
displayName={NetSuiteAccountingMethodPage.displayName} | ||
title="workspace.netsuite.advancedConfig.accountingMethods.label" | ||
headerContent={headerContent} | ||
sections={[{data}]} | ||
listItem={RadioListItem} | ||
onSelectRow={(selection: SelectorType) => selectExpenseReportApprovalLevel(selection as MenuListItem)} | ||
initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} | ||
policyID={policyID} | ||
accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN]} | ||
featureName={CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED} | ||
onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_NETSUITE_AUTO_SYNC.getRoute(policyID))} | ||
connectionName={CONST.POLICY.CONNECTIONS.NAME.NETSUITE} | ||
/> | ||
); | ||
} | ||
|
||
NetSuiteAccountingMethodPage.displayName = 'NetSuiteExpenseReportApprovalLevelSelectPage'; | ||
|
||
export default withPolicyConnections(NetSuiteAccountingMethodPage); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aimane-chnaif can you please confirm these translations, I'm yet to be added in the open source channel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
asked here - https://expensify.slack.com/archives/C01GTK53T8Q/p1730794819460039
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@twilight2294 Here's updated copies:
English: (- added in out of pocket)
Spanish:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the help, it's late here, I will update tomorrow