-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Implemented BE part of Per Diem Request #54760
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 27 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
b5a31a4
Implemented BE part of Per Diem Request
shubham1206agra 28f18ee
Fix default values
shubham1206agra ab084f2
Fix optimistic bug
shubham1206agra 7bd8de9
Fix navigation bug
shubham1206agra 868c4d2
Fix parameters
shubham1206agra 35c0bd7
Fix weird tab navigator behavior
shubham1206agra 57f1e3a
Renaming component
shubham1206agra e3cde6d
Merge branch 'Expensify:main' into per-diem-6
shubham1206agra c3688b4
Fixed subrate page
shubham1206agra ed00cdc
Fixed empty time case
shubham1206agra 6c34373
Fixed weird destination options when options are less than the threshold
shubham1206agra 394a07e
Fixed offline behavior in destination page
shubham1206agra b89b6b5
Fixed subrate form
shubham1206agra 6aa760e
Fix qty translation
shubham1206agra afb3c15
Fix time badge translation
shubham1206agra eb98559
Merge branch 'Expensify:main' into per-diem-6
shubham1206agra 6b69c5c
Fix eReceipts
shubham1206agra e723cf7
Merge branch 'Expensify:main' into per-diem-6
shubham1206agra 06a6ea1
Fix eReceipts part 2
shubham1206agra a51ff73
Fix translations
shubham1206agra 393ba99
Merge branch 'Expensify:main' into per-diem-6
shubham1206agra 1c0d561
Fix variable names
shubham1206agra 3e366f4
Minor fix
shubham1206agra 312b9ff
Merge branch 'Expensify:main' into per-diem-6
shubham1206agra 348c201
Fixed default category not setting up properly
shubham1206agra c07a2bf
Disable blur validation in subrate step
shubham1206agra 35e70a3
Fix lint
shubham1206agra 4bae644
Fix conflicts
shubham1206agra 9616b52
Fix lint part 1
shubham1206agra 784da8e
Fix lint part 2
shubham1206agra 850c339
Fix lint part 3
shubham1206agra 2ae74b1
Merge main
shubham1206agra 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
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,120 @@ | ||
| import React from 'react'; | ||
| import {View} from 'react-native'; | ||
| import {useOnyx} from 'react-native-onyx'; | ||
| import useLocalize from '@hooks/useLocalize'; | ||
| import useStyleUtils from '@hooks/useStyleUtils'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import * as CurrencyUtils from '@libs/CurrencyUtils'; | ||
| import * as ReportUtils from '@libs/ReportUtils'; | ||
| import variables from '@styles/variables'; | ||
| import CONST from '@src/CONST'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import type {TransactionCustomUnit} from '@src/types/onyx/Transaction'; | ||
| import EReceiptThumbnail from './EReceiptThumbnail'; | ||
| import Icon from './Icon'; | ||
| import * as Expensicons from './Icon/Expensicons'; | ||
| import Text from './Text'; | ||
|
|
||
| type PerDiemEReceiptProps = { | ||
| /* TransactionID of the transaction this EReceipt corresponds to */ | ||
| transactionID: string; | ||
| }; | ||
|
|
||
| function computeDefaultPerDiemExpenseRates(customUnit: TransactionCustomUnit, currency: string) { | ||
| const subRates = customUnit.subRates ?? []; | ||
| const subRateComments = subRates.map((subRate) => { | ||
| const rate = subRate.rate ?? 0; | ||
| const rateComment = subRate.name ?? ''; | ||
| const quantity = subRate.quantity ?? 0; | ||
| return `${quantity}x ${rateComment} @ ${CurrencyUtils.convertAmountToDisplayString(rate, currency)}`; | ||
| }); | ||
| return subRateComments.join(', '); | ||
| } | ||
|
|
||
| function getPerDiemDestination(merchant: string) { | ||
| const merchantParts = merchant.split(', '); | ||
| if (merchantParts.length < 3) { | ||
| return ''; | ||
| } | ||
| return merchantParts.slice(0, merchantParts.length - 3).join(', '); | ||
| } | ||
|
|
||
| function getPerDiemDates(merchant: string) { | ||
| const merchantParts = merchant.split(', '); | ||
| if (merchantParts.length < 3) { | ||
| return merchant; | ||
| } | ||
| return merchantParts.slice(-3).join(', '); | ||
| } | ||
|
|
||
| function PerDiemEReceipt({transactionID}: PerDiemEReceiptProps) { | ||
| const styles = useThemeStyles(); | ||
| const StyleUtils = useStyleUtils(); | ||
| const {translate} = useLocalize(); | ||
| const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`); | ||
|
|
||
| // Get receipt colorway, or default to Yellow. | ||
| const {backgroundColor: primaryColor, color: secondaryColor} = StyleUtils.getEReceiptColorStyles(StyleUtils.getEReceiptColorCode(transaction)) ?? {}; | ||
|
|
||
| const {amount: transactionAmount, currency: transactionCurrency, merchant: transactionMerchant} = ReportUtils.getTransactionDetails(transaction, CONST.DATE.MONTH_DAY_YEAR_FORMAT) ?? {}; | ||
| const ratesDescription = computeDefaultPerDiemExpenseRates(transaction?.comment?.customUnit ?? {}, transactionCurrency ?? ''); | ||
| const datesDescription = getPerDiemDates(transactionMerchant ?? ''); | ||
| const destination = getPerDiemDestination(transactionMerchant ?? ''); | ||
| const formattedAmount = CurrencyUtils.convertToDisplayStringWithoutCurrency(transactionAmount ?? 0, transactionCurrency); | ||
| const currency = CurrencyUtils.getCurrencySymbol(transactionCurrency ?? ''); | ||
|
|
||
| const secondaryTextColorStyle = secondaryColor ? StyleUtils.getColorStyle(secondaryColor) : undefined; | ||
|
|
||
| return ( | ||
| <View style={[styles.eReceiptContainer, primaryColor ? StyleUtils.getBackgroundColorStyle(primaryColor) : undefined]}> | ||
| <View style={styles.fullScreen}> | ||
| <EReceiptThumbnail | ||
| transactionID={transactionID} | ||
| centerIconV={false} | ||
| /> | ||
| </View> | ||
| <View style={[styles.alignItemsCenter, styles.ph8, styles.pb14, styles.pt8]}> | ||
| <View style={[StyleUtils.getWidthAndHeightStyle(variables.eReceiptIconWidth, variables.eReceiptIconHeight)]} /> | ||
| </View> | ||
| <View style={[styles.flexColumn, styles.justifyContentBetween, styles.alignItemsCenter, styles.ph9, styles.flex1]}> | ||
| <View style={[styles.alignItemsCenter, styles.alignSelfCenter, styles.flexColumn, styles.gap2, styles.mb8]}> | ||
| <View style={[styles.flexRow, styles.justifyContentCenter, StyleUtils.getWidthStyle(variables.eReceiptTextContainerWidth)]}> | ||
| <View style={[styles.flexColumn, styles.pt1]}> | ||
| <Text style={[styles.eReceiptCurrency, secondaryTextColorStyle]}>{currency}</Text> | ||
| </View> | ||
| <Text | ||
| adjustsFontSizeToFit | ||
| style={[styles.eReceiptAmountLarge, secondaryTextColorStyle]} | ||
| > | ||
| {formattedAmount} | ||
| </Text> | ||
| </View> | ||
| <Text style={[styles.eReceiptMerchant, styles.breakWord, styles.textAlignCenter]}>{`${destination} ${translate('common.perDiem').toLowerCase()}`}</Text> | ||
| </View> | ||
| <View style={[styles.alignSelfStretch, styles.flexColumn, styles.mb8, styles.gap4]}> | ||
| <View style={[styles.flexColumn, styles.gap1]}> | ||
| <Text style={[styles.eReceiptWaypointTitle, secondaryTextColorStyle]}>{translate('iou.dates')}</Text> | ||
| <Text style={[styles.eReceiptWaypointAddress]}>{datesDescription}</Text> | ||
| </View> | ||
| <View style={[styles.flexColumn, styles.gap1]}> | ||
| <Text style={[styles.eReceiptWaypointTitle, secondaryTextColorStyle]}>{translate('iou.rates')}</Text> | ||
| <Text style={[styles.eReceiptWaypointAddress]}>{ratesDescription}</Text> | ||
| </View> | ||
| </View> | ||
| <View style={[styles.justifyContentBetween, styles.alignItemsCenter, styles.alignSelfStretch, styles.flexRow, styles.mb8]}> | ||
| <Icon | ||
| width={variables.eReceiptWordmarkWidth} | ||
| height={variables.eReceiptWordmarkHeight} | ||
| fill={secondaryColor} | ||
| src={Expensicons.ExpensifyWordmark} | ||
| /> | ||
| <Text style={styles.eReceiptGuaranteed}>{translate('eReceipt.guaranteed')}</Text> | ||
| </View> | ||
| </View> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| PerDiemEReceipt.displayName = 'PerDiemEReceipt'; | ||
|
|
||
| export default PerDiemEReceipt; |
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
Oops, something went wrong.
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.
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.
Hi @shubham1206agra, coming from this issue, just wanna confirm if for PerDiem expenses, we allow quantity up to 12 max-length?