Merge pull request #100 from meichthys/develop

Check if family already exists
This commit is contained in:
MeIchthys 2026-02-15 01:18:52 -05:00 committed by GitHub
commit 37a5d322be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 18 additions and 2 deletions

View File

@ -106,6 +106,22 @@ class ChurchPerson(Document):
@frappe.whitelist()
def new_family_from_person(self):
# Check if a family with this person's name already exists
existing_family = frappe.db.exists(
"Church Family", {"family_name": f"{self.last_name} - {self.first_name}"}
)
if existing_family:
# Set this person's family to the existing one
self.family = existing_family
self.is_head_of_household = False # Not head of household in an existing family
self.save()
frappe.msgprint(
f"⚠️ The <a href='/app/church-family/{existing_family}'>{self.last_name} - {self.first_name}</a> family already exists. This person has been added to that family."
)
return # Don't create a new family
doc = frappe.new_doc("Church Family")
doc.family_name = f"{self.last_name} - {self.first_name}"
doc.save()

File diff suppressed because one or more lines are too long