From 8daab8815dfb7c94b86471608849c304a7bdce68 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Fri, 7 Jun 2024 10:37:33 +0700 Subject: [PATCH 1/7] fix: message does not scale according to device font size --- .../workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/pages/workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx b/src/pages/workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx index 2f1b9317e0a9..220708a3eff9 100644 --- a/src/pages/workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx +++ b/src/pages/workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx @@ -137,11 +137,9 @@ function PolicyDistanceRatesSettingsPage({policy, policyCategories, route}: Poli {translate('workspace.distanceRates.taxFeatureNotEnabledMessage')} { Navigation.dismissModal(); Navigation.navigate(ROUTES.WORKSPACE_MORE_FEATURES.getRoute(policyID)); From e4b1ee3ec64b8890a21275bee1cba17daf9ce13c Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Fri, 7 Jun 2024 11:03:35 +0700 Subject: [PATCH 2/7] Fix: App crashes after assigning deleted tax rate to distance rate offline --- .../distanceRates/PolicyDistanceRateTaxRateEditPage.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/workspace/distanceRates/PolicyDistanceRateTaxRateEditPage.tsx b/src/pages/workspace/distanceRates/PolicyDistanceRateTaxRateEditPage.tsx index e8b58b70f474..09ecb7f071f0 100644 --- a/src/pages/workspace/distanceRates/PolicyDistanceRateTaxRateEditPage.tsx +++ b/src/pages/workspace/distanceRates/PolicyDistanceRateTaxRateEditPage.tsx @@ -41,6 +41,7 @@ function PolicyDistanceRateTaxRateEditPage({route, policy}: PolicyDistanceRateTa text: `${value.name} (${value.value})`, isSelected: taxRateExternalID === key, keyForList: key, + isDisabled: !!value.pendingAction, })); return result; }, [policy, taxRateExternalID]); From f496901ab8b742f3015d316ba9043bea91be7ef6 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Fri, 7 Jun 2024 11:37:04 +0700 Subject: [PATCH 3/7] fix: Tax rate and tax reclaimable on rows are not grayed out when edited offline --- src/libs/actions/Policy/DistanceRate.ts | 16 ++++++------- .../PolicyDistanceRateTaxRateEditPage.tsx | 4 +++- .../PolicyDistanceRatesSettingsPage.tsx | 4 +--- src/types/onyx/Policy.ts | 23 +++++++++++-------- 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/libs/actions/Policy/DistanceRate.ts b/src/libs/actions/Policy/DistanceRate.ts index 6b0a9c5c3ee0..f3f8dfb4f3c7 100644 --- a/src/libs/actions/Policy/DistanceRate.ts +++ b/src/libs/actions/Policy/DistanceRate.ts @@ -530,12 +530,12 @@ function updateDistanceTaxClaimableValue(policyID: string, customUnit: CustomUni for (const rateID of Object.keys(customUnit.rates)) { if (rateIDs.includes(rateID)) { const foundRate = customUnitRates.find((rate) => rate.customUnitRateID === rateID); - optimisticRates[rateID] = {...foundRate, pendingFields: {rate: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}}; - successRates[rateID] = {...foundRate, pendingFields: {rate: null}}; + optimisticRates[rateID] = {...foundRate, pendingFields: {taxClaimablePercentage: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}}; + successRates[rateID] = {...foundRate, pendingFields: {taxClaimablePercentage: null}}; failureRates[rateID] = { ...currentRates[rateID], - pendingFields: {rate: null}, - errorFields: {rate: ErrorUtils.getMicroSecondOnyxError('common.genericErrorMessage')}, + pendingFields: {taxClaimablePercentage: null}, + errorFields: {taxClaimablePercentage: ErrorUtils.getMicroSecondOnyxError('common.genericErrorMessage')}, }; } } @@ -601,12 +601,12 @@ function updateDistanceTaxRate(policyID: string, customUnit: CustomUnit, customU for (const rateID of Object.keys(customUnit.rates)) { if (rateIDs.includes(rateID)) { const foundRate = customUnitRates.find((rate) => rate.customUnitRateID === rateID); - optimisticRates[rateID] = {...foundRate, pendingFields: {rate: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}}; - successRates[rateID] = {...foundRate, pendingFields: {rate: null}}; + optimisticRates[rateID] = {...foundRate, pendingFields: {taxRateExternalID: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}}; + successRates[rateID] = {...foundRate, pendingFields: {taxRateExternalID: null}}; failureRates[rateID] = { ...currentRates[rateID], - pendingFields: {rate: null}, - errorFields: {rate: ErrorUtils.getMicroSecondOnyxError('common.genericErrorMessage')}, + pendingFields: {taxRateExternalID: null}, + errorFields: {taxRateExternalID: ErrorUtils.getMicroSecondOnyxError('common.genericErrorMessage')}, }; } } diff --git a/src/pages/workspace/distanceRates/PolicyDistanceRateTaxRateEditPage.tsx b/src/pages/workspace/distanceRates/PolicyDistanceRateTaxRateEditPage.tsx index 09ecb7f071f0..d428cc14fa24 100644 --- a/src/pages/workspace/distanceRates/PolicyDistanceRateTaxRateEditPage.tsx +++ b/src/pages/workspace/distanceRates/PolicyDistanceRateTaxRateEditPage.tsx @@ -15,12 +15,14 @@ import * as DistanceRate from '@userActions/Policy/DistanceRate'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; +import type {PendingAction} from '@src/types/onyx/OnyxCommon'; type ListItemType = { value: string; text: string; isSelected: boolean; keyForList: string; + pendingAction?: PendingAction; }; type PolicyDistanceRateTaxRateEditPageProps = WithPolicyOnyxProps & StackScreenProps; @@ -41,7 +43,7 @@ function PolicyDistanceRateTaxRateEditPage({route, policy}: PolicyDistanceRateTa text: `${value.name} (${value.value})`, isSelected: taxRateExternalID === key, keyForList: key, - isDisabled: !!value.pendingAction, + pendingAction: value.pendingAction, })); return result; }, [policy, taxRateExternalID]); diff --git a/src/pages/workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx b/src/pages/workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx index 220708a3eff9..ac8bb61ff0d8 100644 --- a/src/pages/workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx +++ b/src/pages/workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx @@ -135,9 +135,7 @@ function PolicyDistanceRatesSettingsPage({policy, policyCategories, route}: Poli {!isPolicyTrackTaxEnabled && ( - + {translate('workspace.distanceRates.taxFeatureNotEnabledMessage')} { diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 070803e2e2fd..4e34edf5a764 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -12,16 +12,19 @@ type TaxRateAttributes = { taxRateExternalID?: string; }; -type Rate = OnyxCommon.OnyxValueWithOfflineFeedback<{ - name?: string; - rate?: number; - currency?: string; - customUnitRateID?: string; - enabled?: boolean; - errors?: OnyxCommon.Errors; - errorFields?: OnyxCommon.ErrorFields; - attributes?: TaxRateAttributes; -}>; +type Rate = OnyxCommon.OnyxValueWithOfflineFeedback< + { + name?: string; + rate?: number; + currency?: string; + customUnitRateID?: string; + enabled?: boolean; + errors?: OnyxCommon.Errors; + errorFields?: OnyxCommon.ErrorFields; + attributes?: TaxRateAttributes; + }, + keyof TaxRateAttributes +>; type Attributes = { unit: Unit; From 210014481ddf62b5e0e1a218b2ead4cdd7d74a8c Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Fri, 7 Jun 2024 15:00:50 +0700 Subject: [PATCH 4/7] fix: position 'Track tax' --- .../distanceRates/PolicyDistanceRatesSettingsPage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx b/src/pages/workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx index ac8bb61ff0d8..699e1e368a66 100644 --- a/src/pages/workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx +++ b/src/pages/workspace/distanceRates/PolicyDistanceRatesSettingsPage.tsx @@ -122,7 +122,7 @@ function PolicyDistanceRatesSettingsPage({policy, policyCategories, route}: Poli )} - + {translate('workspace.distanceRates.trackTax')} {!isPolicyTrackTaxEnabled && ( - + {translate('workspace.distanceRates.taxFeatureNotEnabledMessage')} Date: Fri, 7 Jun 2024 16:20:51 +0700 Subject: [PATCH 5/7] fix: tax rate are not grayed out --- .../PolicyDistanceRateDetailsPage.tsx | 16 ++++++++-------- src/types/onyx/Policy.ts | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/pages/workspace/distanceRates/PolicyDistanceRateDetailsPage.tsx b/src/pages/workspace/distanceRates/PolicyDistanceRateDetailsPage.tsx index 7f604efd20ee..8b036d68e278 100644 --- a/src/pages/workspace/distanceRates/PolicyDistanceRateDetailsPage.tsx +++ b/src/pages/workspace/distanceRates/PolicyDistanceRateDetailsPage.tsx @@ -27,7 +27,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 type {Rate} from '@src/types/onyx/Policy'; +import type {Rate, TaxRateAttributes} from '@src/types/onyx/Policy'; type PolicyDistanceRateDetailsPageOnyxProps = { /** Policy details */ @@ -105,7 +105,7 @@ function PolicyDistanceRateDetailsPage({policy, route}: PolicyDistanceRateDetail }, ]; - const clearErrorFields = (fieldName: keyof Rate) => { + const clearErrorFields = (fieldName: keyof Rate | keyof TaxRateAttributes) => { DistanceRate.clearPolicyDistanceRateErrorFields(policyID, customUnit.customUnitID, rateID, {...errorFields, [fieldName]: null}); }; @@ -158,10 +158,10 @@ function PolicyDistanceRateDetailsPage({policy, route}: PolicyDistanceRateDetail {isDistanceTrackTaxEnabled && ( clearErrorFields('attributes')} + onClose={() => clearErrorFields('taxRateExternalID')} > clearErrorFields('attributes')} + onClose={() => clearErrorFields('taxClaimablePercentage')} > Date: Fri, 7 Jun 2024 16:30:21 +0700 Subject: [PATCH 6/7] fix: disbale tax rate after delete --- .../distanceRates/PolicyDistanceRateTaxRateEditPage.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/workspace/distanceRates/PolicyDistanceRateTaxRateEditPage.tsx b/src/pages/workspace/distanceRates/PolicyDistanceRateTaxRateEditPage.tsx index d428cc14fa24..39074da739d9 100644 --- a/src/pages/workspace/distanceRates/PolicyDistanceRateTaxRateEditPage.tsx +++ b/src/pages/workspace/distanceRates/PolicyDistanceRateTaxRateEditPage.tsx @@ -44,6 +44,7 @@ function PolicyDistanceRateTaxRateEditPage({route, policy}: PolicyDistanceRateTa isSelected: taxRateExternalID === key, keyForList: key, pendingAction: value.pendingAction, + isDisabled: value.pendingAction == CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, })); return result; }, [policy, taxRateExternalID]); From 8bfb92249ebbc528f75399f5b0f0ad3a58d4f737 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Fri, 7 Jun 2024 16:47:49 +0700 Subject: [PATCH 7/7] fix lint --- .../distanceRates/PolicyDistanceRateTaxRateEditPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/distanceRates/PolicyDistanceRateTaxRateEditPage.tsx b/src/pages/workspace/distanceRates/PolicyDistanceRateTaxRateEditPage.tsx index 39074da739d9..4ff23cf4ef92 100644 --- a/src/pages/workspace/distanceRates/PolicyDistanceRateTaxRateEditPage.tsx +++ b/src/pages/workspace/distanceRates/PolicyDistanceRateTaxRateEditPage.tsx @@ -44,7 +44,7 @@ function PolicyDistanceRateTaxRateEditPage({route, policy}: PolicyDistanceRateTa isSelected: taxRateExternalID === key, keyForList: key, pendingAction: value.pendingAction, - isDisabled: value.pendingAction == CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, + isDisabled: value.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, })); return result; }, [policy, taxRateExternalID]);