[[Image(https://develop.finki.ukim.mk/projects/agency-os/raw-attachment/wiki/ERModel/AgencyOS.webp)]] = Entities = 1. Company (Tenant) Represents the company/tenant in the system. Attributes: - company_id: Numeric, primary key. - name: Text, required. - address: Text, optional. - vat: Text, optional. - email: Text, required. - created_at: Date, required. - updated_at: Date, required. = 2. User Represents system users with specific roles. Attributes: - user_id: Numeric, primary key. - name: Text, required. - email: Text, unique, required. - password: Text, required. - role: Enum (Admin, HR, Finance Manager), required. - company_id: Foreign key to Company. - created_at: Date, required. - updated_at: Date, required. = 3. Employee Represents employees managed by the company. Attributes: - employee_id: Numeric, primary key. - name: Text, required. - email: Text, unique, required. - status: Enum (Active, Inactive, Terminated), required. - iban: Text, optional. - cv: Text, optional (file path or URL). - photo: Text, optional (file path or URL). - notes: Text, optional. - project: Text, optional. - company_id: Foreign key to Company. - created_at: Date, required. - updated_at: Date, required. = 4. Candidate Represents candidates applying for roles in the company. Attributes: - candidate_id: Numeric, primary key. - name: Text, required. - email: Text, unique, required. - status: Enum (Applied, Interview, Offered, Rejected), required. - cv: Text, optional (file path or URL). - interview_stage: Text, optional. - notes: Text, optional. - company_id: Foreign key to Company. - created_at: Date, required. - updated_at: Date, required. = 5. Client Represents the clients of the company. Attributes: - client_id: Numeric, primary key. - name: Text, required. - representative: Text, required. - email: Text, unique, required. - phone: Text, optional. - address: Text, optional. - vat: Text, optional. - logo: Text, optional (file path or URL). - company_id: Foreign key to Company. - created_at: Date, required. - updated_at: Date, required. = 6. Invoice Represents financial transactions between the company and its clients. Attributes: - invoice_id: Numeric, primary key. - from: Text, required (company details). - to: Text, required (client details). - issue_date: Date, required. - due_date: Date, required. - notes: Text, optional. - status: Enum (Draft, Pending, Paid, Overdue), required. - company_id: Foreign key to Company. - client_id: Foreign key to Client. - created_at: Date, required. - updated_at: Date, required. = 7. LineItem Represents individual items in an invoice. Attributes: - line_item_id: Numeric, primary key. - description: Text, required. - quantity: Integer, required. - unit_price: Decimal, required. - currency: Text, required. - total: Decimal, required. - invoice_id: Foreign key to Invoice. = 8. EmailTemplate Represents customizable email templates. Attributes: - template_id: Numeric, primary key. - type: Enum (New Invoice, Invoice Overdue, Welcome Employee, etc.), required. - subject: Text, required. - body: Text, required. - company_id: Foreign key to Company. - created_at: Date, required. - updated_at: Date, required. = Relations - Company ↔ User: A company has many users; each user belongs to one company. - Company ↔ Employee: A company has many employees; each employee belongs to one company. - Company ↔ Candidate: A company has many candidates; each candidate belongs to one company. - Company ↔ Client: A company has many clients; each client belongs to one company. - Company ↔ Invoice: A company generates many invoices; each invoice belongs to one company. - Client ↔ Invoice: A client can have many invoices; each invoice is addressed to one client. - Invoice ↔ LineItem: An invoice has multiple line items; each line item belongs to one invoice. - Company ↔ EmailTemplate: A company has multiple email templates; each template belongs to one company.