Re-factor LoanGroupSets

Re-factor to use a single class to group loans (and child objects) by the loan type.

Also fixes a bug where grouping, and then saving the loan would set the
lending limits phase_id incorrectly. Caused by an assignment (=) instead
of a comparison (==).