blob: 25601b7471c645c9ed4429d03557b8840e73c817 [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
Anand Doshi486f9df2012-07-19 13:40:31 +053017from __future__ import unicode_literals
Nabin Haita6f05502011-10-12 17:04:31 +053018import unittest
19
20import webnotes
21import webnotes.profile
22webnotes.user = webnotes.profile.Profile()
23
24
Nabin Haita6f05502011-10-12 17:04:31 +053025from webnotes.model.code import get_obj
Nabin Haita6f05502011-10-12 17:04:31 +053026sql = webnotes.conn.sql
27
28from sandbox.testdata import leaves
29#----------------------------------------------------------
30
31
32class TestStockEntry(unittest.TestCase):
33 #===========================================================================
34 def setUp(self):
35 webnotes.conn.begin()
36 leaves.emp.save(new = 1, make_autoname = 0)
37
38 def test_leave_bal(self):
39 leaves.l_all.save(1)
40 leaves.l_app1.save(1)
41 leaves.l_app2.save(1)
42
43 la1 = get_obj('Leave Application', leaves.l_app1.name, with_children=1)
44 la1.validate()
45 la1.doc.docstatus = 1
46 la1.doc.save()
47
48 self.assertTrue(la1.doc.total_leave_days == 2)
49
50 la1.doc.half_day = 1
51 la1.validate()
52 la1.doc.save()
53
54 self.assertTrue(la1.doc.total_leave_days == .5)
55
56 print "Test case for leave applied no of days"
57
58
59 la2 = get_obj('Leave Application', leaves.l_app2.name, with_children=1)
60 la2.validate()
61 bal = la2.get_leave_balance()
62 self.assertTrue(bal, 18)
63 print "Test case for leave balance"
64
65
66
67
68 def tearDown(self):
69 webnotes.conn.rollback()