Skip to main content

Overview

A Wallet represents a financial account where you track money. This could be:
  • Cash in your pocket
  • Bank checking account
  • Savings account
  • Credit card (with negative balance)
  • Investment account

Wallet Properties

PropertyTypeDescription
idStringLocal UUID (primary key)
serverIdString?Server-assigned ID after sync
nameStringDisplay name (e.g., “Cash”, “Chase Checking”)
currencyStringISO 4217 currency code (e.g., “USD”, “EUR”)
balancedoubleCurrent balance
syncStatusSyncStatusCurrent sync state

Creating a Wallet

Using the Cache Manager

final cache = CacheManager.instance;

final wallet = await cache.createWallet(
  name: 'Cash',
  currency: 'USD',
  initialBalance: 100.0,
);

print('Created wallet: ${wallet.id}');

Direct Repository Access

final wallet = Wallet(
  id: cache.generateId(),
  name: 'Chase Checking',
  currency: 'USD',
  balance: 1500.00,
  createdAt: DateTime.now(),
  updatedAt: DateTime.now(),
);

await cache.wallets.save(wallet);

Querying Wallets

Get All Wallets

final wallets = await cache.wallets.findAll();

Find by ID

final wallet = await cache.wallets.findById('wallet-uuid');
if (wallet != null) {
  print('Balance: ${wallet.balance}');
}

Get Pending Sync

final pending = await cache.wallets.findPendingSync();

Updating Wallets

final wallet = await cache.wallets.findById(walletId);
if (wallet != null) {
  final updated = wallet.copyWith(
    name: 'Updated Name',
    balance: wallet.balance + 50.0,
  );
  await cache.wallets.save(updated);
}
When you save an existing wallet, its syncStatus automatically changes to pendingUpdate (if it was synced).

Deleting Wallets

Soft Delete (Default)

Soft delete marks the wallet as deleted but keeps it locally until sync completes:
await cache.wallets.delete(walletId);
The wallet will:
  1. Be marked with isDeleted = true
  2. Get syncStatus = pendingDelete
  3. Not appear in findAll() results
  4. Sync to server
  5. Be hard-deleted after successful sync

Hard Delete

Hard delete removes the wallet immediately (use with caution):
await cache.wallets.delete(walletId, hardDelete: true);
Hard-deleted wallets cannot be recovered and will not sync to the server.

Currency Support

Zeus uses ISO 4217 currency codes. Common codes:
CodeCurrency
USDUS Dollar
EUREuro
GBPBritish Pound
JPYJapanese Yen
CADCanadian Dollar

Best Practices

  1. Use descriptive names - “Chase Checking” is better than “Bank”
  2. Set initial balance - Track your starting point
  3. One wallet per account - Don’t mix different accounts
  4. Regular reconciliation - Compare with bank statements