Skip to content

[Feature] Bulk Transaction Import via CSV and JSON with Validation Engine #578#609

Merged
Renu-code123 merged 1 commit intoRenu-code123:mainfrom
rishabh0510rishabh:Bulk-Transaction-Import
Feb 10, 2026
Merged

[Feature] Bulk Transaction Import via CSV and JSON with Validation Engine #578#609
Renu-code123 merged 1 commit intoRenu-code123:mainfrom
rishabh0510rishabh:Bulk-Transaction-Import

Conversation

@rishabh0510rishabh
Copy link
Contributor

Description

This PR implements the Bulk Import feature, allowing users to upload CSV and JSON files to add multiple transactions at once. This solves the user pain point of manual data entry and facilitates migration from other platforms.

Key Changes

  • Backend:
    • Created controllers/importController.js logic to parse CSV (using exceljs streams) and JSON files from memory buffer.
    • Updated routes/expenses.js to expose the POST /api/expenses/import endpoint.
    • Fix: Added missing validateFile method to services/fileUploadService.js to ensure the shared upload middleware functions correctly and supports CSV/JSON types.
  • Frontend:
    • Added public/js/import-modal.js to handle file selection, client-side validation, and upload via API.
    • Updated public/transactions.html to include the "Import" button and the import modal structure.

Features

  • CSV & JSON Support: Parse standard transaction fields (date, description, amount, category, type, merchant).
  • Duplicate Detection: Intelligent check to prevent re-importing identical transactions (same user, amount, description, type, and date match within 1 minute).
  • Validation: Robust server-side validation using Joi to ensure data integrity.
  • Feedback: Detailed success/error reporting, including count of imported vs. skipped (duplicate) records.

Verification

  • Verified using test_data.csv and test_data.json.
  • Tested duplicate handling by re-uploading the same file.
  • Tested invalid file types and large files (>10MB).

Breaking Changes

  • None. (Fixed a pre-existing issue in fileUploadService.js where validateFile was missing).

Related Issue: #578

Label: ECWoC26

Add server- and client-side support for importing transactions from CSV or JSON files.

- New controllers/importController.js: parses CSV (via exceljs) and JSON uploads, normalizes fields, validates each record with Joi, checks for duplicates (±60s window), and creates Transaction records. Returns import stats and errors. Supports common amount/date formats and falls back to user's preferred currency.
- New public/js/import-modal.js and transactions.html updates: add an Import button, modal UI, client-side validation/preview, and upload flow that posts to /api/expenses/import. Shows success/error messages and triggers a transactions refresh.
- routes/expenses.js: register POST /import route using existing upload middleware and requireAuth.
- services/fileUploadService.js: add validateFile(file) to enforce allowed mimetypes and 10MB size limit; minor whitespace cleanup.
- Add sample test_data.csv and test_data.json templates for testing/import templates.

Notes: accepts .csv and .json, enforces file size/type limits, and reports skipped duplicates and validation errors in the response.
@github-actions
Copy link

github-actions bot commented Feb 9, 2026

🎉 Thanks for the PR, @rishabh0510rishabh!

We really appreciate you taking the time to contribute to ExpenseFlow! 💙


⭐ Love this project?

Please give us a star! It helps the project grow and reach more developers! 🌟

🔗 https://github.com/Renu-code123/ExpenseFlow


✅ PR Checklist

Before we review, please ensure:

  • Your code follows the project's coding standards
  • All file changes are accurate and intentional
  • You've tested your changes locally
  • Any review comments have been addressed

🙌 Thank You for Contributing!

We truly appreciate your interest in contributing to this project.

  • Please make sure your code follows the project structure
  • Add clear commit messages and comments where necessary
  • Ensure your changes do not break existing functionality

We'll review your PR as soon as possible. Keep up the great work! ✨


@vercel
Copy link

vercel bot commented Feb 9, 2026

@rishabh0510rishabh is attempting to deploy a commit to the Renu's projects Team on Vercel.

A member of the Team first needs to authorize it.

3 similar comments
@vercel
Copy link

vercel bot commented Feb 9, 2026

@rishabh0510rishabh is attempting to deploy a commit to the Renu's projects Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link

vercel bot commented Feb 9, 2026

@rishabh0510rishabh is attempting to deploy a commit to the Renu's projects Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link

vercel bot commented Feb 9, 2026

@rishabh0510rishabh is attempting to deploy a commit to the Renu's projects Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link

vercel bot commented Feb 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
expenseflow Ready Ready Preview, Comment Feb 10, 2026 0:51am

@Renu-code123 Renu-code123 merged commit bcfac96 into Renu-code123:main Feb 10, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants