alphagov/EFG — pull request #159 by olly (2013-07-23 12:13:52+00:00)
Title: Fix Realised Loans State Change Logging

We weren't logging the state change when a Realisation Statement was created and the loan's state was changed to realised.

This was causing some issues when displaying information about a realised loan (which checks the `loan_state_changes` table to see whether a loan has been realised in the past).

This is more inefficient `RealisationStatementReceived#realise_loans!` method, as it iterates all the loans selected. I think this is an acceptable trade-off as we get to use the existing API for updating state, and there are rarely many loans selected at one (average: 10, max: 58).