Merge pull request #4621 from neilLasrado/develop

Fixed time log overlap validation. Fixed test case in time log
This commit is contained in:
Nabin Hait 2016-01-19 11:13:00 +05:30
commit 4f0bfcd287
2 changed files with 4 additions and 6 deletions

View File

@ -105,7 +105,7 @@ class TestTimeLog(unittest.TestCase):
task_name = frappe.db.get_value("Task",{"project": "_Test Project 1"})
time_log = make_time_log_test_record(employee="_T-Employee-0002", hours=2,
task=task_name)
task=task_name, simulate=1)
self.assertEqual(time_log.costing_rate, 50)
self.assertEqual(time_log.costing_amount, 100)
self.assertEqual(time_log.billing_rate, 100)
@ -115,7 +115,7 @@ class TestTimeLog(unittest.TestCase):
self.assertEqual(frappe.db.get_value("Project", "_Test Project 1", "total_billing_amount"), 200)
time_log2 = make_time_log_test_record(employee="_T-Employee-0002",
hours=2, task= task_name, from_time = now_datetime() + datetime.timedelta(hours= 3))
hours=2, task= task_name, from_time = now_datetime() + datetime.timedelta(hours= 3), simulate=1)
self.assertEqual(frappe.db.get_value("Task", task_name, "total_billing_amount"), 400)
self.assertEqual(frappe.db.get_value("Project", "_Test Project 1", "total_billing_amount"), 400)

View File

@ -4,7 +4,7 @@
from __future__ import unicode_literals
import frappe
from frappe import _
from frappe.utils import cstr, flt, get_datetime, get_time, getdate
from frappe.utils import flt, get_datetime, get_time, getdate
from dateutil.relativedelta import relativedelta
from erpnext.manufacturing.doctype.manufacturing_settings.manufacturing_settings import get_mins_between_operations
@ -93,14 +93,12 @@ class TimeLog(Document):
(%(from_time)s > from_time and %(from_time)s < to_time) or
(%(from_time)s = from_time and %(to_time)s = to_time))
and name!=%(name)s
and ifnull(task, "")=%(task)s
and docstatus < 2""".format(fieldname),
{
"val": self.get(fieldname),
"from_time": self.from_time,
"to_time": self.to_time,
"name": self.name or "No Name",
"task": cstr(self.task)
"name": self.name or "No Name"
}, as_dict=True)
return existing[0] if existing else None