Changeset 12623


Ignore:
Timestamp:
18 Feb 2015, 12:36:02 (10 years ago)
Author:
Henrik Bettermann
Message:

StudentOnlinePaymentProcessor?: Raise DuplicationError? if payment
(in state paid) with same p_session and p_category exists.

See ticket Uniben #970.

Location:
main/waeup.kofa/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/CHANGES.txt

    r12569 r12623  
    441.3.2.dev0 (unreleased)
    55=======================
     6
     7* StudentOnlinePaymentProcessor: Raise DuplicationError if payment
     8  (in state paid) with same p_session and p_category exists.
    69
    710* Add new payment state 'waived'. This state can only be set by import
  • main/waeup.kofa/trunk/src/waeup/kofa/students/batching.py

    r12513 r12623  
    3838    IBatchProcessor, FatalCSVError, IObjectConverter, IUserAccount,
    3939    IObjectHistory, VALIDATED, REGISTERED, IGNORE_MARKER)
    40 from waeup.kofa.interfaces import IKofaUtils
     40from waeup.kofa.interfaces import IKofaUtils, DuplicationError
    4141from waeup.kofa.interfaces import MessageFactory as _
    4242from waeup.kofa.students.interfaces import (
     
    743743        return
    744744
     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
    745754    def addEntry(self, obj, row, site):
    746755        parent = self.getParent(row, site)
     756        student = parent.student
    747757        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.')
    748762        if len(p_id.split('-')) != 3 and not p_id.startswith('p'):
    749763            # 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
     1p_state,p_category,reg_number,p_session,r_amount_approved,p_item,amount_auth,r_card_num,r_code,creation_date,type
     2paid,schoolfee,1,2003,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
     3paid,schoolfee,1,2004,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
     4paid,schoolfee,1,2005,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
     5paid,schoolfee,1,2006,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
     6paid,schoolfee,1,2007,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
     7paid,schoolfee,1,2008,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
     8paid,schoolfee,1,2009,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
    29paid,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
     10paid,schoolfee,1,2011,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
     11paid,schoolfee,1,2012,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
     12paid,schoolfee,1,2013,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
     13paid,schoolfee,1,2014,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
     14paid,schoolfee,1,2015,19500,BTECHBDT,19500,942,0,2010/11/26 19:59:33.744 GMT+1,online
     15paid,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_current
     1matric_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
    22,paid,schoolfee,3816951290797973744#,1,2010,19500,BTECHBDT,19500,0942,00,2010/11/26 19:59:33.744 GMT+1,online,1
    33100001,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  
    3434
    3535from waeup.kofa.app import University
    36 from waeup.kofa.interfaces import IBatchProcessor, FatalCSVError, IUserAccount
     36from waeup.kofa.interfaces import (
     37    IBatchProcessor, FatalCSVError, IUserAccount, DuplicationError)
    3738from waeup.kofa.students.batching import (
    3839    StudentProcessor, StudentStudyCourseProcessor,
     
    982983        payment = createObject(u'waeup.StudentOnlinePayment')
    983984        payment.p_id = 'p120'
     985        payment.p_session = 2012
     986        payment.p_category = 'schoolfee'
     987        payment.p_state = 'paid'
    984988        self.student['payments'][payment.p_id] = payment
    985989
     
    10461050        self.assertEqual(len(self.student['payments'].keys()),3)
    10471051        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)
    10481060
    10491061    def test_checkConversion(self):
     
    11101122            'p_item=BTECHBDT, creation_date=2010-02-15 13:19:01+00:00, '
    11111123            'p_category=schoolfee, amount_auth=19500.0, p_current=True, '
     1124            'p_session=2009, '
    11121125            'p_id=p1266236341955, r_code=00, r_amount_approved=19500.0, '
    11131126            'p_state=paid'
     
    11181131            'p_item=BTECHBDT, creation_date=2010-02-15 13:19:01+00:00, '
    11191132            'p_category=schoolfee, amount_auth=19500.6, p_current=True, '
     1133            'p_session=2011, '
    11201134            'p_id=ABC-11-1234567890, r_code=SC, r_amount_approved=19500.0, '
    11211135            'p_state=paid'
     
    11531167        num, num_warns, fin_file, fail_file = self.processor.doImport(
    11541168            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)
    11581179
    11591180class StudentVerdictProcessorTest(StudentImportExportSetup):
Note: See TracChangeset for help on using the changeset viewer.