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

Ensure we show upgrade flow for GL/Payroll/Tax codes for non control policy #45866

Merged
merged 10 commits into from
Jul 30, 2024
8 changes: 8 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5411,6 +5411,14 @@ const CONST = {
description: 'workspace.upgrade.glAndPayrollCodes.description' as const,
icon: 'FolderOpen',
},
taxCodes: {
id: 'taxCodes' as const,
alias: 'tax-codes',
name: 'Tax codes',
title: 'workspace.upgrade.taxCodes.title' as const,
description: 'workspace.upgrade.taxCodes.description' as const,
icon: 'Coins',
},
};
},
REPORT_FIELD_TYPES: {
Expand Down
5 changes: 5 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3434,6 +3434,11 @@ export default {
description: `Add GL & Payroll codes to your categories for easy export of expenses to your accounting and payroll systems.`,
onlyAvailableOnPlan: 'GL & Payroll codes are only available on the Control plan, starting at ',
},
taxCodes: {
title: 'Tax codes',
description: `Add tax codes to your taxes for easy export of expenses to your accounting and payroll systems.`,
onlyAvailableOnPlan: 'Tax codes are only available on the Control plan, starting at ',
},
pricing: {
amount: '$9 ',
perActiveMember: 'per active member per month.',
Expand Down
5 changes: 5 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3490,6 +3490,11 @@ export default {
description: `Añada códigos de libro mayor y nómina a sus categorías para exportar fácilmente los gastos a sus sistemas de contabilidad y nómina.`,
onlyAvailableOnPlan: 'Los códigos de libro mayor y nómina solo están disponibles en el plan Control, a partir de ',
},
taxCodes: {
title: 'Código de impuesto',
description: `Añada código de impuesto mayor a sus categorías para exportar fácilmente los gastos a sus sistemas de contabilidad y nómina.`,
onlyAvailableOnPlan: 'Los código de impuesto mayor solo están disponibles en el plan Control, a partir de ',
},
note: {
upgradeWorkspace: 'Mejore su espacio de trabajo para acceder a esta función, o',
learnMore: 'más información',
Expand Down
4 changes: 1 addition & 3 deletions src/pages/workspace/categories/CategorySettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ 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);
Expand Down Expand Up @@ -131,7 +130,7 @@ function CategorySettingsPage({route, policyCategories, navigation}: CategorySet
<OfflineWithFeedback pendingAction={policyCategory.pendingFields?.name}>
<MenuItemWithTopDescription
title={policyCategory.name}
description={translate(`workspace.categories.categoryName`)}
description={translate(`common.name`)}
onPress={navigateToEditCategory}
shouldShowRightIcon
/>
Expand Down Expand Up @@ -162,7 +161,6 @@ function CategorySettingsPage({route, policyCategories, navigation}: CategorySet
Navigation.navigate(ROUTES.WORKSPACE_CATEGORY_PAYROLL_CODE.getRoute(route.params.policyID, policyCategory.name));
}}
shouldShowRightIcon
disabled={shouldDisablePayrollCode}
/>
</OfflineWithFeedback>
{!isThereAnyAccountingConnection && (
Expand Down
2 changes: 1 addition & 1 deletion src/pages/workspace/tags/TagSettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function TagSettingsPage({route, policyTags, navigation}: TagSettingsPageProps)
<OfflineWithFeedback pendingAction={currentPolicyTag.pendingFields?.name}>
<MenuItemWithTopDescription
title={PolicyUtils.getCleanedTagName(currentPolicyTag.name)}
description={translate(`workspace.tags.tagName`)}
description={translate(`common.name`)}
onPress={navigateToEditTag}
shouldShowRightIcon
/>
Expand Down
13 changes: 9 additions & 4 deletions src/pages/workspace/taxes/WorkspaceEditTaxPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ function WorkspaceEditTaxPage({
const [isDeleteModalVisible, setIsDeleteModalVisible] = useState(false);
const canEditTaxRate = policy && PolicyUtils.canEditTaxRate(policy, taxID);
const hasAccountingConnections = PolicyUtils.hasAccountingConnections(policy);
const canEditTaxCode = PolicyUtils.isControlPolicy(policy);

const shouldShowDeleteMenuItem = canEditTaxRate && !hasAccountingConnections;

Expand Down Expand Up @@ -70,6 +69,7 @@ function WorkspaceEditTaxPage({
if (!currentTaxRate) {
return <NotFoundPage />;
}
const taxCodeToShow = PolicyUtils.isControlPolicy(policy) ? taxID : '';

return (
<AccessOrNotFoundWrapper
Expand Down Expand Up @@ -139,12 +139,17 @@ function WorkspaceEditTaxPage({
>
<MenuItemWithTopDescription
shouldShowRightIcon
title={taxID}
title={taxCodeToShow}
description={translate('workspace.taxes.taxCode')}
style={[styles.moneyRequestMenuItem]}
titleStyle={styles.flex1}
disabled={!canEditTaxCode}
onPress={() => Navigation.navigate(ROUTES.WORKSPACE_TAX_CODE.getRoute(`${policyID}`, taxID))}
onPress={() => {
if (!PolicyUtils.isControlPolicy(policy)) {
Navigation.navigate(ROUTES.WORKSPACE_UPGRADE.getRoute(policyID, CONST.UPGRADE_FEATURE_INTRO_MAPPING.taxCodes.alias));
return;
}
Navigation.navigate(ROUTES.WORKSPACE_TAX_CODE.getRoute(`${policyID}`, taxID));
}}
/>
</OfflineWithFeedback>
{shouldShowDeleteMenuItem && (
Expand Down
7 changes: 6 additions & 1 deletion src/pages/workspace/taxes/WorkspaceTaxCodePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,14 @@ function WorkspaceTaxCodePage({route}: WorkspaceTaxCodePageProps) {
if (!policy) {
return {};
}
const newTaxCode = values.taxCode.trim();
if (newTaxCode === currentTaxCode) {
return {};
}

return validateTaxCode(policy, values);
},
[policy],
[currentTaxCode, policy],
);

return (
Expand Down
Loading