Added Estimate dial API calls.

This commit is contained in:
rocketdebris 2026-01-24 17:05:30 -05:00
parent 91e4d47d48
commit 81f3489a24

View file

@ -15,7 +15,7 @@ def get_estimate_table_data_v2(filters={}, sortings=[], page=1, page_size=10):
"""Get paginated estimate table data with filtering and sorting."""
print("DEBUG: Raw estimate options received:", filters, sortings, page, page_size)
filters, sortings, page, page_size = DbUtils.process_query_conditions(filters, sortings, page, page_size)
@frappe.whitelist()
def get_estimate_table_data(filters={}, sortings=[], page=1, page_size=10):
@ -151,7 +151,7 @@ def send_estimate_email(estimate_name):
print("DEBUG: Sending estimate email for:", estimate_name)
quotation = frappe.get_doc("Quotation", estimate_name)
if not DbService.exists("Contact", quotation.contact_person):
return build_error_response("No email found for the customer.", 400)
party = ContactService.get_or_throw(quotation.contact_person)
@ -414,7 +414,7 @@ def upsert_estimate(data):
# estimate.customer_address = data.get("address_name")
# estimate.letter_head = data.get("company")
# estimate.from_onsite_meeting = data.get("onsite_meeting", None)
# Clear existing items and add new ones
estimate.items = []
for item in data.get("items", []):
@ -481,6 +481,31 @@ def upsert_estimate(data):
print(f"DEBUG: Error in upsert_estimate: {str(e)}")
return build_error_response(str(e), 500)
@frappe.whitelist()
def get_unapproved_estimates_count(company):
"""Get the number of unapproved estimates."""
try:
draft_filters = {'status': "Draft", "company": company}
submitted_filters = {'status': "Submitted", "company": company}
draft_count = frappe.db.count("Quotation", filters=draft_filters)
submitted_count = frappe.db.count("Quotation", filters=submitted_filters)
return build_success_response([draft_count, submitted_count])
except Exception as e:
return build_error_response(str(e), 500)
@frappe.whitelist()
def get_estimates_half_down_count(company):
"""Get the number unpaid half-down estimates."""
try:
filters = {'requires_half_payment': True, 'company': company}
count = frappe.db.count("Quotation", filters=filters)
return build_success_response([count])
except Exception as e:
return build_error_response(str(e), 500)
def get_estimate_history(estimate_name):
"""Get the history of changes for a specific estimate."""
pass