Added API calls for the Job Dials and a column for the Invoice Status in the datatable.
This commit is contained in:
parent
37bd0f60a3
commit
00f6d69482
1 changed files with 63 additions and 3 deletions
|
|
@ -7,6 +7,64 @@ from frappe.utils import getdate
|
||||||
# JOB MANAGEMENT API METHODS
|
# JOB MANAGEMENT API METHODS
|
||||||
# ===============================================================================
|
# ===============================================================================
|
||||||
|
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def get_jobs_in_queue_count(company):
|
||||||
|
try:
|
||||||
|
filters = {
|
||||||
|
'company': company,
|
||||||
|
'is_scheduled': True,
|
||||||
|
}
|
||||||
|
count = frappe.db.count("Project", filters=filters)
|
||||||
|
return build_success_response([count])
|
||||||
|
except Exception as e:
|
||||||
|
return build_error_response(str(e), 500)
|
||||||
|
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def get_jobs_in_progress_count(company):
|
||||||
|
try:
|
||||||
|
today = getdate()
|
||||||
|
filters = {
|
||||||
|
'company': company,
|
||||||
|
'invoice_status': 'Not Ready',
|
||||||
|
'expected_start_date': ['<=', today],
|
||||||
|
'expected_end_date': ['>=', today],
|
||||||
|
}
|
||||||
|
count = frappe.db.count("Project", filters=filters)
|
||||||
|
return build_success_response([count])
|
||||||
|
except Exception as e:
|
||||||
|
return build_error_response(str(e), 500)
|
||||||
|
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def get_jobs_late_count(company):
|
||||||
|
try:
|
||||||
|
today = getdate()
|
||||||
|
filters = {
|
||||||
|
'company': company,
|
||||||
|
'invoice_status': 'Not Ready',
|
||||||
|
'expected_end_date': ['<', today]
|
||||||
|
}
|
||||||
|
count = frappe.db.count("Project", filters=filters)
|
||||||
|
return build_success_response([count])
|
||||||
|
except Exception as e:
|
||||||
|
return build_error_response(str(e), 500)
|
||||||
|
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def get_jobs_to_invoice_count(company):
|
||||||
|
try:
|
||||||
|
filters = {
|
||||||
|
'company': company,
|
||||||
|
'invoice_status': 'Ready to Invoice',
|
||||||
|
}
|
||||||
|
count = frappe.db.count("Project", filters=filters)
|
||||||
|
return build_success_response([count])
|
||||||
|
except Exception as e:
|
||||||
|
return build_error_response(str(e), 500)
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_job_templates(company=None):
|
def get_job_templates(company=None):
|
||||||
"""Get list of job (project) templates."""
|
"""Get list of job (project) templates."""
|
||||||
|
|
@ -19,6 +77,7 @@ def get_job_templates(company=None):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return build_error_response(str(e), 500)
|
return build_error_response(str(e), 500)
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def create_job_from_sales_order(sales_order_name):
|
def create_job_from_sales_order(sales_order_name):
|
||||||
"""Create a Job (Project) from a given Sales Order"""
|
"""Create a Job (Project) from a given Sales Order"""
|
||||||
|
|
@ -152,9 +211,10 @@ def get_jobs_table_data(filters={}, sortings=[], page=1, page_size=10):
|
||||||
tableRow = {}
|
tableRow = {}
|
||||||
tableRow["id"] = project["name"]
|
tableRow["id"] = project["name"]
|
||||||
tableRow["name"] = project["name"]
|
tableRow["name"] = project["name"]
|
||||||
tableRow["installation_address"] = project.get("custom_installation_address", "")
|
tableRow["job_address"] = project["job_address"]
|
||||||
tableRow["customer"] = project.get("customer", "")
|
tableRow["customer"] = project.get("customer", "")
|
||||||
tableRow["status"] = project.get("status", "")
|
tableRow["status"] = project.get("status", "")
|
||||||
|
tableRow["invoice_status"] = project.get("invoice_status")
|
||||||
tableRow["percent_complete"] = project.get("percent_complete", 0)
|
tableRow["percent_complete"] = project.get("percent_complete", 0)
|
||||||
tableRows.append(tableRow)
|
tableRows.append(tableRow)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue