Skip to content

Commit

Permalink
Set default tax
Browse files Browse the repository at this point in the history
  • Loading branch information
aldo-expensify committed May 14, 2024
1 parent f9abf1e commit 8668b62
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/components/MoneyRequestConfirmationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import type * as OnyxTypes from '@src/types/onyx';
import type {Participant} from '@src/types/onyx/IOU';
import type {PaymentMethodType} from '@src/types/onyx/OriginalMessage';
import type {SplitShares} from '@src/types/onyx/Transaction';
import { isEmptyObject } from '@src/types/utils/EmptyObject';
import ButtonWithDropdownMenu from './ButtonWithDropdownMenu';
import type {DropdownOption} from './ButtonWithDropdownMenu/types';
import ConfirmedRoute from './ConfirmedRoute';
Expand Down Expand Up @@ -301,6 +302,17 @@ function MoneyRequestConfirmationList({
// TODO: remove the !isTypeInvoice from this condition after BE supports tax for invoices: https://github.com/Expensify/App/issues/41281
const shouldShowTax = isTaxTrackingEnabled(isPolicyExpenseChat, policy) && !isTypeInvoice;

useEffect(() => {
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
if (isEmptyObject(policy) || !shouldShowTax || transaction?.taxCode || !taxRates) {
return;
}
const defaultTaxCode = TransactionUtils.getDefaultTaxCode(policy, transaction);
if (defaultTaxCode) {
IOU.setMoneyRequestTaxRate(transactionID, defaultTaxCode);
}
}, [policy, shouldShowTax, taxRates, transaction, transaction?.taxCode, transactionID]);

// A flag for showing the billable field
const shouldShowBillable = policy?.disabledFields?.defaultBillable === false;
const isMovingTransactionFromTrackExpense = IOUUtils.isMovingTransactionFromTrackExpense(action);
Expand Down

0 comments on commit 8668b62

Please sign in to comment.