Introduces a new database layer to persist CSV transaction data in MariaDB,
enabling both invoicing and sales reporting queries. This replaces the
previous file-to-file-only processing.
Changes:
- Add sqlx, tokio, toml, anyhow, bigdecimal dependencies to Cargo.toml
- Create config module for TOML-based configuration (database credentials)
- Create db module with connection pool, models, and repository
- Create commands module with 'import' subcommand for CSV ingestion
- Refactor main.rs to use subcommand architecture (import/generate)
- Add migration SQL file for manual database schema creation
Schema (3 tables):
- customers: customer_number, card_report_group (1=fleet, 3/4=retail)
- cards: card_number, card_type, customer_id (nullable for anonymous)
- transactions: full transaction data with FK to cards/customers
Usage:
cargo run -- import <csv-file> # Import to database
cargo run -- generate <csv> <dir> # Generate HTML invoices (unchanged)
Configuration:
cp config.example.toml config.toml # Edit with database credentials
mysql < migrations/001_initial_schema.sql # Create database first
Summary now shows:
- Product rows
- Avrundningsfel (rounding error)
- Totalt (rounded to nearest integer)
- Öresutjämning (difference from transactions to rounded total)
- Save original .txt file in the batch folder
- Save cleaned .csv file with just batch number as filename (no '-cleaned' suffix)
- Both files stored alongside the HTML and PDF outputs
- Read quoted tab-separated input with US date format (M/D/YYYY H:MM:SS AM/PM)
- Convert dates to ISO format (YYYY-MM-DD HH:MM:SS)
- Save cleaned version to .cleaned.csv alongside the HTML output
- Continue processing with existing workflow on cleaned file
- Generate both HTML and PDF versions of each customer invoice
- PDFs use printpdf with HTML rendering for consistent styling
- Same layout and formatting as HTML output
- Read CSV files from input/ directory
- Generate static HTML invoices grouped by customer and card
- Filter transactions to only include fleet customers
- Compact print-friendly layout with 2 decimal precision