feat: CSV purchase import for Purchases with duplicate detection #217
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
nidde/parenting-tool!217
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "copilot/add-csv-import-for-purchases"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
Adds CSV import for the Purchases system from Swedish bank statement exports. Flow: upload CSV → preview parsed rows with duplicate detection → select category → select items → import as purchases.
Backend
CsvPurchaseImportService— parses semicolon-delimited Swedish bank CSV (Bokföringsdatum;Valutadatum;...), filters expenses (negative amounts), detects duplicates by(user_id, name, amount, date)usingwhereDate()for SQLite/MySQL compatPurchaseController:previewCsvPurchases(JSON preview via file upload) andimportCsvPurchases(Inertia redirect with category assignment)purchases.preview-csv,purchases.import-csvFrontend
CsvPurchaseImport.vueinComponents/Purchases/— multi-step dialog (upload → preview → select category → select items → import → done) with select-all, duplicate chips, running total, and category selectorFinance/Purchases/Index.vue)CsvPurchasePreviewRow,CsvImportPreviewResponseEdge cases: UTF-8 BOM, Windows line endings, income rows filtered, unparseable lines reported as errors, category ownership validation.
Type of Change
Testing
17 unit tests (
CsvPurchaseImportServiceTest): parsing, duplicate detection, import, category assignment, BOM/CRLF handling. 9 feature tests (CsvPurchaseImportTest): upload, preview, import, validation, category ownership. All 26 CSV import tests pass (63 assertions).Code Quality
CI/CD Checks
Additional Notes
Preview endpoint returns JSON (via
axios.post) since it's a data-fetch operation. Import endpoint uses Inertiarouter.postfor the redirect. File upload limited to 2MB,.csv/.txtextensions. Imported purchases require a category selection — the user picks whichPurchaseCategoryto assign during the import flow.@copilot
No no, you're still getting it wrong!
These have nothing to do with Credit Cards or Credit Card Purchases. They are plain and simple Purchases. There's a whole section for those, with categories and quick purchase buttons and everything.
Please try again.
You're right — the CSV import was incorrectly targeting
CreditCardPurchaseinstead of the standalonePurchasesystem. Inf7d75b0, I've completely moved the feature:CsvPurchaseImportServicenow usesPurchasemodel +User(notCreditCardPurchase+Credit)CreditControllertoPurchaseControllerwith routespurchases.preview-csvandpurchases.import-csvCsvPurchaseImport.vuemoved toComponents/Purchases/with a category selector so imports get assigned to a purchase categoryFinance/Purchases/Index.vue), not the Credit pagePurchasemodel (26 tests pass)LG2M 👍
Comment
@coderabbitai helpto get the list of available commands and usage tips.