[PR #6019] Enables category creation during import #6272

Open
opened 2026-02-28 21:26:02 -06:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/actualbudget/actual/pull/6019

State: open
Merged: No


Adds the ability to create new categories directly from the import transactions modal.

Introduces an "Import Categories" modal that allows users to map imported categories to existing ones or create new categories with specified groups. This streamlines the import process by handling unknown categories on the fly.

Adds unit tests for the import transactions field mapping utility function.

The field mapping tests verify the correct mapping of transaction fields, including category detection based on user-defined mappings. It ensures the category values are properly mapped even with different column names, missing fields, or null mappings.

AI Disclaimer

This PR was created with assistance from Claude. All feedback welcome.

Copilot Summary

This pull request adds support for importing transactions with new categories that do not yet exist in the system. It introduces a workflow allowing users to map imported categories to existing ones or create new categories and groups as needed during the import process. The changes span new modal components, transaction import logic, and UI enhancements for clarity.

Category Import & Creation Workflow:

  • Added a new modal component ImportCategoriesModal that lets users map imported categories to existing ones or create new categories/groups during transaction import.
  • Integrated the new modal into the transaction import flow: when importing transactions, if new categories are detected, the modal prompts the user for mappings or creation before proceeding. [1] [2] [3]
  • Added a checkbox option to the import dialog UI to enable or disable automatic category creation from import. [1] [2]

Transaction Import Logic:

  • Implemented logic to detect new categories in imported transactions and collect them for user mapping/creation.
  • Modified the import process to assign the correct category IDs to transactions, using mappings from the modal or creating new categories as needed.

UI Enhancements:

  • Updated transaction preview rendering to clearly indicate when a transaction's category does not exist yet, displaying it as "(new)" in italics and subdued color. [1] [2]

Codebase Maintenance:

  • Updated imports and type references to support the new modal and category mapping logic. [1] [2]

Screenshots

Using the following test csv in the test budget to make the following screenshots:
test-import-categories.csv

Import Transactions Modal has a new "Create Categories" checkbox. Leaving unchecked will maintain current behavior, leaving unknown categories uncategorized.
Screenshot from 2025-10-28 09-33-06
By default, all categories will be created under the first group, which can be changed using the dropdown, or a new category group created as well.
Screenshot from 2025-10-28 09-33-23
Entering the new category group name uses the existing modal.
Screenshot from 2025-10-28 09-33-33
If an existing category is selected, the existing group is displayed and is unchangeable.
Screenshot from 2025-10-28 09-34-06
Once categories are created, transactions are categorized appropriately and categories can be reorganized as usual.
Screenshot from 2025-10-28 09-34-34


Bundle Stats

Bundle Files count Total bundle size % Changed
desktop-client 28 14.4 MB → 14.42 MB (+18.67 kB) +0.13%
loot-core 1 5.83 MB 0%
api 1 4.37 MB 0%
View detailed bundle stats

desktop-client

Total

Files count Total bundle size % Changed
28 14.4 MB → 14.42 MB (+18.67 kB) +0.13%
Changeset
File Δ Size
src/components/modals/ImportCategoriesModal.tsx 🆕 +13.2 kB 0 B → 13.2 kB
src/components/modals/ImportTransactionsModal/ImportTransactionsModal.tsx 📈 +5.04 kB (+17.79%) 28.33 kB → 33.38 kB
src/components/modals/ImportTransactionsModal/Transaction.tsx 📈 +275 B (+2.18%) 12.33 kB → 12.6 kB
src/components/Modals.tsx 📈 +158 B (+1.11%) 13.95 kB → 14.1 kB
src/hooks/useFailedAccounts.ts 📈 +2 B (+0.55%) 365 B → 367 B
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger

Asset File Size % Changed
static/js/index.js 9.24 MB → 9.25 MB (+18.67 kB) +0.20%

Smaller
No assets were smaller

Unchanged

Asset File Size % Changed
static/js/indexeddb-main-thread-worker-e59fee74.js 12.94 kB 0%
static/js/workbox-window.prod.es5.js 5.64 kB 0%
static/js/da.js 107.03 kB 0%
static/js/de.js 172.31 kB 0%
static/js/en-GB.js 7.24 kB 0%
static/js/en.js 159.21 kB 0%
static/js/es.js 173.04 kB 0%
static/js/fr.js 178.56 kB 0%
static/js/it.js 173.46 kB 0%
static/js/nb-NO.js 158.85 kB 0%
static/js/nl.js 103.57 kB 0%
static/js/pl.js 88.78 kB 0%
static/js/pt-BR.js 147.31 kB 0%
static/js/ru.js 108.05 kB 0%
static/js/sv.js 78.42 kB 0%
static/js/th.js 182.7 kB 0%
static/js/uk.js 217.6 kB 0%
static/js/resize-observer.js 18.37 kB 0%
static/js/BackgroundImage.js 120.54 kB 0%
static/js/ReportRouter.js 1.05 MB 0%
static/js/narrow.js 640.93 kB 0%
static/js/TransactionList.js 101.58 kB 0%
static/js/wide.js 159.96 kB 0%
static/js/AppliedFilters.js 9.71 kB 0%
static/js/usePayeeRuleCounts.js 11.79 kB 0%
static/js/useTransactionBatchActions.js 13.23 kB 0%
static/js/FormulaEditor.js 1.04 MB 0%

loot-core

Total

Files count Total bundle size % Changed
1 5.83 MB 0%
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger
No assets were bigger

Smaller
No assets were smaller

Unchanged

Asset File Size % Changed
kcab.worker.B3_-Z7dv.js 5.83 MB 0%

api

Total

Files count Total bundle size % Changed
1 4.37 MB 0%
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger
No assets were bigger

Smaller
No assets were smaller

Unchanged

Asset File Size % Changed
bundle.api.js 4.37 MB 0%
**Original Pull Request:** https://github.com/actualbudget/actual/pull/6019 **State:** open **Merged:** No --- Adds the ability to create new categories directly from the import transactions modal. Introduces an "Import Categories" modal that allows users to map imported categories to existing ones or create new categories with specified groups. This streamlines the import process by handling unknown categories on the fly. Adds unit tests for the import transactions field mapping utility function. The field mapping tests verify the correct mapping of transaction fields, including category detection based on user-defined mappings. It ensures the category values are properly mapped even with different column names, missing fields, or null mappings. ### AI Disclaimer This PR was created with assistance from Claude. All feedback welcome. ## Copilot Summary This pull request adds support for importing transactions with new categories that do not yet exist in the system. It introduces a workflow allowing users to map imported categories to existing ones or create new categories and groups as needed during the import process. The changes span new modal components, transaction import logic, and UI enhancements for clarity. **Category Import & Creation Workflow:** * Added a new modal component `ImportCategoriesModal` that lets users map imported categories to existing ones or create new categories/groups during transaction import. * Integrated the new modal into the transaction import flow: when importing transactions, if new categories are detected, the modal prompts the user for mappings or creation before proceeding. [[1]](diffhunk://#diff-8d33c82f7d7a1c4f72e0e911132a409eb48134430400d9b409306a37bd13f407R41) [[2]](diffhunk://#diff-8d33c82f7d7a1c4f72e0e911132a409eb48134430400d9b409306a37bd13f407R123-R125) [[3]](diffhunk://#diff-8e5b688cd46976e291e6b960ad3bdce1b28cc399714079c4d290b0515a228dd1R608-R693) * Added a checkbox option to the import dialog UI to enable or disable automatic category creation from import. [[1]](diffhunk://#diff-8e5b688cd46976e291e6b960ad3bdce1b28cc399714079c4d290b0515a228dd1R228) [[2]](diffhunk://#diff-8e5b688cd46976e291e6b960ad3bdce1b28cc399714079c4d290b0515a228dd1R1230-R1242) **Transaction Import Logic:** * Implemented logic to detect new categories in imported transactions and collect them for user mapping/creation. * Modified the import process to assign the correct category IDs to transactions, using mappings from the modal or creating new categories as needed. **UI Enhancements:** * Updated transaction preview rendering to clearly indicate when a transaction's category does not exist yet, displaying it as "(new)" in italics and subdued color. [[1]](diffhunk://#diff-a4b0d08037b4abecdc39a5276e03100ef7ba6c26e7e3befc9f5e99efba498ca1L59) [[2]](diffhunk://#diff-a4b0d08037b4abecdc39a5276e03100ef7ba6c26e7e3befc9f5e99efba498ca1L219-R235) **Codebase Maintenance:** * Updated imports and type references to support the new modal and category mapping logic. [[1]](diffhunk://#diff-8e5b688cd46976e291e6b960ad3bdce1b28cc399714079c4d290b0515a228dd1R43-R59) [[2]](diffhunk://#diff-9c9bcd26f3899c20d43ed81a53a0acbd39ad5938a19d206f7a7ddd1ac633d4a5L1-R1) **Screenshots** Using the following test csv in the test budget to make the following screenshots: [test-import-categories.csv](https://github.com/user-attachments/files/23189187/test-import-categories.csv) Import Transactions Modal has a new "Create Categories" checkbox. Leaving unchecked will maintain current behavior, leaving unknown categories uncategorized. <img width="826" height="800" alt="Screenshot from 2025-10-28 09-33-06" src="https://github.com/user-attachments/assets/a2048305-86d2-4c8e-a4d0-0f1f3d39b603" /> By default, all categories will be created under the first group, which can be changed using the dropdown, or a new category group created as well. <img width="826" height="800" alt="Screenshot from 2025-10-28 09-33-23" src="https://github.com/user-attachments/assets/95a23d20-0f87-4eb0-a5a9-dd74941e9327" /> Entering the new category group name uses the existing modal. <img width="826" height="800" alt="Screenshot from 2025-10-28 09-33-33" src="https://github.com/user-attachments/assets/0c22e3e8-7cb6-4f14-ab74-1eabfed866f9" /> If an existing category is selected, the existing group is displayed and is unchangeable. <img width="826" height="800" alt="Screenshot from 2025-10-28 09-34-06" src="https://github.com/user-attachments/assets/861193e8-ce62-41a2-a8b0-f8dc14317b8c" /> Once categories are created, transactions are categorized appropriately and categories can be reorganized as usual. <img width="826" height="800" alt="Screenshot from 2025-10-28 09-34-34" src="https://github.com/user-attachments/assets/7f6ad361-0ef8-4ff1-8e8f-2dd746ddb2aa" /> <!--- actual-bot-sections ---> <hr /> <!--- bundlestats-action-comment key:combined start ---> ### Bundle Stats Bundle | Files count | Total bundle size | % Changed ------ | ----------- | ----------------- | --------- desktop-client | 28 | 14.4 MB → 14.42 MB (+18.67 kB) | +0.13% loot-core | 1 | 5.83 MB | 0% api | 1 | 4.37 MB | 0% <details> <summary>View detailed bundle stats</summary> #### desktop-client **Total** Files count | Total bundle size | % Changed ----------- | ----------------- | --------- 28 | 14.4 MB → 14.42 MB (+18.67 kB) | +0.13% <details> <summary>Changeset</summary> File | Δ | Size ---- | - | ---- `src/components/modals/ImportCategoriesModal.tsx` | 🆕 +13.2 kB | 0 B → 13.2 kB `src/components/modals/ImportTransactionsModal/ImportTransactionsModal.tsx` | 📈 +5.04 kB (+17.79%) | 28.33 kB → 33.38 kB `src/components/modals/ImportTransactionsModal/Transaction.tsx` | 📈 +275 B (+2.18%) | 12.33 kB → 12.6 kB `src/components/Modals.tsx` | 📈 +158 B (+1.11%) | 13.95 kB → 14.1 kB `src/hooks/useFailedAccounts.ts` | 📈 +2 B (+0.55%) | 365 B → 367 B </details> <details> <summary>View detailed bundle breakdown</summary> <div> **Added** No assets were added **Removed** No assets were removed **Bigger** Asset | File Size | % Changed ----- | --------- | --------- static/js/index.js | 9.24 MB → 9.25 MB (+18.67 kB) | +0.20% **Smaller** No assets were smaller **Unchanged** Asset | File Size | % Changed ----- | --------- | --------- static/js/indexeddb-main-thread-worker-e59fee74.js | 12.94 kB | 0% static/js/workbox-window.prod.es5.js | 5.64 kB | 0% static/js/da.js | 107.03 kB | 0% static/js/de.js | 172.31 kB | 0% static/js/en-GB.js | 7.24 kB | 0% static/js/en.js | 159.21 kB | 0% static/js/es.js | 173.04 kB | 0% static/js/fr.js | 178.56 kB | 0% static/js/it.js | 173.46 kB | 0% static/js/nb-NO.js | 158.85 kB | 0% static/js/nl.js | 103.57 kB | 0% static/js/pl.js | 88.78 kB | 0% static/js/pt-BR.js | 147.31 kB | 0% static/js/ru.js | 108.05 kB | 0% static/js/sv.js | 78.42 kB | 0% static/js/th.js | 182.7 kB | 0% static/js/uk.js | 217.6 kB | 0% static/js/resize-observer.js | 18.37 kB | 0% static/js/BackgroundImage.js | 120.54 kB | 0% static/js/ReportRouter.js | 1.05 MB | 0% static/js/narrow.js | 640.93 kB | 0% static/js/TransactionList.js | 101.58 kB | 0% static/js/wide.js | 159.96 kB | 0% static/js/AppliedFilters.js | 9.71 kB | 0% static/js/usePayeeRuleCounts.js | 11.79 kB | 0% static/js/useTransactionBatchActions.js | 13.23 kB | 0% static/js/FormulaEditor.js | 1.04 MB | 0% </div> </details> --- #### loot-core **Total** Files count | Total bundle size | % Changed ----------- | ----------------- | --------- 1 | 5.83 MB | 0% <details> <summary>View detailed bundle breakdown</summary> <div> **Added** No assets were added **Removed** No assets were removed **Bigger** No assets were bigger **Smaller** No assets were smaller **Unchanged** Asset | File Size | % Changed ----- | --------- | --------- kcab.worker.B3_-Z7dv.js | 5.83 MB | 0% </div> </details> --- #### api **Total** Files count | Total bundle size | % Changed ----------- | ----------------- | --------- 1 | 4.37 MB | 0% <details> <summary>View detailed bundle breakdown</summary> <div> **Added** No assets were added **Removed** No assets were removed **Bigger** No assets were bigger **Smaller** No assets were smaller **Unchanged** Asset | File Size | % Changed ----- | --------- | --------- bundle.api.js | 4.37 MB | 0% </div> </details> </details> <!--- bundlestats-action-comment key:combined end --->
GiteaMirror added the pull-request label 2026-02-28 21:26:02 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/actual#6272