filters added, ui change, update project moved to project.py

This commit is contained in:
Neil Trini Lasrado 2015-04-14 18:49:48 +05:30
parent ec5c66f8f0
commit 4e6e4726a4
7 changed files with 183 additions and 161 deletions

View File

@ -169,3 +169,11 @@ frappe.ui.form.on("Expense Claim", "employee_name", function(frm) {
frappe.ui.form.on("Expense Claim", "task", function(frm) { frappe.ui.form.on("Expense Claim", "task", function(frm) {
erpnext.expense_claim.set_title(frm); erpnext.expense_claim.set_title(frm);
}); });
cur_frm.fields_dict['task'].get_query = function(doc) {
return {
filters:{
'project': doc.project
}
}
}

View File

@ -7,13 +7,6 @@
"doctype": "DocType", "doctype": "DocType",
"document_type": "Master", "document_type": "Master",
"fields": [ "fields": [
{
"fieldname": "overview",
"fieldtype": "Section Break",
"label": "Overview",
"options": "icon-file",
"permlevel": 0
},
{ {
"description": "", "description": "",
"fieldname": "project_name", "fieldname": "project_name",
@ -112,6 +105,49 @@
"permlevel": 0, "permlevel": 0,
"search_index": 0 "search_index": 0
}, },
{
"fieldname": "customer_details",
"fieldtype": "Section Break",
"label": "",
"oldfieldtype": "Section Break",
"options": "icon-user",
"permlevel": 0
},
{
"fieldname": "customer",
"fieldtype": "Link",
"in_filter": 1,
"label": "Customer",
"no_copy": 0,
"oldfieldname": "customer",
"oldfieldtype": "Link",
"options": "Customer",
"permlevel": 0,
"print_hide": 1,
"reqd": 0,
"search_index": 1
},
{
"fieldname": "company",
"fieldtype": "Link",
"label": "Company",
"options": "Company",
"permlevel": 0
},
{
"fieldname": "column_break_14",
"fieldtype": "Column Break",
"permlevel": 0,
"precision": ""
},
{
"fieldname": "sales_order",
"fieldtype": "Link",
"label": "Sales Order",
"options": "Sales Order",
"permlevel": 0,
"precision": ""
},
{ {
"fieldname": "sb_milestones", "fieldname": "sb_milestones",
"fieldtype": "Section Break", "fieldtype": "Section Break",
@ -155,13 +191,6 @@
"permlevel": 0, "permlevel": 0,
"search_index": 0 "search_index": 0
}, },
{
"fieldname": "company",
"fieldtype": "Link",
"label": "Company",
"options": "Company",
"permlevel": 0
},
{ {
"fieldname": "section_break_18", "fieldname": "section_break_18",
"fieldtype": "Section Break", "fieldtype": "Section Break",
@ -179,7 +208,7 @@
{ {
"fieldname": "actual_time", "fieldname": "actual_time",
"fieldtype": "Float", "fieldtype": "Float",
"label": "Actual Time", "label": "Actual Time (in Hours)",
"permlevel": 0, "permlevel": 0,
"precision": "", "precision": "",
"read_only": 1 "read_only": 1
@ -202,18 +231,16 @@
"search_index": 0 "search_index": 0
}, },
{ {
"fieldname": "project_details", "fieldname": "section_break_26",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Project Costing", "permlevel": 0,
"oldfieldtype": "Section Break", "precision": ""
"options": "icon-money",
"permlevel": 0
}, },
{ {
"fieldname": "project_value", "fieldname": "estimated_costing",
"fieldtype": "Currency", "fieldtype": "Currency",
"in_list_view": 1, "in_list_view": 1,
"label": "Project Value", "label": "Estimated Costing",
"no_copy": 0, "no_copy": 0,
"oldfieldname": "project_value", "oldfieldname": "project_value",
"oldfieldtype": "Currency", "oldfieldtype": "Currency",
@ -222,47 +249,12 @@
"reqd": 0, "reqd": 0,
"search_index": 0 "search_index": 0
}, },
{
"fieldname": "total_costing_amount",
"fieldtype": "Currency",
"label": "Total Costing Amount",
"permlevel": 0,
"precision": "",
"read_only": 1
},
{
"fieldname": "total_expense_claim",
"fieldtype": "Currency",
"label": "Total Expense Claim",
"permlevel": 0,
"precision": "",
"read_only": 1
},
{ {
"fieldname": "column_break_22", "fieldname": "column_break_22",
"fieldtype": "Column Break", "fieldtype": "Column Break",
"permlevel": 0, "permlevel": 0,
"precision": "" "precision": ""
}, },
{
"fieldname": "est_material_cost",
"fieldtype": "Currency",
"label": "Estimated Material Cost",
"no_copy": 0,
"oldfieldname": "est_material_cost",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"permlevel": 0,
"search_index": 0
},
{
"fieldname": "total_billing_amount",
"fieldtype": "Currency",
"label": "Total Billing Amount",
"permlevel": 0,
"precision": "",
"read_only": 1
},
{ {
"fieldname": "cost_center", "fieldname": "cost_center",
"fieldtype": "Link", "fieldtype": "Link",
@ -271,24 +263,30 @@
"permlevel": 0 "permlevel": 0
}, },
{ {
"fieldname": "margin", "fieldname": "project_details",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Margin", "label": "",
"oldfieldtype": "Column Break", "oldfieldtype": "Section Break",
"permlevel": 0, "options": "icon-money",
"width": "50%" "permlevel": 0
}, },
{ {
"fieldname": "gross_margin_value", "description": "",
"fieldname": "total_costing_amount",
"fieldtype": "Currency", "fieldtype": "Currency",
"label": "Gross Margin Value", "label": "Total Costing Amount (via Time Logs)",
"no_copy": 0,
"oldfieldname": "gross_margin_value",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"permlevel": 0, "permlevel": 0,
"reqd": 0, "precision": "",
"search_index": 0 "read_only": 1
},
{
"description": "",
"fieldname": "total_expense_claim",
"fieldtype": "Currency",
"label": "Total Expense Claim (via Expense Claims)",
"permlevel": 0,
"precision": "",
"read_only": 1
}, },
{ {
"fieldname": "column_break_28", "fieldname": "column_break_28",
@ -297,44 +295,59 @@
"precision": "" "precision": ""
}, },
{ {
"fieldname": "per_gross_margin", "description": "",
"fieldname": "total_billing_amount",
"fieldtype": "Currency", "fieldtype": "Currency",
"label": "Gross Margin %", "label": "Total Billing Amount (via Time Logs)",
"permlevel": 0,
"precision": "",
"read_only": 1
},
{
"fieldname": "margin",
"fieldtype": "Section Break",
"label": "",
"oldfieldtype": "Column Break",
"permlevel": 0,
"width": "50%"
},
{
"fieldname": "gross_margin",
"fieldtype": "Currency",
"label": "Gross Margin",
"no_copy": 0, "no_copy": 0,
"oldfieldname": "per_gross_margin", "oldfieldname": "gross_margin_value",
"oldfieldtype": "Currency", "oldfieldtype": "Currency",
"options": "Company:company:default_currency", "options": "Company:company:default_currency",
"permlevel": 0, "permlevel": 0,
"read_only": 1,
"reqd": 0, "reqd": 0,
"search_index": 0 "search_index": 0
}, },
{ {
"fieldname": "customer_details", "fieldname": "column_break_37",
"fieldtype": "Section Break", "fieldtype": "Column Break",
"label": "Customer Details", "permlevel": 0,
"oldfieldtype": "Section Break", "precision": ""
"options": "icon-user",
"permlevel": 0
}, },
{ {
"fieldname": "customer", "fieldname": "per_gross_margin",
"fieldtype": "Link", "fieldtype": "Percent",
"in_filter": 1, "label": "Gross Margin %",
"label": "Customer",
"no_copy": 0, "no_copy": 0,
"oldfieldname": "customer", "oldfieldname": "per_gross_margin",
"oldfieldtype": "Link", "oldfieldtype": "Currency",
"options": "Customer", "options": "",
"permlevel": 0, "permlevel": 0,
"print_hide": 1, "read_only": 1,
"reqd": 0, "reqd": 0,
"search_index": 1 "search_index": 0
} }
], ],
"icon": "icon-puzzle-piece", "icon": "icon-puzzle-piece",
"idx": 1, "idx": 1,
"max_attachments": 4, "max_attachments": 4,
"modified": "2015-04-13 07:13:06.962942", "modified": "2015-04-14 07:37:56.810833",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Projects", "module": "Projects",
"name": "Project", "name": "Project",

View File

@ -44,6 +44,8 @@ class Project(Document):
def sync_tasks(self): def sync_tasks(self):
"""sync tasks and remove table""" """sync tasks and remove table"""
if self.flags.dont_sync_tasks: return
task_names = [] task_names = []
for t in self.tasks: for t in self.tasks:
if t.task_id: if t.task_id:
@ -80,6 +82,22 @@ class Project(Document):
frappe.db.set_value("Project", self.name, "percent_complete", frappe.db.set_value("Project", self.name, "percent_complete",
int(float(completed) / total * 100)) int(float(completed) / total * 100))
def update_costing(self):
total_cost = frappe.db.sql("""select sum(total_costing_amount) as costing_amount,
sum(total_billing_amount) as billing_amount, sum(total_expense_claim) as expense_claim,
min(act_start_date) as start_date, max(act_end_date) as end_date, sum(actual_time) as time
from `tabTask` where project = %s""", self.name, as_dict=1)[0]
self.total_costing_amount = total_cost.costing_amount
self.total_billing_amount = total_cost.billing_amount
self.total_expense_claim = total_cost.expense_claim
self.actual_start_date = total_cost.start_date
self.actual_end_date = total_cost.end_date
self.actual_time = total_cost.time
self.gross_margin = flt(total_cost.billing_amount) - flt(total_cost.costing_amount)
if self.total_billing_amount:
self.per_gross_margin = (self.gross_margin / flt(self.total_billing_amount)) *100
@frappe.whitelist() @frappe.whitelist()
def get_cost_center_name(project_name): def get_cost_center_name(project_name):
return frappe.db.get_value("Project", project_name, "cost_center") return frappe.db.get_value("Project", project_name, "cost_center")

View File

@ -18,24 +18,14 @@
"reqd": 1 "reqd": 1
}, },
{ {
"fieldname": "exp_start_date", "fieldname": "project",
"fieldtype": "Date", "fieldtype": "Link",
"label": "Expected Start Date", "in_list_view": 1,
"oldfieldname": "exp_start_date", "label": "Project",
"oldfieldtype": "Date", "oldfieldname": "project",
"permlevel": 0, "oldfieldtype": "Link",
"reqd": 0 "options": "Project",
}, "permlevel": 0
{
"fieldname": "exp_end_date",
"fieldtype": "Date",
"in_filter": 1,
"label": "Expected End Date",
"oldfieldname": "exp_end_date",
"oldfieldtype": "Date",
"permlevel": 0,
"reqd": 0,
"search_index": 1
}, },
{ {
"fieldname": "column_break0", "fieldname": "column_break0",
@ -56,16 +46,6 @@
"options": "Open\nWorking\nPending Review\nClosed\nCancelled", "options": "Open\nWorking\nPending Review\nClosed\nCancelled",
"permlevel": 0 "permlevel": 0
}, },
{
"fieldname": "project",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Project",
"oldfieldname": "project",
"oldfieldtype": "Link",
"options": "Project",
"permlevel": 0
},
{ {
"fieldname": "priority", "fieldname": "priority",
"fieldtype": "Select", "fieldtype": "Select",
@ -104,33 +84,45 @@
"oldfieldtype": "Section Break", "oldfieldtype": "Section Break",
"permlevel": 0 "permlevel": 0
}, },
{
"fieldname": "exp_start_date",
"fieldtype": "Date",
"label": "Expected Start Date",
"oldfieldname": "exp_start_date",
"oldfieldtype": "Date",
"permlevel": 0,
"reqd": 0
},
{ {
"default": "0", "default": "0",
"description": "in Hours", "description": "",
"fieldname": "expected_time", "fieldname": "expected_time",
"fieldtype": "Float", "fieldtype": "Float",
"label": "Expected Time", "label": "Expected Time (in hours)",
"oldfieldname": "exp_total_hrs", "oldfieldname": "exp_total_hrs",
"oldfieldtype": "Data", "oldfieldtype": "Data",
"permlevel": 0, "permlevel": 0,
"reqd": 0 "reqd": 0
}, },
{ {
"fieldname": "column_break_12", "fieldname": "column_break_11",
"fieldtype": "Column Break", "fieldtype": "Column Break",
"permlevel": 0, "permlevel": 0,
"precision": "" "precision": ""
}, },
{ {
"fieldname": "allocated_budget", "fieldname": "exp_end_date",
"fieldtype": "Currency", "fieldtype": "Date",
"label": "Allocated Budget", "in_filter": 1,
"oldfieldname": "allocated_budget", "label": "Expected End Date",
"oldfieldtype": "Currency", "oldfieldname": "exp_end_date",
"options": "Company:company:default_currency", "oldfieldtype": "Date",
"permlevel": 0 "permlevel": 0,
"reqd": 0,
"search_index": 1
}, },
{ {
"description": "",
"fieldname": "actual", "fieldname": "actual",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "", "label": "",
@ -142,7 +134,7 @@
{ {
"fieldname": "act_start_date", "fieldname": "act_start_date",
"fieldtype": "Date", "fieldtype": "Date",
"label": "Actual Start Date", "label": "Actual Start Date (via Time Logs)",
"oldfieldname": "act_start_date", "oldfieldname": "act_start_date",
"oldfieldtype": "Date", "oldfieldtype": "Date",
"permlevel": 0, "permlevel": 0,
@ -150,10 +142,10 @@
}, },
{ {
"default": "", "default": "",
"description": "in Hours", "description": "",
"fieldname": "actual_time", "fieldname": "actual_time",
"fieldtype": "Float", "fieldtype": "Float",
"label": "Actual Time", "label": "Actual Time (in hours)",
"options": "", "options": "",
"permlevel": 0, "permlevel": 0,
"precision": "", "precision": "",
@ -168,7 +160,7 @@
{ {
"fieldname": "act_end_date", "fieldname": "act_end_date",
"fieldtype": "Date", "fieldtype": "Date",
"label": "Actual End Date", "label": "Actual End Date (via Time Logs)",
"oldfieldname": "act_end_date", "oldfieldname": "act_end_date",
"oldfieldtype": "Date", "oldfieldtype": "Date",
"permlevel": 0, "permlevel": 0,
@ -183,7 +175,7 @@
{ {
"fieldname": "total_costing_amount", "fieldname": "total_costing_amount",
"fieldtype": "Currency", "fieldtype": "Currency",
"label": "Total Costing Amount", "label": "Total Costing Amount (via Time Logs)",
"oldfieldname": "actual_budget", "oldfieldname": "actual_budget",
"oldfieldtype": "Currency", "oldfieldtype": "Currency",
"options": "Company:company:default_currency", "options": "Company:company:default_currency",
@ -193,7 +185,7 @@
{ {
"fieldname": "total_expense_claim", "fieldname": "total_expense_claim",
"fieldtype": "Currency", "fieldtype": "Currency",
"label": "Total Expense Claim", "label": "Total Expense Claim (via Expense Claim)",
"options": "Company:company:default_currency", "options": "Company:company:default_currency",
"permlevel": 0, "permlevel": 0,
"precision": "", "precision": "",
@ -209,7 +201,7 @@
"fieldname": "total_billing_amount", "fieldname": "total_billing_amount",
"fieldtype": "Currency", "fieldtype": "Currency",
"hidden": 0, "hidden": 0,
"label": "Total Billing Amount", "label": "Total Billing Amount (via Time Logs)",
"permlevel": 0, "permlevel": 0,
"precision": "", "precision": "",
"read_only": 1 "read_only": 1
@ -257,7 +249,7 @@
"idx": 1, "idx": 1,
"istable": 0, "istable": 0,
"max_attachments": 5, "max_attachments": 5,
"modified": "2015-04-13 05:36:33.544083", "modified": "2015-04-14 07:56:24.481667",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Projects", "module": "Projects",
"name": "Task", "name": "Task",

View File

@ -64,18 +64,10 @@ class Task(Document):
def update_project(self): def update_project(self):
if self.project and frappe.db.exists("Project", self.project): if self.project and frappe.db.exists("Project", self.project):
total_cost = frappe.db.sql("""select sum(total_costing_amount) as costing_amount, project = frappe.get_doc("Project", self.project)
sum(total_billing_amount) as billing_amount, sum(total_expense_claim) as expense_claim, project.flags.dont_sync_tasks = True
min(act_start_date) as start_date, max(act_end_date) as end_date, sum(actual_time) as time project.update_costing()
from `tabTask` where project = %s""", self.project, as_dict=1)[0] project.save()
frappe.db.set_values("Project", self.project, {
"total_costing_amount": total_cost.costing_amount,
"total_billing_amount": total_cost.billing_amount,
"total_expense_claim": total_cost.expense_claim,
"actual_start_date": total_cost.start_date,
"actual_end_date": total_cost.end_date,
"actual_time": total_cost.time
})
@frappe.whitelist() @frappe.whitelist()
def get_events(start, end, filters=None): def get_events(start, end, filters=None):

View File

@ -4,7 +4,6 @@
frappe.provide("erpnext.projects"); frappe.provide("erpnext.projects");
frappe.ui.form.on("Time Log", "onload", function(frm) { frappe.ui.form.on("Time Log", "onload", function(frm) {
frm.set_query("task", erpnext.queries.task);
if (frm.doc.for_manufacturing) { if (frm.doc.for_manufacturing) {
frappe.ui.form.trigger("Time Log", "production_order"); frappe.ui.form.trigger("Time Log", "production_order");
} }
@ -88,3 +87,11 @@ frappe.ui.form.on("Time Log", "billable", function(frm) {
frm.doc("billing_amount", 0); frm.doc("billing_amount", 0);
} }
}); });
cur_frm.fields_dict['task'].get_query = function(doc) {
return {
filters:{
'project': doc.project
}
}
}

View File

@ -232,10 +232,10 @@
}, },
{ {
"default": "0", "default": "0",
"description": "per hour", "description": "",
"fieldname": "costing_rate", "fieldname": "costing_rate",
"fieldtype": "Currency", "fieldtype": "Currency",
"label": "Costing Rate", "label": "Costing Rate (per hour)",
"permlevel": 0, "permlevel": 0,
"precision": "", "precision": "",
"read_only": 1 "read_only": 1
@ -257,10 +257,10 @@
}, },
{ {
"default": "0", "default": "0",
"description": "per hour", "description": "",
"fieldname": "billing_rate", "fieldname": "billing_rate",
"fieldtype": "Currency", "fieldtype": "Currency",
"label": "Billing Rate", "label": "Billing Rate (per hour)",
"permlevel": 0, "permlevel": 0,
"precision": "", "precision": "",
"read_only": 1 "read_only": 1
@ -322,15 +322,7 @@
"icon": "icon-time", "icon": "icon-time",
"idx": 1, "idx": 1,
"is_submittable": 1, "is_submittable": 1,
<<<<<<< HEAD "modified": "2015-04-14 09:07:28.468792",
<<<<<<< HEAD
"modified": "2015-04-06 02:47:16.187046",
=======
"modified": "2015-04-09 08:29:34.464429",
>>>>>>> Fixes in time_log
=======
"modified": "2015-04-13 04:31:20.855439",
>>>>>>> task and project- billing amount and actual amount added
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Projects", "module": "Projects",
"name": "Time Log", "name": "Time Log",