big update

This commit is contained in:
Casey 2026-01-15 08:36:08 -06:00
parent d53ebf9ecd
commit 5c7e93fcc7
26 changed files with 1890 additions and 423 deletions

View file

@ -0,0 +1,40 @@
import frappe
from .db_service import DbService
class ContactService:
@staticmethod
def create(data: dict):
"""Create a new contact."""
print("DEBUG: Creating new Contact with data:", data)
contact = frappe.get_doc({
"doctype": "Contact",
**data
})
contact.insert(ignore_permissions=True)
print("DEBUG: Created new Contact:", contact.as_dict())
return contact
@staticmethod
def link_contact_to_customer(contact_doc, customer_type, customer_name):
"""Link a contact to a customer or lead."""
print(f"DEBUG: Linking Contact {contact_doc.name} to {customer_type} {customer_name}")
contact_doc.customer_type = customer_type
contact_doc.customer_name = customer_name
contact_doc.save(ignore_permissions=True)
print(f"DEBUG: Linked Contact {contact_doc.name} to {customer_type} {customer_name}")
@staticmethod
def link_contact_to_address(contact_doc, address_name):
"""Link an address to a contact."""
print(f"DEBUG: Linking Address {address_name} to Contact {contact_doc.name}")
contact_doc.append("addresses", {
"address": address_name
})
contact_doc.save(ignore_permissions=True)
print(f"DEBUG: Linked Address {address_name} to Contact {contact_doc.name}")
@staticmethod
def get_or_throw(contact_name: str):
"""Retrieve a Contact document or throw an error if it does not exist."""
return DbService.get_or_throw("Contact", contact_name)