PEP_CreateFixedTermFee_TDTM
PE Pathway create fixed term fee trigger handler/TDTM
Custom Permission | REDU - Admin |
Event | AfterInsert, BeforeUpdate |
Object |
PE Pathway |
Related RIO Education Settings | Prevent Fee regen with active Payments Skip PE Non-Tuition for Term - Course Use Course Fee Generation Timing |
Description
Whenever a new PE Pathway record is inserted, if the Fee Method is 'Fixed Term' (or the 'Use Course Fee Generation Timing' custom setting is enabled and the Fee Method is 'Term'), the Term Fee Status is either 'Not generated' or null and the Term Generate Fixed Term Fees field is true, this class sets the Term Fee Status to 'Generate'.
Whenever an existing PE Pathway is updated, if the Fee Method is 'Fixed Term' (or the Fee Method is 'Term' and either the 'Use Course Fee Generation Timing' custom setting is enabled or Term Fee Status is 'Regenerate'), then this class will generate the fixed term fee.
Firstly, like in the insert trigger, if the Term Fee Status is either 'Not generated' or null and the Term Generate Fixed Term Fees field is true, this class sets the Term Fee Status to 'Generate'.
If the Term Fee Status is 'Regenerate', it will find any existing Student Fees for that PE Pathway, void them, record them as historical Student Fees and mark them for deletion if they are not locked.
Then, if the Term Fee Status is either 'Generate' or 'Regenerate', this class will create a new Student Fee for the PE Pathway's Term, linking to the PE Pathway and its Enrollment, setting the Student Fee Label to be the name of the PE Pathway's related Term, setting the Due Date to the Term's Fee Due Date (or the current date if not set), and setting the Main Term Student Fee field to true. If the PE Pathway has a historical Student Fee, it will set the Historical Student Fee field to that fee's Fee Reference. If the class has unlock access, then the Student Fee is unlocked by setting Manual Unlock to true, in case the fees are being generated after the census date.
If the Fee Method is 'Fixed Term', it will create a Fee Line for the term fee using the appropriate Fee Schedule Term if the Program Enrollment's Fee field is set.
If the Fee Method is Term, the 'Skip PE Non-Tuition for Term - Course' custom setting is not enabled and the Program Enrollment's Non Tuition Fee field is set, it will also create fee lines for the non tuition fee (or any child fees).
Otherwise, if the Fee Method is 'Term', then a Fee Line will be created for each Course Connection related to the PE Pathway.
Once a fee has been generated, the Term Fee Status is set to 'Fee generated'. Historical Student Fees are deleted and any related Payments are reparented to the new Student Fee. An error will be thrown if any of the Payments have parent Disbursements as these cannot be reparented or if the 'Prevent Fee regen with active Payments' custom setting is enabled.
Use case
For an example use case of using this trigger to regenerate Student Fees, see: Regenerate Fees.