blob: 52715eca634747c7ead414f507fe9fc2fba8f0ec [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
25from webnotes.model.doc import Document
26from webnotes.model.code import get_obj
27from webnotes.utils import cstr, flt
28from webnotes.model.doclist import getlist
29sql = webnotes.conn.sql
30
31from sandbox.testdata import leaves
32#----------------------------------------------------------
33
34
35class TestStockEntry(unittest.TestCase):
36 #===========================================================================
37 def setUp(self):
38 webnotes.conn.begin()
39 leaves.emp.save(new = 1, make_autoname = 0)
40
41 def test_leave_bal(self):
42 leaves.l_all.save(1)
43 leaves.l_app1.save(1)
44 leaves.l_app2.save(1)
45
46 la1 = get_obj('Leave Application', leaves.l_app1.name, with_children=1)
47 la1.validate()
48 la1.doc.docstatus = 1
49 la1.doc.save()
50
51 self.assertTrue(la1.doc.total_leave_days == 2)
52
53 la1.doc.half_day = 1
54 la1.validate()
55 la1.doc.save()
56
57 self.assertTrue(la1.doc.total_leave_days == .5)
58
59 print "Test case for leave applied no of days"
60
61
62 la2 = get_obj('Leave Application', leaves.l_app2.name, with_children=1)
63 la2.validate()
64 bal = la2.get_leave_balance()
65 self.assertTrue(bal, 18)
66 print "Test case for leave balance"
67
68
69
70
71 def tearDown(self):
72 webnotes.conn.rollback()