alphagov/EFG — pull request #139 by tjmw (2013-03-27 10:58:12+00:00)
Title: Generate correct premium schedule values for each repayment frequency

Note: Please don't merge this for now. I've been communicating with CfE regularly while working on this change and am confident in the code but I'd like for them to have a more in depth look at the results before merging.

### Description

The existing system always generates premium schedules as though the repayment frequency is monthly. For quarterly repayments this *usually* works out correctly (the two only differ in a few edge cases). For interest-only, six-monthly and annually it's incorrect.

This change implements the correct premium schedule logic for each repayment frequency. All existing premium schedules are locked into the values already generated for them (monthly). A new boolean field on the premium schedule `legacy_premium_calculation` forces the calculation to monthly when true. For new loans and reschedules of existing loans the new logic is used.

### Notes

The code has been restructured fairly significantly. The bulk of the logic used to be in the `PremiumScheduleQuarter` model. It's now mostly in `OutstandingDrawdownValue` (the complex part is working out the outstanding value of a given drawdown at a given point in time.

The test cases have grown to cover different permutations of loan repayment frequency, duration, drawdowns and payment holidays.