source: main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/students/tests/test_utils.py @ 16223

Last change on this file since 16223 was 16223, checked in by Henrik Bettermann, 4 years ago

Puuh, there are different municipal fees for fresh and returning students.

File size: 6.4 KB
Line 
1## $Id: test_utils.py 15763 2019-11-07 06:39:29Z henrik $
2##
3## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann
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 2 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, write to the Free Software
16## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17##
18import grok
19from hurry.workflow.interfaces import IWorkflowState
20from zope.component import getUtility, createObject
21from waeup.kofa.students.studylevel import StudentStudyLevel
22from waeup.kofa.students.tests.test_browser import StudentsFullSetup
23from waeup.kofa.students.interfaces import IStudentsUtils
24from waeup.kofa.students.studylevel import StudentStudyLevel
25from kofacustom.iuokada.testing import FunctionalLayer
26
27class StudentsUtilsTests(StudentsFullSetup):
28
29    layer = FunctionalLayer
30
31    def test_setMatricNumber(self):
32        IWorkflowState(self.student).setState('school fee paid')
33        site = grok.getSite()
34        utils = getUtility(IStudentsUtils)
35        site['configuration'].next_matric_integer = 21305
36        self.student.matric_number = None
37        msg, mnumber = utils.setMatricNumber(self.student)
38        self.assertEqual(self.student.matric_number, '04/021305')
39        self.assertEqual(msg, None)
40        return
41
42    def test_set_payment_details(self):
43        self.app['configuration']['2004'].book = 150.0
44        self.app['configuration']['2004'].develop = 90.0
45        self.app['configuration']['2004'].registration = 180.0
46        self.app['configuration']['2004'].municipal_fresh = 280.0
47        self.app['configuration']['2004'].pcf = 380.0
48        self.student['studycourse'].certificate.school_fee_2 = 6666.0
49        IWorkflowState(self.student).setState('cleared')
50        utils = getUtility(IStudentsUtils)
51        error, payment = utils.setPaymentDetails('schoolfee',self.student)
52        self.assertEqual(error,
53            'Registration Fee, Book Deposit, Development Fee, Fresh Students Municipal Fee, '
54            'Parents Consultative Forum (PCF) Fee must be paid before Tution Fee. '
55            'Make either single payments or make a \'Required Combi Payment\'.')
56        # A 'Required Combi Payment' is sufficient.
57        reg_payment = createObject('waeup.StudentOnlinePayment')
58        reg_payment.p_category = u'required_combi'
59        reg_payment.p_id = u'anyid'
60        reg_payment.p_state = u'paid'
61        reg_payment.p_session = 2004
62        self.student['payments']['anykey'] = reg_payment
63        error, payment = utils.setPaymentDetails('schoolfee',self.student)
64        self.assertEqual(error, None)
65        # Let's try with single payments.
66        reg_payment.p_category = u'registration'
67        error, payment = utils.setPaymentDetails('schoolfee',self.student)
68        self.assertEqual(error,
69            'Book Deposit, Development Fee, Fresh Students Municipal Fee, Parents Consultative '
70            'Forum (PCF) Fee must be paid before Tution Fee. '
71            'Make either single payments or make a \'Required Combi Payment\'.')
72        IWorkflowState(self.student).setState('returning')
73        configuration = createObject('waeup.SessionConfiguration')
74        configuration.academic_session = 2005
75        self.app['configuration'].addSessionConfiguration(configuration)
76        self.app['configuration']['2005'].registration = 170.0
77        error, payment = utils.setPaymentDetails('schoolfee',self.student)
78        self.assertEqual(error,
79            'Registration Fee, Book Deposit, Development Fee, Fresh Students Municipal Fee, '
80            'Parents Consultative Forum (PCF) Fee must be paid before Tution Fee. '
81            'Make either single payments or make a \'Required Combi Payment\'.')
82        reg_payment.p_session = 2005
83        error, payment = utils.setPaymentDetails('schoolfee',self.student)
84        self.assertEqual(error,
85            'Book Deposit, Development Fee, Fresh Students Municipal Fee, Parents Consultative '
86            'Forum (PCF) Fee must be paid before Tution Fee. '
87            'Make either single payments or make a \'Required Combi Payment\'.')
88        pcf_payment = createObject('waeup.StudentOnlinePayment')
89        pcf_payment.p_category = u'parentsconsult'
90        pcf_payment.p_id = u'anyid'
91        pcf_payment.p_state = u'paid'
92        pcf_payment.p_session = 2005
93        self.student['payments']['anykey2'] = pcf_payment
94        error, payment = utils.setPaymentDetails('schoolfee',self.student)
95        self.assertEqual(error,
96            'Book Deposit, Development Fee, Fresh Students Municipal Fee must be paid before Tution Fee. '
97            'Make either single payments or make a \'Required Combi Payment\'.')
98        munic_payment = createObject('waeup.StudentOnlinePayment')
99        munic_payment.p_category = u'municipal_fresh'
100        munic_payment.p_id = u'anyid'
101        munic_payment.p_state = u'paid'
102        munic_payment.p_session = 2005
103        self.student['payments']['anykey3'] = munic_payment
104        error, payment = utils.setPaymentDetails('schoolfee',self.student)
105        self.assertEqual(error,
106            'Book Deposit, Development Fee must be paid before Tution Fee. '
107            'Make either single payments or make a \'Required Combi Payment\'.')
108        book_payment = createObject('waeup.StudentOnlinePayment')
109        book_payment.p_category = u'book'
110        book_payment.p_id = u'anyid'
111        book_payment.p_state = u'paid'
112        book_payment.p_session = 2005
113        self.student['payments']['anykey4'] = book_payment
114        develop_payment = createObject('waeup.StudentOnlinePayment')
115        develop_payment.p_category = u'develop'
116        develop_payment.p_id = u'anyid'
117        develop_payment.p_state = u'paid'
118        develop_payment.p_session = 2005
119        self.student['payments']['anykey5'] = develop_payment
120        error, payment = utils.setPaymentDetails('schoolfee',self.student)
121        self.assertEqual(error, None)
122        self.assertEqual(payment.p_level, 200)
123        self.assertEqual(payment.p_session, 2005)
124        self.assertEqual(payment.amount_auth, 6666.0)
125        return
Note: See TracBrowser for help on using the repository browser.