Skip to content

Commit b27cf1f

Browse files
authored
Merge pull request #1 from ddjlabs/develop
Ready for release. Tested the solution
2 parents 17245be + 1efc002 commit b27cf1f

26 files changed

+8894
-1
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Release on PR to Main
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
types: [closed]
8+
9+
jobs:
10+
build-and-release:
11+
if: github.event.pull_request.merged == true
12+
runs-on: windows-latest
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: '20'
21+
22+
- name: Install dependencies
23+
run: npm install
24+
25+
- name: Run tests
26+
run: npm test
27+
28+
- name: Build Windows MSI
29+
run: npm run build:win
30+
31+
- name: Upload MSI artifact
32+
uses: actions/upload-artifact@v4
33+
with:
34+
name: cashcounter-msi
35+
path: dist/*.msi
36+
37+
- name: Create GitHub Release
38+
uses: softprops/action-gh-release@v2
39+
with:
40+
files: dist/*.msi
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# dependencies
2+
/node_modules
3+
4+
# builds
5+
/build
6+
7+
# development artifacts
8+
/.env
9+
/.env.local
10+
/.env.development.local
11+
/.env.test.local
12+
/.env.production.local
13+
14+
# log files
15+
/logs
16+
17+
# editor files
18+
/.vscode
19+
/.idea
20+
/.nvm
21+
/.npm
22+
/.yarn
23+
24+
# misc
25+
/.DS_Store
26+
/Thumbs.db
27+
28+
# electron-builder
29+
/dist

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2025 DDJ Labs
3+
Copyright (c) 2025 Doug Jenkins
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
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.

docs/prd.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# Cash Counting Application – Product Requirement Document
2+
3+
## Overview
4+
The Cash Counting Application is a desktop tool built with **Electron** to assist users in counting physical U.S. currency. It will run on **Windows, Mac, and Linux**, with the initial release focusing on **Windows MSI installer packaging**. The application provides a simple interface for inputting counts of bills and coins, calculates the total, and generates a printable/exportable report.
5+
6+
## Purpose
7+
This application helps users quickly total the value of physical U.S. currency, including both bills and coins. It ensures accuracy in manual cash counts and provides a formatted report for recordkeeping.
8+
9+
---
10+
11+
## Supported Currency Denominations
12+
- **Bills:** $100, $50, $20, $10, $5, $2, $1
13+
- **Coins:** $0.50, $0.25, $0.10, $0.05, $0.01
14+
15+
---
16+
17+
## Functional Requirements
18+
19+
### User Interface
20+
- Provide **text boxes** for each denomination.
21+
- Text boxes accept **only whole positive integers** (no decimals, negatives, or non-numeric input).
22+
- Pressing **Tab** moves focus to the next denomination field.
23+
- A **Calculate Total** button computes the total and displays:
24+
- Subtotal per denomination
25+
- Grand total
26+
27+
### Report Generation
28+
- A **Print Report** button generates a report with:
29+
- Tabular layout of denominations, quantity, subtotal
30+
- Grand total
31+
- Date and time of the count
32+
- Simple header with application logo
33+
34+
- Reports can be:
35+
- Printed directly to the **default system printer**
36+
- Exported to **PDF**
37+
38+
### Application Behavior
39+
- Always starts with blank fields (no persistence of previous data).
40+
- Works **fully offline**, with no internet requirements.
41+
- Minimal, clean UI similar to a calculator.
42+
- Optional **keyboard shortcuts**:
43+
- `Ctrl+P` for Print
44+
- `Ctrl+E` for Export to PDF
45+
- `Ctrl+C` for Calculate
46+
47+
---
48+
49+
## Non-Functional Requirements
50+
- Cross-platform support: **Windows, Mac, Linux** (initial release targets Windows).
51+
- Windows build distributed as an **MSI installer**.
52+
- Performance: Calculation and report generation must complete in <1 second for typical inputs.
53+
- Security: No internet access required; no data storage on disk.
54+
55+
---
56+
57+
## Deliverables
58+
1. Electron application source code.
59+
2. Windows MSI installer.
60+
3. Documentation for installation and usage.
61+
62+
---
63+
64+
## Future Enhancements (Out of Scope for MVP)
65+
- Multi-currency support
66+
- CSV export
67+
- Custom logo upload
68+
- Persistence of last counts
69+
- Advanced report metadata (username, machine name)
70+
71+
---
72+
73+
## Report Mock-Up
74+
75+
Below is a sample layout of the printed/exported report. In the application, this will be formatted with a logo, alignment, and clean styling.
76+
77+
---
78+
79+
# 🧾 Cash Counting Report
80+
81+
[LOGO HERE]
82+
83+
**Cash Counting Application**
84+
**Date/Time:** 2025-08-30 14:32
85+
86+
---
87+
88+
### Currency Breakdown
89+
90+
| Denomination | Quantity | Subtotal |
91+
|--------------|----------|----------|
92+
| $100 Bill | 5 | $500.00 |
93+
| $50 Bill | 2 | $100.00 |
94+
| $20 Bill | 7 | $140.00 |
95+
| $10 Bill | 3 | $30.00 |
96+
| $5 Bill | 4 | $20.00 |
97+
| $2 Bill | 0 | $0.00 |
98+
| $1 Bill | 12 | $12.00 |
99+
| 50¢ Coin | 6 | $3.00 |
100+
| 25¢ Coin | 8 | $2.00 |
101+
| 10¢ Coin | 10 | $1.00 |
102+
| 5¢ Coin | 15 | $0.75 |
103+
| 1¢ Coin | 23 | $0.23 |
104+
105+
---
106+
107+
### Grand Total
108+
**$808.98**
109+
110+
---

jest.config.cjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/** @type {import('jest').Config} */
2+
module.exports = {
3+
testEnvironment: 'node',
4+
roots: ['<rootDir>/tests'],
5+
moduleFileExtensions: ['js', 'json'],
6+
collectCoverage: true,
7+
collectCoverageFrom: ['src/lib/**/*.js'],
8+
};

0 commit comments

Comments
 (0)