PSA/docs/DELETION_RULES.md
Hermes 284313f908
Some checks are pending
Bidi Control Character Guard / bidi-control-guard (push) Waiting to run
Circular Dependency Check / Check for new circular dependencies (push) Waiting to run
Citus Migration Smoke / Combined migrations on single-node Citus (push) Waiting to run
E2E Fresh Install Tests / fresh-install-e2e (push) Waiting to run
ext-v2 guardrails / Run ext-v2 guard and ESLint (push) Waiting to run
Integration Tests / Check for relevant changes (push) Waiting to run
Integration Tests / ${{ (github.event_name == 'schedule' || github.event.inputs.suite == 'full') && 'Full integration suite' || 'Tier-1 integration subset' }} (push) Blocked by required conditions
Mobile checks / Mobile lint + typecheck (push) Waiting to run
Mobile checks / Mobile unit tests (push) Waiting to run
Mobile checks / Mobile dependency audit (report) (push) Waiting to run
Mobile checks / Mobile reproducibility checks (push) Waiting to run
Secrets guard (env backups) / Ensure no tracked env backup files (push) Waiting to run
Temporal Readiness / fast-readiness (push) Waiting to run
Temporal Readiness / docker-parity (push) Waiting to run
TypeScript Type Check / Nx affected typecheck (push) Waiting to run
Unit Tests / Skipped-test budget (push) Waiting to run
Unit Tests / Nx affected unit tests (push) Waiting to run
Unit Tests / Server unit coverage (informational) (push) Waiting to run
Validate Tenant Management Schema / Check for relevant changes (push) Waiting to run
Validate Tenant Management Schema / Validate Tenant Management Schema (push) Blocked by required conditions
EE Workflows Build Guard / ee-workflows-build-guard (push) Waiting to run
Initial import of AlgaPSA codebase from PSA server
Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz

Source: /opt/alga-psa on psa.joliet.tech
2026-06-22 16:12:17 -05:00

3.5 KiB

Alga PSA Deletion Rules

This document explains how client and contact deletion works in Alga PSA.

Client Deletion Rules

You CAN delete a client if they have:

  • Addresses/locations only (these will be automatically cleaned up)
  • Tax settings (these will be automatically cleaned up)
  • Tags (these will be automatically cleaned up)

You CANNOT delete a client if they have:

  • Contacts - Remove or reassign contacts first
  • Tickets (including closed tickets) - For audit trail preservation
  • Projects - Complete or reassign projects first
  • Documents - Move or delete documents first
  • Invoices or billing history - For legal/compliance requirements
  • Interactions - Communication history must be preserved
  • Assets or devices - Reassign or remove assets first

Alternative: Mark as Inactive

If a client has business records, consider marking as inactive instead:

  • Hides the client from active lists
  • Preserves all historical data
  • Prevents new business activities
  • Can be reactivated if needed
  • Related contacts can also be marked inactive

Contact Deletion Rules

You CAN delete a contact if they have:

  • No ticket history
  • No communication records
  • Not set as billing contact

You CANNOT delete a contact if they are:

  • Billing contact for their client - Assign a different billing contact first
  • Referenced in tickets (including closed) - For support history
  • Referenced in interactions - For communication history
  • Associated with documents - For audit trails
  • Assigned to projects - Reassign or complete projects first

Alternative: Mark as Inactive

Instead of deletion, mark contacts as inactive:

  • Hides from active contact lists
  • Preserves all business relationships
  • Maintains audit trails
  • Prevents new activities
  • Can be reactivated if needed

Why These Rules Exist

These deletion rules ensure:

  1. Data Integrity - Prevents orphaned records and broken relationships
  2. Audit Compliance - Maintains required business records
  3. Legal Protection - Preserves invoices and communications
  4. Business Continuity - Protects operational history and reporting
  5. User Experience - Clear, predictable behavior

Best Practices

Instead of Deleting:

  1. Mark clients as inactive when they have business history
  2. Mark contacts as inactive rather than deleting
  3. Clean up test data before it accumulates business records

When Deletion is Appropriate:

  1. Test/demo clients with no real business data
  2. Duplicate entries created by mistake (before they gain dependencies)
  3. Initial setup cleanup during implementation

Technical Implementation

  • All deletions happen within database transactions for safety
  • Permission checks ensure only authorized users can delete/mark inactive
  • Cascade cleanup automatically removes safe-to-delete related data
  • Detailed error messages explain exactly what's blocking deletion

Error Messages You Might See

Client with dependencies:

"Cannot delete client with active business records. Consider marking as inactive instead to preserve data integrity."

Contact with history:

"Cannot delete contact with business history: 5 tickets, communication history. Consider marking the contact as inactive instead."

Billing contact:

"Cannot delete this contact because they are set as the billing contact. Please assign a different billing contact first."


This document describes the actual deletion behavior implemented in Alga PSA.