Skip to main content

Documentation Index

Fetch the complete documentation index at: https://grantmaster.dev/llms.txt

Use this file to discover all available pages before exploring further.

shared/organization

Organization lifecycle, settings, internationalization, and tenant provisioning services.

Module Map

FileRole
organizationService.tsCore org CRUD (create, read, update, suspend)
settingsService.tsOperational settings read/write
settings.types.tsOrganizationOperationalSettings type definition
tenantProvisioningService.tsFull new-tenant setup wizard backend
ownershipTransfer.tsAdmin ownership transfer workflow
internationalization.tsLocale, currency, timezone helpers
superAdminService.tsCross-tenant org reads for SuperAdmin

Settings API

The primary settings entry point for features is features/settings/services/settingsCanonical.ts, which wraps this module. Direct usage is for shared services that need org settings without importing from a feature.
import { loadOrganizationSettings, updateOrganizationSettings } from '@/shared/organization/settingsService';

// Read operational settings
const settings = await loadOrganizationSettings(orgId);
// → { approvalRouting, budgetCategories, costCenters, officeHours, ... }

// Partial update
await updateOrganizationSettings(orgId, {
  officeHours: { start: '09:00', end: '17:00', timezone: 'Europe/Amsterdam' },
});

// Reset to defaults
await resetSettingsToDefaults(orgId);

// Audit log a settings change
await logSettingsAuditEvent({ orgId, userId, userName, changedFields });

Tenant Provisioning

tenantProvisioningService.ts is called by features/onboarding/TenantOnboardingWizard. It orchestrates the multi-step setup:
  1. Creates the organizations/{id} document
  2. Promotes the creating user to SystemRole.ADMIN
  3. Writes default config/settings
  4. Seeds default budget categories and cost centers
  5. Creates initial compliance checklist (if compliance-vault is enabled)

Internationalization

import { getSupportedLocales, getCurrencySymbol, formatCurrencyForLocale } from '@/shared/organization/internationalization';

const locales = getSupportedLocales();
// → [{ code: 'en-US', label: 'English (US)' }, ...]

const symbol = getCurrencySymbol('EUR');  // → '€'
const formatted = formatCurrencyForLocale(1250.50, 'EUR', 'nl-NL');  // → '€ 1.250,50'

Firestore Collections

CollectionDescription
organizations/{id}Organization document
organizations/{id}/config/settingsCanonical app settings (via AppSettingsService)
organizations/{id}/config/operationalSettingsOperational settings (approval routing, categories)