Skip to content

Add wallet feature for separate fund tracking#16

Draft
Claude wants to merge 5 commits intomainfrom
claude/add-wallet-feature
Draft

Add wallet feature for separate fund tracking#16
Claude wants to merge 5 commits intomainfrom
claude/add-wallet-feature

Conversation

@Claude
Copy link

@Claude Claude AI commented Feb 28, 2026

Implements wallet management to track separate funds (bank accounts, cash, work funds) with automatic balance updates when expenses are created, edited, or deleted.

Database Schema

  • New wallets table with initial_balance, current_balance, currency
  • Added nullable wallet_id foreign key to expenses table
  • Migration script: migrations/007_wallets.sql

Backend (Cloudflare Workers + D1)

  • API Endpoints: REST CRUD at /api/wallets (GET, POST, PUT, DELETE)
  • Wallet Handler: worker/handlers/wallet.handler.ts with Zod validation
  • Balance Management: Automatic updates in DBService expense operations:
    • Create: Deduct from wallet
    • Update: Restore old wallet, deduct from new wallet
    • Delete: Restore to wallet
  • Types: Added Wallet interface, updated Expense with optional wallet_id

Frontend (React + TypeScript)

  • Wallets Page: Full CRUD with balance display (src/pages/WalletsPage.tsx)
  • Expense Integration: Optional wallet selector in ExpenseForm showing name, currency, and current balance
  • Navigation: Added to header (desktop) and bottom nav (mobile)
  • Service Layer: src/lib/wallet-service.ts for API calls

Example Usage

// Create wallet
POST /api/wallets
{
  "name": "Bank Account",
  "initialBalance": 1000,
  "currency": "USD"
}

// Create expense with wallet
POST /api/expenses
{
  "merchant": "Store",
  "total": 50,
  "walletId": "wallet-123",  // Optional
  ...
}
// Wallet balance automatically decreases to 950

Backward Compatibility

Expenses without wallet_id continue to work. Feature is fully optional.

Deployment

npm run db:migrate:007:prod  # Run migration
npm run deploy               # Deploy

Documentation: docs/WALLET_FEATURE.md

Co-authored-by: Creative-Geek <20252333+Creative-Geek@users.noreply.github.com>
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 28, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
focal-expensi 3cb4640 Commit Preview URL

Branch Preview URL
Feb 28 2026, 02:01 AM

Claude AI and others added 3 commits February 28, 2026 01:58
Co-authored-by: Creative-Geek <20252333+Creative-Geek@users.noreply.github.com>
Co-authored-by: Creative-Geek <20252333+Creative-Geek@users.noreply.github.com>
Co-authored-by: Creative-Geek <20252333+Creative-Geek@users.noreply.github.com>
@Claude Claude AI changed the title [WIP] Add wallet feature for expense management Add wallet feature for separate fund tracking Feb 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants