alphagov/EFG — pull request #147 by tjmw (2013-04-26 10:57:45+00:00)
Title: Fix issue with displaying total_subsequent_premiums for a loan

It's possible for a loan to have no subsequent premium payments (if it's not a reschedule and the loan term is less than or equal to the repayment frequency).

In this case Loan#subsequent_premiums will return an empty array. Loan#total_subsequent_premiums then calls sum on the array which in Rails returns 0. We expect the sum to be a Money object and call format on it downstream, which raises an exception.

This change ensures Loan#total_subsequent_premiums always returns a Money object (in this case representing 0).