update with main

This commit is contained in:
Casey 2026-01-24 07:25:21 -06:00
parent 5e192a61e1
commit ba3e2a4d8e
29 changed files with 51749 additions and 139 deletions

View file

@ -19,6 +19,8 @@ def after_install():
frappe.reload_doctype("On-Site Meeting")
update_onsite_meeting_fields()
update_address_fields()
check_and_create_holiday_list()
create_snw_install_task_types()
build_frontend()
def after_migrate():
@ -33,6 +35,7 @@ def after_migrate():
frappe.reload_doctype(doctype)
check_and_create_holiday_list()
create_snw_install_task_types()
# update_address_fields()
# build_frontend()
@ -1020,3 +1023,143 @@ def get_all_sundays(year):
d += timedelta(days=7)
return sundays
def create_snw_install_task_types():
task_types = [
{
"title": "Locate",
"description": "Utility locate request prior to installation start.",
"base_date": "Start",
"offset_days": 7,
"offset_direction": "Before",
"calculate_from": "Service Appointment",
"trigger": "Scheduled",
},
{
"title": "Permit",
"description": "Permits required prior to installation start.",
"base_date": "Start",
"offset_days": 7,
"offset_direction": "Before",
"calculate_from": "Service Appointment",
"trigger": "Scheduled",
},
{
"title": "1/2 Down Payment",
"description": "Collect half down payment on project creation.",
"calculate_from": "Project",
"trigger": "Created",
"no_due_date": 1,
},
{
"title": "Machine Staging",
"description": "Stage machinery one day before installation start.",
"base_date": "Start",
"offset_days": 1,
"offset_direction": "Before",
"calculate_from": "Service Appointment",
"trigger": "Scheduled",
},
{
"title": "Final Invoice",
"description": "Send final invoice within 5 days of job completion.",
"base_date": "Completion",
"offset_days": 5,
"offset_direction": "After",
"calculate_from": "Service Appointment",
"trigger": "Completed",
},
{
"title": "Backflow Test",
"description": "Backflow test after job completion if quoted.",
"base_date": "Completion",
"offset_days": 0,
"offset_direction": "After",
"calculate_from": "Service Appointment",
"trigger": "Completed",
},
{
"title": "Schedule Permit Inspection",
"description": "Schedule permit inspection 5 days after completion.",
"base_date": "Completion",
"offset_days": 5,
"offset_direction": "After",
"calculate_from": "Service Appointment",
"trigger": "Completed",
},
{
"title": "15 Day Warranty Follow-Up",
"description": "15-day warranty follow-up after completion.",
"base_date": "Completion",
"offset_days": 15,
"offset_direction": "After",
"calculate_from": "Service Appointment",
"trigger": "Completed",
},
{
"title": "30 Day Warranty Check",
"description": "30-day warranty check after completion.",
"base_date": "Completion",
"offset_days": 30,
"offset_direction": "After",
"calculate_from": "Service Appointment",
"trigger": "Completed",
},
{
"title": "30 Day Payment Reminder",
"description": "Payment reminder sent 30 days after completion.",
"base_date": "Completion",
"offset_days": 30,
"offset_direction": "After",
"calculate_from": "Service Appointment",
"trigger": "Completed",
},
{
"title": "60 Day Late Payment Notice",
"description": "Late payment notification at 60 days post completion.",
"base_date": "Completion",
"offset_days": 60,
"offset_direction": "After",
"calculate_from": "Service Appointment",
"trigger": "Completed",
},
{
"title": "80 Day Lien Notice",
"description": "Lien notice if payment is still late after 80 days.",
"base_date": "Completion",
"offset_days": 80,
"offset_direction": "After",
"calculate_from": "Service Appointment",
"trigger": "Completed",
},
{
"title": "365 Day Warranty Call / Walk",
"description": "One-year warranty call or walk-through.",
"base_date": "Completion",
"offset_days": 365,
"offset_direction": "After",
"calculate_from": "Service Appointment",
"trigger": "Completed",
},
]
for task_type in task_types:
# Idempotency check
if frappe.db.exists("Task Type", task_type["title"]):
continue
doc = frappe.get_doc({
"doctype": "Task Type",
"title": task_type["title"],
"description": task_type["description"],
"base_date": task_type.get("base_date"),
"offset_days": task_type.get("offset_days", 0),
"offset_direction": task_type.get("offset_direction"),
"calculate_from": task_type.get("calculate_from", "Service Appointment"),
"trigger": task_type["trigger"],
"no_due_date": task_type.get("no_due_date", 0),
})
doc.insert(ignore_permissions=True)
frappe.db.commit()