Skip to main content

Dev/E2E Chart of Accounts Seeding

This system provides convenient ways to seed development and testing organizations with a standard set of chart of accounts, eliminating the need to manually create accounts during testing.

Overview

The seeding system provides the following standard dev chart of accounts:

Usage Methods

Navigate to /setup/chart-of-accounts in your dev environment and click the “🛠️ Seed Dev Accounts” button in the chart of accounts card header.
  • Only visible in development environment (NODE_ENV === “development”)
  • Uses the new warning button variant with proper CI colors for dev/testing purposes
  • Shows loading state during seeding
  • Displays success/error toasts
  • Automatically refreshes the page to show new accounts
Use the CLI script for automated testing or CI/CD pipelines:
Examples: Interactive Mode:
Non-Interactive Mode:
Environment Requirements:
  • DATABASE_URL must be set (uses organization’s database)

Features

  • Interactive Prompts: Asks for required parameters if not provided as arguments
  • Validation: Validates organization ID format
  • Confirmation: Shows summary and asks for confirmation before seeding
  • Non-Interactive Mode: Supports automation by providing arguments

3. Server Action (Programmatic Use)

For programmatic usage in tests or other server-side code:

E2E Testing Integration

Playwright/E2E Tests

Add this to your test setup:

CI/CD Integration

Add to your CI pipeline after creating a test organization:
Note: In CI/CD environments, always provide parameters as arguments to avoid interactive prompts.

Features

  • Upsert Logic: Accounts are upserted, so running the seed multiple times is safe
  • Existing Account Handling: Won’t duplicate accounts, will update existing ones
  • Audit Trail: Uses actor ID for created/modified by tracking
  • Error Handling: Continues seeding even if individual accounts fail
  • Logging: Comprehensive logging for debugging
  • Single Source of Truth: Chart data defined once in CLI script, imported by UI seeding functions

Important Notes

⚠️ This is for development/testing only!
  • This seeding is NOT part of production organization setup
  • It’s separate from the standard organization seeding in create-organisation.ts
  • The UI button only appears in development environment and uses the proper warning variant styling
  • Accounts are created with standard test data, not production-ready configurations
  • Uses centralized getEnvironmentInfo() utility for consistent dev environment detection

Modifying Chart Data

To add, remove, or modify the standard dev chart of accounts:
  1. Edit only apps/webapp/scripts/seed-dev-chart-accounts.mjs
  2. Update the DEV_CHART_OF_ACCOUNTS array
  3. Both UI button and CLI will automatically use the updated data
The chart data is defined once in the CLI script and imported by the UI seeding functions, ensuring consistency and eliminating duplication.

File Structure

Troubleshooting

“Organization not found” error:
  • Verify the organization ID is correct
  • Ensure you have database access
“Actor not found” warning:
  • The script will continue without an actor ID
  • You can provide a specific actor ID as the second parameter
Database connection errors:
  • Verify DATABASE_URL environment variable is set
  • Check database connectivity
UI button not visible:
  • Ensure you’re in a development environment
  • Check that you’re authenticated and have access to the organization

Environment Utilities Usage

You can use the existing environment utilities in other components for consistent environment detection: