diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index be705ba50800..273f7581f08c 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -196,6 +196,8 @@ function MoneyRequestView({allReports, report, policy, shouldShowAnimatedBackgro const taxRatesDescription = taxRates?.name; const taxRateTitle = updatedTransaction ? getTaxName(policy, updatedTransaction) : getTaxName(policy, transaction); + const fallbackTaxRateTitle = transaction?.taxValue; + const isSettled = isSettledReportUtils(moneyRequestReport?.reportID); const isCancelled = moneyRequestReport && moneyRequestReport?.isCancelledIOU; const isChatReportArchived = useReportIsArchived(moneyRequestReport?.chatReportID); @@ -776,7 +778,7 @@ function MoneyRequestView({allReports, report, policy, shouldShowAnimatedBackgro {shouldShowTax && ( violation.name === CONST.VIOLATIONS.OVER_TRIP_LIMIT); const hasCategoryOverLimitViolation = transactionViolations.some((violation) => violation.name === CONST.VIOLATIONS.OVER_CATEGORY_LIMIT); const hasMissingCommentViolation = transactionViolations.some((violation) => violation.name === CONST.VIOLATIONS.MISSING_COMMENT); + const hasTaxOutOfPolicyViolation = transactionViolations.some((violation) => violation.name === CONST.VIOLATIONS.TAX_OUT_OF_POLICY); + const isPolicyTrackTaxEnabled = !!policy?.tax?.trackingEnabled; + const isTaxInPolicy = Object.keys(policy.taxRates?.taxes ?? {}).some((key) => key === updatedTransaction.taxCode); + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const amount = updatedTransaction.modifiedAmount || updatedTransaction.amount; // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing @@ -425,6 +429,13 @@ const ViolationsUtils = { newTransactionViolations = reject(newTransactionViolations, {name: CONST.VIOLATIONS.MISSING_COMMENT}); } + if (isPolicyTrackTaxEnabled && !hasTaxOutOfPolicyViolation && !isTaxInPolicy) { + newTransactionViolations.push({name: CONST.VIOLATIONS.TAX_OUT_OF_POLICY, type: CONST.VIOLATION_TYPES.VIOLATION}); + } + + if (isPolicyTrackTaxEnabled && hasTaxOutOfPolicyViolation && isTaxInPolicy) { + newTransactionViolations = reject(newTransactionViolations, {name: CONST.VIOLATIONS.TAX_OUT_OF_POLICY}); + } return { onyxMethod: Onyx.METHOD.SET, key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${updatedTransaction.transactionID}`, diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index f71a01854feb..cbe084de43b5 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -4338,6 +4338,7 @@ function getUpdateMoneyRequestParams( const hasModifiedCurrency = 'currency' in transactionChanges; const hasModifiedComment = 'comment' in transactionChanges; + const hasModifiedTaxCode = 'taxCode' in transactionChanges; const hasModifiedDate = 'date' in transactionChanges; const isInvoice = isInvoiceReportReportUtils(iouReport); @@ -4346,7 +4347,15 @@ function getUpdateMoneyRequestParams( isPaidGroupPolicy(policy) && !isInvoice && updatedTransaction && - (hasModifiedTag || hasModifiedCategory || hasModifiedComment || hasModifiedDistanceRate || hasModifiedDate || hasModifiedCurrency || hasModifiedAmount || hasModifiedCreated) + (hasModifiedTag || + hasModifiedCategory || + hasModifiedComment || + hasModifiedDistanceRate || + hasModifiedDate || + hasModifiedCurrency || + hasModifiedAmount || + hasModifiedCreated || + hasModifiedTaxCode) ) { const currentTransactionViolations = allTransactionViolations[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`] ?? []; // If the amount, currency or date have been modified, we remove the duplicate violations since they would be out of date as the transaction has changed diff --git a/src/types/onyx/Transaction.ts b/src/types/onyx/Transaction.ts index 0ca2909fcd4a..38459cad2539 100644 --- a/src/types/onyx/Transaction.ts +++ b/src/types/onyx/Transaction.ts @@ -406,6 +406,9 @@ type Transaction = OnyxCommon.OnyxValueWithOfflineFeedback< /** The transaction tax code */ taxCode?: string; + /** The transaction tax value */ + taxValue?: string | undefined; + /** Whether the expense is billable */ billable?: boolean;