Changeset 12623 for main/waeup.kofa/trunk/src/waeup
- Timestamp:
- 18 Feb 2015, 12:36:02 (10 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/students
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/batching.py
r12513 r12623 38 38 IBatchProcessor, FatalCSVError, IObjectConverter, IUserAccount, 39 39 IObjectHistory, VALIDATED, REGISTERED, IGNORE_MARKER) 40 from waeup.kofa.interfaces import IKofaUtils 40 from waeup.kofa.interfaces import IKofaUtils, DuplicationError 41 41 from waeup.kofa.interfaces import MessageFactory as _ 42 42 from waeup.kofa.students.interfaces import ( … … 743 743 return 744 744 745 def samePaymentMade(self, student, category, p_session): 746 for key in student['payments'].keys(): 747 ticket = student['payments'][key] 748 if ticket.p_state == 'paid' and\ 749 ticket.p_category == category and \ 750 ticket.p_session == p_session: 751 return True 752 return False 753 745 754 def addEntry(self, obj, row, site): 746 755 parent = self.getParent(row, site) 756 student = parent.student 747 757 p_id = row['p_id'].strip('#') 758 # Requirement added on 19/02/2015: same payment must not exist. 759 #if not None in (obj.p_category, obj.p_session): 760 if self.samePaymentMade(student, obj.p_category, obj.p_session): 761 raise DuplicationError('Same payment has already been made.') 748 762 if len(p_id.split('-')) != 3 and not p_id.startswith('p'): 749 763 # For data migration from old SRP -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/sample_create_payment_data.csv
r8884 r12623 1 p_state,p_category,reg_number,session_id,r_amount_approved,p_item,amount_auth,r_card_num,r_code,creation_date,type 1 p_state,p_category,reg_number,p_session,r_amount_approved,p_item,amount_auth,r_card_num,r_code,creation_date,type 2 paid,schoolfee,1,2003,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 3 paid,schoolfee,1,2004,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 4 paid,schoolfee,1,2005,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 5 paid,schoolfee,1,2006,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 6 paid,schoolfee,1,2007,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 7 paid,schoolfee,1,2008,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 8 paid,schoolfee,1,2009,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 2 9 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 3 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 4 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 5 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 6 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 7 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 8 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 9 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 10 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 11 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 12 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 13 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 14 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 15 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 16 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 17 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 18 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 19 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 20 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 21 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 22 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 23 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 24 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 25 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 26 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 27 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 28 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 29 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 30 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 31 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 32 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 33 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 34 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 35 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 36 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 37 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 38 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 39 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 40 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 41 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 42 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 43 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 44 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 45 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 46 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 47 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 48 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 49 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 50 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 51 paid,schoolfee,1,2010,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 10 paid,schoolfee,1,2011,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 11 paid,schoolfee,1,2012,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 12 paid,schoolfee,1,2013,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 13 paid,schoolfee,1,2014,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 14 paid,schoolfee,1,2015,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online 15 paid,schoolfee,1,2015,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/sample_payment_data.csv
r11737 r12623 1 matric_number,p_state,p_category,p_id,reg_number, session_id,r_amount_approved,p_item,amount_auth,r_card_num,r_code,creation_date,type,p_current1 matric_number,p_state,p_category,p_id,reg_number,p_session,r_amount_approved,p_item,amount_auth,r_card_num,r_code,creation_date,type,p_current 2 2 ,paid,schoolfee,3816951290797973744#,1,2010,19500,BTECHBDT,19500,0942,00,2010/11/26 19:59:33.744 GMT+1,online,1 3 3 100001,unpaid,schoolfee,3816951290712593757,,2010,0,BTECHBDT,19500.1,0942,Z0,2010-11-25 20:16:33.757 WAT,online,0 -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_batching.py
r12515 r12623 34 34 35 35 from waeup.kofa.app import University 36 from waeup.kofa.interfaces import IBatchProcessor, FatalCSVError, IUserAccount 36 from waeup.kofa.interfaces import ( 37 IBatchProcessor, FatalCSVError, IUserAccount, DuplicationError) 37 38 from waeup.kofa.students.batching import ( 38 39 StudentProcessor, StudentStudyCourseProcessor, … … 982 983 payment = createObject(u'waeup.StudentOnlinePayment') 983 984 payment.p_id = 'p120' 985 payment.p_session = 2012 986 payment.p_category = 'schoolfee' 987 payment.p_state = 'paid' 984 988 self.student['payments'][payment.p_id] = payment 985 989 … … 1046 1050 self.assertEqual(len(self.student['payments'].keys()),3) 1047 1051 self.assertEqual(self.student['payments']['p560'].p_id, 'p560') 1052 # Requirement added on 19/02/2015: same payment must not exist. 1053 payment3 = createObject(u'waeup.StudentOnlinePayment') 1054 payment3.p_id = 'p456' 1055 payment3.p_session = 2012 1056 payment3.p_category = 'schoolfee' 1057 self.assertRaises( 1058 DuplicationError, self.processor.addEntry, payment3, 1059 dict(student_id=self.student.student_id, p_id='p456'), self.app) 1048 1060 1049 1061 def test_checkConversion(self): … … 1110 1122 'p_item=BTECHBDT, creation_date=2010-02-15 13:19:01+00:00, ' 1111 1123 'p_category=schoolfee, amount_auth=19500.0, p_current=True, ' 1124 'p_session=2009, ' 1112 1125 'p_id=p1266236341955, r_code=00, r_amount_approved=19500.0, ' 1113 1126 'p_state=paid' … … 1118 1131 'p_item=BTECHBDT, creation_date=2010-02-15 13:19:01+00:00, ' 1119 1132 'p_category=schoolfee, amount_auth=19500.6, p_current=True, ' 1133 'p_session=2011, ' 1120 1134 'p_id=ABC-11-1234567890, r_code=SC, r_amount_approved=19500.0, ' 1121 1135 'p_state=paid' … … 1153 1167 num, num_warns, fin_file, fail_file = self.processor.doImport( 1154 1168 self.csv_file2, PAYMENT_CREATE_HEADER_FIELDS,'create') 1155 self.assertEqual(num_warns,0) 1156 shutil.rmtree(os.path.dirname(fin_file)) 1157 self.assertEqual(len(self.app['students']['X666666']['payments']), 50) 1169 # One payment with same session and category exists 1170 self.assertEqual(num_warns,1) 1171 content = open(fail_file).read() 1172 self.assertTrue( 1173 '1,942,online,BTECHBDT,2010/11/26 19:59:33.744 GMT+1,0,' 1174 '19500,schoolfee,19500,2015,paid,' 1175 'Same payment has already been made. Skipping.' 1176 in content) 1177 shutil.rmtree(os.path.dirname(fin_file)) 1178 self.assertEqual(len(self.app['students']['X666666']['payments']), 13) 1158 1179 1159 1180 class StudentVerdictProcessorTest(StudentImportExportSetup):
Note: See TracChangeset for help on using the changeset viewer.