Fixes in time_log
diff --git a/erpnext/projects/doctype/task/task.py b/erpnext/projects/doctype/task/task.py
index 4e29d17..fdd225d 100644
--- a/erpnext/projects/doctype/task/task.py
+++ b/erpnext/projects/doctype/task/task.py
@@ -49,6 +49,17 @@
 		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]
+		if self.status == "Open":
+			self.status = "Working"
+		self.actual_cost= tl.cost
+		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:
 			total_activity_cost = frappe.db.sql("""select sum(actual_cost) from `tabTask` 
diff --git a/erpnext/projects/doctype/time_log/test_time_log.py b/erpnext/projects/doctype/time_log/test_time_log.py
index 630962d..fad2433 100644
--- a/erpnext/projects/doctype/time_log/test_time_log.py
+++ b/erpnext/projects/doctype/time_log/test_time_log.py
@@ -85,7 +85,7 @@
 		self.assertRaises(frappe.ValidationError, test_time_log.save)
 		frappe.db.sql("delete from `tabTime Log`")
 		
-	def test_time_log_costing(self):
+	def test_total_activity_cost_for_project(self):
 		frappe.db.sql("delete from `tabTask`")
 		frappe.db.sql("delete from `tabProject`")
 		
diff --git a/erpnext/projects/doctype/time_log/time_log.js b/erpnext/projects/doctype/time_log/time_log.js
index e1fa91b..5625ff3 100644
--- a/erpnext/projects/doctype/time_log/time_log.js
+++ b/erpnext/projects/doctype/time_log/time_log.js
@@ -80,11 +80,11 @@
 	get_activity_cost(frm);
 });
 
-cur_frm.cscript.billable = function(doc) {
-	if (doc.billable==1) {
-		calculate_cost(doc);
+frappe.ui.form.on("Time Log", "billable", function(frm) {
+	if (frm.doc.billable==1) {
+		calculate_cost(frm.doc);
 	}
 	else {
-		cur_frm.set_value("billing_amount", 0);
+		frm.doc("billing_amount", 0);
 	}
-}
+});
diff --git a/erpnext/projects/doctype/time_log/time_log.json b/erpnext/projects/doctype/time_log/time_log.json
index 92ae856..a2852ae 100644
--- a/erpnext/projects/doctype/time_log/time_log.json
+++ b/erpnext/projects/doctype/time_log/time_log.json
@@ -242,7 +242,7 @@
   }, 
   {
    "default": "0", 
-   "description": "will be updated only if Time Log is 'Billable'", 
+   "description": "Will be updated only if Time Log is 'Billable'", 
    "fieldname": "billing_amount", 
    "fieldtype": "Currency", 
    "label": "Billing Amount", 
@@ -297,7 +297,11 @@
  "icon": "icon-time", 
  "idx": 1, 
  "is_submittable": 1, 
+<<<<<<< HEAD
  "modified": "2015-04-06 02:47:16.187046", 
+=======
+ "modified": "2015-04-09 08:29:34.464429", 
+>>>>>>> Fixes in time_log
  "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 fc6ae53..34b244f 100644
--- a/erpnext/projects/doctype/time_log/time_log.py
+++ b/erpnext/projects/doctype/time_log/time_log.py
@@ -217,29 +217,22 @@
 	
 	def validate_cost(self):
 		rate = get_activity_cost(self.employee, self.activity_type)
-		self.costing_rate = rate.get('costing_rate') or 0
-		self.billing_rate = rate.get('billing_rate') or 0 
-		self.costing_amount = self.costing_rate * self.hours
-		if self.billable:
-			self.billing_amount = self.billing_rate * self.hours
-		else:
-			self.billing_amount = 0
+		if rate:
+			self.costing_rate = rate.get('costing_rate')
+			self.billing_rate = rate.get('billing_rate') 
+			self.costing_amount = self.costing_rate * self.hours
+			if self.billable:
+				self.billing_amount = self.billing_rate * self.hours
+			else:
+				self.billing_amount = 0
 				
 	def validate_task(self):
 		if self.project and not self.task:
 			frappe.throw(_("Task is Mandatory if Time Log is against a project"))
 	
 	def update_task(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.task),as_dict=1)[0]
-			
 		task = frappe.get_doc("Task", self.task)
-		if task.status == "Open":
-			task.status = "Working"
-		task.actual_cost= tl.cost
-		task.actual_time= tl.time
-		task.act_start_date= tl.start_date
-		task.act_end_date= tl.end_date
+		task.update_actual_time_and_costing()
 		task.save()
 
 @frappe.whitelist()
@@ -281,7 +274,7 @@
 	
 @frappe.whitelist()
 def get_activity_cost(employee=None, activity_type=None):
-	costing_rate = frappe.db.get_value("Activity Cost", {"employee":employee,"activity_type":activity_type}, "costing_rate")
-	billing_rate = frappe.db.get_value("Activity Cost", {"employee":employee,"activity_type":activity_type}, "billing_rate")
-	return {"costing_rate": costing_rate, "billing_rate": billing_rate }
-
+	rate = frappe.db.sql("""select costing_rate, billing_rate from `tabActivity Cost` where employee= %s
+		and activity_type= %s""", (employee, activity_type), as_dict=1)
+	if rate:
+		return {"costing_rate": rate[0].costing_rate, "billing_rate": rate[0].billing_rate }