Added half down payment tracking to Project.
This commit is contained in:
parent
8452f57787
commit
ab0dced9ec
2 changed files with 35 additions and 9 deletions
|
|
@ -1,6 +1,16 @@
|
||||||
import frappe
|
import frappe
|
||||||
from custom_ui.services import DbService, AddressService, ClientService
|
from custom_ui.services import DbService, AddressService, ClientService
|
||||||
|
|
||||||
|
|
||||||
|
def on_save(doc, method):
|
||||||
|
print("DEBUG: on_save hook triggered for Sales Order", doc.name)
|
||||||
|
if doc.advance_paid >= doc.grand_total/2:
|
||||||
|
if doc.project and doc.half_down_required:
|
||||||
|
print("DEBUG: Advance payments exceed required threshold of half down, setting project half down paid.")
|
||||||
|
project = frappe.get_doc("Project", doc.project)
|
||||||
|
project.is_half_down_paid = True
|
||||||
|
|
||||||
|
|
||||||
def before_insert(doc, method):
|
def before_insert(doc, method):
|
||||||
print("DEBUG: before_insert hook triggered for Sales Order")
|
print("DEBUG: before_insert hook triggered for Sales Order")
|
||||||
# if doc.custom_project_template == "SNW Install":
|
# if doc.custom_project_template == "SNW Install":
|
||||||
|
|
@ -9,6 +19,7 @@ def before_insert(doc, method):
|
||||||
# if "SNW Install" in [link.project_template for link in address_doc.sales_orders]:
|
# if "SNW Install" in [link.project_template for link in address_doc.sales_orders]:
|
||||||
# raise frappe.ValidationError("A Sales Order with project template 'SNW Install' is already linked to this address.")
|
# raise frappe.ValidationError("A Sales Order with project template 'SNW Install' is already linked to this address.")
|
||||||
|
|
||||||
|
|
||||||
def on_submit(doc, method):
|
def on_submit(doc, method):
|
||||||
print("DEBUG: Info from Sales Order")
|
print("DEBUG: Info from Sales Order")
|
||||||
print(doc.custom_installation_address)
|
print(doc.custom_installation_address)
|
||||||
|
|
@ -29,7 +40,8 @@ def on_submit(doc, method):
|
||||||
"custom_warranty_duration_days": 90,
|
"custom_warranty_duration_days": 90,
|
||||||
"customer": doc.customer,
|
"customer": doc.customer,
|
||||||
"job_address": doc.custom_job_address,
|
"job_address": doc.custom_job_address,
|
||||||
"sales_order": doc.name
|
"sales_order": doc.name,
|
||||||
|
"requires_half_payment": doc.requires_half_payment
|
||||||
})
|
})
|
||||||
# attatch the job to the sales_order links
|
# attatch the job to the sales_order links
|
||||||
new_job.insert()
|
new_job.insert()
|
||||||
|
|
@ -37,6 +49,7 @@ def on_submit(doc, method):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("ERROR creating Project from Sales Order:", str(e))
|
print("ERROR creating Project from Sales Order:", str(e))
|
||||||
|
|
||||||
|
|
||||||
def after_insert(doc, method):
|
def after_insert(doc, method):
|
||||||
print("DEBUG: after_insert hook triggered for Sales Order:", doc.name)
|
print("DEBUG: after_insert hook triggered for Sales Order:", doc.name)
|
||||||
AddressService.append_link_v2(
|
AddressService.append_link_v2(
|
||||||
|
|
@ -49,6 +62,7 @@ def after_insert(doc, method):
|
||||||
doc.customer, "sales_orders", {"sales_order": doc.name, "project_template": doc.custom_project_template}
|
doc.customer, "sales_orders", {"sales_order": doc.name, "project_template": doc.custom_project_template}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def create_sales_invoice_from_sales_order(doc, method):
|
def create_sales_invoice_from_sales_order(doc, method):
|
||||||
pass
|
pass
|
||||||
# try:
|
# try:
|
||||||
|
|
|
||||||
|
|
@ -596,7 +596,7 @@ def add_custom_fields():
|
||||||
label="Is Scheduled",
|
label="Is Scheduled",
|
||||||
fieldtype="Check",
|
fieldtype="Check",
|
||||||
default=0,
|
default=0,
|
||||||
insert_after="expected_end_time"
|
insert_after="is_half_down_paid"
|
||||||
),
|
),
|
||||||
dict(
|
dict(
|
||||||
fieldname="invoice_status",
|
fieldname="invoice_status",
|
||||||
|
|
@ -606,6 +606,20 @@ def add_custom_fields():
|
||||||
options="Not Ready\nReady to Invoice\nInvoice Created\nInvoice Sent",
|
options="Not Ready\nReady to Invoice\nInvoice Created\nInvoice Sent",
|
||||||
insert_after="is_scheduled"
|
insert_after="is_scheduled"
|
||||||
),
|
),
|
||||||
|
dict(
|
||||||
|
fieldname="requires_half_payment",
|
||||||
|
label="Requires Half Payment",
|
||||||
|
fieldtype="Check",
|
||||||
|
default=0,
|
||||||
|
insert_after="expected_end_time"
|
||||||
|
),
|
||||||
|
dict(
|
||||||
|
fieldname="is_half_down_paid",
|
||||||
|
label="Is Half Down Paid",
|
||||||
|
fieldtype="Check",
|
||||||
|
default=0,
|
||||||
|
insert_after="requires_half_payment"
|
||||||
|
),
|
||||||
],
|
],
|
||||||
"Project Template": [
|
"Project Template": [
|
||||||
dict(
|
dict(
|
||||||
|
|
@ -1150,7 +1164,7 @@ def create_task_types():
|
||||||
"calculate_from": "Service Address 2",
|
"calculate_from": "Service Address 2",
|
||||||
"trigger": "Completed",
|
"trigger": "Completed",
|
||||||
"triggering_doctype": "Service Address 2"
|
"triggering_doctype": "Service Address 2"
|
||||||
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "80 Day Lien Notice",
|
"title": "80 Day Lien Notice",
|
||||||
|
|
@ -1196,10 +1210,10 @@ def create_task_types():
|
||||||
})
|
})
|
||||||
|
|
||||||
doc.insert(ignore_permissions=True)
|
doc.insert(ignore_permissions=True)
|
||||||
|
|
||||||
|
|
||||||
frappe.db.commit()
|
frappe.db.commit()
|
||||||
|
|
||||||
def create_tasks():
|
def create_tasks():
|
||||||
print("\n🔧 Creating default Tasks if they do not exist...")
|
print("\n🔧 Creating default Tasks if they do not exist...")
|
||||||
default_tasks = [
|
default_tasks = [
|
||||||
|
|
@ -1223,7 +1237,7 @@ def create_tasks():
|
||||||
"priority": "High"
|
"priority": "High"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
for task in default_tasks:
|
for task in default_tasks:
|
||||||
if frappe.db.exists("Task", task["task_name"]):
|
if frappe.db.exists("Task", task["task_name"]):
|
||||||
continue
|
continue
|
||||||
|
|
@ -1237,7 +1251,7 @@ def create_tasks():
|
||||||
"type": task["type"]
|
"type": task["type"]
|
||||||
})
|
})
|
||||||
doc.insert(ignore_permissions=True)
|
doc.insert(ignore_permissions=True)
|
||||||
|
|
||||||
def create_project_templates():
|
def create_project_templates():
|
||||||
"""Create default Project Templates if they do not exist."""
|
"""Create default Project Templates if they do not exist."""
|
||||||
print("\n🔧 Checking for default Project Templates...")
|
print("\n🔧 Checking for default Project Templates...")
|
||||||
|
|
@ -1251,8 +1265,6 @@ def create_project_templates():
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
import frappe
|
|
||||||
|
|
||||||
|
|
||||||
def create_bid_meeting_note_form_templates():
|
def create_bid_meeting_note_form_templates():
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue