-
Notifications
You must be signed in to change notification settings - Fork 3.5k
feat: Receipt Audit Feature / Note type violations. #37813
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
Merged
Merged
Changes from all commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
9467b3a
feat: Receipt Audit Feature / Note type violations.
Krishna2323 8c400c3
added translations.
Krishna2323 96744d5
extract noticeViolations from transactionViolations.
Krishna2323 952a4da
Update the dot separator sub-state for the request preview.
Krishna2323 8438383
Remove redundant code.
Krishna2323 7f97519
minor fix.
Krishna2323 cebc960
minor fix.
Krishna2323 86014ab
hide ReceiptAudit when scan is in progress.
Krishna2323 3db41da
minor updates.
Krishna2323 afb1afb
Merge branch 'main' into krishna2323/feat/36288
Krishna2323 b538331
Update MoneyRequestView.tsx
Krishna2323 48d1543
fix: translations.
Krishna2323 77165e7
minor fixes.
Krishna2323 699bb28
Merge branch 'Expensify:main' into krishna2323/feat/36288
Krishna2323 25cc0fa
receipt audit design changes.
Krishna2323 da3ae8c
Receipt audit design updates.
Krishna2323 f2a59fd
Merge branch 'Expensify:main' into krishna2323/feat/36288
Krishna2323 fd457cd
show notes violation for only admins and approvers in a paid policy.
Krishna2323 7a194c9
Merge branch 'krishna2323/feat/36288' of https://github.com/Krishna23…
Krishna2323 0de547a
Merge branch 'main' into krishna2323/feat/36288
Krishna2323 b785e1f
show notes violation to everyone.
Krishna2323 f4e118a
fix: violation messages styles.
Krishna2323 67d7dc4
Merge branch 'main' into krishna2323/feat/36288
Krishna2323 80b7eb5
Update MoneyRequestView.tsx
Krishna2323 bfec360
remove ReceiptAuditHeader condition.
Krishna2323 d9975d8
Merge branch 'Expensify:main' into krishna2323/feat/36288
Krishna2323 269163f
Merge branch 'Expensify:main' into krishna2323/feat/36288
Krishna2323 ae2324e
fix: margins issue.
Krishna2323 4bb11b5
Merge branch 'Expensify:main' into krishna2323/feat/36288
Krishna2323 899f12c
Merge branch 'Expensify:main' into krishna2323/feat/36288
Krishna2323 4225d83
show red dot when review is required.
Krishna2323 98ef4fb
Merge branch 'Expensify:main' into krishna2323/feat/36288
Krishna2323 78b79cc
allow admin & approver to update receipt when iou request is open.
Krishna2323 87270fb
revert: allow admin & approver to update receipt when iou request is …
Krishna2323 51cb29d
Merge branch 'Expensify:main' into krishna2323/feat/36288
Krishna2323 cd91773
show empty receipt for admin & approver if not present.
Krishna2323 ca0650b
revert margin changes.
Krishna2323 943df82
Merge branch 'main' into krishna2323/feat/36288
Krishna2323 cd52fee
Merge branch 'Expensify:main' into krishna2323/feat/36288
Krishna2323 1ae1c5b
show audit status only when receipt is scanned.
Krishna2323 31f34a8
Merge branch 'main' into krishna2323/feat/36288
Krishna2323 2c9ab1e
fix: disabled receipt cursor style.
Krishna2323 8f17210
Merge branch 'Expensify:main' into krishna2323/feat/36288
Krishna2323 148c2b9
fix: no space between audit message and notes violations.
Krishna2323 ace1043
fix lint warning.
Krishna2323 cfbddf1
minor updates according to suggestions.
Krishna2323 a0a2fc3
second commit: minor updates according to suggestions.
Krishna2323 812fd14
Merge branch 'Expensify:main' into krishna2323/feat/36288
Krishna2323 9fbf78e
third commit: minor updates according to suggestions.
Krishna2323 4081f85
Merge branch 'krishna2323/feat/36288' of https://github.com/Krishna23…
Krishna2323 e117ef5
fourth commit: minor updates according to suggestions.
Krishna2323 22e6fcb
5th commit: minor updates according to suggestions.
Krishna2323 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import React from 'react'; | ||
| import {View} from 'react-native'; | ||
| import useLocalize from '@hooks/useLocalize'; | ||
| import useTheme from '@hooks/useTheme'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import Icon from './Icon'; | ||
| import * as Expensicons from './Icon/Expensicons'; | ||
| import Text from './Text'; | ||
|
|
||
| function ReceiptAuditHeader({notes, shouldShowAuditMessage}: {notes: string[]; shouldShowAuditMessage: boolean}) { | ||
| const styles = useThemeStyles(); | ||
| const theme = useTheme(); | ||
| const {translate} = useLocalize(); | ||
|
|
||
| const auditText = notes.length > 0 ? translate('iou.receiptIssuesFound', notes.length) : translate('common.verified'); | ||
| return ( | ||
| <View style={[styles.ph5, styles.mbn1]}> | ||
| <View style={[styles.flexRow, styles.alignItemsCenter]}> | ||
| <Text style={[styles.textLabelSupporting]}>{translate('common.receipt')}</Text> | ||
| {shouldShowAuditMessage && ( | ||
| <> | ||
| <Text style={[styles.textLabelSupporting]}>{` • ${auditText}`}</Text> | ||
| <Icon | ||
| width={12} | ||
| height={12} | ||
| src={notes.length ? Expensicons.DotIndicator : Expensicons.Checkmark} | ||
| fill={notes.length ? theme.danger : theme.success} | ||
| additionalStyles={styles.ml1} | ||
| /> | ||
| </> | ||
| )} | ||
| </View> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| function ReceiptAuditMessages({notes = []}: {notes?: string[]}) { | ||
| const styles = useThemeStyles(); | ||
| return <View style={[styles.mtn1, styles.mb2, styles.ph5, styles.gap1]}>{notes.length > 0 && notes.map((message) => <Text style={[styles.textLabelError]}>{message}</Text>)}</View>; | ||
Krishna2323 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| export {ReceiptAuditHeader, ReceiptAuditMessages}; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,8 @@ import ConfirmedRoute from '@components/ConfirmedRoute'; | |
| import * as Expensicons from '@components/Icon/Expensicons'; | ||
| import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; | ||
| import OfflineWithFeedback from '@components/OfflineWithFeedback'; | ||
| import {useSession} from '@components/OnyxProvider'; | ||
| import {ReceiptAuditHeader, ReceiptAuditMessages} from '@components/ReceiptAudit'; | ||
| import ReceiptEmptyState from '@components/ReceiptEmptyState'; | ||
| import SpacerView from '@components/SpacerView'; | ||
| import Switch from '@components/Switch'; | ||
|
|
@@ -99,6 +101,7 @@ function MoneyRequestView({ | |
| }: MoneyRequestViewProps) { | ||
| const theme = useTheme(); | ||
| const styles = useThemeStyles(); | ||
| const session = useSession(); | ||
| const StyleUtils = useStyleUtils(); | ||
| const {isOffline} = useNetwork(); | ||
| const {isSmallScreenWidth} = useWindowDimensions(); | ||
|
|
@@ -125,7 +128,7 @@ function MoneyRequestView({ | |
| const isEmptyMerchant = transactionMerchant === '' || transactionMerchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT; | ||
| const isDistanceRequest = TransactionUtils.isDistanceRequest(transaction); | ||
| const formattedTransactionAmount = transactionAmount ? CurrencyUtils.convertToDisplayString(transactionAmount, transactionCurrency) : ''; | ||
| const hasPendingWaypoints = transaction?.pendingFields?.waypoints; | ||
| const hasPendingWaypoints = Boolean(transaction?.pendingFields?.waypoints); | ||
| const showMapAsImage = isDistanceRequest && hasPendingWaypoints; | ||
| const formattedOriginalAmount = transactionOriginalAmount && transactionOriginalCurrency && CurrencyUtils.convertToDisplayString(transactionOriginalAmount, transactionOriginalCurrency); | ||
| const isCardTransaction = TransactionUtils.isCardTransaction(transaction); | ||
|
|
@@ -151,9 +154,14 @@ function MoneyRequestView({ | |
| const canEditMerchant = ReportUtils.canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.MERCHANT); | ||
| const canEditDate = ReportUtils.canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.DATE); | ||
| 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); | ||
| // TODO: remove the !isTrackExpense from this condition after this fix: https://github.com/Expensify/Expensify/issues/382786 | ||
| const canEditDistance = ReportUtils.canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.DISTANCE) && !isTrackExpense; | ||
|
|
||
| const isAdmin = policy?.role === 'admin'; | ||
| const isApprover = ReportUtils.isMoneyRequestReport(moneyRequestReport) && moneyRequestReport?.managerID !== null && session?.accountID === moneyRequestReport?.managerID; | ||
| // A flag for verifying that the current report is a sub-report of a workspace chat | ||
| // if the policy of the report is either Collect or Control, then this report must be tied to workspace chat | ||
| const isPolicyExpenseChat = ReportUtils.isGroupPolicy(report); | ||
|
|
@@ -238,7 +246,6 @@ function MoneyRequestView({ | |
| } | ||
| } | ||
|
|
||
| const hasReceipt = TransactionUtils.hasReceipt(transaction); | ||
| let receiptURIs; | ||
| const hasErrors = canEdit && TransactionUtils.hasMissingSmartscanFields(transaction); | ||
| if (hasReceipt) { | ||
|
|
@@ -324,12 +331,20 @@ function MoneyRequestView({ | |
| </OfflineWithFeedback> | ||
| ); | ||
|
|
||
| const shouldShowMapOrReceipt = showMapAsImage || hasReceipt; | ||
|
Contributor
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.
Contributor
Author
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. can you pls check again. |
||
| const shouldShowReceiptEmptyState = !hasReceipt && (canEditReceipt || isAdmin || isApprover); | ||
| const noticeTypeViolations = transactionViolations?.filter((violation) => violation.type === 'notice').map((v) => ViolationsUtils.getViolationTranslation(v, translate)) ?? []; | ||
| const shouldShowNotesViolations = !isReceiptBeingScanned && canUseViolations && ReportUtils.isPaidGroupPolicy(report); | ||
|
|
||
| return ( | ||
| <View style={[StyleUtils.getReportWelcomeContainerStyle(isSmallScreenWidth, true, shouldShowAnimatedBackground)]}> | ||
| {shouldShowAnimatedBackground && <AnimatedEmptyStateBackground />} | ||
| <View style={shouldShowAnimatedBackground && [StyleUtils.getReportWelcomeTopMarginStyle(isSmallScreenWidth, true)]}> | ||
| {/* eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing */} | ||
| {(showMapAsImage || hasReceipt) && ( | ||
| <ReceiptAuditHeader | ||
| notes={noticeTypeViolations} | ||
| shouldShowAuditMessage={Boolean(shouldShowNotesViolations && didRceiptScanSucceed)} | ||
| /> | ||
| {shouldShowMapOrReceipt && ( | ||
| <OfflineWithFeedback | ||
| pendingAction={pendingAction} | ||
| errors={transaction?.errors} | ||
|
|
@@ -359,9 +374,10 @@ function MoneyRequestView({ | |
| </View> | ||
| </OfflineWithFeedback> | ||
| )} | ||
| {!hasReceipt && canEditReceipt && ( | ||
| {shouldShowReceiptEmptyState && ( | ||
| <ReceiptEmptyState | ||
| hasError={hasErrors} | ||
| disabled={!canEditReceipt} | ||
| onPress={() => | ||
| Navigation.navigate( | ||
| ROUTES.MONEY_REQUEST_STEP_SCAN.getRoute( | ||
|
|
@@ -375,6 +391,8 @@ function MoneyRequestView({ | |
| } | ||
| /> | ||
| )} | ||
| {!shouldShowReceiptEmptyState && !shouldShowMapOrReceipt && <View style={{marginVertical: 6}} />} | ||
| {shouldShowNotesViolations && <ReceiptAuditMessages notes={noticeTypeViolations} />} | ||
| {canUseViolations && <ViolationMessages violations={getViolationsForField('receipt')} />} | ||
| <OfflineWithFeedback pendingAction={getPendingFieldAction('amount')}> | ||
| <MenuItemWithTopDescription | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.