clarifying changes made for MIFOSX-1788

This commit is contained in:
Vishwas Babu A J
2015-07-23 22:30:03 -07:00
parent a3dcf36e6b
commit 39c13268f5
@@ -8,7 +8,8 @@ package org.mifosplatform.portfolio.loanaccount.domain;
import java.util.Comparator;
/**
* Sort loan transactions by transaction date and transaction type placing
* Sort loan transactions by transaction date, created date and transaction type
* placing
*/
public class LoanTransactionComparator implements Comparator<LoanTransaction> {
@@ -16,13 +17,18 @@ public class LoanTransactionComparator implements Comparator<LoanTransaction> {
public int compare(final LoanTransaction o1, final LoanTransaction o2) {
int compareResult = 0;
final int comparsion = o1.getTransactionDate().compareTo(o2.getTransactionDate());
/**
* For transactions bearing the same transaction date, we sort
* transactions based on created date (when available) after which
* sorting for waivers takes place
**/
if (comparsion == 0) {
int comparsionCreate = 0;
if (o1.getCreatedDateTime() != null && o2.getCreatedDateTime() != null){
comparsionCreate = o1.getCreatedDateTime().compareTo(o2.getCreatedDateTime());
int comparisonBasedOnCreatedDate = 0;
if (o1.getCreatedDateTime() != null && o2.getCreatedDateTime() != null) {
comparisonBasedOnCreatedDate = o1.getCreatedDateTime().compareTo(o2.getCreatedDateTime());
}
// equal transaction dates
if (comparsionCreate == 0) {
if (comparisonBasedOnCreatedDate == 0) {
if (o1.isWaiver() && o2.isNotWaiver()) {
compareResult = -1;
} else if (o1.isNotWaiver() && o2.isWaiver()) {