Skip to content

Commit

Permalink
Merge pull request #36521 from Expensify/vit-removeIsTaxTrackingEnabled
Browse files Browse the repository at this point in the history
Add the policy tax trackingEnabled
  • Loading branch information
thienlnam authored Feb 14, 2024
2 parents 26b4ba5 + 519896f commit f413efb
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/components/MoneyRequestConfirmationList.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ function MoneyRequestConfirmationList(props) {
const shouldShowTags = props.isPolicyExpenseChat && (props.iouTag || OptionsListUtils.hasEnabledOptions(_.values(policyTagList)));

// A flag for showing tax fields - tax rate and tax amount
const shouldShowTax = props.isPolicyExpenseChat && props.policy.isTaxTrackingEnabled;
const shouldShowTax = props.isPolicyExpenseChat && lodashGet(props.policy, 'tax.trackingEnabled', props.policy.isTaxTrackingEnabled);

// A flag for showing the billable field
const shouldShowBillable = !lodashGet(props.policy, 'disabledFields.defaultBillable', true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ function MoneyTemporaryForRefactorRequestConfirmationList({
const shouldShowTags = isPolicyExpenseChat && OptionsListUtils.hasEnabledOptions(_.values(policyTagList));

// A flag for showing tax rate
const shouldShowTax = isPolicyExpenseChat && policy && policy.isTaxTrackingEnabled;
const shouldShowTax = isPolicyExpenseChat && policy && lodashGet(policy, 'tax.trackingEnabled', policy.isTaxTrackingEnabled);

// A flag for showing the billable field
const shouldShowBillable = !lodashGet(policy, 'disabledFields.defaultBillable', true);
Expand Down
14 changes: 12 additions & 2 deletions src/pages/iou/request/step/IOURequestStepAmount.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {useFocusEffect} from '@react-navigation/native';
import lodashGet from 'lodash/get';
import PropTypes from 'prop-types';
import React, {useCallback, useEffect, useRef} from 'react';
import {withOnyx} from 'react-native-onyx';
Expand Down Expand Up @@ -39,8 +40,17 @@ const propTypes = {

/** The policy of the report */
policy: PropTypes.shape({
/** Is Tax tracking Enabled */
/**
* Whether or not the policy has tax tracking enabled
*
* @deprecated - use tax.trackingEnabled instead
*/
isTaxTrackingEnabled: PropTypes.bool,

/** Whether or not the policy has tax tracking enabled */
tax: PropTypes.shape({
trackingEnabled: PropTypes.bool,
}),
}),
};

Expand Down Expand Up @@ -74,7 +84,7 @@ function IOURequestStepAmount({
const iouRequestType = getRequestType(transaction);

const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(ReportUtils.getRootParentReport(report));
const isTaxTrackingEnabled = isPolicyExpenseChat && policy.isTaxTrackingEnabled;
const isTaxTrackingEnabled = isPolicyExpenseChat && lodashGet(policy, 'tax.trackingEnabled', policy.isTaxTrackingEnabled);

useFocusEffect(
useCallback(() => {
Expand Down
11 changes: 10 additions & 1 deletion src/pages/workspace/withPolicy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,17 @@ const policyPropTypes = {
/** Whether or not the policy has multiple tag lists */
hasMultipleTagLists: PropTypes.bool,

/** Whether or not the policy has tax tracking enabled */
/**
* Whether or not the policy has tax tracking enabled
*
* @deprecated - use tax.trackingEnabled instead
*/
isTaxTrackingEnabled: PropTypes.bool,

/** Whether or not the policy has tax tracking enabled */
tax: PropTypes.shape({
trackingEnabled: PropTypes.bool,
}),
}),

/** The employee list of this policy */
Expand Down
11 changes: 10 additions & 1 deletion src/types/onyx/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,18 @@ type Policy = {
/** Whether the workspace has multiple levels of tags enabled */
hasMultipleTagLists?: boolean;

/** When tax tracking is enabled */
/**
* Whether or not the policy has tax tracking enabled
*
* @deprecated - use tax.trackingEnabled instead
*/
isTaxTrackingEnabled?: boolean;

/** Whether or not the policy has tax tracking enabled */
tax?: {
trackingEnabled: boolean;
};

/** ReportID of the admins room for this workspace */
chatReportIDAdmins?: number;

Expand Down

0 comments on commit f413efb

Please sign in to comment.