Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/release-on-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Release on PR to Main

on:
pull_request:
branches:
- main
types: [closed]

jobs:
build-and-release:
if: github.event.pull_request.merged == true
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies
run: npm install

- name: Run tests
run: npm test

- name: Build Windows MSI
run: npm run build:win

- name: Upload MSI artifact
uses: actions/upload-artifact@v4
with:
name: cashcounter-msi
path: dist/*.msi

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: dist/*.msi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29 changes: 29 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# dependencies
/node_modules

# builds
/build

# development artifacts
/.env
/.env.local
/.env.development.local
/.env.test.local
/.env.production.local

# log files
/logs

# editor files
/.vscode
/.idea
/.nvm
/.npm
/.yarn

# misc
/.DS_Store
/Thumbs.db

# electron-builder
/dist
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2025 DDJ Labs
Copyright (c) 2025 Doug Jenkins

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
105 changes: 105 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Cash Counter

A minimal offline Electron app to count U.S. currency with printing and PDF export.

- Cross-platform (Windows, macOS, Linux). Initial release focuses on Windows MSI.
- Offline only. No persistence. Clean, calculator-like UI.

## Features

- **Minimal, Calculator-like UI:** Clean, responsive interface for quick cash counting.
- **Supports All U.S. Denominations:** Inputs for bills ($100, $50, $20, $10, $5, $2, $1) and coins (50¢, 25¢, 10¢, 5¢, 1¢).
- **Live Validation:** Only whole, non-negative integers are accepted for counts. Invalid input is highlighted.
- **Real-time Calculation:** Subtotals and grand total update as you type.
- **Print and PDF Export:** Print the report or export it as a PDF, including a timestamp and optional description.
- **Keyboard Shortcuts:**
- Ctrl+P: Print
- Ctrl+E: Export PDF
- Ctrl+C: Calculate (if a button is present)
- **Reset and Exit:** Quickly clear all fields or exit the app.
- **No Data Persistence:** All data is cleared on exit; nothing is stored on disk.
- **Cross-platform:** Works on Windows, macOS, and Linux (Windows MSI build supported).

## How it Works

- **Main Process (`src/main.js`):**
- Sets up the Electron window and application menu.
- Handles print, export, reset, and exit actions via IPC and menu.
- Uses Electron's `printToPDF` and system dialogs for export/print.

- **Preload Script (`src/preload.js`):**
- Exposes safe APIs (`print`, `exportPdf`, `exit`, `onReset`) to the renderer via `contextBridge`.

- **Calculation Library (`src/lib/calc.js`):**
- Defines denominations and their values in cents.
- Provides functions for validation, subtotal, and grand total calculation.
- Ensures all math is done in integer cents to avoid floating-point errors.

- **Renderer (`src/renderer/renderer.js`):**
- Dynamically builds the input grid for all denominations.
- Handles user input, validation, and live subtotal/grand total updates.
- Manages print/export/reset/exit actions and keyboard shortcuts.
- Populates a print-optimized report for printing/PDF export.

- **UI (`src/renderer/index.html`, `styles.css`):**
- Modern, accessible layout with print-optimized styles.
- Print and export include a timestamp and optional description.

## Requirements Summary (from `docs/prd.md`)
- Inputs for bills: $100, $50, $20, $10, $5, $2, $1
- Inputs for coins: 50¢, 25¢, 10¢, 5¢, 1¢
- Validate whole non-negative integers only
- Calculate subtotals and grand total
- Print and Export to PDF
- Keyboard shortcuts: Ctrl+P (Print), Ctrl+E (Export), Ctrl+C (Calculate)

## Project Structure
```
.
├── docs/
│ └── prd.md
├── src/
│ ├── assets/
│ │ └── logo.svg
│ ├── lib/
│ │ └── calc.js
│ ├── main.js
│ ├── preload.js
│ └── renderer/
│ ├── index.html
│ ├── renderer.js
│ └── styles.css
├── tests/
│ └── calc.test.js
├── jest.config.cjs
└── package.json
```

## Getting Started

1. Install dependencies
```bash
npm install
```

2. Run the app in development
```bash
npm run dev
```

3. Run unit tests
```bash
npm test
```

4. Build Windows MSI (on Windows)
```bash
npm run build:win
```
MSI will be output to `dist/`.

## Notes
- Calculations are done in integer cents to avoid floating-point errors (`src/lib/calc.js`).
- The renderer loads the report table dynamically after calculation.
- Printing uses the system print dialog; PDF export uses a save dialog and Electron `printToPDF`.
- No data is stored on disk; app opens with blank fields every time.
110 changes: 110 additions & 0 deletions docs/prd.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Cash Counting Application – Product Requirement Document

## Overview
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.

## Purpose
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.

---

## Supported Currency Denominations
- **Bills:** $100, $50, $20, $10, $5, $2, $1
- **Coins:** $0.50, $0.25, $0.10, $0.05, $0.01

---

## Functional Requirements

### User Interface
- Provide **text boxes** for each denomination.
- Text boxes accept **only whole positive integers** (no decimals, negatives, or non-numeric input).
- Pressing **Tab** moves focus to the next denomination field.
- A **Calculate Total** button computes the total and displays:
- Subtotal per denomination
- Grand total

### Report Generation
- A **Print Report** button generates a report with:
- Tabular layout of denominations, quantity, subtotal
- Grand total
- Date and time of the count
- Simple header with application logo

- Reports can be:
- Printed directly to the **default system printer**
- Exported to **PDF**

### Application Behavior
- Always starts with blank fields (no persistence of previous data).
- Works **fully offline**, with no internet requirements.
- Minimal, clean UI similar to a calculator.
- Optional **keyboard shortcuts**:
- `Ctrl+P` for Print
- `Ctrl+E` for Export to PDF
- `Ctrl+C` for Calculate

---

## Non-Functional Requirements
- Cross-platform support: **Windows, Mac, Linux** (initial release targets Windows).
- Windows build distributed as an **MSI installer**.
- Performance: Calculation and report generation must complete in <1 second for typical inputs.
- Security: No internet access required; no data storage on disk.

---

## Deliverables
1. Electron application source code.
2. Windows MSI installer.
3. Documentation for installation and usage.

---

## Future Enhancements (Out of Scope for MVP)
- Multi-currency support
- CSV export
- Custom logo upload
- Persistence of last counts
- Advanced report metadata (username, machine name)

---

## Report Mock-Up

Below is a sample layout of the printed/exported report. In the application, this will be formatted with a logo, alignment, and clean styling.

---

# 🧾 Cash Counting Report

[LOGO HERE]

**Cash Counting Application**
**Date/Time:** 2025-08-30 14:32

---

### Currency Breakdown

| Denomination | Quantity | Subtotal |
|--------------|----------|----------|
| $100 Bill | 5 | $500.00 |
| $50 Bill | 2 | $100.00 |
| $20 Bill | 7 | $140.00 |
| $10 Bill | 3 | $30.00 |
| $5 Bill | 4 | $20.00 |
| $2 Bill | 0 | $0.00 |
| $1 Bill | 12 | $12.00 |
| 50¢ Coin | 6 | $3.00 |
| 25¢ Coin | 8 | $2.00 |
| 10¢ Coin | 10 | $1.00 |
| 5¢ Coin | 15 | $0.75 |
| 1¢ Coin | 23 | $0.23 |

---

### Grand Total
**$808.98**

---
8 changes: 8 additions & 0 deletions jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/** @type {import('jest').Config} */
module.exports = {
testEnvironment: 'node',
roots: ['<rootDir>/tests'],
moduleFileExtensions: ['js', 'json'],
collectCoverage: true,
collectCoverageFrom: ['src/lib/**/*.js'],
};
Loading
Loading