diff --git a/erpnext/projects/doctype/project/project.json b/erpnext/projects/doctype/project/project.json index 62210b80c34..ef6140a37a6 100644 --- a/erpnext/projects/doctype/project/project.json +++ b/erpnext/projects/doctype/project/project.json @@ -14,12 +14,6 @@ "options": "icon-file", "permlevel": 0 }, - { - "fieldname": "cb_project_status", - "fieldtype": "Column Break", - "label": "Status", - "permlevel": 0 - }, { "description": "", "fieldname": "project_name", @@ -45,6 +39,23 @@ "reqd": 1, "search_index": 1 }, + { + "fieldname": "project_type", + "fieldtype": "Select", + "label": "Project Type", + "no_copy": 0, + "oldfieldname": "project_type", + "oldfieldtype": "Data", + "options": "Internal\nExternal\nOther", + "permlevel": 0, + "search_index": 0 + }, + { + "fieldname": "column_break_5", + "fieldtype": "Column Break", + "permlevel": 0, + "precision": "" + }, { "fieldname": "is_active", "fieldtype": "Select", @@ -69,16 +80,16 @@ "search_index": 0 }, { - "fieldname": "cb_project_dates", - "fieldtype": "Column Break", - "label": "Dates", - "permlevel": 0 + "fieldname": "section_break_12", + "fieldtype": "Section Break", + "permlevel": 0, + "precision": "" }, { - "fieldname": "project_start_date", + "fieldname": "expected_start_date", "fieldtype": "Date", "in_filter": 1, - "label": "Project Start Date", + "label": "Expected Start Date", "no_copy": 0, "oldfieldname": "project_start_date", "oldfieldtype": "Date", @@ -86,36 +97,21 @@ "search_index": 0 }, { - "fieldname": "completion_date", + "fieldname": "column_break_11", + "fieldtype": "Column Break", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "expected_end_date", "fieldtype": "Date", - "label": "Completion Date", + "label": "Expected End Date", "no_copy": 0, "oldfieldname": "completion_date", "oldfieldtype": "Date", "permlevel": 0, "search_index": 0 }, - { - "fieldname": "act_completion_date", - "fieldtype": "Date", - "label": "Actual Completion Date", - "no_copy": 0, - "oldfieldname": "act_completion_date", - "oldfieldtype": "Date", - "permlevel": 0, - "search_index": 0 - }, - { - "fieldname": "project_type", - "fieldtype": "Select", - "label": "Project Type", - "no_copy": 0, - "oldfieldname": "project_type", - "oldfieldtype": "Data", - "options": "Internal\nExternal\nOther", - "permlevel": 0, - "search_index": 0 - }, { "fieldname": "sb_milestones", "fieldtype": "Section Break", @@ -131,7 +127,7 @@ "options": "Project Task", "permlevel": 0, "precision": "", - "reqd": 1 + "reqd": 0 }, { "fieldname": "percent_complete", @@ -166,6 +162,45 @@ "options": "Company", "permlevel": 0 }, + { + "fieldname": "section_break_18", + "fieldtype": "Section Break", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "actual_start_date", + "fieldtype": "Data", + "label": "Actual Start Date", + "permlevel": 0, + "precision": "", + "read_only": 1 + }, + { + "fieldname": "actual_time", + "fieldtype": "Float", + "label": "Actual Time", + "permlevel": 0, + "precision": "", + "read_only": 1 + }, + { + "fieldname": "column_break_20", + "fieldtype": "Column Break", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "actual_end_date", + "fieldtype": "Date", + "label": "Actual End Date", + "no_copy": 0, + "oldfieldname": "act_completion_date", + "oldfieldtype": "Date", + "permlevel": 0, + "read_only": 1, + "search_index": 0 + }, { "fieldname": "project_details", "fieldtype": "Section Break", @@ -188,20 +223,9 @@ "search_index": 0 }, { - "fieldname": "est_material_cost", + "fieldname": "total_costing_amount", "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_activity_cost", - "fieldtype": "Currency", - "label": "Total Activity Cost", + "label": "Total Costing Amount", "permlevel": 0, "precision": "", "read_only": 1 @@ -214,6 +238,31 @@ "precision": "", "read_only": 1 }, + { + "fieldname": "column_break_22", + "fieldtype": "Column Break", + "permlevel": 0, + "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", "fieldtype": "Link", @@ -222,8 +271,8 @@ "permlevel": 0 }, { - "fieldname": "column_break0", - "fieldtype": "Column Break", + "fieldname": "margin", + "fieldtype": "Section Break", "label": "Margin", "oldfieldtype": "Column Break", "permlevel": 0, @@ -241,6 +290,12 @@ "reqd": 0, "search_index": 0 }, + { + "fieldname": "column_break_28", + "fieldtype": "Column Break", + "permlevel": 0, + "precision": "" + }, { "fieldname": "per_gross_margin", "fieldtype": "Currency", @@ -279,7 +334,7 @@ "icon": "icon-puzzle-piece", "idx": 1, "max_attachments": 4, - "modified": "2015-04-10 05:11:18.849171", + "modified": "2015-04-13 07:13:06.962942", "modified_by": "Administrator", "module": "Projects", "name": "Project", diff --git a/erpnext/projects/doctype/project/project.py b/erpnext/projects/doctype/project/project.py index b481ee422ab..0b45e4d3bb4 100644 --- a/erpnext/projects/doctype/project/project.py +++ b/erpnext/projects/doctype/project/project.py @@ -38,9 +38,9 @@ class Project(Document): self.sync_tasks() def validate_dates(self): - if self.project_start_date and self.completion_date: - if getdate(self.completion_date) < getdate(self.project_start_date): - frappe.throw(_("Expected Completion Date can not be less than Project Start Date")) + if self.expected_start_date and self.expected_end_date: + if getdate(self.expected_end_date) < getdate(self.expected_start_date): + frappe.throw(_("Expected End Date can not be less than Expected Start Date")) def sync_tasks(self): """sync tasks and remove table""" @@ -68,6 +68,8 @@ class Project(Document): # delete for t in frappe.get_all("Task", ["name"], {"project": self.name, "name": ("not in", task_names)}): frappe.delete_doc("Task", t.name) + + self.tasks = [] def update_percent_complete(self): total = frappe.db.sql("""select count(*) from tabTask where project=%s""", diff --git a/erpnext/projects/doctype/project_task/project_task.json b/erpnext/projects/doctype/project_task/project_task.json index 11d5b551682..f3d2c66d9be 100644 --- a/erpnext/projects/doctype/project_task/project_task.json +++ b/erpnext/projects/doctype/project_task/project_task.json @@ -37,7 +37,7 @@ "in_filter": 0, "in_list_view": 1, "label": "Status", - "no_copy": 0, + "no_copy": 1, "options": "Open\nWorking\nPending Review\nClosed\nCancelled", "permlevel": 0, "precision": "", @@ -128,7 +128,7 @@ { "fieldname": "task_id", "fieldtype": "Link", - "hidden": 0, + "hidden": 1, "label": "Task ID", "no_copy": 1, "options": "Task", @@ -143,7 +143,7 @@ "is_submittable": 0, "issingle": 0, "istable": 1, - "modified": "2015-04-06 09:41:50.911955", + "modified": "2015-04-13 04:56:18.766659", "modified_by": "Administrator", "module": "Projects", "name": "Project Task", diff --git a/erpnext/projects/doctype/task/task.json b/erpnext/projects/doctype/task/task.json index b46fe2111cf..664210016d9 100644 --- a/erpnext/projects/doctype/task/task.json +++ b/erpnext/projects/doctype/task/task.json @@ -148,6 +148,17 @@ "permlevel": 0, "read_only": 1 }, + { + "default": "", + "description": "in Hours", + "fieldname": "actual_time", + "fieldtype": "Float", + "label": "Actual Time", + "options": "", + "permlevel": 0, + "precision": "", + "read_only": 1 + }, { "fieldname": "column_break_15", "fieldtype": "Column Break", @@ -170,26 +181,9 @@ "precision": "" }, { - "default": "0", - "description": "in Hours", - "fieldname": "actual_time", - "fieldtype": "Float", - "label": "Actual Time", - "options": "", - "permlevel": 0, - "precision": "", - "read_only": 1 - }, - { - "fieldname": "column_break_20", - "fieldtype": "Column Break", - "permlevel": 0, - "precision": "" - }, - { - "fieldname": "actual_cost", + "fieldname": "total_costing_amount", "fieldtype": "Currency", - "label": "Actual Cost", + "label": "Total Costing Amount", "oldfieldname": "actual_budget", "oldfieldtype": "Currency", "options": "Company:company:default_currency", @@ -205,6 +199,21 @@ "precision": "", "read_only": 1 }, + { + "fieldname": "column_break_20", + "fieldtype": "Column Break", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "total_billing_amount", + "fieldtype": "Currency", + "hidden": 0, + "label": "Total Billing Amount", + "permlevel": 0, + "precision": "", + "read_only": 1 + }, { "fieldname": "more_details", "fieldtype": "Section Break", @@ -248,7 +257,7 @@ "idx": 1, "istable": 0, "max_attachments": 5, - "modified": "2015-03-31 03:31:13.055284", + "modified": "2015-04-13 05:36:33.544083", "modified_by": "Administrator", "module": "Projects", "name": "Task", diff --git a/erpnext/projects/doctype/task/task.py b/erpnext/projects/doctype/task/task.py index 617809954d6..8c74edb941a 100644 --- a/erpnext/projects/doctype/task/task.py +++ b/erpnext/projects/doctype/task/task.py @@ -49,23 +49,33 @@ class Task(Document): self.total_expense_claim = frappe.db.sql("""select sum(total_sanctioned_amount) from `tabExpense Claim` where project = %s and task = %s and approval_status = "Approved" and docstatus=1""",(self.project, self.name)) - def update_actual_time_and_costing(self): - tl = frappe.db.sql("""select min(from_time) as start_date, max(to_time) as - end_date, sum(billing_amount) as cost, sum(hours) as time from `tabTime Log` where - project = %s and task = %s and docstatus=1""",(self.project, self.name),as_dict=1)[0] + def update_time_and_costing(self): + tl = frappe.db.sql("""select min(from_time) as start_date, max(to_time) as end_date, + sum(billing_amount) as total_billing_amount, sum(costing_amount) as total_costing_amount, + sum(hours) as time from `tabTime Log` where project = %s and task = %s and docstatus=1""", + (self.project, self.name),as_dict=1)[0] if self.status == "Open": self.status = "Working" - self.actual_cost= tl.cost + self.total_costing_amount= tl.total_costing_amount + self.total_billing_amount= tl.total_billing_amount self.actual_time= tl.time self.act_start_date= tl.start_date self.act_end_date= tl.end_date def update_project(self): if self.project and frappe.db.exists("Project", self.project): - total_cost = frappe.db.sql("""select sum(actual_cost) as actual_cost, sum(total_expense_claim) as expense_claim + 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.project, as_dict=1)[0] - frappe.db.set_value("Project", self.project, "total_activity_cost", total_cost.actual_cost) - frappe.db.set_value("Project", self.project, "total_expense_claim", total_cost.expense_claim) + 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() def get_events(start, end, filters=None): diff --git a/erpnext/projects/doctype/time_log/time_log.json b/erpnext/projects/doctype/time_log/time_log.json index a2852aedbab..09c4e87c330 100644 --- a/erpnext/projects/doctype/time_log/time_log.json +++ b/erpnext/projects/doctype/time_log/time_log.json @@ -16,6 +16,28 @@ "read_only": 0, "reqd": 1 }, + { + "fieldname": "column_break_2", + "fieldtype": "Column Break", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "status", + "fieldtype": "Select", + "in_list_view": 0, + "label": "Status", + "options": "Draft\nSubmitted\nBatched for Billing\nBilled\nCancelled", + "permlevel": 0, + "read_only": 1, + "reqd": 0 + }, + { + "fieldname": "section_break_4", + "fieldtype": "Section Break", + "permlevel": 0, + "precision": "" + }, { "fieldname": "from_time", "fieldtype": "Datetime", @@ -25,15 +47,6 @@ "read_only": 0, "reqd": 1 }, - { - "fieldname": "to_time", - "fieldtype": "Datetime", - "in_list_view": 0, - "label": "To Time", - "permlevel": 0, - "read_only": 0, - "reqd": 1 - }, { "default": "0", "fieldname": "hours", @@ -44,52 +57,19 @@ "read_only": 0 }, { - "fieldname": "user", - "fieldtype": "Link", - "label": "User", - "options": "User", + "fieldname": "to_time", + "fieldtype": "Datetime", + "in_list_view": 0, + "label": "To Time", "permlevel": 0, - "precision": "" + "read_only": 0, + "reqd": 1 }, { - "fieldname": "employee", - "fieldtype": "Link", - "label": "Employee", - "options": "Employee", - "permlevel": 0, - "precision": "" - }, - { - "fieldname": "column_break_3", + "fieldname": "column_break_8", "fieldtype": "Column Break", "permlevel": 0, - "read_only": 0 - }, - { - "fieldname": "status", - "fieldtype": "Select", - "in_list_view": 0, - "label": "Status", - "options": "Draft\nSubmitted\nBatched for Billing\nBilled\nCancelled", - "permlevel": 0, - "read_only": 1, - "reqd": 0 - }, - { - "fieldname": "billable", - "fieldtype": "Check", - "in_list_view": 0, - "label": "Billable", - "permlevel": 0, - "read_only": 0 - }, - { - "fieldname": "for_manufacturing", - "fieldtype": "Check", - "label": "For Manufacturing", - "permlevel": 0, - "precision": "", - "read_only": 1 + "precision": "" }, { "depends_on": "", @@ -121,6 +101,51 @@ "read_only": 0, "reqd": 0 }, + { + "fieldname": "section_break_12", + "fieldtype": "Section Break", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "user", + "fieldtype": "Link", + "label": "User", + "options": "User", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "employee", + "fieldtype": "Link", + "label": "Employee", + "options": "Employee", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "column_break_3", + "fieldtype": "Column Break", + "permlevel": 0, + "read_only": 0 + }, + { + "fieldname": "for_manufacturing", + "fieldtype": "Check", + "hidden": 1, + "label": "For Manufacturing", + "permlevel": 0, + "precision": "", + "read_only": 1 + }, + { + "fieldname": "billable", + "fieldtype": "Check", + "in_list_view": 0, + "label": "Billable", + "permlevel": 0, + "read_only": 0 + }, { "depends_on": "eval:doc.for_manufacturing", "fieldname": "section_break_11", @@ -297,11 +322,15 @@ "icon": "icon-time", "idx": 1, "is_submittable": 1, +<<<<<<< HEAD <<<<<<< 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", "module": "Projects", "name": "Time Log", diff --git a/erpnext/projects/doctype/time_log/time_log.py b/erpnext/projects/doctype/time_log/time_log.py index 34b244faf94..2018425055a 100644 --- a/erpnext/projects/doctype/time_log/time_log.py +++ b/erpnext/projects/doctype/time_log/time_log.py @@ -232,7 +232,7 @@ class TimeLog(Document): def update_task(self): task = frappe.get_doc("Task", self.task) - task.update_actual_time_and_costing() + task.update_time_and_costing() task.save() @frappe.whitelist()