alphagov/EFG — pull request #144 by tjmw (2013-04-19 13:03:26+00:00)
Title: Generate correct premium schedule values for each repayment frequency

**Note:** This set of changes was already merged into the long running premium schedule refactoring branch via PR #139. CFE would now like to see these changes deployed to preview and production. This PR is to get these changes merged into master.

### 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.