Commit graph

12 commits

Author SHA1 Message Date
dlawler489
a36582b843 Fix Etsy fee categorization to include listing fees, ads, and other business expenses
Major improvements to expense categorization and profit calculations:

NEW: Granular Etsy Fee Parsing
- Parse individual Etsy fees with proper categorization:
  * Listing Fees (should be included in expenses)
  * Marketing & Advertising (Etsy Ads - should be included)
  * Transaction Fees (tied to orders - excluded to avoid double-counting)
  * Processing Fees (tied to orders - excluded to avoid double-counting)
  * Taxes & GST (should be included)
  * Shipping & Postage (should be included)

FIXED: Profit Calculation Logic
- Only exclude sale transaction fees that have order references
- Include all other Etsy business expenses (ads, listing fees, GST)
- More accurate profit margins that account for all business costs

ENHANCED: CSV Import
- Creates specific expense categories instead of lumping as 'Transaction Fees'
- Better duplicate detection based on description, amount, date, and category
- Improved user feedback showing specific fee types created

This fixes the issue where listing fees and advertising costs were incorrectly excluded from profit calculations, resulting in unrealistically high profit margins.
2026-05-05 18:32:23 +10:00
dlawler489
99068d6710 Fix Australia Post CSV duplicate imports with comprehensive duplicate prevention
Multi-layer duplicate prevention system:
- Enhanced frontend duplicate detection with tracking number, amount, and date comparison
- Added MongoDB compound index to prevent database-level duplicates
- Improved backend error handling for duplicate key violations
- Added cleanup endpoint to remove existing duplicates
- Enhanced user feedback for import operations

Frontend changes:
- Stricter duplicate detection comparing tracking number, vendor, amount, and date
- Better error handling and user feedback for duplicate scenarios
- Added 'Clean Duplicates' button to remove existing duplicates

Backend changes:
- Database compound index on reference, vendor, userId, amount, date
- Enhanced error responses with duplicate detection flags
- New POST /expenses/cleanup-duplicates endpoint
- Improved duplicate key error handling

This should eliminate the double Australia Post expense entries.
2026-05-05 13:40:28 +10:00
dlawler489
761fce047a Fix profit analysis calculations to include shipping expenses and other costs
- Updated ProfitAnalysisService to accept and integrate expense data
- Modified calculateProfitMetrics to include expenses in profit calculations
- Added totalExpenses field to ProfitMetrics interface
- Updated ProfitAnalysis component to pass filtered expenses to calculations
- Enhanced UI to show breakdown of expenses vs printing costs
- Fixed inconsistency between Analytics and ProfitAnalysis profit calculations
- Now shipping expenses and Etsy fees are properly deducted from profits
- Excluded transaction fees to avoid double-counting
2026-05-05 13:21:00 +10:00
dlawler489
22799cb732 Integrate Data Import with Expenses tab
 FIXES MAJOR WORKFLOW ISSUE:
- Data Import CSV processing now automatically creates expenses
- Etsy fees → 'Transaction Fees' category expenses
- Australia Post shipping → 'Shipping & Postage' expenses
- Prevents duplicate expense creation with reference checking
- Added user notices in both Data Import and Expenses tabs

🔄 INTEGRATION FEATURES:
- Automatic expense creation from CSV order costs
- Duplicate prevention by order number/tracking number
- Proper categorization and tax-deductible flagging
- Clear user notifications and workflow guidance

📊 USER EXPERIENCE:
- Expenses tab now shows integration notice
- Data Import shows automatic expense creation info
- Seamless workflow between sales data and expense tracking
2026-05-05 12:29:07 +10:00
dlawler489
f39d4ca266 Fix modal persistence issue
- Add duplicate prevention with isProcessing state
- Implement loading spinner and disabled states
- Enhance modal closure logic in DataImport.tsx
- Add proper state reset on modal close
- Prevent multiple button clicks during processing
- Improve user feedback with console logging
2026-05-01 15:31:26 +10:00
dlawler489
461e424e5e Fix product matching for Modern Minimalist Shelf Decor variants
Enhanced product matching algorithm to properly handle:
- Large vs Small size variants for shelf decor products
- Improved size extraction from product titles
- Higher confidence thresholds for shelf decor products to prevent wrong matches
- Better handling of 3D-Printed product variations
- Enhanced logging for debugging matching issues

