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

[Simplified Collect][Taxes] Create WorkspaceTaxesPage #37870

Merged
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
049c487
Create WorkspaceTaxesPage
filip-solecki Mar 7, 2024
a491463
Remove unnecessary check
filip-solecki Mar 7, 2024
bc18001
Remove unnecessary import
filip-solecki Mar 7, 2024
0ff7067
Fix icon fill color
filip-solecki Mar 7, 2024
2d43808
CR fixes
filip-solecki Mar 7, 2024
b63bcbb
use ListItem type
filip-solecki Mar 7, 2024
a97c874
Fix tax icon
filip-solecki Mar 7, 2024
60aa7d3
Fix icon tax fill
filip-solecki Mar 7, 2024
e933a60
Header buttons
filip-solecki Mar 7, 2024
be9c328
Merge branch 'main' into wave8/WorkspaceTaxesPage
filip-solecki Mar 8, 2024
f06d07b
Merge branch 'main' into wave8/WorkspaceTaxesPage
filip-solecki Mar 11, 2024
c160d40
Add translations and adjust SelectionList
filip-solecki Mar 11, 2024
6838836
Merge branch 'main' into wave8/WorkspaceTaxesPage
filip-solecki Mar 11, 2024
940370c
Merge branch 'main' into wave8/WorkspaceTaxesPage
filip-solecki Mar 12, 2024
fd6716b
Fix failing TS
filip-solecki Mar 12, 2024
8bfd4ef
Fix Lint
filip-solecki Mar 12, 2024
e0ca61f
CR fixes
filip-solecki Mar 12, 2024
4ba47a8
Add possibility to remove foreign currency default tax
filip-solecki Mar 12, 2024
606c12d
Rename prop
filip-solecki Mar 12, 2024
2687bfb
handle isOffline mode and fetching taxes data
filip-solecki Mar 12, 2024
f3ab59c
Merge branch 'main' into wave8/WorkspaceTaxesPage
filip-solecki Mar 12, 2024
9fd30e5
Merge branch 'main' into wave8/WorkspaceTaxesPage
filip-solecki Mar 13, 2024
d772221
Fix type for WorkspaceTaxesPage
filip-solecki Mar 13, 2024
d696446
Refactor isDisabledCheckbox
filip-solecki Mar 13, 2024
14072ae
Merge branch 'main' into wave8/WorkspaceTaxesPage
kosmydel Mar 13, 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
8 changes: 8 additions & 0 deletions assets/images/tax.svg
filip-solecki marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,10 @@ const ROUTES = {
route: 'settings/workspaces/:policyID/tags/edit',
getRoute: (policyID: string) => `settings/workspaces/${policyID}/tags/edit` as const,
},
WORKSPACE_TAXES: {
route: 'settings/workspaces/:policyID/taxes',
getRoute: (policyID: string) => `settings/workspaces/${policyID}/taxes` as const,
},
WORKSPACE_MEMBER_DETAILS: {
route: 'settings/workspaces/:policyID/members/:accountID',
getRoute: (policyID: string, accountID: number, backTo?: string) => getUrlWithBackToParam(`settings/workspaces/${policyID}/members/${accountID}`, backTo),
Expand All @@ -597,7 +601,6 @@ const ROUTES = {
route: 'workspace/:policyID/distance-rates',
getRoute: (policyID: string) => `workspace/${policyID}/distance-rates` as const,
},

// Referral program promotion
REFERRAL_DETAILS_MODAL: {
route: 'referral/:contentType',
Expand Down
1 change: 1 addition & 0 deletions src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ const SCREENS = {
TAGS: 'Workspace_Tags',
TAGS_SETTINGS: 'Tags_Settings',
TAGS_EDIT: 'Tags_Edit',
TAXES: 'Workspace_Taxes',
filip-solecki marked this conversation as resolved.
Show resolved Hide resolved
TAG_CREATE: 'Tag_Create',
CURRENCY: 'Workspace_Profile_Currency',
WORKFLOWS: 'Workspace_Workflows',
Expand Down
2 changes: 2 additions & 0 deletions src/components/Icon/Expensicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ import Stopwatch from '@assets/images/stopwatch.svg';
import Sync from '@assets/images/sync.svg';
import Tag from '@assets/images/tag.svg';
import Task from '@assets/images/task.svg';
import Tax from '@assets/images/tax.svg';
import ThreeDots from '@assets/images/three-dots.svg';
import ThumbsUp from '@assets/images/thumbs-up.svg';
import Transfer from '@assets/images/transfer.svg';
Expand Down Expand Up @@ -226,6 +227,7 @@ export {
Fullscreen,
Folder,
Tag,
Tax,
Gallery,
Gear,
Globe,
Expand Down
5 changes: 3 additions & 2 deletions src/components/SelectionList/BaseListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,10 @@ function BaseListItem<TItem extends ListItem>({
<PressableWithFeedback
accessibilityLabel={item.text ?? ''}
role={CONST.ROLE.BUTTON}
disabled={isDisabled}
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
disabled={isDisabled || item.isDisabledCheckbox}
onPress={handleCheckboxPress}
style={[styles.cursorUnset, StyleUtils.getCheckboxPressableStyle()]}
style={[styles.cursorUnset, StyleUtils.getCheckboxPressableStyle(), item.isDisabledCheckbox && styles.cursorDisabled]}
>
<View style={selectMultipleStyle}>
{item.isSelected && (
Expand Down
3 changes: 2 additions & 1 deletion src/components/SelectionList/BaseSelectionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ function BaseSelectionList<TItem extends ListItem>(
});

// If disabled, add to the disabled indexes array
if (!!section.isDisabled || item.isDisabled) {
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
if (!!section.isDisabled || item.isDisabled || item.isDisabledCheckbox) {
disabledOptionsIndexes.push(disabledIndex);
}
disabledIndex += 1;
Expand Down
3 changes: 3 additions & 0 deletions src/components/SelectionList/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ type ListItem = {
/** Whether this option is selected */
isSelected?: boolean;

/** Whether the checkbox should be disabled */
isDisabledCheckbox?: boolean;

/** Whether this option is disabled for selection */
isDisabled?: boolean | null;

Expand Down
7 changes: 7 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1741,6 +1741,7 @@ export default {
reimburse: 'Reimbursements',
categories: 'Categories',
tags: 'Tags',
taxes: 'Taxes',
bills: 'Bills',
invoices: 'Invoices',
travel: 'Travel',
Expand Down Expand Up @@ -1844,6 +1845,12 @@ export default {
existingTagError: 'A tag with this name already exists.',
genericFailureMessage: 'An error occurred while updating the tag, please try again.',
},
taxes: {
subtitle: 'Add tax names, rates, and set defaults.',
addRate: 'Add rate',
workspaceDefault: 'Workspace currency default',
foreignDefault: 'Foreign currency default',
},
emptyWorkspace: {
title: 'Create a workspace',
subtitle: 'Workspaces are where you’ll chat with your team, reimburse expenses, issue cards, send invoices, pay bills, and more - all in one place.',
Expand Down
7 changes: 7 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1765,6 +1765,7 @@ export default {
reimburse: 'Reembolsos',
categories: 'Categorías',
tags: 'Etiquetas',
taxes: 'Impuestos',
filip-solecki marked this conversation as resolved.
Show resolved Hide resolved
bills: 'Pagar facturas',
invoices: 'Enviar facturas',
travel: 'Viajes',
Expand Down Expand Up @@ -1868,6 +1869,12 @@ export default {
existingTagError: 'Ya existe una etiqueta con este nombre.',
genericFailureMessage: 'Se produjo un error al actualizar la etiqueta, inténtelo nuevamente.',
},
taxes: {
subtitle: 'Añade nombres, tasas y establezca valores por defecto para los impuestos.',
addRate: 'Añadir tasa',
workspaceDefault: 'Moneda por defecto del espacio de trabajo',
foreignDefault: 'Moneda extranjera por defecto',
},
emptyWorkspace: {
title: 'Crea un espacio de trabajo',
subtitle: 'En los espacios de trabajo podrás chatear con tu equipo, reembolsar gastos, emitir tarjetas, enviar y pagar facturas, y mucho más - todo en un mismo lugar.',
Expand Down
5 changes: 5 additions & 0 deletions src/libs/API/parameters/OpenPolicyTaxesPageParams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type OpenPolicyTaxesPageParams = {
policyID: string;
};

export default OpenPolicyTaxesPageParams;
1 change: 1 addition & 0 deletions src/libs/API/parameters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,5 @@ export type {default as DeclineJoinRequestParams} from './DeclineJoinRequest';
export type {default as JoinPolicyInviteLinkParams} from './JoinPolicyInviteLink';
export type {default as OpenPolicyWorkflowsPageParams} from './OpenPolicyWorkflowsPageParams';
export type {default as OpenPolicyDistanceRatesPageParams} from './OpenPolicyDistanceRatesPageParams';
export type {default as OpenPolicyTaxesPageParams} from './OpenPolicyTaxesPageParams';
export type {default as CreatePolicyTagsParams} from './CreatePolicyTagsParams';
2 changes: 2 additions & 0 deletions src/libs/API/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ const READ_COMMANDS = {
OPEN_WORKSPACE_MEMBERS_PAGE: 'OpenWorkspaceMembersPage',
OPEN_POLICY_CATEGORIES_PAGE: 'OpenPolicyCategoriesPage',
OPEN_POLICY_TAGS_PAGE: 'OpenPolicyTagsPage',
OPEN_POLICY_TAXES_PAGE: 'OpenPolicyTaxesPage',
OPEN_WORKSPACE_INVITE_PAGE: 'OpenWorkspaceInvitePage',
OPEN_DRAFT_WORKSPACE_REQUEST: 'OpenDraftWorkspaceRequest',
OPEN_POLICY_WORKFLOWS_PAGE: 'OpenPolicyWorkflowsPage',
Expand Down Expand Up @@ -412,6 +413,7 @@ type ReadCommandParameters = {
[READ_COMMANDS.OPEN_WORKSPACE_MEMBERS_PAGE]: Parameters.OpenWorkspaceMembersPageParams;
[READ_COMMANDS.OPEN_POLICY_CATEGORIES_PAGE]: Parameters.OpenPolicyCategoriesPageParams;
[READ_COMMANDS.OPEN_POLICY_TAGS_PAGE]: Parameters.OpenPolicyTagsPageParams;
[READ_COMMANDS.OPEN_POLICY_TAXES_PAGE]: Parameters.OpenPolicyTaxesPageParams;
[READ_COMMANDS.OPEN_WORKSPACE_INVITE_PAGE]: Parameters.OpenWorkspaceInvitePageParams;
[READ_COMMANDS.OPEN_DRAFT_WORKSPACE_REQUEST]: Parameters.OpenDraftWorkspaceRequestParams;
[READ_COMMANDS.OPEN_POLICY_WORKFLOWS_PAGE]: Parameters.OpenPolicyWorkflowsPageParams;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ const WorkspaceSettingsModalStackNavigator = createModalStackNavigator(
[SCREENS.WORKSPACE.CATEGORIES]: () => require('../../../pages/workspace/categories/WorkspaceCategoriesPage').default as React.ComponentType,
[SCREENS.WORKSPACE.MORE_FEATURES]: () => require('../../../pages/workspace/WorkspaceMoreFeaturesPage').default as React.ComponentType,
[SCREENS.WORKSPACE.TAGS]: () => require('../../../pages/workspace/tags/WorkspaceTagsPage').default as React.ComponentType,
[SCREENS.WORKSPACE.TAXES]: () => require('../../../pages/workspace/taxes/WorkspaceTaxesPage').default as React.ComponentType,
[SCREENS.WORKSPACE.DISTANCE_RATES]: () => require('../../../pages/workspace/distanceRates/PolicyDistanceRatesPage').default as React.ComponentType,
},
(styles) => ({cardStyle: styles.navigationScreenCardStyle, headerShown: false}),
Expand Down
3 changes: 3 additions & 0 deletions src/libs/Navigation/linkingConfig/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,9 @@ const config: LinkingOptions<RootStackParamList>['config'] = {
[SCREENS.WORKSPACE.TAGS]: {
path: ROUTES.WORKSPACE_TAGS.route,
},
[SCREENS.WORKSPACE.TAXES]: {
path: ROUTES.WORKSPACE_TAXES.route,
},
[SCREENS.WORKSPACE.DISTANCE_RATES]: {
path: ROUTES.WORKSPACE_DISTANCE_RATES.route,
},
Expand Down
3 changes: 3 additions & 0 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,9 @@ type WorkspacesCentralPaneNavigatorParamList = {
policyID: string;
categoryName: string;
};
[SCREENS.WORKSPACE.TAXES]: {
policyID: string;
};
[SCREENS.WORKSPACE.DISTANCE_RATES]: {
policyID: string;
};
Expand Down
19 changes: 19 additions & 0 deletions src/libs/actions/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import type {
OpenPolicyCategoriesPageParams,
OpenPolicyDistanceRatesPageParams,
OpenPolicyTagsPageParams,
OpenPolicyTaxesPageParams,
OpenPolicyWorkflowsPageParams,
OpenWorkspaceInvitePageParams,
OpenWorkspaceMembersPageParams,
Expand Down Expand Up @@ -2107,6 +2108,19 @@ function openPolicyTagsPage(policyID: string) {
API.read(READ_COMMANDS.OPEN_POLICY_TAGS_PAGE, params);
}

function openPolicyTaxesPage(policyID: string) {
if (!policyID) {
Log.warn('openPolicyTaxesPage invalid params', {policyID});
return;
}

const params: OpenPolicyTaxesPageParams = {
policyID,
};

API.read(READ_COMMANDS.OPEN_POLICY_TAXES_PAGE, params);
}

function openWorkspaceInvitePage(policyID: string, clientMemberEmails: string[]) {
if (!policyID || !clientMemberEmails) {
Log.warn('openWorkspaceInvitePage invalid params', {policyID, clientMemberEmails});
Expand Down Expand Up @@ -3271,6 +3285,10 @@ function enablePolicyTaxes(policyID: string, enabled: boolean) {
const parameters: EnablePolicyTaxesParams = {policyID, enabled};

API.write(WRITE_COMMANDS.ENABLE_POLICY_TAXES, parameters, onyxData);

if (enabled) {
navigateWhenEnableFeature(policyID, ROUTES.WORKSPACE_TAXES.getRoute(policyID));
}
}

function enablePolicyWorkflows(policyID: string, enabled: boolean) {
Expand Down Expand Up @@ -3479,6 +3497,7 @@ export {
openWorkspaceMembersPage,
openPolicyCategoriesPage,
openPolicyTagsPage,
openPolicyTaxesPage,
openWorkspaceInvitePage,
openWorkspace,
removeWorkspace,
Expand Down
9 changes: 9 additions & 0 deletions src/pages/workspace/WorkspaceInitialPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,15 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, policyMembers, r
});
}

if (policy?.tax?.trackingEnabled) {
protectedCollectPolicyMenuItems.push({
translationKey: 'workspace.common.taxes',
icon: Expensicons.Tax,
action: singleExecution(waitForNavigate(() => Navigation.navigate(ROUTES.WORKSPACE_TAXES.getRoute(policyID)))),
routeName: SCREENS.WORKSPACE.TAXES,
});
}

protectedCollectPolicyMenuItems.push({
translationKey: 'workspace.common.moreFeatures',
icon: Expensicons.Gear,
Expand Down
10 changes: 10 additions & 0 deletions src/pages/workspace/WorkspaceMoreFeaturesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro
Policy.enablePolicyTags(policy?.id ?? '', isEnabled);
},
},
{
icon: Illustrations.Coins,
titleTranslationKey: 'workspace.moreFeatures.taxes.title',
subtitleTranslationKey: 'workspace.moreFeatures.taxes.subtitle',
isActive: policy?.tax?.trackingEnabled ?? false,
pendingAction: policy?.pendingFields?.tax,
action: (isEnabled: boolean) => {
Policy.enablePolicyTaxes(policy?.id ?? '', isEnabled);
},
},
];

const sections: SectionObject[] = [
Expand Down
Loading
Loading