SuiteConsultance/modules/crm/client.py
2025-09-20 13:18:04 +02:00

54 lines
No EOL
1.5 KiB
Python

from datetime import date
import uuid
from datetime import date
import uuid
class Client:
def __init__(
self,
name: str,
company: str = "",
email: str = "",
phone: str = "",
notes: str = "",
tags: list = None,
last_contact: str = None,
next_action: str = "",
linked_docs: dict = None,
id: str = None,
created_at: str = None
):
self.id = id or f"cli_{uuid.uuid4().hex[:8]}"
self.name = name
self.company = company
self.email = email
self.phone = phone
self.notes = notes
self.tags = tags or []
self.last_contact = last_contact or str(date.today())
self.next_action = next_action
self.linked_docs = linked_docs or {"devis": [], "propositions": [], "factures": []}
self.created_at = created_at or str(date.today())
def to_dict(self):
return {
"id": self.id,
"name": self.name,
"company": self.company,
"email": self.email,
"phone": self.phone,
"notes": self.notes,
"tags": self.tags,
"last_contact": self.last_contact,
"next_action": self.next_action,
"linked_docs": self.linked_docs,
"created_at": self.created_at
}
@staticmethod
def from_dict(data: dict):
return Client(**data)
def __str__(self):
return f"Client({self.name}, {self.company}, {self.email}, {self.phone})"