-
Notifications
You must be signed in to change notification settings - Fork 4k
Add mappable Unique ID field to company card CSV import #99201
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
Changes from all commits
ef3d90b
e771bca
0babab4
8e0d91a
c879d69
4229d45
8c52dd9
a0bafda
9235f97
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -109,8 +109,14 @@ function buildOptimisticCompanyCardCSVTransactions( | |
| const normalizedColumnMappings = [...columnMappings]; | ||
| const csvDataWithGeneratedIDs = csvData.map((row) => [...row]); | ||
|
|
||
| normalizedColumnMappings.push(CONST.CSV_IMPORT_COLUMNS.EXTERNAL_ID); | ||
| const externalIDColumnIndex = normalizedColumnMappings.length - 1; | ||
| // The backend dedupes rows by their `externalID`, so a mapped Unique ID column makes re-uploading | ||
| // the same file idempotent. Without one, every row gets a fresh generated ID and always imports. | ||
| const mappedExternalIDColumnIndex = getColumnIndex(normalizedColumnMappings, CONST.CSV_IMPORT_COLUMNS.EXTERNAL_ID); | ||
| const isExternalIDColumnMapped = mappedExternalIDColumnIndex >= 0; | ||
| if (!isExternalIDColumnMapped) { | ||
| normalizedColumnMappings.push(CONST.CSV_IMPORT_COLUMNS.EXTERNAL_ID); | ||
| } | ||
| const externalIDColumnIndex = isExternalIDColumnMapped ? mappedExternalIDColumnIndex : normalizedColumnMappings.length - 1; | ||
|
|
||
| const cardNumberColumnIndex = getColumnIndex(normalizedColumnMappings, CONST.CSV_IMPORT_COLUMNS.CARD_NUMBER); | ||
| const postedDateColumnIndex = getColumnIndex(normalizedColumnMappings, CONST.CSV_IMPORT_COLUMNS.POSTED_DATE); | ||
|
|
@@ -125,7 +131,11 @@ function buildOptimisticCompanyCardCSVTransactions( | |
| const transactions: OptimisticCompanyCardCSVTransaction[] = []; | ||
| for (const row of csvDataWithGeneratedIDs) { | ||
| const transactionID = rand64(); | ||
| row[externalIDColumnIndex] = transactionID; | ||
|
|
||
| // Fills the synthetic column, and any row whose mapped Unique ID cell is blank. | ||
| if (!row.at(externalIDColumnIndex)?.trim()) { | ||
| row[externalIDColumnIndex] = transactionID; | ||
| } | ||
|
Comment on lines
+135
to
+138
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.
When mapped IDs already exist during an exact or overlapping re-import, preserving them here lets the backend skip those rows, but every valid input row is still added to Useful? React with 👍 / 👎.
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. Agreed that this is now inaccurate: before this PR dedup could never match, so every input row really was inserted and the count was right. With stable IDs a fully-deduped re-import will still report all rows as added. Not fixing it here, for two reasons:
Raised with the PR author to decide between softening the copy here or opening a follow-up for the backend count. 🤖 Posted by Claude (an AI agent) on behalf of the user. |
||
|
|
||
| const cardName = row.at(cardNumberColumnIndex)?.trim(); | ||
| const rawPostedDate = row.at(postedDateColumnIndex)?.trim(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.