cleaning up MIFOSX-1463

This commit is contained in:
Vishwas Babu A J
2014-11-04 19:05:03 +05:30
parent 2b93590c5c
commit c5c34138a7
6 changed files with 50 additions and 23 deletions
+1
View File
@@ -8830,6 +8830,7 @@ GET https://DomainName/api/v1/loans/{loanId}/transactions/{transactionId}
5,
14
],
"manuallyReversed": false,
"currency": {
"code": "USD",
"name": "US Dollar",
@@ -44,6 +44,8 @@ public class LoanTransactionData {
@SuppressWarnings("unused")
private final LocalDate submittedOnDate;
private final boolean manuallyReversed;
// templates
final Collection<CodeValueData> paymentTypeOptions;
@@ -54,7 +56,9 @@ public class LoanTransactionData {
loanTransactionData.amount, loanTransactionData.principalPortion, loanTransactionData.interestPortion,
loanTransactionData.feeChargesPortion, loanTransactionData.penaltyChargesPortion, loanTransactionData.overpaymentPortion,
loanTransactionData.unrecognizedIncomePortion, paymentTypeOptions, loanTransactionData.externalId,
loanTransactionData.transfer, loanTransactionData.fixedEmiAmount, loanTransactionData.outstandingLoanBalance);
loanTransactionData.transfer, loanTransactionData.fixedEmiAmount, loanTransactionData.outstandingLoanBalance,
loanTransactionData.manuallyReversed);
}
public LoanTransactionData(final Long id, final Long officeId, final String officeName, final LoanTransactionEnumData transactionType,
@@ -62,10 +66,10 @@ public class LoanTransactionData {
final BigDecimal principalPortion, final BigDecimal interestPortion, final BigDecimal feeChargesPortion,
final BigDecimal penaltyChargesPortion, final BigDecimal overpaymentPortion, final String externalId,
final AccountTransferData transfer, BigDecimal fixedEmiAmount, BigDecimal outstandingLoanBalance,
final BigDecimal unrecognizedIncomePortion) {
final BigDecimal unrecognizedIncomePortion,final boolean manuallyReversed) {
this(id, officeId, officeName, transactionType, paymentDetailData, currency, date, amount, principalPortion, interestPortion,
feeChargesPortion, penaltyChargesPortion, overpaymentPortion, unrecognizedIncomePortion, null, externalId, transfer,
fixedEmiAmount, outstandingLoanBalance);
fixedEmiAmount, outstandingLoanBalance,manuallyReversed);
}
public LoanTransactionData(final Long id, final Long officeId, final String officeName, final LoanTransactionEnumData transactionType,
@@ -73,10 +77,10 @@ public class LoanTransactionData {
final BigDecimal principalPortion, final BigDecimal interestPortion, final BigDecimal feeChargesPortion,
final BigDecimal penaltyChargesPortion, final BigDecimal overpaymentPortion, BigDecimal unrecognizedIncomePortion,
final Collection<CodeValueData> paymentTypeOptions, final String externalId, final AccountTransferData transfer,
final BigDecimal fixedEmiAmount, BigDecimal outstandingLoanBalance) {
final BigDecimal fixedEmiAmount, BigDecimal outstandingLoanBalance,boolean manuallyReversed) {
this(id, officeId, officeName, transactionType, paymentDetailData, currency, date, amount, principalPortion, interestPortion,
feeChargesPortion, penaltyChargesPortion, overpaymentPortion, unrecognizedIncomePortion, paymentTypeOptions, externalId,
transfer, fixedEmiAmount, outstandingLoanBalance, null);
transfer, fixedEmiAmount, outstandingLoanBalance, null,manuallyReversed);
}
public LoanTransactionData(final Long id, final Long officeId, final String officeName, final LoanTransactionEnumData transactionType,
@@ -84,10 +88,10 @@ public class LoanTransactionData {
final BigDecimal principalPortion, final BigDecimal interestPortion, final BigDecimal feeChargesPortion,
final BigDecimal penaltyChargesPortion, final BigDecimal overpaymentPortion, final BigDecimal unrecognizedIncomePortion,
final String externalId, final AccountTransferData transfer, BigDecimal fixedEmiAmount, BigDecimal outstandingLoanBalance,
LocalDate submittedOnDate) {
LocalDate submittedOnDate,final boolean manuallyReversed) {
this(id, officeId, officeName, transactionType, paymentDetailData, currency, date, amount, principalPortion, interestPortion,
feeChargesPortion, penaltyChargesPortion, overpaymentPortion, unrecognizedIncomePortion, null, externalId, transfer,
fixedEmiAmount, outstandingLoanBalance, submittedOnDate);
fixedEmiAmount, outstandingLoanBalance, submittedOnDate,manuallyReversed);
}
public LoanTransactionData(final Long id, final Long officeId, final String officeName, final LoanTransactionEnumData transactionType,
@@ -95,7 +99,7 @@ public class LoanTransactionData {
final BigDecimal principalPortion, final BigDecimal interestPortion, final BigDecimal feeChargesPortion,
final BigDecimal penaltyChargesPortion, final BigDecimal overpaymentPortion, final BigDecimal unrecognizedIncomePortion,
final Collection<CodeValueData> paymentTypeOptions, final String externalId, final AccountTransferData transfer,
final BigDecimal fixedEmiAmount, BigDecimal outstandingLoanBalance, final LocalDate submittedOnDate) {
final BigDecimal fixedEmiAmount, BigDecimal outstandingLoanBalance, final LocalDate submittedOnDate,final boolean manuallyReversed) {
this.id = id;
this.officeId = officeId;
this.officeName = officeName;
@@ -116,13 +120,14 @@ public class LoanTransactionData {
this.fixedEmiAmount = fixedEmiAmount;
this.outstandingLoanBalance = outstandingLoanBalance;
this.submittedOnDate = submittedOnDate;
this.manuallyReversed = manuallyReversed;
}
public LoanTransactionData(Long id, LoanTransactionEnumData transactionType, LocalDate date, BigDecimal totalAmount,
BigDecimal principalPortion, BigDecimal interestPortion, BigDecimal feeChargesPortion, BigDecimal penaltyChargesPortion,
BigDecimal overPaymentPortion, BigDecimal unrecognizedIncomePortion, BigDecimal outstandingLoanBalance) {
BigDecimal overPaymentPortion, BigDecimal unrecognizedIncomePortion, BigDecimal outstandingLoanBalance,final boolean manuallyReversed) {
this(id, null, null, transactionType, null, null, date, totalAmount, principalPortion, interestPortion, feeChargesPortion,
penaltyChargesPortion, overPaymentPortion, unrecognizedIncomePortion, null, null, null, null, outstandingLoanBalance, null);
penaltyChargesPortion, overPaymentPortion, unrecognizedIncomePortion, null, null, null, null, outstandingLoanBalance, null,manuallyReversed);
}
public LocalDate dateOf() {
@@ -2880,6 +2880,7 @@ public class Loan extends AbstractPersistable<Long> {
}
transactionForAdjustment.reverse();
transactionForAdjustment.manuallyAdjustedOrReversed();
if (isClosedWrittenOff()) {
// find write off transaction and reverse it
@@ -106,6 +106,9 @@ public final class LoanTransaction extends AbstractPersistable<Long> {
@Column(name = "outstanding_loan_balance_derived", scale = 6, precision = 19, nullable = true)
private BigDecimal outstandingLoanBalance;
@Column(name = "manually_adjusted_or_reversed", nullable = false)
private boolean manuallyAdjustedOrReversed;
protected LoanTransaction() {
this.loan = null;
this.dateOf = null;
@@ -504,7 +507,7 @@ public final class LoanTransaction extends AbstractPersistable<Long> {
return new LoanTransactionData(getId(), this.office.getId(), this.office.getName(), transactionType, paymentDetailData,
currencyData, getTransactionDate(), this.amount, this.principalPortion, this.interestPortion, this.feeChargesPortion,
this.penaltyChargesPortion, this.overPaymentPortion, this.externalId, transfer, null, outstandingLoanBalance,
unrecognizedIncomePortion);
this.unrecognizedIncomePortion, this.manuallyAdjustedOrReversed);
}
public Map<String, Object> toMapData(final CurrencyData currencyData) {
@@ -578,4 +581,15 @@ public final class LoanTransaction extends AbstractPersistable<Long> {
this.outstandingLoanBalance = outstandingLoanBalance;
}
public boolean isManuallyAdjustedOrReversed() {
return this.manuallyAdjustedOrReversed;
}
public boolean isNotManuallyAdjustedOrReversed() {
return !this.manuallyAdjustedOrReversed;
}
public void manuallyAdjustedOrReversed() {
this.manuallyAdjustedOrReversed = true;
}
}
@@ -207,7 +207,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
/*** TODO Vishwas: Remove references to "Contra" from the codebase ***/
final String sql = "select "
+ rm.LoanPaymentsSchema()
+ " where tr.loan_id = ? and tr.transaction_type_enum not in (0, 3) and tr.is_reversed=0 order by tr.transaction_date ASC,id ";
+ " where tr.loan_id = ? and tr.transaction_type_enum not in (0, 3) and (tr.is_reversed=0 or tr.manually_adjusted_or_reversed = 1) order by tr.transaction_date ASC,id ";
return this.jdbcTemplate.query(sql, rm, new Object[] { loanId });
} catch (final EmptyResultDataAccessException e) {
return null;
@@ -369,7 +369,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
.getPrincipalOutstanding(currency).getAmount(), loanRepaymentScheduleInstallment.getInterestOutstanding(currency)
.getAmount(), loanRepaymentScheduleInstallment.getFeeChargesOutstanding(currency).getAmount(),
loanRepaymentScheduleInstallment.getPenaltyChargesOutstanding(currency).getAmount(), null, unrecognizedIncomePortion,
paymentOptions, null, null, null, outstandingLoanBalance);
paymentOptions, null, null, null, outstandingLoanBalance,false);
}
@Override
@@ -398,7 +398,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
.getPrincipalOutstanding(currency).getAmount(), loanRepaymentScheduleInstallment.getInterestOutstanding(currency)
.getAmount(), loanRepaymentScheduleInstallment.getFeeChargesOutstanding(currency).getAmount(),
loanRepaymentScheduleInstallment.getPenaltyChargesOutstanding(currency).getAmount(), null, unrecognizedIncomePortion,
paymentOptions, null, null, null, outstandingLoanBalance);
paymentOptions, null, null, null, outstandingLoanBalance,false);
}
@Override
@@ -424,7 +424,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
final BigDecimal outstandingLoanBalance = null;
final BigDecimal unrecognizedIncomePortion = null;
return new LoanTransactionData(null, null, null, transactionType, null, currencyData, waiveOfInterest.getTransactionDate(), amount,
null, null, null, null, null, null, null, null, outstandingLoanBalance, unrecognizedIncomePortion);
null, null, null, null, null, null, null, null, outstandingLoanBalance, unrecognizedIncomePortion,false);
}
@Override
@@ -435,7 +435,8 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
final LoanTransactionEnumData transactionType = LoanEnumerations.transactionType(LoanTransactionType.WRITEOFF);
final BigDecimal unrecognizedIncomePortion = null;
return new LoanTransactionData(null, null, null, transactionType, null, null, DateUtils.getLocalDateOfTenant(), null, null, null,
null, null, null, null, null, null, outstandingLoanBalance, unrecognizedIncomePortion);
null, null, null, null, null, null, outstandingLoanBalance, unrecognizedIncomePortion,false);
}
@Override
@@ -451,7 +452,8 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
final BigDecimal unrecognizedIncomePortion = null;
return new LoanTransactionData(null, null, null, transactionType, null, null, loan.getExpectedDisbursedOnLocalDateForTemplate(),
loan.getDisburseAmountForTemplate(), null, null, null, null, null, unrecognizedIncomePortion, paymentOptions, null, null,
loan.retriveLastEmiAmount(), outstandingLoanBalance);
loan.retriveLastEmiAmount(), outstandingLoanBalance,false);
}
@Override
@@ -1072,6 +1074,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
+ " tr.overpayment_portion_derived as overpayment, tr.outstanding_loan_balance_derived as outstandingLoanBalance, "
+ " tr.unrecognized_income_portion as unrecognizedIncome,"
+ " tr.submitted_on_date as submittedOnDate, "
+ " tr.manually_adjusted_or_reversed as manuallyReversed, "
+ " pd.payment_type_cv_id as paymentType,pd.account_number as accountNumber,pd.check_number as checkNumber, "
+ " pd.receipt_number as receiptNumber, pd.bank_number as bankNumber,pd.routing_code as routingCode, "
+ " l.currency_code as currencyCode, l.currency_digits as currencyDigits, l.currency_multiplesof as inMultiplesOf, rc.`name` as currencyName, "
@@ -1108,6 +1111,8 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
final String officeName = rs.getString("officeName");
final int transactionTypeInt = JdbcSupport.getInteger(rs, "transactionType");
final LoanTransactionEnumData transactionType = LoanEnumerations.transactionType(transactionTypeInt);
final boolean manuallyReversed = rs.getBoolean("manuallyReversed");
PaymentDetailData paymentDetailData = null;
@@ -1157,10 +1162,9 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
transfer = AccountTransferData.transferBasicDetails(toTransferId, currencyData, toTransferAmount, toTransferDate,
toTransferDescription, toTransferReversed);
}
return new LoanTransactionData(id, officeId, officeName, transactionType, paymentDetailData, currencyData, date, totalAmount,
principalPortion, interestPortion, feeChargesPortion, penaltyChargesPortion, overPaymentPortion,
unrecognizedIncomePortion, externalId, transfer, null, outstandingLoanBalance, submittedOnDate);
unrecognizedIncomePortion, externalId, transfer, null, outstandingLoanBalance, submittedOnDate,manuallyReversed);
}
}
@@ -1579,7 +1583,8 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
BigDecimal outstandingLoanBalance = null;
final BigDecimal unrecognizedIncomePortion = null;
return new LoanTransactionData(null, null, null, transactionType, null, null, null, loan.getTotalWrittenOff(), null, null, null,
null, null, unrecognizedIncomePortion, paymentOptions, null, null, null, outstandingLoanBalance);
null, null, unrecognizedIncomePortion, paymentOptions, null, null, null, outstandingLoanBalance,false);
}
@@ -1592,7 +1597,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
final BigDecimal unrecognizedIncomePortion = null;
return new LoanTransactionData(null, null, null, transactionType, null, loan.currency(), DateUtils.getLocalDateOfTenant(),
loan.getTotalOutstandingAmount(), null, null, null, null, null, null, null, null, outstandingLoanBalance,
unrecognizedIncomePortion);
unrecognizedIncomePortion,false);
}
@Override
@@ -1660,7 +1665,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
final BigDecimal outstandingLoanBalance = JdbcSupport.getBigDecimalDefaultToZeroIfNull(rs, "outstandingLoanBalance");
return new LoanTransactionData(id, transactionType, date, totalAmount, principalPortion, interestPortion, feeChargesPortion,
penaltyChargesPortion, overPaymentPortion, unrecognizedIncomePortion, outstandingLoanBalance);
penaltyChargesPortion, overPaymentPortion, unrecognizedIncomePortion, outstandingLoanBalance,false);
}
}
@@ -1742,7 +1747,6 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
totalPaid, totalPaidInAdvanceForPeriod, totalPaidLateForPeriod, totalWaived, totalWrittenOff, totalOutstanding,
totalActualCostOfLoanForPeriod);
}
}
}
@@ -0,0 +1,2 @@
Alter table m_loan_transaction
Add column manually_adjusted_or_reversed tinyint(1) default 0;