Ignore:
Timestamp:
5 Aug 2022, 16:34:49 (2 years ago)
Author:
Henrik Bettermann
Message:

Restructure school fee calculation completely.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.aaue/trunk/src/waeup/aaue/students/utils.py

    r16936 r17057  
    400400                    return _("You are not allowed "
    401401                             "to pay by instalments."), None
     402            # We determine the base amount first
     403            if student.entry_session < 2015:
     404                amount = getattr(certificate, 'school_fee_3', 0.0)
     405            elif student.entry_session < 2020:
     406                amount = getattr(certificate, 'school_fee_2', 0.0)
     407            else:
     408                amount = getattr(certificate, 'school_fee_1', 0.0)
    402409            if previous_session:
    403410                # Students can pay for previous sessions in all
    404411                # workflow states.  Fresh students are excluded by the
    405412                # update method of the PreviousPaymentAddFormPage.
    406                 if previous_level == 100:
    407                     amount = getattr(certificate, 'school_fee_1', 0.0)
    408                 else:
    409                     if student.entry_session in (2015, 2016):
    410                         amount = getattr(certificate, 'school_fee_2', 0.0)
    411                     else:
    412                         amount = getattr(certificate, 'school_fee_3', 0.0)
    413             elif student.state == CLEARED and category != 'schoolfee_2':
    414                 amount = getattr(certificate, 'school_fee_1', 0.0)
     413                pass
     414            elif student.state == CLEARED:
    415415                # Cut school fee by 50%
    416                 if category == 'schoolfee_1' and amount:
    417                     amount = gateway_net_amt(amount) / 2 + GATEWAY_AMT
    418             elif student.is_fresh and category == 'schoolfee_2':
    419                 amount = getattr(certificate, 'school_fee_1', 0.0)
    420                 # Cut school fee by 50%
    421                 if amount:
     416                if category in ('schoolfee_1', 'schoolfee_2') and amount:
    422417                    amount = gateway_net_amt(amount) / 2 + GATEWAY_AMT
    423418            elif student.state == RETURNING and category != 'schoolfee_2':
     
    433428                except KeyError:
    434429                    return _(u'Session configuration object is not available.'), None
    435                 if student.entry_session >= 2015:
    436                     amount = getattr(certificate, 'school_fee_2', 0.0)
    437                 else:
    438                     amount = getattr(certificate, 'school_fee_3', 0.0)
    439430                # Cut school fee by 50%
    440431                if category == 'schoolfee_1' and amount:
    441432                    amount = gateway_net_amt(amount) / 2 + GATEWAY_AMT
    442             elif category == 'schoolfee_2':
    443                 amount = getattr(certificate, 'school_fee_2', 0.0)
    444                 # Cut school fee by 50%
    445                 if amount:
    446                     amount = gateway_net_amt(amount) / 2 + GATEWAY_AMT
     433            elif category == 'schoolfee_2' and amount:
     434                amount = gateway_net_amt(amount) / 2 + GATEWAY_AMT
    447435            else:
    448436                return _('Wrong state.'), None
Note: See TracChangeset for help on using the changeset viewer.