|
| 1 | +# Cash Counter |
| 2 | + |
| 3 | +A minimal offline Electron app to count U.S. currency with printing and PDF export. |
| 4 | + |
| 5 | +- Cross-platform (Windows, macOS, Linux). Initial release focuses on Windows MSI. |
| 6 | +- Offline only. No persistence. Clean, calculator-like UI. |
| 7 | + |
| 8 | +## Features |
| 9 | + |
| 10 | +- **Minimal, Calculator-like UI:** Clean, responsive interface for quick cash counting. |
| 11 | +- **Supports All U.S. Denominations:** Inputs for bills ($100, $50, $20, $10, $5, $2, $1) and coins (50¢, 25¢, 10¢, 5¢, 1¢). |
| 12 | +- **Live Validation:** Only whole, non-negative integers are accepted for counts. Invalid input is highlighted. |
| 13 | +- **Real-time Calculation:** Subtotals and grand total update as you type. |
| 14 | +- **Print and PDF Export:** Print the report or export it as a PDF, including a timestamp and optional description. |
| 15 | +- **Keyboard Shortcuts:** |
| 16 | + - Ctrl+P: Print |
| 17 | + - Ctrl+E: Export PDF |
| 18 | + - Ctrl+C: Calculate (if a button is present) |
| 19 | +- **Reset and Exit:** Quickly clear all fields or exit the app. |
| 20 | +- **No Data Persistence:** All data is cleared on exit; nothing is stored on disk. |
| 21 | +- **Cross-platform:** Works on Windows, macOS, and Linux (Windows MSI build supported). |
| 22 | + |
| 23 | +## How it Works |
| 24 | + |
| 25 | +- **Main Process (`src/main.js`):** |
| 26 | + - Sets up the Electron window and application menu. |
| 27 | + - Handles print, export, reset, and exit actions via IPC and menu. |
| 28 | + - Uses Electron's `printToPDF` and system dialogs for export/print. |
| 29 | + |
| 30 | +- **Preload Script (`src/preload.js`):** |
| 31 | + - Exposes safe APIs (`print`, `exportPdf`, `exit`, `onReset`) to the renderer via `contextBridge`. |
| 32 | + |
| 33 | +- **Calculation Library (`src/lib/calc.js`):** |
| 34 | + - Defines denominations and their values in cents. |
| 35 | + - Provides functions for validation, subtotal, and grand total calculation. |
| 36 | + - Ensures all math is done in integer cents to avoid floating-point errors. |
| 37 | + |
| 38 | +- **Renderer (`src/renderer/renderer.js`):** |
| 39 | + - Dynamically builds the input grid for all denominations. |
| 40 | + - Handles user input, validation, and live subtotal/grand total updates. |
| 41 | + - Manages print/export/reset/exit actions and keyboard shortcuts. |
| 42 | + - Populates a print-optimized report for printing/PDF export. |
| 43 | + |
| 44 | +- **UI (`src/renderer/index.html`, `styles.css`):** |
| 45 | + - Modern, accessible layout with print-optimized styles. |
| 46 | + - Print and export include a timestamp and optional description. |
| 47 | + |
| 48 | +## Requirements Summary (from `docs/prd.md`) |
| 49 | +- Inputs for bills: $100, $50, $20, $10, $5, $2, $1 |
| 50 | +- Inputs for coins: 50¢, 25¢, 10¢, 5¢, 1¢ |
| 51 | +- Validate whole non-negative integers only |
| 52 | +- Calculate subtotals and grand total |
| 53 | +- Print and Export to PDF |
| 54 | +- Keyboard shortcuts: Ctrl+P (Print), Ctrl+E (Export), Ctrl+C (Calculate) |
| 55 | + |
| 56 | +## Project Structure |
| 57 | +``` |
| 58 | +. |
| 59 | +├── docs/ |
| 60 | +│ └── prd.md |
| 61 | +├── src/ |
| 62 | +│ ├── assets/ |
| 63 | +│ │ └── logo.svg |
| 64 | +│ ├── lib/ |
| 65 | +│ │ └── calc.js |
| 66 | +│ ├── main.js |
| 67 | +│ ├── preload.js |
| 68 | +│ └── renderer/ |
| 69 | +│ ├── index.html |
| 70 | +│ ├── renderer.js |
| 71 | +│ └── styles.css |
| 72 | +├── tests/ |
| 73 | +│ └── calc.test.js |
| 74 | +├── jest.config.cjs |
| 75 | +└── package.json |
| 76 | +``` |
| 77 | + |
| 78 | +## Getting Started |
| 79 | + |
| 80 | +1. Install dependencies |
| 81 | +```bash |
| 82 | +npm install |
| 83 | +``` |
| 84 | + |
| 85 | +2. Run the app in development |
| 86 | +```bash |
| 87 | +npm run dev |
| 88 | +``` |
| 89 | + |
| 90 | +3. Run unit tests |
| 91 | +```bash |
| 92 | +npm test |
| 93 | +``` |
| 94 | + |
| 95 | +4. Build Windows MSI (on Windows) |
| 96 | +```bash |
| 97 | +npm run build:win |
| 98 | +``` |
| 99 | +MSI will be output to `dist/`. |
| 100 | + |
| 101 | +## Notes |
| 102 | +- Calculations are done in integer cents to avoid floating-point errors (`src/lib/calc.js`). |
| 103 | +- The renderer loads the report table dynamically after calculation. |
| 104 | +- Printing uses the system print dialog; PDF export uses a save dialog and Electron `printToPDF`. |
| 105 | +- No data is stored on disk; app opens with blank fields every time. |
0 commit comments