-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
fix: [Violations] Distance - Incorrect error message when distance amount is changed to smaller amount. #41649
Changes from all commits
2f4d561
bac54f1
d399453
c7ec1df
34d5e2e
0549056
ef8e655
f039038
be4f9be
c9fd9aa
b801997
4240c2f
1043d16
3c71e67
12f0433
407e552
7611122
4ebb250
03a9345
d693489
245d667
efd639c
4e8f365
9e452c4
49954fb
d671670
e2851c4
7ae2d6b
e5420c1
7c38e5c
1595f33
2589ba6
6e63f57
9fec7f9
4fe1913
68ebaa7
2a76377
c5d5a3c
995eaed
e3b692e
0a92c99
1c4d2a1
7cdc36c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ import MenuItem from '@components/MenuItem'; | |
import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; | ||
import OfflineWithFeedback from '@components/OfflineWithFeedback'; | ||
import {useSession} from '@components/OnyxProvider'; | ||
import {ReceiptAuditHeader, ReceiptAuditMessages} from '@components/ReceiptAudit'; | ||
import ReceiptAudit, {ReceiptAuditMessages} from '@components/ReceiptAudit'; | ||
import ReceiptEmptyState from '@components/ReceiptEmptyState'; | ||
import Switch from '@components/Switch'; | ||
import Text from '@components/Text'; | ||
|
@@ -163,7 +163,7 @@ function MoneyRequestView({ | |
const canEditReceipt = ReportUtils.canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.RECEIPT); | ||
const hasReceipt = TransactionUtils.hasReceipt(transaction); | ||
const isReceiptBeingScanned = hasReceipt && TransactionUtils.isReceiptBeingScanned(transaction); | ||
const didRceiptScanSucceed = hasReceipt && TransactionUtils.didRceiptScanSucceed(transaction); | ||
const didReceiptScanSucceed = hasReceipt && TransactionUtils.didReceiptScanSucceed(transaction); | ||
const canEditDistance = ReportUtils.canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.DISTANCE); | ||
|
||
const isAdmin = policy?.role === 'admin'; | ||
|
@@ -189,7 +189,7 @@ function MoneyRequestView({ | |
const tripID = ReportUtils.getTripIDFromTransactionParentReport(parentReport); | ||
const shouldShowViewTripDetails = TransactionUtils.hasReservationList(transaction) && !!tripID; | ||
|
||
const {getViolationsForField} = useViolations(transactionViolations ?? []); | ||
const {getViolationsForField} = useViolations(transactionViolations ?? [], isReceiptBeingScanned || !ReportUtils.isPaidGroupPolicy(report)); | ||
const hasViolations = useCallback( | ||
(field: ViolationField, data?: OnyxTypes.TransactionViolation['data'], policyHasDependentTags = false, tagValue?: string): boolean => | ||
!!canUseViolations && getViolationsForField(field, data, policyHasDependentTags, tagValue).length > 0, | ||
|
@@ -340,14 +340,17 @@ function MoneyRequestView({ | |
const receiptViolationNames: OnyxTypes.ViolationName[] = [ | ||
CONST.VIOLATIONS.RECEIPT_REQUIRED, | ||
CONST.VIOLATIONS.RECEIPT_NOT_SMART_SCANNED, | ||
CONST.VIOLATIONS.MODIFIED_DATE, | ||
CONST.VIOLATIONS.CASH_EXPENSE_WITH_NO_RECEIPT, | ||
CONST.VIOLATIONS.SMARTSCAN_FAILED, | ||
]; | ||
const receiptViolations = | ||
transactionViolations?.filter((violation) => receiptViolationNames.includes(violation.name)).map((violation) => ViolationsUtils.getViolationTranslation(violation, translate)) ?? []; | ||
const shouldShowNotesViolations = !isReceiptBeingScanned && canUseViolations && ReportUtils.isPaidGroupPolicy(report); | ||
const shouldShowReceiptHeader = isReceiptAllowed && (shouldShowReceiptEmptyState || hasReceipt); | ||
|
||
// Whether to show receipt audit result (e.g.`Verified`, `Issue Found`) and messages (e.g. `Receipt not verified. Please confirm accuracy.`) | ||
// `!!(receiptViolations.length || didReceiptScanSucceed)` is for not showing `Verified` when `receiptViolations` is empty and `didReceiptScanSucceed` is false. | ||
const shouldShowAuditMessage = | ||
!isReceiptBeingScanned && hasReceipt && !!(receiptViolations.length || didReceiptScanSucceed) && !!canUseViolations && ReportUtils.isPaidGroupPolicy(report); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sobitneupane @cead22, updated |
||
const shouldShowReceiptAudit = isReceiptAllowed && (shouldShowReceiptEmptyState || hasReceipt); | ||
|
||
const errors = { | ||
...(transaction?.errorFields?.route ?? transaction?.errors), | ||
|
@@ -389,10 +392,10 @@ function MoneyRequestView({ | |
<View style={styles.pRelative}> | ||
{shouldShowAnimatedBackground && <AnimatedEmptyStateBackground />} | ||
<> | ||
{shouldShowReceiptHeader && ( | ||
<ReceiptAuditHeader | ||
{shouldShowReceiptAudit && ( | ||
<ReceiptAudit | ||
notes={receiptViolations} | ||
shouldShowAuditMessage={!!(shouldShowNotesViolations && didRceiptScanSucceed)} | ||
shouldShowAuditResult={shouldShowAuditMessage} | ||
/> | ||
)} | ||
{(hasReceipt || errors) && ( | ||
|
@@ -448,7 +451,7 @@ function MoneyRequestView({ | |
/> | ||
)} | ||
{!shouldShowReceiptEmptyState && !hasReceipt && <View style={{marginVertical: 6}} />} | ||
{shouldShowNotesViolations && <ReceiptAuditMessages notes={receiptViolations} />} | ||
{shouldShowAuditMessage && <ReceiptAuditMessages notes={receiptViolations} />} | ||
<OfflineWithFeedback pendingAction={getPendingFieldAction('amount')}> | ||
<MenuItemWithTopDescription | ||
title={amountTitle} | ||
|
@@ -555,7 +558,6 @@ function MoneyRequestView({ | |
/> | ||
</OfflineWithFeedback> | ||
)} | ||
|
||
{shouldShowTax && ( | ||
<OfflineWithFeedback pendingAction={getPendingFieldAction('taxAmount')}> | ||
<MenuItemWithTopDescription | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,6 +102,7 @@ import type { | |
ViolationsInvoiceMarkupParams, | ||
ViolationsMaxAgeParams, | ||
ViolationsMissingTagParams, | ||
ViolationsModifiedAmountParams, | ||
ViolationsOverCategoryLimitParams, | ||
ViolationsOverLimitParams, | ||
ViolationsPerDayLimitParams, | ||
|
@@ -3633,7 +3634,19 @@ export default { | |
missingCategory: 'Missing category', | ||
missingComment: 'Description required for selected category', | ||
missingTag: ({tagName}: ViolationsMissingTagParams) => `Missing ${tagName ?? 'tag'}`, | ||
modifiedAmount: 'Amount greater than scanned receipt', | ||
modifiedAmount: ({type, displayPercentVariance}: ViolationsModifiedAmountParams): string => { | ||
switch (type) { | ||
case 'distance': | ||
return 'Amount differs from calculated distance'; | ||
case 'card': | ||
return 'Amount greater than card transaction'; | ||
default: | ||
if (displayPercentVariance) { | ||
return `Amount ${displayPercentVariance}% greater than scanned receipt`; | ||
} | ||
return 'Amount greater than scanned receipt'; | ||
} | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated 👀 |
||
modifiedDate: 'Date differs from scanned receipt', | ||
nonExpensiworksExpense: 'Non-Expensiworks expense', | ||
overAutoApprovalLimit: ({formattedLimit}: ViolationsOverLimitParams) => `Expense exceeds auto approval limit of ${formattedLimit}`, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sobitneupane @cead22, I mistakenly added
modified amount
violation here while resolving conflict, thats why the violation was shown under receipt. I have removed that and alsoCONST.VIOLATIONS.MODIFIED_DATE
because I believe the date violation should also be shown under date field.