FINERACT-1724: Added loan external ID into transaction events

This commit is contained in:
Arnold Galovics
2022-11-07 17:49:40 +01:00
committed by Arnold Gálovics
parent 24efd6da1c
commit aa7747c5ce
4 changed files with 58 additions and 35 deletions
@@ -19,6 +19,14 @@
"long" "long"
] ]
}, },
{
"default": null,
"name": "externalLoanId",
"type": [
"null",
"string"
]
},
{ {
"default": null, "default": null,
"name": "officeId", "name": "officeId",
@@ -37,6 +37,7 @@ public class LoanTransactionData {
private final Long id; private final Long id;
private final Long loanId; private final Long loanId;
private final String externalLoanId;
private final Long officeId; private final Long officeId;
private final String officeName; private final String officeName;
@@ -113,6 +114,7 @@ public class LoanTransactionData {
this.type = null; this.type = null;
this.id = null; this.id = null;
this.loanId = null; this.loanId = null;
this.externalLoanId = null;
this.officeId = null; this.officeId = null;
this.officeName = null; this.officeName = null;
this.currency = null; this.currency = null;
@@ -159,6 +161,7 @@ public class LoanTransactionData {
this.locale = locale; this.locale = locale;
this.id = null; this.id = null;
this.loanId = null; this.loanId = null;
this.externalLoanId = null;
this.officeId = null; this.officeId = null;
this.officeName = null; this.officeName = null;
this.type = null; this.type = null;
@@ -200,7 +203,8 @@ public class LoanTransactionData {
loanTransactionData.interestPortion, loanTransactionData.feeChargesPortion, loanTransactionData.penaltyChargesPortion, loanTransactionData.interestPortion, loanTransactionData.feeChargesPortion, loanTransactionData.penaltyChargesPortion,
loanTransactionData.overpaymentPortion, loanTransactionData.unrecognizedIncomePortion, paymentTypeOptions, loanTransactionData.overpaymentPortion, loanTransactionData.unrecognizedIncomePortion, paymentTypeOptions,
loanTransactionData.externalId, loanTransactionData.transfer, loanTransactionData.fixedEmiAmount, loanTransactionData.externalId, loanTransactionData.transfer, loanTransactionData.fixedEmiAmount,
loanTransactionData.outstandingLoanBalance, loanTransactionData.manuallyReversed, loanTransactionData.loanId); loanTransactionData.outstandingLoanBalance, loanTransactionData.manuallyReversed, loanTransactionData.loanId,
loanTransactionData.externalLoanId);
} }
@@ -209,10 +213,10 @@ public class LoanTransactionData {
final BigDecimal netDisbursalAmount, final BigDecimal principalPortion, final BigDecimal interestPortion, final BigDecimal netDisbursalAmount, final BigDecimal principalPortion, final BigDecimal interestPortion,
final BigDecimal feeChargesPortion, final BigDecimal penaltyChargesPortion, final BigDecimal overpaymentPortion, final BigDecimal feeChargesPortion, final BigDecimal penaltyChargesPortion, final BigDecimal overpaymentPortion,
final String externalId, final AccountTransferData transfer, BigDecimal fixedEmiAmount, BigDecimal outstandingLoanBalance, final String externalId, final AccountTransferData transfer, BigDecimal fixedEmiAmount, BigDecimal outstandingLoanBalance,
final BigDecimal unrecognizedIncomePortion, final boolean manuallyReversed, Long loanId) { final BigDecimal unrecognizedIncomePortion, final boolean manuallyReversed, Long loanId, String externalLoanId) {
this(id, officeId, officeName, transactionType, paymentDetailData, currency, date, amount, netDisbursalAmount, principalPortion, this(id, officeId, officeName, transactionType, paymentDetailData, currency, date, amount, netDisbursalAmount, principalPortion,
interestPortion, feeChargesPortion, penaltyChargesPortion, overpaymentPortion, unrecognizedIncomePortion, null, externalId, interestPortion, feeChargesPortion, penaltyChargesPortion, overpaymentPortion, unrecognizedIncomePortion, null, externalId,
transfer, fixedEmiAmount, outstandingLoanBalance, manuallyReversed, loanId); transfer, fixedEmiAmount, outstandingLoanBalance, manuallyReversed, loanId, externalLoanId);
} }
public LoanTransactionData(final Long id, final Long officeId, final String officeName, final LoanTransactionEnumData transactionType, public LoanTransactionData(final Long id, final Long officeId, final String officeName, final LoanTransactionEnumData transactionType,
@@ -221,10 +225,11 @@ public class LoanTransactionData {
final BigDecimal feeChargesPortion, final BigDecimal penaltyChargesPortion, final BigDecimal overpaymentPortion, final BigDecimal feeChargesPortion, final BigDecimal penaltyChargesPortion, final BigDecimal overpaymentPortion,
BigDecimal unrecognizedIncomePortion, final Collection<PaymentTypeData> paymentTypeOptions, final String externalId, BigDecimal unrecognizedIncomePortion, final Collection<PaymentTypeData> paymentTypeOptions, final String externalId,
final AccountTransferData transfer, final BigDecimal fixedEmiAmount, BigDecimal outstandingLoanBalance, final AccountTransferData transfer, final BigDecimal fixedEmiAmount, BigDecimal outstandingLoanBalance,
boolean manuallyReversed, Long loanId) { boolean manuallyReversed, Long loanId, String externalLoanId) {
this(id, loanId, officeId, officeName, transactionType, paymentDetailData, currency, date, amount, netDisbursalAmount, this(id, externalLoanId, officeId, officeName, transactionType, paymentDetailData, currency, date, amount, netDisbursalAmount,
principalPortion, interestPortion, feeChargesPortion, penaltyChargesPortion, overpaymentPortion, unrecognizedIncomePortion, principalPortion, interestPortion, feeChargesPortion, penaltyChargesPortion, overpaymentPortion, unrecognizedIncomePortion,
paymentTypeOptions, externalId, transfer, fixedEmiAmount, outstandingLoanBalance, null, manuallyReversed, null, null); paymentTypeOptions, externalId, transfer, fixedEmiAmount, outstandingLoanBalance, null, manuallyReversed, null, null,
loanId);
} }
public LoanTransactionData(final Long id, final Long officeId, final String officeName, final LoanTransactionEnumData transactionType, public LoanTransactionData(final Long id, final Long officeId, final String officeName, final LoanTransactionEnumData transactionType,
@@ -233,23 +238,24 @@ public class LoanTransactionData {
final BigDecimal feeChargesPortion, final BigDecimal penaltyChargesPortion, final BigDecimal overpaymentPortion, final BigDecimal feeChargesPortion, final BigDecimal penaltyChargesPortion, final BigDecimal overpaymentPortion,
final BigDecimal unrecognizedIncomePortion, final String externalId, final AccountTransferData transfer, final BigDecimal unrecognizedIncomePortion, final String externalId, final AccountTransferData transfer,
BigDecimal fixedEmiAmount, BigDecimal outstandingLoanBalance, LocalDate submittedOnDate, final boolean manuallyReversed, BigDecimal fixedEmiAmount, BigDecimal outstandingLoanBalance, LocalDate submittedOnDate, final boolean manuallyReversed,
final String reversalExternalId, final LocalDate reversedOnDate, Long loanId) { final String reversalExternalId, final LocalDate reversedOnDate, Long loanId, String externalLoanId) {
this(id, loanId, officeId, officeName, transactionType, paymentDetailData, currency, date, amount, netDisbursalAmount, this(id, externalLoanId, officeId, officeName, transactionType, paymentDetailData, currency, date, amount, netDisbursalAmount,
principalPortion, interestPortion, feeChargesPortion, penaltyChargesPortion, overpaymentPortion, unrecognizedIncomePortion, principalPortion, interestPortion, feeChargesPortion, penaltyChargesPortion, overpaymentPortion, unrecognizedIncomePortion,
null, externalId, transfer, fixedEmiAmount, outstandingLoanBalance, submittedOnDate, manuallyReversed, reversalExternalId, null, externalId, transfer, fixedEmiAmount, outstandingLoanBalance, submittedOnDate, manuallyReversed, reversalExternalId,
reversedOnDate); reversedOnDate, loanId);
} }
public LoanTransactionData(final Long id, Long loanId, final Long officeId, final String officeName, public LoanTransactionData(final Long id, final String externalLoanId, final Long officeId, final String officeName,
final LoanTransactionEnumData transactionType, final PaymentDetailData paymentDetailData, final CurrencyData currency, final LoanTransactionEnumData transactionType, final PaymentDetailData paymentDetailData, final CurrencyData currency,
final LocalDate date, final BigDecimal amount, final BigDecimal netDisbursalAmount, final BigDecimal principalPortion, final LocalDate date, final BigDecimal amount, final BigDecimal netDisbursalAmount, final BigDecimal principalPortion,
final BigDecimal interestPortion, final BigDecimal feeChargesPortion, final BigDecimal penaltyChargesPortion, final BigDecimal interestPortion, final BigDecimal feeChargesPortion, final BigDecimal penaltyChargesPortion,
final BigDecimal overpaymentPortion, final BigDecimal unrecognizedIncomePortion, final BigDecimal overpaymentPortion, final BigDecimal unrecognizedIncomePortion,
final Collection<PaymentTypeData> paymentTypeOptions, final String externalId, final AccountTransferData transfer, final Collection<PaymentTypeData> 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, final String reversalExternalId, final LocalDate reversedOnDate) { final boolean manuallyReversed, final String reversalExternalId, final LocalDate reversedOnDate, Long loanId) {
this.id = id; this.id = id;
this.loanId = loanId; this.loanId = loanId;
this.externalLoanId = externalLoanId;
this.officeId = officeId; this.officeId = officeId;
this.officeName = officeName; this.officeName = officeName;
this.type = transactionType; this.type = transactionType;
@@ -279,10 +285,10 @@ public class LoanTransactionData {
public LoanTransactionData(Long id, LoanTransactionEnumData transactionType, LocalDate date, BigDecimal totalAmount, public LoanTransactionData(Long id, LoanTransactionEnumData transactionType, LocalDate date, BigDecimal totalAmount,
BigDecimal netDisbursalAmount, BigDecimal principalPortion, BigDecimal interestPortion, BigDecimal feeChargesPortion, BigDecimal netDisbursalAmount, BigDecimal principalPortion, BigDecimal interestPortion, BigDecimal feeChargesPortion,
BigDecimal penaltyChargesPortion, BigDecimal overpaymentPortion, BigDecimal unrecognizedIncomePortion, BigDecimal penaltyChargesPortion, BigDecimal overpaymentPortion, BigDecimal unrecognizedIncomePortion,
BigDecimal outstandingLoanBalance, final boolean manuallyReversed, Long loanId) { BigDecimal outstandingLoanBalance, final boolean manuallyReversed, Long loanId, String externalLoanId) {
this(id, loanId, null, null, transactionType, null, null, date, totalAmount, netDisbursalAmount, principalPortion, interestPortion, this(id, externalLoanId, null, null, transactionType, null, null, date, totalAmount, netDisbursalAmount, principalPortion,
feeChargesPortion, penaltyChargesPortion, overpaymentPortion, unrecognizedIncomePortion, null, null, null, null, interestPortion, feeChargesPortion, penaltyChargesPortion, overpaymentPortion, unrecognizedIncomePortion, null, null, null,
outstandingLoanBalance, null, manuallyReversed, null, null); null, outstandingLoanBalance, null, manuallyReversed, null, null, loanId);
} }
public static LoanTransactionData loanTransactionDataForDisbursalTemplate(final LoanTransactionEnumData transactionType, public static LoanTransactionData loanTransactionDataForDisbursalTemplate(final LoanTransactionEnumData transactionType,
@@ -291,6 +297,7 @@ public class LoanTransactionData {
final LocalDate possibleNextRepaymentDate) { final LocalDate possibleNextRepaymentDate) {
final Long id = null; final Long id = null;
final Long loanId = null; final Long loanId = null;
final String externalLoanId = null;
final Long officeId = null; final Long officeId = null;
final String officeName = null; final String officeName = null;
final PaymentDetailData paymentDetailData = null; final PaymentDetailData paymentDetailData = null;
@@ -306,22 +313,24 @@ public class LoanTransactionData {
final AccountTransferData transfer = null; final AccountTransferData transfer = null;
final LocalDate submittedOnDate = null; final LocalDate submittedOnDate = null;
final boolean manuallyReversed = false; final boolean manuallyReversed = false;
return new LoanTransactionData(id, loanId, officeId, officeName, transactionType, paymentDetailData, currency, return new LoanTransactionData(id, officeId, officeName, transactionType, paymentDetailData, currency,
expectedDisbursedOnLocalDateForTemplate, disburseAmountForTemplate, netDisbursalAmount, principalPortion, interestPortion, expectedDisbursedOnLocalDateForTemplate, disburseAmountForTemplate, netDisbursalAmount, principalPortion, interestPortion,
feeChargesPortion, penaltyChargesPortion, overpaymentPortion, unrecognizedIncomePortion, paymentOptions, transfer, feeChargesPortion, penaltyChargesPortion, overpaymentPortion, unrecognizedIncomePortion, paymentOptions, transfer,
externalId, retriveLastEmiAmount, outstandingLoanBalance, submittedOnDate, manuallyReversed, possibleNextRepaymentDate); externalId, retriveLastEmiAmount, outstandingLoanBalance, submittedOnDate, manuallyReversed, possibleNextRepaymentDate,
loanId, externalLoanId);
} }
private LoanTransactionData(Long id, Long loanId, final Long officeId, final String officeName, LoanTransactionEnumData transactionType, private LoanTransactionData(Long id, final Long officeId, final String officeName, LoanTransactionEnumData transactionType,
final PaymentDetailData paymentDetailData, final CurrencyData currency, final LocalDate date, BigDecimal amount, final PaymentDetailData paymentDetailData, final CurrencyData currency, final LocalDate date, BigDecimal amount,
BigDecimal netDisbursalAmount, final BigDecimal principalPortion, final BigDecimal interestPortion, BigDecimal netDisbursalAmount, final BigDecimal principalPortion, final BigDecimal interestPortion,
final BigDecimal feeChargesPortion, final BigDecimal penaltyChargesPortion, final BigDecimal overpaymentPortion, final BigDecimal feeChargesPortion, final BigDecimal penaltyChargesPortion, final BigDecimal overpaymentPortion,
BigDecimal unrecognizedIncomePortion, Collection<PaymentTypeData> paymentOptions, final AccountTransferData transfer, BigDecimal unrecognizedIncomePortion, Collection<PaymentTypeData> paymentOptions, final AccountTransferData transfer,
final String externalId, final BigDecimal fixedEmiAmount, BigDecimal outstandingLoanBalance, final LocalDate submittedOnDate, final String externalId, final BigDecimal fixedEmiAmount, BigDecimal outstandingLoanBalance, final LocalDate submittedOnDate,
final boolean manuallyReversed, final LocalDate possibleNextRepaymentDate) { final boolean manuallyReversed, final LocalDate possibleNextRepaymentDate, Long loanId, String externalLoanId) {
this.id = id; this.id = id;
this.loanId = loanId; this.loanId = loanId;
this.externalLoanId = externalLoanId;
this.officeId = officeId; this.officeId = officeId;
this.officeName = officeName; this.officeName = officeName;
this.type = transactionType; this.type = transactionType;
@@ -673,7 +673,8 @@ public class LoanTransaction extends AbstractAuditableWithUTCDateTimeCustom {
return new LoanTransactionData(getId(), this.office.getId(), this.office.getName(), transactionType, paymentDetailData, return new LoanTransactionData(getId(), this.office.getId(), this.office.getName(), transactionType, paymentDetailData,
currencyData, getTransactionDate(), this.amount, this.loan.getNetDisbursalAmount(), this.principalPortion, currencyData, getTransactionDate(), this.amount, this.loan.getNetDisbursalAmount(), this.principalPortion,
this.interestPortion, this.feeChargesPortion, this.penaltyChargesPortion, this.overPaymentPortion, this.externalId, this.interestPortion, this.feeChargesPortion, this.penaltyChargesPortion, this.overPaymentPortion, this.externalId,
transfer, null, outstandingLoanBalance, this.unrecognizedIncomePortion, this.manuallyAdjustedOrReversed, this.loan.getId()); transfer, null, outstandingLoanBalance, this.unrecognizedIncomePortion, this.manuallyAdjustedOrReversed, this.loan.getId(),
this.loan.getExternalId());
} }
public Map<String, Object> toMapData(final String currencyCode) { public Map<String, Object> toMapData(final String currencyCode) {
@@ -459,7 +459,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
loanRepaymentScheduleInstallment.getInterestOutstanding(currency).getAmount(), loanRepaymentScheduleInstallment.getInterestOutstanding(currency).getAmount(),
loanRepaymentScheduleInstallment.getFeeChargesOutstanding(currency).getAmount().subtract(adjustedChargeAmount), loanRepaymentScheduleInstallment.getFeeChargesOutstanding(currency).getAmount().subtract(adjustedChargeAmount),
loanRepaymentScheduleInstallment.getPenaltyChargesOutstanding(currency).getAmount(), null, unrecognizedIncomePortion, loanRepaymentScheduleInstallment.getPenaltyChargesOutstanding(currency).getAmount(), null, unrecognizedIncomePortion,
paymentOptions, null, null, null, outstandingLoanBalance, false, loanId); paymentOptions, null, null, null, outstandingLoanBalance, false, loanId, loan.getExternalId());
} }
private BigDecimal adjustPrepayInstallmentCharge(Loan loan, final LocalDate onDate) { private BigDecimal adjustPrepayInstallmentCharge(Loan loan, final LocalDate onDate) {
@@ -497,7 +497,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
final BigDecimal unrecognizedIncomePortion = null; final BigDecimal unrecognizedIncomePortion = null;
return new LoanTransactionData(null, null, null, transactionType, null, currencyData, waiveOfInterest.getTransactionDate(), amount, return new LoanTransactionData(null, null, null, transactionType, null, currencyData, waiveOfInterest.getTransactionDate(), amount,
loan.getNetDisbursalAmount(), null, null, null, null, null, null, null, null, outstandingLoanBalance, loan.getNetDisbursalAmount(), null, null, null, null, null, null, null, null, outstandingLoanBalance,
unrecognizedIncomePortion, false, loanId); unrecognizedIncomePortion, false, loanId, loan.getExternalId());
} }
@Override @Override
@@ -508,7 +508,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
final LoanTransactionEnumData transactionType = LoanEnumerations.transactionType(LoanTransactionType.WRITEOFF); final LoanTransactionEnumData transactionType = LoanEnumerations.transactionType(LoanTransactionType.WRITEOFF);
final BigDecimal unrecognizedIncomePortion = null; final BigDecimal unrecognizedIncomePortion = null;
return new LoanTransactionData(null, null, null, transactionType, null, null, DateUtils.getBusinessLocalDate(), null, null, null, return new LoanTransactionData(null, null, null, transactionType, null, null, DateUtils.getBusinessLocalDate(), null, null, null,
null, null, null, null, null, null, null, outstandingLoanBalance, unrecognizedIncomePortion, false, null); null, null, null, null, null, null, null, outstandingLoanBalance, unrecognizedIncomePortion, false, null, null);
} }
@@ -1310,7 +1310,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
+ " pd.payment_type_id as paymentType,pd.account_number as accountNumber,pd.check_number as checkNumber, " + " pd.payment_type_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.net_disbursal_amount as netDisbursalAmount," + " pd.receipt_number as receiptNumber, pd.bank_number as bankNumber,pd.routing_code as routingCode, l.net_disbursal_amount as netDisbursalAmount,"
+ " l.currency_code as currencyCode, l.currency_digits as currencyDigits, l.currency_multiplesof as inMultiplesOf, rc." + " l.currency_code as currencyCode, l.currency_digits as currencyDigits, l.currency_multiplesof as inMultiplesOf, rc."
+ sqlGenerator.escape("name") + " as currencyName, l.id as loanId, " + sqlGenerator.escape("name") + " as currencyName, l.id as loanId, l.external_id as externalLoanId, "
+ " rc.display_symbol as currencyDisplaySymbol, rc.internationalized_name_code as currencyNameCode, " + " rc.display_symbol as currencyDisplaySymbol, rc.internationalized_name_code as currencyNameCode, "
+ " pt.value as paymentTypeName, tr.external_id as externalId, tr.office_id as officeId, office.name as officeName, " + " pt.value as paymentTypeName, tr.external_id as externalId, tr.office_id as officeId, office.name as officeName, "
+ " fromtran.id as fromTransferId, fromtran.is_reversed as fromTransferReversed," + " fromtran.id as fromTransferId, fromtran.is_reversed as fromTransferReversed,"
@@ -1340,6 +1340,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
final Long id = rs.getLong("id"); final Long id = rs.getLong("id");
final Long loanId = rs.getLong("loanId"); final Long loanId = rs.getLong("loanId");
final String externalLoanId = rs.getString("externalLoanId");
final Long officeId = rs.getLong("officeId"); final Long officeId = rs.getLong("officeId");
final String officeName = rs.getString("officeName"); final String officeName = rs.getString("officeName");
final int transactionTypeInt = JdbcSupport.getInteger(rs, "transactionType"); final int transactionTypeInt = JdbcSupport.getInteger(rs, "transactionType");
@@ -1402,7 +1403,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
return new LoanTransactionData(id, officeId, officeName, transactionType, paymentDetailData, currencyData, date, totalAmount, return new LoanTransactionData(id, officeId, officeName, transactionType, paymentDetailData, currencyData, date, totalAmount,
netDisbursalAmount, principalPortion, interestPortion, feeChargesPortion, penaltyChargesPortion, overPaymentPortion, netDisbursalAmount, principalPortion, interestPortion, feeChargesPortion, penaltyChargesPortion, overPaymentPortion,
unrecognizedIncomePortion, externalId, transfer, null, outstandingLoanBalance, submittedOnDate, manuallyReversed, unrecognizedIncomePortion, externalId, transfer, null, outstandingLoanBalance, submittedOnDate, manuallyReversed,
reversalExternalId, reversedOnDate, loanId); reversalExternalId, reversedOnDate, loanId, externalLoanId);
} }
} }
@@ -1872,7 +1873,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
final BigDecimal unrecognizedIncomePortion = null; final BigDecimal unrecognizedIncomePortion = null;
return new LoanTransactionData(null, null, null, transactionType, null, null, null, loan.getTotalWrittenOff(), return new LoanTransactionData(null, null, null, transactionType, null, null, null, loan.getTotalWrittenOff(),
loan.getNetDisbursalAmount(), null, null, null, null, null, unrecognizedIncomePortion, paymentOptions, null, null, null, loan.getNetDisbursalAmount(), null, null, null, null, null, unrecognizedIncomePortion, paymentOptions, null, null, null,
outstandingLoanBalance, false, loanId); outstandingLoanBalance, false, loanId, loan.getExternalId());
} }
@@ -1886,7 +1887,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
this.codeValueReadPlatformService.retrieveCodeValuesByCode(LoanApiConstants.WRITEOFFREASONS)); this.codeValueReadPlatformService.retrieveCodeValuesByCode(LoanApiConstants.WRITEOFFREASONS));
LoanTransactionData loanTransactionData = new LoanTransactionData(null, null, null, transactionType, null, loan.getCurrency(), LoanTransactionData loanTransactionData = new LoanTransactionData(null, null, null, transactionType, null, loan.getCurrency(),
DateUtils.getBusinessLocalDate(), totalOutstanding, loan.getNetDisbursalAmount(), null, null, null, null, null, null, null, DateUtils.getBusinessLocalDate(), totalOutstanding, loan.getNetDisbursalAmount(), null, null, null, null, null, null, null,
null, null, null, false, loanId); null, null, null, false, loanId, loan.getExternalId());
loanTransactionData.setWriteOffReasonOptions(writeOffReasonOptions); loanTransactionData.setWriteOffReasonOptions(writeOffReasonOptions);
return loanTransactionData; return loanTransactionData;
} }
@@ -2016,7 +2017,8 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
+ ", tr.amount as total, tr.principal_portion_derived as principal, tr.interest_portion_derived as interest, " + ", tr.amount as total, tr.principal_portion_derived as principal, tr.interest_portion_derived as interest, "
+ " tr.fee_charges_portion_derived as fees, tr.penalty_charges_portion_derived as penalties, " + " tr.fee_charges_portion_derived as fees, tr.penalty_charges_portion_derived as penalties, "
+ " tr.overpayment_portion_derived as overpayment, tr.outstanding_loan_balance_derived as outstandingLoanBalance, " + " tr.overpayment_portion_derived as overpayment, tr.outstanding_loan_balance_derived as outstandingLoanBalance, "
+ " tr.unrecognized_income_portion as unrecognizedIncome, tr.loan_id as loanId from m_loan_transaction tr "; + " tr.unrecognized_income_portion as unrecognizedIncome, tr.loan_id as loanId, l.external_id as externalLoanId from m_loan_transaction tr "
+ " left join m_loan l on tr.loan_id = l.id";
} }
@Override @Override
@@ -2024,6 +2026,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
final Long id = rs.getLong("id"); final Long id = rs.getLong("id");
final Long loanId = rs.getLong("loanId"); final Long loanId = rs.getLong("loanId");
final String externalLoanId = rs.getString("externalLoanId");
final int transactionTypeInt = JdbcSupport.getInteger(rs, "transactionType"); final int transactionTypeInt = JdbcSupport.getInteger(rs, "transactionType");
final LoanTransactionEnumData transactionType = LoanEnumerations.transactionType(transactionTypeInt); final LoanTransactionEnumData transactionType = LoanEnumerations.transactionType(transactionTypeInt);
@@ -2039,7 +2042,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
return new LoanTransactionData(id, transactionType, date, totalAmount, null, principalPortion, interestPortion, return new LoanTransactionData(id, transactionType, date, totalAmount, null, principalPortion, interestPortion,
feeChargesPortion, penaltyChargesPortion, overPaymentPortion, unrecognizedIncomePortion, outstandingLoanBalance, false, feeChargesPortion, penaltyChargesPortion, overPaymentPortion, unrecognizedIncomePortion, outstandingLoanBalance, false,
loanId); loanId, externalLoanId);
} }
} }
@@ -2157,7 +2160,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
final Collection<PaymentTypeData> paymentOptions = this.paymentTypeReadPlatformService.retrieveAllPaymentTypes(); final Collection<PaymentTypeData> paymentOptions = this.paymentTypeReadPlatformService.retrieveAllPaymentTypes();
final Loan loan = this.loanRepositoryWrapper.findOneWithNotFoundDetection(loanId, true); final Loan loan = this.loanRepositoryWrapper.findOneWithNotFoundDetection(loanId, true);
return retrieveRefundTemplate(loanId, LoanTransactionType.REFUND_FOR_ACTIVE_LOAN, paymentOptions, loan.getCurrency(), return retrieveRefundTemplate(loanId, LoanTransactionType.REFUND_FOR_ACTIVE_LOAN, paymentOptions, loan.getCurrency(),
retrieveTotalPaidInAdvance(loan.getId()).getPaidInAdvance(), loan.getNetDisbursalAmount()); retrieveTotalPaidInAdvance(loan.getId()).getPaidInAdvance(), loan.getNetDisbursalAmount(), loan.getExternalId());
} }
@Override @Override
@@ -2168,12 +2171,13 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
final BigDecimal netDisbursal = null; final BigDecimal netDisbursal = null;
final Loan loan = this.loanRepositoryWrapper.findOneWithNotFoundDetection(loanId, true); final Loan loan = this.loanRepositoryWrapper.findOneWithNotFoundDetection(loanId, true);
return retrieveRefundTemplate(loanId, LoanTransactionType.CREDIT_BALANCE_REFUND, paymentOptions, loan.getCurrency(), return retrieveRefundTemplate(loanId, LoanTransactionType.CREDIT_BALANCE_REFUND, paymentOptions, loan.getCurrency(),
loan.getTotalOverpaid(), netDisbursal); loan.getTotalOverpaid(), netDisbursal, loan.getExternalId());
} }
private LoanTransactionData retrieveRefundTemplate(Long loanId, LoanTransactionType loanTransactionType, private LoanTransactionData retrieveRefundTemplate(Long loanId, LoanTransactionType loanTransactionType,
Collection<PaymentTypeData> paymentOptions, MonetaryCurrency currency, BigDecimal transactionAmount, BigDecimal netDisbursal) { Collection<PaymentTypeData> paymentOptions, MonetaryCurrency currency, BigDecimal transactionAmount, BigDecimal netDisbursal,
String externalLoanId) {
final ApplicationCurrency applicationCurrency = this.applicationCurrencyRepository.findOneWithNotFoundDetection(currency); final ApplicationCurrency applicationCurrency = this.applicationCurrencyRepository.findOneWithNotFoundDetection(currency);
@@ -2183,7 +2187,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
final LoanTransactionEnumData transactionType = LoanEnumerations.transactionType(loanTransactionType); final LoanTransactionEnumData transactionType = LoanEnumerations.transactionType(loanTransactionType);
return new LoanTransactionData(null, null, null, transactionType, null, currencyData, currentDate, transactionAmount, null, return new LoanTransactionData(null, null, null, transactionType, null, currencyData, currentDate, transactionAmount, null,
netDisbursal, null, null, null, null, null, paymentOptions, null, null, null, null, false, loanId); netDisbursal, null, null, null, null, null, paymentOptions, null, null, null, null, false, loanId, externalLoanId);
} }
@Override @Override
@@ -2277,7 +2281,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
loanRepaymentScheduleInstallment.getInterestOutstanding(currency).getAmount(), loanRepaymentScheduleInstallment.getInterestOutstanding(currency).getAmount(),
loanRepaymentScheduleInstallment.getFeeChargesOutstanding(currency).getAmount(), loanRepaymentScheduleInstallment.getFeeChargesOutstanding(currency).getAmount(),
loanRepaymentScheduleInstallment.getPenaltyChargesOutstanding(currency).getAmount(), null, unrecognizedIncomePortion, loanRepaymentScheduleInstallment.getPenaltyChargesOutstanding(currency).getAmount(), null, unrecognizedIncomePortion,
paymentTypeOptions, null, null, null, outstandingLoanBalance, isReversed, loanId); paymentTypeOptions, null, null, null, outstandingLoanBalance, isReversed, loanId, loan.getExternalId());
} }
private static final class CurrencyMapper implements RowMapper<CurrencyData> { private static final class CurrencyMapper implements RowMapper<CurrencyData> {
@@ -2350,6 +2354,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
final BigDecimal netDisbursalAmount = JdbcSupport.getBigDecimalDefaultToZeroIfNull(rs, "netDisbursalAmount"); final BigDecimal netDisbursalAmount = JdbcSupport.getBigDecimalDefaultToZeroIfNull(rs, "netDisbursalAmount");
final Long id = null; final Long id = null;
final Long loanId = null; final Long loanId = null;
final String externalLoanId = null;
final Long officeId = null; final Long officeId = null;
final String officeName = null; final String officeName = null;
boolean manuallyReversed = false; boolean manuallyReversed = false;
@@ -2359,7 +2364,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
final BigDecimal fixedEmiAmount = null; final BigDecimal fixedEmiAmount = null;
return new LoanTransactionData(id, officeId, officeName, transactionType, paymentDetailData, currencyData, date, totalDue, return new LoanTransactionData(id, officeId, officeName, transactionType, paymentDetailData, currencyData, date, totalDue,
netDisbursalAmount, principalPortion, interestDue, feeDue, penaltyDue, overPaymentPortion, externalId, transfer, netDisbursalAmount, principalPortion, interestDue, feeDue, penaltyDue, overPaymentPortion, externalId, transfer,
fixedEmiAmount, outstandingLoanBalance, unrecognizedIncomePortion, manuallyReversed, loanId); fixedEmiAmount, outstandingLoanBalance, unrecognizedIncomePortion, manuallyReversed, loanId, externalLoanId);
} }
} }