Data Models
User (JWT + Role Extension)​
Purpose: Represents EMTB staff and client users with role-based permissions and client access rights
Key Attributes:
- id: string - User identifier (primary key)
- email: string - User email address
- name: string - Full user name
- role: UserRole - Role enumeration (ADMIN, ACCOUNT_MANAGER, TAX_SPECIALIST, CLIENT)
- client_access: string[] - Array of client IDs this user can access
- created_at: DateTime - Account creation timestamp
- updated_at: DateTime - Last modification timestamp
interface User {
id: string;
email: string;
name: string;
role: UserRole;
client_access: string[]; // Client IDs this user can access
created_at: Date;
updated_at: Date;
}
enum UserRole {
ADMIN = "ADMIN", // Full system access
ACCOUNT_MANAGER = "ACCOUNT_MANAGER", // Assigned clients only
TAX_SPECIALIST = "TAX_SPECIALIST", // Assigned by account managers
CLIENT = "CLIENT", // Own company data only
}
Relationships:
- Has access to multiple clients through client_access array
- Role determines permission level within accessible clients
Client (Existing Model - Minimal Changes)​
Purpose: Represents business clients of EMTB with their company information
interface Client {
id: string;
company_name: string;
contact_email: string;
address: string;
created_at: Date;
// Existing fields preserved
sites?: Site[];
reclamations?: Reclamation[];
factures?: Facture[];
}
Relationships:
- One-to-many with Sites (existing)
- One-to-many with Reclamations (existing)
- One-to-many with Factures (existing)
Site (Existing Model - No Changes)​
Purpose: Represents physical locations for tax claims
interface Site {
id: string;
client_id: string;
site_name: string;
address: string;
// Tenant isolation through client_id relationship
client?: Client;
reclamations?: Reclamation[];
}
Relationships:
- Many-to-one with Client (existing) - This provides tenant isolation
- One-to-many with Reclamations (existing)
Reclamation (Existing Model - No Changes)​
Purpose: Represents tax claims (TF/CFE) for specific sites
interface Reclamation {
id: string;
client_id: string; // Direct client reference for efficient filtering
site_id: string;
claim_type: "TF" | "CFE";
amount: number;
status: string;
// Tenant isolation through client_id relationship
client?: Client;
site?: Site;
documents?: Document[];
}
Relationships:
- Many-to-one with Client (existing) - Primary tenant isolation
- Many-to-one with Site (existing)
- One-to-many with Documents (existing)
Document (Existing Model - No Changes)​
Purpose: File attachments related to tax claims
interface Document {
id: string;
reclamation_id: string;
filename: string;
file_path: string;
uploaded_at: Date;
// Tenant isolation through reclamation.client_id chain
reclamation?: Reclamation;
}
Relationships:
- Many-to-one with Reclamation (existing) - Tenant isolation through reclamation.client_id