-
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
feat: add new input fields for tax tracking #32550
Merged
MonilBhavsar
merged 90 commits into
Expensify:main
from
teneeto:feat/31672/add-new-input-fields-for-tax-tracking
Jan 3, 2024
Merged
Changes from 73 commits
Commits
Show all changes
90 commits
Select commit
Hold shift + click to select a range
3d85737
initial input screens
teneeto 20efbfc
fix lint
teneeto 71b49b9
check policy expense chat: a flag for showing tax rate
teneeto 50e1a81
add policy tax rates in tax rate page
teneeto c683500
add tax rates list threshold
teneeto c14bbe3
add tax rates sections in options utils
teneeto 88d352d
add tax propTypes
teneeto 8b26228
add tax pickerPropTypes
teneeto e4be96d
add tax picker
teneeto 11a4691
use TaxPicker in tax rates page
teneeto df81cf5
fix lint
teneeto c34095e
remove whitespace
teneeto 2f78afd
add default amount to avoid Nan
teneeto 8098ae1
add default title for tax rate and format amount
teneeto 11ab530
set tax rate and tax amount to onyx
teneeto bebace8
add defaulttax title
teneeto 0675e22
update tax rate section
teneeto 2abfc7c
update tax Amount based on tax rate
teneeto ce50e7c
should show search input if threshold is more than 8
teneeto 9e12ece
should show error if current amount is greater than iou amount
teneeto e5f6e17
update comment
teneeto d9fa49d
set taxAmount in Onyx
teneeto 98db78b
add tax translation strings
teneeto e28ae1b
format tax amount and use translation for invalid tax amount
teneeto 781952a
translate titles
teneeto 6fe318c
Merge branch 'main' of github.com:teneeto/App into feat/31672/add-new…
teneeto 7f80963
update merge conflict
teneeto 62e98c1
translate tax amount and rate
teneeto 5b11998
Merge branch 'main' of github.com:teneeto/App into feat/31672/add-new…
teneeto ff9ca23
refactor tax amount and rate pages
teneeto b692144
refactor tax amount and rate routes and navigation
teneeto 0f4fb66
update tax picker
teneeto 4341e90
refactor invalid tax amount error
teneeto c6d902c
sync Temp refactor request confirmation list with tax rate and amount…
teneeto ac4092e
fix lint
teneeto 353345a
Merge branch 'main' of github.com:teneeto/App into feat/31672/add-new…
teneeto f0f8ca6
update tax proptypes
teneeto 3ca564a
add proptypes for transactions draft
teneeto 9383f8a
transform taxes to a new object with code
teneeto 6a0d3a8
use proptypes
teneeto 5db26b7
fix lint
teneeto 9112347
update translations
teneeto 88c001e
transform tax rates
teneeto b4d6055
update invalid tax amount error
teneeto 86edc81
update amount defaults
teneeto b59dcae
add JSDOC and comments
teneeto 8ed66c7
send taxCode and taxAmount to RequestMoney API
teneeto a2696d3
use transactions from onyx instead of transactionsDraft
teneeto 25e128c
Update src/pages/iou/request/step/IOURequestStepTaxAmountPage.js
teneeto 42f7fcf
Update src/libs/OptionsListUtils.js
teneeto 15b45af
Update src/libs/OptionsListUtils.js
teneeto bd72c6c
Update src/components/TaxPicker/taxPickerPropTypes.js
teneeto 8a1e906
Update src/components/taxPropTypes.js
teneeto bedc6ef
Update src/pages/iou/request/step/IOURequestStepTaxAmountPage.js
teneeto a456030
fix lint
teneeto 15a7954
Update src/components/MoneyRequestConfirmationList.js
teneeto 41edcb8
Update src/components/taxPropTypes.js
teneeto 8e78e34
Update src/components/taxPropTypes.js
teneeto 8dfb843
Update src/components/taxPropTypes.js
teneeto 0f52c39
Update src/components/taxPropTypes.js
teneeto 16319b9
Update src/libs/OptionsListUtils.js
teneeto a7be0dc
Update src/libs/OptionsListUtils.js
teneeto 1404d7c
Update src/libs/OptionsListUtils.js
teneeto 4e0a034
test getFilteredOptions for taxRate
teneeto 3afed39
Merge branch 'feat/31672/add-new-input-fields-for-tax-tracking' of gi…
teneeto c168e74
Update tests/unit/OptionsListUtilsTest.js
teneeto 5ec8788
Update src/pages/iou/request/step/IOURequestStepTaxRatePage.js
teneeto a3ac0b6
Update src/pages/iou/request/step/IOURequestStepTaxRatePage.js
teneeto bea71c4
Update src/pages/iou/request/step/IOURequestStepTaxRatePage.js
teneeto 70fe7a1
it should be calculateTaxAmount
teneeto 679193c
define policyTaxRates
teneeto 2d6f3a6
Merge branch 'feat/31672/add-new-input-fields-for-tax-tracking' of gi…
teneeto b07509d
fix lint
teneeto 80a876a
Merge branch 'main' of github.com:teneeto/App into feat/31672/add-new…
teneeto 3135939
fix review comments
teneeto e7f0f16
fix test
teneeto 4dadd3b
calculate default tax on amount request
teneeto bd78b48
Merge branch 'main' of github.com:teneeto/App into feat/31672/add-new…
teneeto 29c3c64
calculate tax amount on request page if only isTaxTrackingEnabled is …
teneeto 33def32
Merge branch 'main' of github.com:teneeto/App into feat/31672/add-new…
teneeto 3b30476
fix app crash on request money
teneeto 6ac4eb9
Update src/components/MoneyRequestConfirmationList.js
teneeto 7a1345b
fix typo
teneeto e64a73e
fix typo
teneeto 0d69fac
fix prop types
teneeto 40cd5a3
use default tax amount to check invalidTaxAmont
teneeto 21d6849
Merge branch 'main' of github.com:teneeto/App into feat/31672/add-new…
teneeto f1644e9
Merge branch 'main' of github.com:teneeto/App into feat/31672/add-new…
teneeto 844fdd4
Merge branch 'main' of github.com:teneeto/App into feat/31672/add-new…
teneeto 70f3b99
Merge branch 'main' of github.com:teneeto/App into feat/31672/add-new…
teneeto 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 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 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 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 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 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 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 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,89 @@ | ||
import lodashGet from 'lodash/get'; | ||
import React, {useMemo, useState} from 'react'; | ||
import _ from 'underscore'; | ||
import OptionsSelector from '@components/OptionsSelector'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useStyleUtils from '@hooks/useStyleUtils'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import * as OptionsListUtils from '@libs/OptionsListUtils'; | ||
import CONST from '@src/CONST'; | ||
import {defaultProps, propTypes} from './taxPickerPropTypes'; | ||
|
||
function TaxPicker({selectedTaxRate, policyTaxRates, insets, onSubmit}) { | ||
const styles = useThemeStyles(); | ||
const StyleUtils = useStyleUtils(); | ||
const {translate} = useLocalize(); | ||
const [searchValue, setSearchValue] = useState(''); | ||
|
||
const policyTaxRatesCount = OptionsListUtils.getEnabledTaxRateCount(policyTaxRates.taxes); | ||
const isTaxRatesCountBelowThreshold = policyTaxRatesCount < CONST.TAX_RATES_LIST_THRESHOLD; | ||
|
||
const shouldShowTextInput = !isTaxRatesCountBelowThreshold; | ||
|
||
const selectedOptions = useMemo(() => { | ||
if (!selectedTaxRate) { | ||
return []; | ||
} | ||
|
||
return [ | ||
{ | ||
name: selectedTaxRate, | ||
enabled: true, | ||
accountID: null, | ||
}, | ||
]; | ||
}, [selectedTaxRate]); | ||
|
||
const sections = useMemo(() => { | ||
const {policyTaxRatesOptions} = OptionsListUtils.getFilteredOptions( | ||
{}, | ||
{}, | ||
[], | ||
searchValue, | ||
selectedOptions, | ||
[], | ||
false, | ||
false, | ||
false, | ||
{}, | ||
[], | ||
false, | ||
{}, | ||
[], | ||
false, | ||
false, | ||
true, | ||
policyTaxRates, | ||
); | ||
return policyTaxRatesOptions; | ||
}, [policyTaxRates, searchValue, selectedOptions]); | ||
|
||
const selectedOptionKey = lodashGet(_.filter(lodashGet(sections, '[0].data', []), (taxRate) => taxRate.searchText === selectedTaxRate)[0], 'keyForList'); | ||
|
||
return ( | ||
<OptionsSelector | ||
contentContainerStyles={[{paddingBottom: StyleUtils.getSafeAreaMargins(insets).marginBottom}]} | ||
optionHoveredStyle={styles.hoveredComponentBG} | ||
sectionHeaderStyle={styles.mt5} | ||
sections={sections} | ||
selectedOptions={selectedOptions} | ||
value={searchValue} | ||
// Focus the first option when searching | ||
focusedIndex={0} | ||
initiallyFocusedOptionKey={selectedOptionKey} | ||
textInputLabel={translate('common.search')} | ||
boldStyle | ||
highlightSelectedOptions | ||
isRowMultilineSupported | ||
shouldShowTextInput={shouldShowTextInput} | ||
onChangeText={setSearchValue} | ||
onSelectRow={onSubmit} | ||
/> | ||
); | ||
} | ||
|
||
TaxPicker.displayName = 'TaxPicker'; | ||
TaxPicker.propTypes = propTypes; | ||
TaxPicker.defaultProps = defaultProps; | ||
|
||
export default TaxPicker; |
This file contains 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,21 @@ | ||
import PropTypes from 'prop-types'; | ||
import taxPropTypes from '@components/taxPropTypes'; | ||
|
||
const propTypes = { | ||
/** The selected tax rate of an expense */ | ||
selectedTaxRate: PropTypes.string, | ||
|
||
/** Callback to fire when a tax is pressed */ | ||
onSubmit: PropTypes.func.isRequired, | ||
|
||
/* Onyx Props */ | ||
/** Collection of tax rates attached to a policy */ | ||
policyTaxRates: taxPropTypes, | ||
}; | ||
|
||
const defaultProps = { | ||
selectedTaxRate: '', | ||
policyTaxRates: {}, | ||
}; | ||
|
||
export {propTypes, defaultProps}; |
Oops, something went wrong.
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.
NAB, this seems unused and can be removed in a follow up PR as it is unrelated to this change
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.
O will see to it.