-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[CP Staging] Feat/36985 create new rate field followups #40711
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
neil-marcellini
merged 11 commits into
Expensify:main
from
koko57:feat/36985-create-new-rate-field-followups
Apr 23, 2024
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5111487
fix: NAB comments from pull 38543
koko57 69f54e2
fix: NAB comments + change requested from pull 38543
koko57 f34e527
Merge branch 'main' into feat/36985-create-new-rate-field-followups
koko57 a49422d
fix: typecheck error
koko57 7851a8b
fix: show pending field when route is 0
koko57 535cc20
fix: apply requested changes
koko57 eefa152
fix: get the distance from comment quantity
koko57 5355cca
fix: fix initially focused option
koko57 895d37e
fix: minor fixes
koko57 f88f23d
fix: display pending while changing the distance, block editing dista…
koko57 e75d8f5
fix: minor fix
koko57 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
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 |
|---|---|---|
|
|
@@ -67,8 +67,8 @@ type MoneyRequestViewOnyxPropsWithoutTransaction = { | |
| /** The actions from the parent report */ | ||
| parentReportActions: OnyxEntry<OnyxTypes.ReportActions>; | ||
|
|
||
| /** The rates for the policy */ | ||
| rates: Record<string, MileageRate>; | ||
| /** The distance rates from the policy */ | ||
| distanceRates: Record<string, MileageRate>; | ||
| }; | ||
|
|
||
| type MoneyRequestViewPropsWithoutTransaction = MoneyRequestViewOnyxPropsWithoutTransaction & { | ||
|
|
@@ -95,16 +95,17 @@ function MoneyRequestView({ | |
| policy, | ||
| transactionViolations, | ||
| shouldShowAnimatedBackground, | ||
| rates, | ||
| distanceRates, | ||
| }: MoneyRequestViewProps) { | ||
| const theme = useTheme(); | ||
| const styles = useThemeStyles(); | ||
| const StyleUtils = useStyleUtils(); | ||
| const {isOffline} = useNetwork(); | ||
| const {isSmallScreenWidth} = useWindowDimensions(); | ||
| const {translate, toLocaleDigit} = useLocalize(); | ||
| const {canUseViolations, canUseP2PDistanceRequests} = usePermissions(); | ||
| const parentReportAction = parentReportActions?.[report.parentReportActionID ?? ''] ?? null; | ||
| const isTrackExpense = ReportUtils.isTrackExpenseReport(report); | ||
| const {canUseViolations, canUseP2PDistanceRequests} = usePermissions(isTrackExpense ? CONST.IOU.TYPE.TRACK : undefined); | ||
| const moneyRequestReport = parentReport; | ||
| const { | ||
| created: transactionDate, | ||
|
|
@@ -150,15 +151,15 @@ 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 canEditDistance = ReportUtils.canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.DISTANCE); | ||
| // 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; | ||
|
|
||
| // 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); | ||
|
|
||
| const policyTagLists = useMemo(() => PolicyUtils.getTagLists(policyTagList), [policyTagList]); | ||
|
|
||
| const isTrackExpense = ReportUtils.isTrackExpenseReport(report); | ||
| const iouType = isTrackExpense ? CONST.IOU.TYPE.TRACK : CONST.IOU.TYPE.SUBMIT; | ||
|
|
||
| // Flags for showing categories and tags | ||
|
|
@@ -186,10 +187,11 @@ function MoneyRequestView({ | |
|
|
||
| const currency = policy ? policy.outputCurrency : PolicyUtils.getPersonalPolicy()?.outputCurrency ?? CONST.CURRENCY.USD; | ||
|
|
||
| const mileageRate = TransactionUtils.isCustomUnitRateIDForP2P(transaction) ? DistanceRequestUtils.getRateForP2P(currency) : rates[rateID as string] ?? {}; | ||
| const {unit, rate} = mileageRate; | ||
| const mileageRate = TransactionUtils.isCustomUnitRateIDForP2P(transaction) ? DistanceRequestUtils.getRateForP2P(currency) : distanceRates[rateID as string] ?? {}; | ||
| const {unit} = mileageRate; | ||
| const rate = (transaction?.comment?.customUnit?.defaultP2PRate as number) ?? mileageRate.rate; | ||
|
|
||
| const distance = DistanceRequestUtils.getDistanceFromMerchant(transactionMerchant, unit); | ||
| const distance = DistanceRequestUtils.convertToDistanceInMeters((transaction?.comment?.customUnit?.quantity as number) ?? 0, unit); | ||
| const rateToDisplay = DistanceRequestUtils.getRateForDisplay(unit, rate, currency, translate, toLocaleDigit, isOffline); | ||
| const distanceToDisplay = DistanceRequestUtils.getDistanceForDisplay(hasRoute, distance, unit, rate, translate); | ||
|
|
||
|
|
@@ -283,13 +285,14 @@ function MoneyRequestView({ | |
| <OfflineWithFeedback pendingAction={getPendingFieldAction('waypoints')}> | ||
| <MenuItemWithTopDescription | ||
| description={translate('common.distance')} | ||
| title={distanceToDisplay} | ||
| title={getPendingFieldAction('waypoints') ? translate('iou.fieldPending') : distanceToDisplay} | ||
|
Member
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. We don't need this now. #43569 |
||
| interactive={canEditDistance} | ||
| shouldShowRightIcon={canEditDistance} | ||
| titleStyle={styles.flex1} | ||
| onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DISTANCE.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '', report.reportID))} | ||
| /> | ||
| </OfflineWithFeedback> | ||
| {/* TODO: correct the pending field action https://github.com/Expensify/App/issues/36987 */} | ||
| <OfflineWithFeedback pendingAction={getPendingFieldAction('waypoints')}> | ||
| <MenuItemWithTopDescription | ||
| description={translate('common.rate')} | ||
|
|
@@ -561,7 +564,7 @@ export default withOnyx<MoneyRequestViewPropsWithoutTransaction, MoneyRequestVie | |
| key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report ? report.parentReportID : '0'}`, | ||
| canEvict: false, | ||
| }, | ||
| rates: { | ||
| distanceRates: { | ||
| key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report.policyID}`, | ||
| selector: DistanceRequestUtils.getMileageRates, | ||
| }, | ||
|
|
||
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
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.