Repository navigation
#47927: Export Categories CSV #48687
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
mountiny
merged 6 commits into
Expensify:main
from
software-mansion-labs:Guccio163/47927-ExportCSV
Sep 9, 2024
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9e76b69
Categories export done
Guccio163 b35465e
swm review fixes
Guccio163 4f695c6
add solve for imports from #48623
Guccio163 0b87e4f
downloading on Android solved
Guccio163 9edd3cb
Merge branch 'main' of github.com:software-mansion-labs/expensify-app…
Guccio163 dc9cd2d
Merge branch 'main' of github.com:software-mansion-labs/expensify-app…
Guccio163 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| type ExportCategoriesSpreadsheetParams = { | ||
| /** ID of the policy */ | ||
| policyID: string; | ||
| }; | ||
|
|
||
| export default ExportCategoriesSpreadsheetParams; |
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 |
|---|---|---|
|
|
@@ -17,11 +17,14 @@ import type { | |
| UpdatePolicyCategoryGLCodeParams, | ||
| } from '@libs/API/parameters'; | ||
| import {READ_COMMANDS, WRITE_COMMANDS} from '@libs/API/types'; | ||
| import * as ApiUtils from '@libs/ApiUtils'; | ||
| import * as CurrencyUtils from '@libs/CurrencyUtils'; | ||
| import * as ErrorUtils from '@libs/ErrorUtils'; | ||
| import fileDownload from '@libs/fileDownload'; | ||
| import getIsNarrowLayout from '@libs/getIsNarrowLayout'; | ||
| import {translateLocal} from '@libs/Localize'; | ||
| import Log from '@libs/Log'; | ||
| import enhanceParameters from '@libs/Network/enhanceParameters'; | ||
| import * as OptionsListUtils from '@libs/OptionsListUtils'; | ||
| import {navigateWhenEnableFeature, removePendingFieldsFromCustomUnit} from '@libs/PolicyUtils'; | ||
| import * as ReportUtils from '@libs/ReportUtils'; | ||
|
|
@@ -512,7 +515,7 @@ function importPolicyCategories(policyID: string, categories: PolicyCategory[]) | |
| categories: JSON.stringify([...categories.map((category) => ({name: category.name, enabled: category.enabled, 'GL Code': String(category['GL Code'])}))]), | ||
| }; | ||
|
|
||
| API.write(WRITE_COMMANDS.IMPORT_CATEGORIES_SREADSHEET, parameters, onyxData); | ||
| API.write(WRITE_COMMANDS.IMPORT_CATEGORIES_SPREADSHEET, parameters, onyxData); | ||
| } | ||
|
|
||
| function renamePolicyCategory(policyID: string, policyCategory: {oldName: string; newName: string}) { | ||
|
|
@@ -998,6 +1001,19 @@ function setPolicyDistanceRatesDefaultCategory(policyID: string, currentCustomUn | |
| API.write(WRITE_COMMANDS.SET_POLICY_DISTANCE_RATES_DEFAULT_CATEGORY, params, {optimisticData, successData, failureData}); | ||
| } | ||
|
|
||
| function downloadCategoriesCSV(policyID: string) { | ||
| const finalParameters = enhanceParameters(WRITE_COMMANDS.EXPORT_CATEGORIES_CSV, { | ||
| policyID, | ||
| }); | ||
|
|
||
| const formData = new FormData(); | ||
| Object.entries(finalParameters).forEach(([key, value]) => { | ||
| formData.append(key, String(value)); | ||
| }); | ||
|
|
||
| fileDownload(ApiUtils.getCommandURL({command: WRITE_COMMANDS.EXPORT_CATEGORIES_CSV}), 'Categories.csv', '', false, formData, CONST.NETWORK.METHOD.POST); | ||
|
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. Can you make the
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. Sure, I'll try to remember to add it in |
||
| } | ||
|
|
||
| function setWorkspaceCategoryDescriptionHint(policyID: string, categoryName: string, commentHint: string) { | ||
| const originalCommentHint = allPolicyCategories?.[`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`]?.[categoryName]?.commentHint; | ||
|
|
||
|
|
@@ -1311,4 +1327,5 @@ export { | |
| setPolicyCategoryApprover, | ||
| setPolicyCategoryTax, | ||
| importPolicyCategories, | ||
| downloadCategoriesCSV, | ||
| }; | ||
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.