blob: 407b0f10a282d325ffd79b11243b70cfda1ba067 [file] [log] [blame]
Rushabh Mehta3966f1d2012-02-23 12:35:32 +05301# ERPNext - web based ERP (http://erpnext.com)
2# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
3#
4# This program is free software: you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation, either version 3 of the License, or
7# (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
Nabin Haita6f05502011-10-12 17:04:31 +053017import unittest
18
19import webnotes
20import webnotes.profile
21webnotes.user = webnotes.profile.Profile()
22
23
24from webnotes.model.doc import Document
25from webnotes.model.code import get_obj
26from webnotes.utils import cstr, flt
27from webnotes.model.doclist import getlist
28sql = webnotes.conn.sql
29
30from sandbox.testdata import leaves
31#----------------------------------------------------------
32
33
34class TestStockEntry(unittest.TestCase):
35 #===========================================================================
36 def setUp(self):
37 webnotes.conn.begin()
38 leaves.emp.save(new = 1, make_autoname = 0)
39
40 def test_leave_bal(self):
41 leaves.l_all.save(1)
42 leaves.l_app1.save(1)
43 leaves.l_app2.save(1)
44
45 la1 = get_obj('Leave Application', leaves.l_app1.name, with_children=1)
46 la1.validate()
47 la1.doc.docstatus = 1
48 la1.doc.save()
49
50 self.assertTrue(la1.doc.total_leave_days == 2)
51
52 la1.doc.half_day = 1
53 la1.validate()
54 la1.doc.save()
55
56 self.assertTrue(la1.doc.total_leave_days == .5)
57
58 print "Test case for leave applied no of days"
59
60
61 la2 = get_obj('Leave Application', leaves.l_app2.name, with_children=1)
62 la2.validate()
63 bal = la2.get_leave_balance()
64 self.assertTrue(bal, 18)
65 print "Test case for leave balance"
66
67
68
69
70 def tearDown(self):
71 webnotes.conn.rollback()