This fixes the issue where packing slips would create duplicate products
instead of matching to existing Large/Small variants of the same product.
2026-05-01 15:02:46 +10:00
dlawler489
ec1d204c36 Add comprehensive CSV product import system with templates and enhanced UI
Features Added:
- Enhanced CSV import service with smart parsing for product data
- Two CSV templates: simple and complete with example data
- Advanced product import UI with template downloads
- Comprehensive CSV import documentation and guide
- Support for all product fields including costs, dimensions, materials
- Error handling and validation for bulk imports
- Integration with profit analysis system for accurate cost tracking

UI Improvements:
- Template download buttons (Simple Template, Full Template)
- Enhanced import workflow with progress feedback
- Better error messaging and validation
- Updated Products page with CSV functionality

Documentation:
- Complete CSV_IMPORT_GUIDE.md with examples and best practices
- Updated DEPLOYMENT_STATUS.md reflecting production readiness
- Enhanced README.md with current feature status
- CHANGELOG.md with comprehensive development history

Production Ready:
- All functionality tested and integrated with existing profit analysis
- Bulk import capability for efficient product catalog setup
- Supports accurate cost tracking for comprehensive profit margins
2026-05-01 13:26:33 +10:00
dlawler489
1bc7daf33a Remove Vite template dark-mode styles from index.css
The default :root styles (dark background, white text, centered #root)
were overriding Tailwind and making all pages appear blank/dark.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 20:02:07 +10:00
dlawler489
a820ed4729 Fix unused import TypeScript errors in DataImport and Orders
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 11:50:34 +10:00
dlawler489
1a3bd33be8 Migrate frontend from localStorage to MongoDB API
- Remove localStorage from all 4 Redux slices (products, orders, expenses, customers)
- Layout fetches all data from API on mount; adds logout button with active nav highlighting
- Wire API calls in Products, Orders, Expenses pages for all CRUD operations
- DataImport uses POST /orders/bulk for CSV upserts and API for PDF slip orders
- MissingProductsModal creates products via API
- Relax Order model: optional customerId, embedded customer, fees, printingCost on items, default paymentStatus=paid
- Relax Expense model: free-string category, add taxDeductible/vendor/reference fields
- Add printingCost to Product model
- Add POST /orders/bulk endpoint for upsert-by-orderNumber
- Raise rate limit to 1000 req/15min for bulk imports

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 08:48:05 +10:00
dlawler489
0d42d97d70 Add JWT auth with protected routes and per-user data isolation
Frontend:
- Login and Register pages wired up to API
- PrivateRoute redirects unauthenticated users to /login
- Token persisted in localStorage, restored on page load
- Axios instance automatically attaches Bearer token, redirects on 401

Backend:
- userId field added to all models (Product, Order, Customer, Expense)
- All queries scoped to authenticated user's userId
- Register/login return JWT token

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 08:16:51 +10:00
dlawler489
9e1a098a70 Initial commit: Complete Etsy Business Tracker with Profit Analysis Dashboard
Features:
- React + TypeScript frontend with Tailwind CSS
- Node.js + Express backend with TypeScript
- Comprehensive order tracking and management
- Product catalog with inventory tracking
- Customer data management
- Expense tracking and categorization
- Advanced Profit Analysis Dashboard with:
  - Real-time profit metrics and KPI visualization
  - Detailed order-level profit breakdown
  - Product performance analysis
  - Enhanced time range filtering (monthly, quarterly, yearly)
  - Interactive expandable order analysis
  - Performance categorization and color coding
- CSV import functionality for Etsy statements
- PDF parsing capabilities
- Redux state management with persistence
- Responsive design with mobile support
- Australian date formatting and currency display
2026-04-20 09:44:54 +10:00