Complete specification for rewriting Swarmops v5 as using.cash v6: - Proposal: scope buckets (Working Rewrite / First Beyond Working / Maybe), non-goals (governance, geography, memberships permanently cut) - Design: 18 architectural decisions including preserved patterns (Basic/Logic, stored procs, credential split), new patterns (repository classes, chain abstraction, rate providers), and operational concerns (Galera awareness, continuation transactions, VAT booking, OOD denormalization) - Specs: 17 capability specifications with SHALL/MUST requirements and WHEN/THEN scenarios, covering accounting core, AP/AR, crypto treasury, exchange rates, organizations, users/auth, documents, comms, dashboard, end-of-month, backend worker, event bus, data migration, API layer, frontend app, and CI/packaging - Tasks: 145 implementation tasks grouped by subsystem, ordered by dependency (migration gates API/frontend work) Two rounds of adversarial review incorporated. Made-with: Cursor
8.0 KiB
ADDED Requirements
Requirement: React SPA with Material UI
The frontend SHALL be a single-page application built with React 18+, Material UI (MUI), and TypeScript. Vite SHALL be used as the build tool. The SPA communicates exclusively via the REST API and WebSocket — no server-side rendering.
Scenario: Application loads
- WHEN a user navigates to the application URL
- THEN the React SPA loads and presents the login page (if unauthenticated) or dashboard (if authenticated)
Requirement: Login and session management
The frontend SHALL present a login form and manage the authenticated session via HTTP-only session cookies. On successful login, the server sets a session cookie that is automatically included in subsequent API requests and WebSocket upgrade requests. Session expiry redirects to login.
Scenario: Login flow
- WHEN a user enters valid credentials on the login page
- THEN the server sets a session cookie and the frontend navigates to the dashboard
Scenario: Session expiry
- WHEN an API call returns 401 during an active session (cookie expired or invalidated)
- THEN the frontend redirects to the login page
Requirement: Navigation structure
The frontend SHALL provide a sidebar navigation matching the Bucket 1 functional areas: Dashboard, Ledgers (Chart of Accounts, Inspect Ledgers, Balance Sheet, P&L, Budget vs Actual), Financial (Expense Claims, Inbound Invoices, Outbound Invoices, Payouts), Crypto Treasury, End-of-Month, Administration (Organization Settings, Users).
Scenario: Navigate to ledger page
- WHEN a user clicks "Balance Sheet" in the navigation
- THEN the balance sheet page loads with data for the active organization
Requirement: Ledger pages
The frontend SHALL implement pages for: chart of accounts (tree view, create/edit/close accounts), inspect ledgers (account + date range → transaction rows), balance sheet (as-of date), P&L (fiscal year), and budget vs actual (year view with variance).
Scenario: Inspect ledger with date range
- WHEN a user selects an account and date range on the inspect ledgers page
- THEN transaction rows for that account and period are displayed with running balance
Scenario: Chart of accounts tree
- WHEN a user views the chart of accounts
- THEN accounts are displayed in a hierarchical tree grouped by type (Asset, Debt, Income, Cost)
Requirement: Financial workflow pages
The frontend SHALL implement pages for: expense claim submission (with document upload), inbound invoice registration, outbound invoice creation, attestation queue (list of items pending the user's attestation), receipt validation, and payout management.
Scenario: Submit expense claim with manual VAT
- WHEN a user fills out the expense claim form, enters the total and the VAT amount exactly as shown on the receipt, and uploads the receipt
- THEN the claim is submitted via the API with the manually entered VAT amount
Scenario: Inbound invoice with manual VAT
- WHEN a user registers a supplier invoice with a VAT amount
- THEN the VAT field accepts manual entry (no rate computation) matching the invoice exactly
Scenario: Outbound invoice with default VAT
- WHEN a user creates an outbound invoice in a VAT-enabled org
- THEN the VAT amount is pre-filled from the org's default rate applied to the net amount, and the user can override it
Scenario: Attestation queue
- WHEN a budget owner views the attestation page
- THEN they see all expenses and invoices pending their attestation with approve/reject actions
Requirement: Crypto treasury page
The frontend SHALL display the hot wallet overview: total balance per chain (BCH in Bucket 1), list of wallet addresses with individual balances, recent deposits and payouts, and fiat equivalent using current exchange rates.
Scenario: View crypto treasury
- WHEN a user navigates to the crypto treasury page
- THEN they see the total BCH balance, address list, and fiat equivalent
Requirement: End-of-month page
The frontend SHALL implement the end-of-month workflow page with the monthly checklist, bank statement upload, and year-end close link when applicable.
Scenario: View end-of-month
- WHEN a user navigates to the end-of-month page
- THEN they see the checklist for the current month with actionable items
Requirement: Administration pages
The frontend SHALL implement pages for: organization settings (name, currency, logo), and user management (list users, create user, assign roles, deactivate user).
Scenario: Manage users
- WHEN an administrator navigates to user management
- THEN they see a list of users with their roles and can create, edit, or deactivate users
Requirement: Localization
The frontend SHALL support multiple languages: English (primary), Swedish (secondary), and German (should-have). Translation uses a JSON-based i18n system (e.g., react-i18next). Language selection is per-user (stored in user preferences). AI-assisted translation generates initial packs; Swedish reviewed by human translator.
Scenario: Switch language
- WHEN a user selects Swedish as their preferred language
- THEN all UI labels, menu items, and system messages are displayed in Swedish
Scenario: Fallback to English
- WHEN a translation key is missing in the selected language
- THEN the system falls back to the English translation
Requirement: Smart monetary input component
The frontend SHALL provide a reusable monetary input component that accepts flexible numeric input (handling both decimal commas and decimal points as decimal separators), interprets the value as a currency amount, and displays the formatted result so the user can confirm the interpretation was correct. The component SHALL display the formatted amount in the organization's currency format after the user finishes typing.
Scenario: Decimal point input
- WHEN a user types "1234.50" into a monetary input
- THEN the component interprets this as 1234 units and 50 cents and displays the formatted result (e.g., "1,234.50" or "1 234,50" depending on locale)
Scenario: Decimal comma input
- WHEN a user types "1234,50" into a monetary input
- THEN the component interprets this as 1234 units and 50 cents (not one million two hundred thirty-four thousand fifty)
Scenario: Ambiguous input resolved
- WHEN a user types "1.234" into a monetary input
- THEN the component makes a qualified guess based on locale conventions (likely 1234 in European locale, 1.23 in US locale) and displays the formatted result so the user can verify
Scenario: Confirmation feedback
- WHEN the component finishes interpreting the input
- THEN the formatted amount is displayed clearly so the user can see whether the system understood their input correctly before submitting
Requirement: Smart date input component
The frontend SHALL provide a reusable date input component that accepts flexible date entry (various formats like YYYY-MM-DD, DD/MM/YYYY, MM/DD/YYYY) and displays the interpreted date in a consistent format so the user can confirm correctness.
Scenario: ISO date input
- WHEN a user types "2025-03-15"
- THEN the component interprets this as March 15, 2025 and displays it in the locale-appropriate format
Scenario: Ambiguous date resolved
- WHEN a user types "03/04/2025"
- THEN the component interprets it based on locale conventions and displays the full result (e.g., "April 3, 2025" or "March 4, 2025") so the user can verify
Requirement: Organization switcher
The frontend SHALL provide an organization switcher (in the top bar or navigation) for users with access to multiple organizations. Switching reloads all data for the new organization context.
Scenario: Switch organization
- WHEN a user selects a different organization from the switcher
- THEN all page data reloads scoped to the newly selected organization