From fda657cf96c1235cf0606a89cd91cd4d764f7ad7 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 6 Jun 2024 02:42:10 +0300 Subject: [PATCH 01/35] add payroll screen --- src/SCREENS.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SCREENS.ts b/src/SCREENS.ts index fd7418aee1c5..5dea2db57668 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -310,6 +310,7 @@ const SCREENS = { NAME: 'Workspace_Profile_Name', CATEGORY_CREATE: 'Category_Create', CATEGORY_EDIT: 'Category_Edit', + CATEGORY_PAYROLL_CODE: 'Category_Payroll_Code', CATEGORY_SETTINGS: 'Category_Settings', CATEGORIES_SETTINGS: 'Categories_Settings', MORE_FEATURES: 'Workspace_More_Features', From bdf8070fa997f2efb2c48d080f318a18fc0f5bc8 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 6 Jun 2024 02:42:41 +0300 Subject: [PATCH 02/35] add payroll route --- src/ROUTES.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 5a8f4a2cd4d0..9081c58fb9b0 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -688,6 +688,10 @@ const ROUTES = { route: 'settings/workspaces/:policyID/categories/:categoryName/edit', getRoute: (policyID: string, categoryName: string) => `settings/workspaces/${policyID}/categories/${encodeURIComponent(categoryName)}/edit` as const, }, + WORKSPACE_CATEGORY_PAYROLL_CODE: { + route: 'settings/workspaces/:policyID/categories/:categoryName/payroll-code', + getRoute: (policyID: string, categoryName: string) => `settings/workspaces/${policyID}/categories/${encodeURIComponent(categoryName)}/payroll-code` as const, + }, WORKSPACE_MORE_FEATURES: { route: 'settings/workspaces/:policyID/more-features', getRoute: (policyID: string) => `settings/workspaces/${policyID}/more-features` as const, From b29331ad03df15319d4326918475dee2b168100c Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 6 Jun 2024 02:45:52 +0300 Subject: [PATCH 03/35] add navigation links for payroll --- .../AppNavigator/ModalStackNavigators/index.tsx | 1 + .../linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts | 8 +++++++- src/libs/Navigation/linkingConfig/config.ts | 6 ++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 9a391e386f15..827ea8cd74f8 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -243,6 +243,7 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/members/WorkspaceOwnerChangeErrorPage').default as React.ComponentType, [SCREENS.WORKSPACE.CATEGORY_CREATE]: () => require('../../../../pages/workspace/categories/CreateCategoryPage').default as React.ComponentType, [SCREENS.WORKSPACE.CATEGORY_EDIT]: () => require('../../../../pages/workspace/categories/EditCategoryPage').default as React.ComponentType, + [SCREENS.WORKSPACE.CATEGORY_PAYROLL_CODE]: () => require('../../../../pages/workspace/categories/CategoryPayrollCodePage').default as React.ComponentType, [SCREENS.WORKSPACE.CREATE_DISTANCE_RATE]: () => require('../../../../pages/workspace/distanceRates/CreateDistanceRatePage').default as React.ComponentType, [SCREENS.WORKSPACE.DISTANCE_RATES_SETTINGS]: () => require('../../../../pages/workspace/distanceRates/PolicyDistanceRatesSettingsPage').default as React.ComponentType, [SCREENS.WORKSPACE.DISTANCE_RATE_DETAILS]: () => require('../../../../pages/workspace/distanceRates/PolicyDistanceRateDetailsPage').default as React.ComponentType, diff --git a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts index f91d290639ff..67d1c6a76851 100755 --- a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts @@ -74,7 +74,13 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial> = { SCREENS.WORKSPACE.TAG_EDIT, SCREENS.WORKSPACE.TAG_LIST_VIEW, ], - [SCREENS.WORKSPACE.CATEGORIES]: [SCREENS.WORKSPACE.CATEGORY_CREATE, SCREENS.WORKSPACE.CATEGORY_SETTINGS, SCREENS.WORKSPACE.CATEGORIES_SETTINGS, SCREENS.WORKSPACE.CATEGORY_EDIT], + [SCREENS.WORKSPACE.CATEGORIES]: [ + SCREENS.WORKSPACE.CATEGORY_CREATE, + SCREENS.WORKSPACE.CATEGORY_SETTINGS, + SCREENS.WORKSPACE.CATEGORIES_SETTINGS, + SCREENS.WORKSPACE.CATEGORY_EDIT, + SCREENS.WORKSPACE.CATEGORY_PAYROLL_CODE, + ], [SCREENS.WORKSPACE.DISTANCE_RATES]: [ SCREENS.WORKSPACE.CREATE_DISTANCE_RATE, SCREENS.WORKSPACE.DISTANCE_RATES_SETTINGS, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index b3f27d422b4b..bf0d35eb9363 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -408,6 +408,12 @@ const config: LinkingOptions['config'] = { categoryName: (categoryName: string) => decodeURIComponent(categoryName), }, }, + [SCREENS.WORKSPACE.CATEGORY_PAYROLL_CODE]: { + path: ROUTES.WORKSPACE_CATEGORY_PAYROLL_CODE.route, + parse: { + categoryName: (categoryName: string) => decodeURIComponent(categoryName), + }, + }, [SCREENS.WORKSPACE.CREATE_DISTANCE_RATE]: { path: ROUTES.WORKSPACE_CREATE_DISTANCE_RATE.route, }, From 78cb66102120c9525d4e91e1fdd52736a740855d Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 6 Jun 2024 02:46:31 +0300 Subject: [PATCH 04/35] add nav type --- src/libs/Navigation/types.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 2267d2d38fb7..0d2f61b29b09 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -200,6 +200,10 @@ type SettingsNavigatorParamList = { categoryName: string; backTo?: Routes; }; + [SCREENS.WORKSPACE.CATEGORY_PAYROLL_CODE]: { + policyID: string; + categoryName: string; + }; [SCREENS.WORKSPACE.CATEGORY_SETTINGS]: { policyID: string; categoryName: string; From 4ad00ea3049430c3ac16a1706e1ad9d1ecc132b5 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 6 Jun 2024 02:48:05 +0300 Subject: [PATCH 05/35] add menu item for payroll code to category settings page --- src/pages/workspace/categories/CategorySettingsPage.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/pages/workspace/categories/CategorySettingsPage.tsx b/src/pages/workspace/categories/CategorySettingsPage.tsx index 22f2b4f02fbf..eab73db63367 100644 --- a/src/pages/workspace/categories/CategorySettingsPage.tsx +++ b/src/pages/workspace/categories/CategorySettingsPage.tsx @@ -138,6 +138,14 @@ function CategorySettingsPage({route, policyCategories, navigation}: CategorySet shouldShowRightIcon /> + + Navigation.navigate(ROUTES.WORKSPACE_CATEGORY_PAYROLL_CODE.getRoute(route.params.policyID, policyCategory.name))} + shouldShowRightIcon + /> + From 2cec124f843f43816a9322de70b9644ac85565b1 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 6 Jun 2024 02:51:11 +0300 Subject: [PATCH 06/35] add payroll code to category type --- src/types/onyx/PolicyCategory.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/types/onyx/PolicyCategory.ts b/src/types/onyx/PolicyCategory.ts index d4162bfdcddf..15e237eebf01 100644 --- a/src/types/onyx/PolicyCategory.ts +++ b/src/types/onyx/PolicyCategory.ts @@ -17,6 +17,9 @@ type PolicyCategory = OnyxCommon.OnyxValueWithOfflineFeedback<{ // eslint-disable-next-line @typescript-eslint/naming-convention 'GL Code'?: string; + /** Payroll code is used to keep track of taxes, deductions, and an employee’s earnings */ + payrollCode?: string; + /** An ID for this category from an external accounting system */ externalID?: string; From bf7b779535cd768f6c7fdc243de4d17f9ff123fc Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 6 Jun 2024 02:52:33 +0300 Subject: [PATCH 07/35] add payroll code to form type --- src/types/form/WorkspaceCategoryForm.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/types/form/WorkspaceCategoryForm.ts b/src/types/form/WorkspaceCategoryForm.ts index 4f5f9282373c..9e813319b38c 100644 --- a/src/types/form/WorkspaceCategoryForm.ts +++ b/src/types/form/WorkspaceCategoryForm.ts @@ -3,6 +3,7 @@ import type Form from './Form'; const INPUT_IDS = { CATEGORY_NAME: 'categoryName', + PAYROLL_CODE: 'payrollCode', } as const; type InputID = ValueOf; From 6d1e6033b0d767974aa07a86f0a7db3571757fc1 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 6 Jun 2024 02:52:45 +0300 Subject: [PATCH 08/35] add payroll code to form type --- src/types/form/WorkspaceCategoryForm.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/types/form/WorkspaceCategoryForm.ts b/src/types/form/WorkspaceCategoryForm.ts index 9e813319b38c..9224957847a3 100644 --- a/src/types/form/WorkspaceCategoryForm.ts +++ b/src/types/form/WorkspaceCategoryForm.ts @@ -12,6 +12,7 @@ type WorkspaceCategoryForm = Form< InputID, { [INPUT_IDS.CATEGORY_NAME]: string; + [INPUT_IDS.PAYROLL_CODE]: string; } >; From 4e6c965f9e954c004bb0f327ab8a877b15b4dede Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 6 Jun 2024 02:55:15 +0300 Subject: [PATCH 09/35] add payroll code --- src/languages/en.ts | 1 + src/languages/es.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src/languages/en.ts b/src/languages/en.ts index 9a047178147e..328f81a14b7d 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2197,6 +2197,7 @@ export default { existingCategoryError: 'A category with this name already exists.', invalidCategoryName: 'Invalid category name.', importedFromAccountingSoftware: 'The categories below are imported from your', + payrollCode: 'Payroll code', }, moreFeatures: { spendSection: { diff --git a/src/languages/es.ts b/src/languages/es.ts index c3fd2bc46849..693bf874e385 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2236,6 +2236,7 @@ export default { existingCategoryError: 'Ya existe una categoría con este nombre.', invalidCategoryName: 'Lo nombre de la categoría es invalido.', importedFromAccountingSoftware: 'Categorías importadas desde', + payrollCode: 'Payroll code', }, moreFeatures: { spendSection: { From 2e60d83936f9979b450b3e0954fcfd407615e656 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 6 Jun 2024 02:55:58 +0300 Subject: [PATCH 10/35] add payroll code err msg --- src/languages/en.ts | 1 + src/languages/es.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src/languages/en.ts b/src/languages/en.ts index 328f81a14b7d..62e52911f564 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2198,6 +2198,7 @@ export default { invalidCategoryName: 'Invalid category name.', importedFromAccountingSoftware: 'The categories below are imported from your', payrollCode: 'Payroll code', + updatePayrollCodeFailureMessage: 'An error occurred while updating the payroll code, please try again.', }, moreFeatures: { spendSection: { diff --git a/src/languages/es.ts b/src/languages/es.ts index 693bf874e385..5ea9fe95643e 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2237,6 +2237,7 @@ export default { invalidCategoryName: 'Lo nombre de la categoría es invalido.', importedFromAccountingSoftware: 'Categorías importadas desde', payrollCode: 'Payroll code', + updatePayrollCodeFailureMessage: 'An error occurred while updating the payroll code, please try again.', }, moreFeatures: { spendSection: { From f20f10c4035d327b4e68c31d564f53fbfda4fe7c Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 6 Jun 2024 02:56:27 +0300 Subject: [PATCH 11/35] add payroll code page --- .../categories/CategoryPayrollCodePage.tsx | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 src/pages/workspace/categories/CategoryPayrollCodePage.tsx diff --git a/src/pages/workspace/categories/CategoryPayrollCodePage.tsx b/src/pages/workspace/categories/CategoryPayrollCodePage.tsx new file mode 100644 index 000000000000..2761c8fdb533 --- /dev/null +++ b/src/pages/workspace/categories/CategoryPayrollCodePage.tsx @@ -0,0 +1,94 @@ +import type {StackScreenProps} from '@react-navigation/stack'; +import React, {useCallback} from 'react'; +import {withOnyx} from 'react-native-onyx'; +import type {OnyxEntry} from 'react-native-onyx'; +import FormProvider from '@components/Form/FormProvider'; +import InputWrapper from '@components/Form/InputWrapper'; +import type {FormOnyxValues} from '@components/Form/types'; +import HeaderWithBackButton from '@components/HeaderWithBackButton'; +import ScreenWrapper from '@components/ScreenWrapper'; +import TextInput from '@components/TextInput'; +import useAutoFocusInput from '@hooks/useAutoFocusInput'; +import useLocalize from '@hooks/useLocalize'; +import useThemeStyles from '@hooks/useThemeStyles'; +import Navigation from '@libs/Navigation/Navigation'; +import type {SettingsNavigatorParamList} from '@navigation/types'; +import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; +import * as Category from '@userActions/Policy/Category'; +import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; +import ROUTES from '@src/ROUTES'; +import type SCREENS from '@src/SCREENS'; +import INPUT_IDS from '@src/types/form/WorkspaceCategoryForm'; +import type {PolicyCategories} from '@src/types/onyx'; + +type WorkspaceEditCategoryPayrollCodePageOnyxProps = { + /** Collection of categories attached to a policy */ + policyCategories: OnyxEntry; +}; + +type EditCategoryPageProps = WorkspaceEditCategoryPayrollCodePageOnyxProps & StackScreenProps; + +function CategoryPayrollCodePage({route, policyCategories}: EditCategoryPageProps) { + const styles = useThemeStyles(); + const {translate} = useLocalize(); + const categoryName = route.params.categoryName; + const glCode = policyCategories?.[categoryName]?.payrollCode; + const {inputCallbackRef} = useAutoFocusInput(); + + const editGLCode = useCallback( + (values: FormOnyxValues) => { + const newGLCode = values.payrollCode.trim(); + if (newGLCode !== glCode) { + Category.setPolicyCategoryPayrollCode(route.params.policyID, categoryName, newGLCode); + } + Navigation.goBack(); + }, + [categoryName, glCode, route.params.policyID], + ); + + return ( + + + Navigation.goBack(ROUTES.WORKSPACE_CATEGORY_SETTINGS.getRoute(route.params.policyID, route.params.categoryName))} + /> + + + + + + ); +} + +CategoryPayrollCodePage.displayName = 'CategoryPayrollCodePage'; + +export default withOnyx({ + policyCategories: { + key: ({route}) => `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${route?.params?.policyID}`, + }, +})(CategoryPayrollCodePage); \ No newline at end of file From bf3dd2f538581edb5152eda2c72a0d1dbab07492 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 6 Jun 2024 02:58:48 +0300 Subject: [PATCH 12/35] add api command impl for set payroll code --- src/libs/actions/Policy/Category.ts | 61 +++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/src/libs/actions/Policy/Category.ts b/src/libs/actions/Policy/Category.ts index 294712666bdf..c4d6d6c54f25 100644 --- a/src/libs/actions/Policy/Category.ts +++ b/src/libs/actions/Policy/Category.ts @@ -334,6 +334,66 @@ function renamePolicyCategory(policyID: string, policyCategory: {oldName: string API.write(WRITE_COMMANDS.RENAME_WORKSPACE_CATEGORY, parameters, onyxData); } +function setPolicyCategoryPayrollCode(policyID: string, categoryName: string, payrollCode: string) { + const policyCategoryToUpdate = allPolicyCategories?.[`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`]?.[categoryName] ?? {}; + + const onyxData: OnyxData = { + optimisticData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`, + value: { + [categoryName]: { + ...policyCategoryToUpdate, + pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + pendingFields: { + name: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + }, + payrollCode, + }, + }, + }, + ], + successData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`, + value: { + [categoryName]: { + ...policyCategoryToUpdate, + pendingAction: null, + pendingFields: { + name: null, + }, + payrollCode, + }, + }, + }, + ], + failureData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`, + value: { + [categoryName]: { + ...policyCategoryToUpdate, + errors: ErrorUtils.getMicroSecondOnyxError('workspace.categories.updatePayrollCodeFailureMessage'), + pendingAction: null, + }, + }, + }, + ], + }; + + const parameters = { + policyID, + categoryName, + payrollCode, + }; + + API.write(WRITE_COMMANDS.UPDATE_POLICY_CATEGORY_GL_CODE, parameters, onyxData); +} + function setWorkspaceRequiresCategory(policyID: string, requiresCategory: boolean) { const onyxData: OnyxData = { optimisticData: [ @@ -591,6 +651,7 @@ export { buildOptimisticPolicyRecentlyUsedCategories, setWorkspaceCategoryEnabled, setWorkspaceRequiresCategory, + setPolicyCategoryPayrollCode, createPolicyCategory, renamePolicyCategory, clearCategoryErrors, From ed69bd00fc5b8558cc7b7edcc60a8c95fc8ddda4 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 6 Jun 2024 03:01:42 +0300 Subject: [PATCH 13/35] add api params --- .../parameters/UpdatePolicyCategoryPayrollCodeParams.ts | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/libs/API/parameters/UpdatePolicyCategoryPayrollCodeParams.ts diff --git a/src/libs/API/parameters/UpdatePolicyCategoryPayrollCodeParams.ts b/src/libs/API/parameters/UpdatePolicyCategoryPayrollCodeParams.ts new file mode 100644 index 000000000000..d5f71f7179c4 --- /dev/null +++ b/src/libs/API/parameters/UpdatePolicyCategoryPayrollCodeParams.ts @@ -0,0 +1,7 @@ +type UpdatePolicyCategoryPayrollCodeParams = { + policyID: string; + categoryName: string; + payroll: string; +}; + +export default UpdatePolicyCategoryPayrollCodeParams; \ No newline at end of file From d150bdc4d7a9a69137a3c03cfdb421ffc41d41f5 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 6 Jun 2024 03:01:52 +0300 Subject: [PATCH 14/35] link api params --- src/libs/API/parameters/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index de8d6f55418b..7fb617ca71a5 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -165,6 +165,7 @@ export type {default as CreateWorkspaceCategoriesParams} from './CreateWorkspace export type {default as RenameWorkspaceCategoriesParams} from './RenameWorkspaceCategoriesParams'; export type {default as SetWorkspaceRequiresCategoryParams} from './SetWorkspaceRequiresCategoryParams'; export type {default as DeleteWorkspaceCategoriesParams} from './DeleteWorkspaceCategoriesParams'; +export type {default as UpdatePolicyCategoryPayrollCodeParams} from './UpdatePolicyCategoryPayrollCodeParams'; export type {default as SetWorkspaceAutoReportingParams} from './SetWorkspaceAutoReportingParams'; export type {default as SetWorkspaceAutoReportingFrequencyParams} from './SetWorkspaceAutoReportingFrequencyParams'; export type {default as SetWorkspaceAutoReportingMonthlyOffsetParams} from './SetWorkspaceAutoReportingMonthlyOffsetParams'; From 05be40cb5c43c611fcbbf7bfa394f9b1ba169b4e Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 6 Jun 2024 03:03:49 +0300 Subject: [PATCH 15/35] add payroll code api typing --- src/libs/API/types.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index 3f1acaaed466..9a8fbe457d28 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -132,6 +132,7 @@ const WRITE_COMMANDS = { CREATE_POLICY_TAG: 'CreatePolicyTag', RENAME_POLICY_TAG: 'RenamePolicyTag', SET_WORKSPACE_REQUIRES_CATEGORY: 'SetWorkspaceRequiresCategory', + UPDATE_POLICY_CATEGORY_PAYROLL_CODE: 'UpdatePolicyCategoryPayrollCode', DELETE_WORKSPACE_CATEGORIES: 'DeleteWorkspaceCategories', SET_POLICY_REQUIRES_TAG: 'SetPolicyRequiresTag', RENAME_POLICY_TAG_LIST: 'RenamePolicyTaglist', @@ -342,6 +343,7 @@ type WriteCommandParameters = { [WRITE_COMMANDS.RENAME_WORKSPACE_CATEGORY]: Parameters.RenameWorkspaceCategoriesParams; [WRITE_COMMANDS.SET_WORKSPACE_REQUIRES_CATEGORY]: Parameters.SetWorkspaceRequiresCategoryParams; [WRITE_COMMANDS.DELETE_WORKSPACE_CATEGORIES]: Parameters.DeleteWorkspaceCategoriesParams; + [WRITE_COMMANDS.UPDATE_POLICY_CATEGORY_PAYROLL_CODE]: Parameters.UpdatePolicyCategoryPayrollCodeParams; [WRITE_COMMANDS.SET_POLICY_REQUIRES_TAG]: Parameters.SetPolicyRequiresTag; [WRITE_COMMANDS.RENAME_POLICY_TAG_LIST]: Parameters.RenamePolicyTaglist; [WRITE_COMMANDS.CREATE_POLICY_TAG]: Parameters.CreatePolicyTagsParams; From 9a1509813bccbde7122f3b6da22ec2f6c57974af Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 6 Jun 2024 03:10:51 +0300 Subject: [PATCH 16/35] api call to payroll code --- src/libs/actions/Policy/Category.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/Policy/Category.ts b/src/libs/actions/Policy/Category.ts index c4d6d6c54f25..4dd66dbce4bb 100644 --- a/src/libs/actions/Policy/Category.ts +++ b/src/libs/actions/Policy/Category.ts @@ -391,7 +391,7 @@ function setPolicyCategoryPayrollCode(policyID: string, categoryName: string, pa payrollCode, }; - API.write(WRITE_COMMANDS.UPDATE_POLICY_CATEGORY_GL_CODE, parameters, onyxData); + API.write(WRITE_COMMANDS.UPDATE_POLICY_CATEGORY_PAYROLL_CODE, parameters, onyxData); } function setWorkspaceRequiresCategory(policyID: string, requiresCategory: boolean) { From 47d4566c3b59e37e4bade371ac16133605a094a8 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 6 Jun 2024 03:16:41 +0300 Subject: [PATCH 17/35] fix typo --- .../API/parameters/UpdatePolicyCategoryPayrollCodeParams.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/API/parameters/UpdatePolicyCategoryPayrollCodeParams.ts b/src/libs/API/parameters/UpdatePolicyCategoryPayrollCodeParams.ts index d5f71f7179c4..8751832f7cad 100644 --- a/src/libs/API/parameters/UpdatePolicyCategoryPayrollCodeParams.ts +++ b/src/libs/API/parameters/UpdatePolicyCategoryPayrollCodeParams.ts @@ -1,7 +1,7 @@ type UpdatePolicyCategoryPayrollCodeParams = { policyID: string; categoryName: string; - payroll: string; + payrollCode: string; }; -export default UpdatePolicyCategoryPayrollCodeParams; \ No newline at end of file +export default UpdatePolicyCategoryPayrollCodeParams; From b8aa3b2df48cbf0ff50f25b6998f63166962c477 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 6 Jun 2024 03:21:02 +0300 Subject: [PATCH 18/35] use correct pending fields --- src/libs/actions/Policy/Category.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/Policy/Category.ts b/src/libs/actions/Policy/Category.ts index 4dd66dbce4bb..ad4fd97c535b 100644 --- a/src/libs/actions/Policy/Category.ts +++ b/src/libs/actions/Policy/Category.ts @@ -347,7 +347,7 @@ function setPolicyCategoryPayrollCode(policyID: string, categoryName: string, pa ...policyCategoryToUpdate, pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, pendingFields: { - name: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + payrollCode: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, }, payrollCode, }, @@ -363,7 +363,7 @@ function setPolicyCategoryPayrollCode(policyID: string, categoryName: string, pa ...policyCategoryToUpdate, pendingAction: null, pendingFields: { - name: null, + payrollCode: null, }, payrollCode, }, From ff2c26166100ed50a01ecd014cc8c4b3264bb9b5 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 6 Jun 2024 03:29:51 +0300 Subject: [PATCH 19/35] run prettier --- src/pages/workspace/categories/CategoryPayrollCodePage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/categories/CategoryPayrollCodePage.tsx b/src/pages/workspace/categories/CategoryPayrollCodePage.tsx index 2761c8fdb533..8dc491e2b331 100644 --- a/src/pages/workspace/categories/CategoryPayrollCodePage.tsx +++ b/src/pages/workspace/categories/CategoryPayrollCodePage.tsx @@ -91,4 +91,4 @@ export default withOnyx `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${route?.params?.policyID}`, }, -})(CategoryPayrollCodePage); \ No newline at end of file +})(CategoryPayrollCodePage); From e5c6ca0d6f2e7a3bf259f87f6c2c08e8aab668ed Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 26 Jun 2024 16:03:49 +0300 Subject: [PATCH 20/35] add max length --- src/CONST.ts | 2 ++ src/pages/workspace/categories/CategoryPayrollCodePage.tsx | 1 + 2 files changed, 3 insertions(+) diff --git a/src/CONST.ts b/src/CONST.ts index e71ad55a452c..6364391f72c3 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -4912,6 +4912,8 @@ const CONST = { }, }, + MAX_LENGTH_256: 256, + EXCLUDE_FROM_LAST_VISITED_PATH: [SCREENS.NOT_FOUND, SCREENS.SAML_SIGN_IN, SCREENS.VALIDATE_LOGIN] as string[], } as const; diff --git a/src/pages/workspace/categories/CategoryPayrollCodePage.tsx b/src/pages/workspace/categories/CategoryPayrollCodePage.tsx index 8dc491e2b331..bc8666effb74 100644 --- a/src/pages/workspace/categories/CategoryPayrollCodePage.tsx +++ b/src/pages/workspace/categories/CategoryPayrollCodePage.tsx @@ -78,6 +78,7 @@ function CategoryPayrollCodePage({route, policyCategories}: EditCategoryPageProp accessibilityLabel={translate('workspace.categories.payrollCode')} inputID={INPUT_IDS.PAYROLL_CODE} role={CONST.ROLE.PRESENTATION} + maxLength={CONST.MAX_LENGTH_256} /> From 2a4637b08bb6070b621bce6f9f8ef169df55486d Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 26 Jun 2024 16:04:21 +0300 Subject: [PATCH 21/35] fix merge --- src/pages/workspace/categories/CategorySettingsPage.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/pages/workspace/categories/CategorySettingsPage.tsx b/src/pages/workspace/categories/CategorySettingsPage.tsx index ce216b16d306..317cb50d66f4 100644 --- a/src/pages/workspace/categories/CategorySettingsPage.tsx +++ b/src/pages/workspace/categories/CategorySettingsPage.tsx @@ -126,7 +126,6 @@ function CategorySettingsPage({route, policyCategories, navigation}: CategorySet shouldShowRightIcon /> -<<<<<<< HEAD -======= {!isThereAnyAccountingConnection && ( setDeleteCategoryConfirmModalVisible(true)} /> )} ->>>>>>> main From 3e7bb90a94125d44fa31094f303f366c6859ac37 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 26 Jun 2024 16:07:55 +0300 Subject: [PATCH 22/35] use translation key --- src/libs/actions/Policy/Category.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/Policy/Category.ts b/src/libs/actions/Policy/Category.ts index 0eb3622f3ed6..b68c8a8c082b 100644 --- a/src/libs/actions/Policy/Category.ts +++ b/src/libs/actions/Policy/Category.ts @@ -374,7 +374,7 @@ function setPolicyCategoryPayrollCode(policyID: string, categoryName: string, pa value: { [categoryName]: { ...policyCategoryToUpdate, - errors: ErrorUtils.getMicroSecondOnyxError('workspace.categories.updatePayrollCodeFailureMessage'), + errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('workspace.categories.updatePayrollCodeFailureMessage'), pendingAction: null, }, }, From cc0423b159d5c9f9258dd375d604459ef6330915 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Sat, 6 Jul 2024 20:12:40 +0300 Subject: [PATCH 23/35] set pending fields as none --- src/libs/actions/Policy/Category.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libs/actions/Policy/Category.ts b/src/libs/actions/Policy/Category.ts index b68c8a8c082b..f9da0ece9a2c 100644 --- a/src/libs/actions/Policy/Category.ts +++ b/src/libs/actions/Policy/Category.ts @@ -376,6 +376,9 @@ function setPolicyCategoryPayrollCode(policyID: string, categoryName: string, pa ...policyCategoryToUpdate, errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('workspace.categories.updatePayrollCodeFailureMessage'), pendingAction: null, + pendingFields: { + payrollCode: null, + }, }, }, }, From d7f3aa433776f02b3bdd8451de9e7c22a8e7e37a Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Sat, 6 Jul 2024 20:23:36 +0300 Subject: [PATCH 24/35] use useonyx --- .../categories/CategoryPayrollCodePage.tsx | 34 +++++++------------ 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/src/pages/workspace/categories/CategoryPayrollCodePage.tsx b/src/pages/workspace/categories/CategoryPayrollCodePage.tsx index bc8666effb74..58174c7738d2 100644 --- a/src/pages/workspace/categories/CategoryPayrollCodePage.tsx +++ b/src/pages/workspace/categories/CategoryPayrollCodePage.tsx @@ -1,7 +1,6 @@ import type {StackScreenProps} from '@react-navigation/stack'; import React, {useCallback} from 'react'; -import {withOnyx} from 'react-native-onyx'; -import type {OnyxEntry} from 'react-native-onyx'; +import {useOnyx} from 'react-native-onyx'; import FormProvider from '@components/Form/FormProvider'; import InputWrapper from '@components/Form/InputWrapper'; import type {FormOnyxValues} from '@components/Form/types'; @@ -20,31 +19,28 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import INPUT_IDS from '@src/types/form/WorkspaceCategoryForm'; -import type {PolicyCategories} from '@src/types/onyx'; -type WorkspaceEditCategoryPayrollCodePageOnyxProps = { - /** Collection of categories attached to a policy */ - policyCategories: OnyxEntry; -}; +type EditCategoryPageProps = StackScreenProps; -type EditCategoryPageProps = WorkspaceEditCategoryPayrollCodePageOnyxProps & StackScreenProps; - -function CategoryPayrollCodePage({route, policyCategories}: EditCategoryPageProps) { +function CategoryPayrollCodePage({route}: EditCategoryPageProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); + const policyId = route.params.policyID ?? '-1'; + const [policyCategories] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyId}`); + const categoryName = route.params.categoryName; - const glCode = policyCategories?.[categoryName]?.payrollCode; + const payrollCode = policyCategories?.[categoryName]?.payrollCode; const {inputCallbackRef} = useAutoFocusInput(); const editGLCode = useCallback( (values: FormOnyxValues) => { - const newGLCode = values.payrollCode.trim(); - if (newGLCode !== glCode) { - Category.setPolicyCategoryPayrollCode(route.params.policyID, categoryName, newGLCode); + const newPayrollCode = values.payrollCode.trim(); + if (newPayrollCode !== payrollCode) { + Category.setPolicyCategoryPayrollCode(route.params.policyID, categoryName, newPayrollCode); } Navigation.goBack(); }, - [categoryName, glCode, route.params.policyID], + [categoryName, payrollCode, route.params.policyID], ); return ( @@ -73,7 +69,7 @@ function CategoryPayrollCodePage({route, policyCategories}: EditCategoryPageProp ({ - policyCategories: { - key: ({route}) => `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${route?.params?.policyID}`, - }, -})(CategoryPayrollCodePage); +export default CategoryPayrollCodePage; From 3bb29bcb0ac6f5c006690bfcc6511a4b28a21e75 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Sat, 6 Jul 2024 20:25:44 +0300 Subject: [PATCH 25/35] add fallback navigation --- src/pages/workspace/categories/CategoryPayrollCodePage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/categories/CategoryPayrollCodePage.tsx b/src/pages/workspace/categories/CategoryPayrollCodePage.tsx index 58174c7738d2..85aa031d3fc4 100644 --- a/src/pages/workspace/categories/CategoryPayrollCodePage.tsx +++ b/src/pages/workspace/categories/CategoryPayrollCodePage.tsx @@ -38,9 +38,9 @@ function CategoryPayrollCodePage({route}: EditCategoryPageProps) { if (newPayrollCode !== payrollCode) { Category.setPolicyCategoryPayrollCode(route.params.policyID, categoryName, newPayrollCode); } - Navigation.goBack(); + Navigation.goBack(ROUTES.WORKSPACE_CATEGORY_SETTINGS.getRoute(route.params.policyID, route.params.categoryName)); }, - [categoryName, payrollCode, route.params.policyID], + [categoryName, payrollCode, route.params.categoryName, route.params.policyID], ); return ( From 2bc06c976f637c046361a2cd258fd04a27894f3c Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 9 Jul 2024 15:31:34 +0300 Subject: [PATCH 26/35] add control policy access variant --- src/CONST.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CONST.ts b/src/CONST.ts index caf0b1453fae..c5953fb74a03 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -2048,6 +2048,7 @@ const CONST = { ACCESS_VARIANTS: { PAID: 'paid', ADMIN: 'admin', + CONTROL: 'control', }, DEFAULT_MAX_EXPENSE_AGE: 90, DEFAULT_MAX_EXPENSE_AMOUNT: 200000, From 89fec2f10faf9fd2be5cc5b1dcf24d8494a3d8db Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 9 Jul 2024 15:31:43 +0300 Subject: [PATCH 27/35] add control policy access variant --- src/libs/PolicyUtils.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index fc9a04e2507c..74709faedc9c 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -305,6 +305,10 @@ function isPaidGroupPolicy(policy: OnyxEntry): boolean { return policy?.type === CONST.POLICY.TYPE.TEAM || policy?.type === CONST.POLICY.TYPE.CORPORATE; } +function isControlPolicy(policy: OnyxEntry): boolean { + return policy?.type === CONST.POLICY.TYPE.CORPORATE; +} + function isTaxTrackingEnabled(isPolicyExpenseChat: boolean, policy: OnyxEntry, isDistanceRequest: boolean): boolean { const distanceUnit = getCustomUnit(policy); const customUnitID = distanceUnit?.customUnitID ?? 0; @@ -727,6 +731,7 @@ export { getIntegrationLastSuccessfulDate, getCurrentConnectionName, getCustomersOrJobsLabelNetSuite, + isControlPolicy, }; export type {MemberEmailsToAccountIDs}; From d884e041c1c797476281e83d56f2715fe3f605c2 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 9 Jul 2024 15:31:54 +0300 Subject: [PATCH 28/35] add control policy access variant --- src/pages/workspace/AccessOrNotFoundWrapper.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/workspace/AccessOrNotFoundWrapper.tsx b/src/pages/workspace/AccessOrNotFoundWrapper.tsx index c7f89559fdda..351bd36fbb34 100644 --- a/src/pages/workspace/AccessOrNotFoundWrapper.tsx +++ b/src/pages/workspace/AccessOrNotFoundWrapper.tsx @@ -23,6 +23,7 @@ import {isEmptyObject} from '@src/types/utils/EmptyObject'; const ACCESS_VARIANTS = { [CONST.POLICY.ACCESS_VARIANTS.PAID]: (policy: OnyxEntry) => PolicyUtils.isPaidGroupPolicy(policy), + [CONST.POLICY.ACCESS_VARIANTS.CONTROL]: (policy: OnyxEntry) => PolicyUtils.isControlPolicy(policy), [CONST.POLICY.ACCESS_VARIANTS.ADMIN]: (policy: OnyxEntry, login: string) => PolicyUtils.isPolicyAdmin(policy, login), [CONST.IOU.ACCESS_VARIANTS.CREATE]: ( policy: OnyxEntry, From 39f60d525bb77081054c5bab2f2cc8fd932c9ff2 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 9 Jul 2024 15:32:09 +0300 Subject: [PATCH 29/35] add control policy access variant --- src/pages/workspace/categories/CategoryPayrollCodePage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/categories/CategoryPayrollCodePage.tsx b/src/pages/workspace/categories/CategoryPayrollCodePage.tsx index 85aa031d3fc4..8028906401fb 100644 --- a/src/pages/workspace/categories/CategoryPayrollCodePage.tsx +++ b/src/pages/workspace/categories/CategoryPayrollCodePage.tsx @@ -45,7 +45,7 @@ function CategoryPayrollCodePage({route}: EditCategoryPageProps) { return ( From e2ac2e0c1e52f5df7b16c77cf7c0f230b8c06889 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 9 Jul 2024 15:36:34 +0300 Subject: [PATCH 30/35] spanish translation --- src/languages/es.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/languages/es.ts b/src/languages/es.ts index 576837421c39..ee77c030f054 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2540,8 +2540,8 @@ export default { existingCategoryError: 'Ya existe una categoría con este nombre.', invalidCategoryName: 'Lo nombre de la categoría es invalido.', importedFromAccountingSoftware: 'Categorías importadas desde', - payrollCode: 'Payroll code', - updatePayrollCodeFailureMessage: 'An error occurred while updating the payroll code, please try again.', + payrollCode: 'Código de nómina', + updatePayrollCodeFailureMessage: 'Se produjo un error al actualizar el código de nómina, por favor intente nuevamente.', }, moreFeatures: { spendSection: { From 1fc92a86c8ba8197dc9f4d1582aeb980ed150522 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 10 Jul 2024 14:28:19 +0300 Subject: [PATCH 31/35] rename to payroll --- src/pages/workspace/categories/CategoryPayrollCodePage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/categories/CategoryPayrollCodePage.tsx b/src/pages/workspace/categories/CategoryPayrollCodePage.tsx index 8028906401fb..cef0aadf5b40 100644 --- a/src/pages/workspace/categories/CategoryPayrollCodePage.tsx +++ b/src/pages/workspace/categories/CategoryPayrollCodePage.tsx @@ -32,7 +32,7 @@ function CategoryPayrollCodePage({route}: EditCategoryPageProps) { const payrollCode = policyCategories?.[categoryName]?.payrollCode; const {inputCallbackRef} = useAutoFocusInput(); - const editGLCode = useCallback( + const editPayrollCode = useCallback( (values: FormOnyxValues) => { const newPayrollCode = values.payrollCode.trim(); if (newPayrollCode !== payrollCode) { @@ -61,7 +61,7 @@ function CategoryPayrollCodePage({route}: EditCategoryPageProps) { /> Date: Wed, 10 Jul 2024 14:34:22 +0300 Subject: [PATCH 32/35] rename to payroll code --- src/libs/actions/Policy/Category.ts | 15 ++++++++++----- .../categories/CategoryPayrollCodePage.tsx | 2 +- .../workspace/categories/CategorySettingsPage.tsx | 4 ++-- src/types/onyx/PolicyCategory.ts | 3 ++- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/libs/actions/Policy/Category.ts b/src/libs/actions/Policy/Category.ts index f9da0ece9a2c..94ba629c5da7 100644 --- a/src/libs/actions/Policy/Category.ts +++ b/src/libs/actions/Policy/Category.ts @@ -344,9 +344,11 @@ function setPolicyCategoryPayrollCode(policyID: string, categoryName: string, pa ...policyCategoryToUpdate, pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, pendingFields: { - payrollCode: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + // eslint-disable-next-line @typescript-eslint/naming-convention + 'Payroll Code': CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, }, - payrollCode, + // eslint-disable-next-line @typescript-eslint/naming-convention + 'Payroll Code': payrollCode, }, }, }, @@ -360,9 +362,11 @@ function setPolicyCategoryPayrollCode(policyID: string, categoryName: string, pa ...policyCategoryToUpdate, pendingAction: null, pendingFields: { - payrollCode: null, + // eslint-disable-next-line @typescript-eslint/naming-convention + 'Payroll Code': null, }, - payrollCode, + // eslint-disable-next-line @typescript-eslint/naming-convention + 'Payroll Code': payrollCode, }, }, }, @@ -377,7 +381,8 @@ function setPolicyCategoryPayrollCode(policyID: string, categoryName: string, pa errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('workspace.categories.updatePayrollCodeFailureMessage'), pendingAction: null, pendingFields: { - payrollCode: null, + // eslint-disable-next-line @typescript-eslint/naming-convention + 'Payroll Code': null, }, }, }, diff --git a/src/pages/workspace/categories/CategoryPayrollCodePage.tsx b/src/pages/workspace/categories/CategoryPayrollCodePage.tsx index cef0aadf5b40..22143add373a 100644 --- a/src/pages/workspace/categories/CategoryPayrollCodePage.tsx +++ b/src/pages/workspace/categories/CategoryPayrollCodePage.tsx @@ -29,7 +29,7 @@ function CategoryPayrollCodePage({route}: EditCategoryPageProps) { const [policyCategories] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyId}`); const categoryName = route.params.categoryName; - const payrollCode = policyCategories?.[categoryName]?.payrollCode; + const payrollCode = policyCategories?.[categoryName]?.['Payroll Code']; const {inputCallbackRef} = useAutoFocusInput(); const editPayrollCode = useCallback( diff --git a/src/pages/workspace/categories/CategorySettingsPage.tsx b/src/pages/workspace/categories/CategorySettingsPage.tsx index fa12766820e5..e6b26c45fea2 100644 --- a/src/pages/workspace/categories/CategorySettingsPage.tsx +++ b/src/pages/workspace/categories/CategorySettingsPage.tsx @@ -134,9 +134,9 @@ function CategorySettingsPage({route, policyCategories, navigation}: CategorySet shouldShowRightIcon /> - + Navigation.navigate(ROUTES.WORKSPACE_CATEGORY_PAYROLL_CODE.getRoute(route.params.policyID, policyCategory.name))} shouldShowRightIcon diff --git a/src/types/onyx/PolicyCategory.ts b/src/types/onyx/PolicyCategory.ts index 66d48c2c18ce..18a714208819 100644 --- a/src/types/onyx/PolicyCategory.ts +++ b/src/types/onyx/PolicyCategory.ts @@ -19,7 +19,8 @@ type PolicyCategory = OnyxCommon.OnyxValueWithOfflineFeedback<{ 'GL Code'?: string; /** Payroll code is used to keep track of taxes, deductions, and an employee’s earnings */ - payrollCode?: string; + // eslint-disable-next-line @typescript-eslint/naming-convention + 'Payroll Code'?: string; /** An ID for this category from an external accounting system */ externalID?: string; From 7d8abfb590f8286eda2c5560b5b7a83fba2744cc Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 10 Jul 2024 14:38:40 +0300 Subject: [PATCH 33/35] disable for non control policy --- src/pages/workspace/categories/CategorySettingsPage.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pages/workspace/categories/CategorySettingsPage.tsx b/src/pages/workspace/categories/CategorySettingsPage.tsx index e6b26c45fea2..19ce3cce54f4 100644 --- a/src/pages/workspace/categories/CategorySettingsPage.tsx +++ b/src/pages/workspace/categories/CategorySettingsPage.tsx @@ -26,6 +26,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import type * as OnyxTypes from '@src/types/onyx'; +import { isControlPolicy } from '@libs/PolicyUtils'; type CategorySettingsPageOnyxProps = { /** Collection of categories attached to a policy */ @@ -40,6 +41,7 @@ function CategorySettingsPage({route, policyCategories, navigation}: CategorySet const [deleteCategoryConfirmModalVisible, setDeleteCategoryConfirmModalVisible] = useState(false); const backTo = route.params?.backTo; const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${route.params.policyID}`); + const shouldDisablePayrollCode = !isControlPolicy(policy); const policyCategory = policyCategories?.[route.params.categoryName] ?? Object.values(policyCategories ?? {}).find((category) => category.previousCategoryName === route.params.categoryName); @@ -140,6 +142,7 @@ function CategorySettingsPage({route, policyCategories, navigation}: CategorySet description={translate(`workspace.categories.payrollCode`)} onPress={() => Navigation.navigate(ROUTES.WORKSPACE_CATEGORY_PAYROLL_CODE.getRoute(route.params.policyID, policyCategory.name))} shouldShowRightIcon + disabled={shouldDisablePayrollCode} /> {!isThereAnyAccountingConnection && ( From 22df8b4122b70a5a219cd080ec5ada409cb771cc Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 11 Jul 2024 17:21:06 +0300 Subject: [PATCH 34/35] run prettier --- src/pages/workspace/categories/CategorySettingsPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/categories/CategorySettingsPage.tsx b/src/pages/workspace/categories/CategorySettingsPage.tsx index 19ce3cce54f4..165255336296 100644 --- a/src/pages/workspace/categories/CategorySettingsPage.tsx +++ b/src/pages/workspace/categories/CategorySettingsPage.tsx @@ -16,6 +16,7 @@ import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import * as ErrorUtils from '@libs/ErrorUtils'; import Navigation from '@libs/Navigation/Navigation'; +import {isControlPolicy} from '@libs/PolicyUtils'; import type {SettingsNavigatorParamList} from '@navigation/types'; import NotFoundPage from '@pages/ErrorPage/NotFoundPage'; import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; @@ -26,7 +27,6 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import type * as OnyxTypes from '@src/types/onyx'; -import { isControlPolicy } from '@libs/PolicyUtils'; type CategorySettingsPageOnyxProps = { /** Collection of categories attached to a policy */ From 06265b28fc1fce93a3fca9f9a931163e657a189b Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 11 Jul 2024 23:24:05 +0300 Subject: [PATCH 35/35] fix merge --- src/pages/workspace/AccessOrNotFoundWrapper.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/workspace/AccessOrNotFoundWrapper.tsx b/src/pages/workspace/AccessOrNotFoundWrapper.tsx index 99acf6222444..351bd36fbb34 100644 --- a/src/pages/workspace/AccessOrNotFoundWrapper.tsx +++ b/src/pages/workspace/AccessOrNotFoundWrapper.tsx @@ -25,7 +25,6 @@ const ACCESS_VARIANTS = { [CONST.POLICY.ACCESS_VARIANTS.PAID]: (policy: OnyxEntry) => PolicyUtils.isPaidGroupPolicy(policy), [CONST.POLICY.ACCESS_VARIANTS.CONTROL]: (policy: OnyxEntry) => PolicyUtils.isControlPolicy(policy), [CONST.POLICY.ACCESS_VARIANTS.ADMIN]: (policy: OnyxEntry, login: string) => PolicyUtils.isPolicyAdmin(policy, login), - [CONST.POLICY.ACCESS_VARIANTS.CONTROL]: (policy: OnyxEntry) => PolicyUtils.isControlPolicy(policy), [CONST.IOU.ACCESS_VARIANTS.CREATE]: ( policy: OnyxEntry, login: string,