FINERACT-1971: Align dates and dateformat in tests

This commit is contained in:
Adam Saghy
2023-09-21 18:43:17 +02:00
parent 710e6145be
commit 0927c8e1d9
11 changed files with 407 additions and 386 deletions
@@ -402,7 +402,7 @@ final class ClientsApiResourceSwagger {
@Schema(example = "03 August 2021") @Schema(example = "03 August 2021")
public String activationDate; public String activationDate;
@Schema(example = "dd MMM yyyy") @Schema(example = "dd MMMM yyyy")
public String dateFormat; public String dateFormat;
@Schema(example = "en") @Schema(example = "en")
public String locale; public String locale;
@@ -2541,204 +2541,210 @@ public class ClientLoanIntegrationTest {
*/ */
@Test @Test
public void loanWithChargesOfTypeAmountPercentageAndPeriodicAccrualAccountingEnabled() throws InterruptedException { public void loanWithChargesOfTypeAmountPercentageAndPeriodicAccrualAccountingEnabled() throws InterruptedException {
try {
GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC,
GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true);
final Integer clientID = ClientHelper.createClient(REQUEST_SPEC, RESPONSE_SPEC);
ClientHelper.verifyClientCreatedOnServer(REQUEST_SPEC, RESPONSE_SPEC, clientID);
final Integer clientID = ClientHelper.createClient(REQUEST_SPEC, RESPONSE_SPEC); // Add charges with payment mode regular
ClientHelper.verifyClientCreatedOnServer(REQUEST_SPEC, RESPONSE_SPEC, clientID); List<HashMap> charges = new ArrayList<>();
Integer percentageDisbursementCharge = ChargesHelper.createCharges(REQUEST_SPEC, RESPONSE_SPEC,
ChargesHelper.getLoanDisbursementJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1"));
addCharges(charges, percentageDisbursementCharge, "1", null);
// Add charges with payment mode regular Integer percentageSpecifiedDueDateCharge = ChargesHelper.createCharges(REQUEST_SPEC, RESPONSE_SPEC,
List<HashMap> charges = new ArrayList<>(); ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1", false));
Integer percentageDisbursementCharge = ChargesHelper.createCharges(REQUEST_SPEC, RESPONSE_SPEC, addCharges(charges, percentageSpecifiedDueDateCharge, "1", "29 September 2011");
ChargesHelper.getLoanDisbursementJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1"));
addCharges(charges, percentageDisbursementCharge, "1", null);
Integer percentageSpecifiedDueDateCharge = ChargesHelper.createCharges(REQUEST_SPEC, RESPONSE_SPEC, Integer percentageInstallmentFee = ChargesHelper.createCharges(REQUEST_SPEC, RESPONSE_SPEC,
ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1", false)); ChargesHelper.getLoanInstallmentJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1", false));
addCharges(charges, percentageSpecifiedDueDateCharge, "1", "29 September 2011"); addCharges(charges, percentageInstallmentFee, "1", "29 September 2011");
Integer percentageInstallmentFee = ChargesHelper.createCharges(REQUEST_SPEC, RESPONSE_SPEC, final Account assetAccount = ACCOUNT_HELPER.createAssetAccount();
ChargesHelper.getLoanInstallmentJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1", false)); final Account incomeAccount = ACCOUNT_HELPER.createIncomeAccount();
addCharges(charges, percentageInstallmentFee, "1", "29 September 2011"); final Account expenseAccount = ACCOUNT_HELPER.createExpenseAccount();
final Account overpaymentAccount = ACCOUNT_HELPER.createLiabilityAccount();
final Account assetAccount = ACCOUNT_HELPER.createAssetAccount(); List<HashMap> collaterals = new ArrayList<>();
final Account incomeAccount = ACCOUNT_HELPER.createIncomeAccount();
final Account expenseAccount = ACCOUNT_HELPER.createExpenseAccount();
final Account overpaymentAccount = ACCOUNT_HELPER.createLiabilityAccount();
List<HashMap> collaterals = new ArrayList<>(); final Integer collateralId = CollateralManagementHelper.createCollateralProduct(REQUEST_SPEC, RESPONSE_SPEC);
final Integer collateralId = CollateralManagementHelper.createCollateralProduct(REQUEST_SPEC, RESPONSE_SPEC); final Integer clientCollateralId = CollateralManagementHelper.createClientCollateral(REQUEST_SPEC, RESPONSE_SPEC,
String.valueOf(clientID), collateralId);
addCollaterals(collaterals, clientCollateralId, BigDecimal.valueOf(1));
final Integer clientCollateralId = CollateralManagementHelper.createClientCollateral(REQUEST_SPEC, RESPONSE_SPEC, final Integer loanProductID = createLoanProduct(false, ACCRUAL_PERIODIC, assetAccount, incomeAccount, expenseAccount,
String.valueOf(clientID), collateralId); overpaymentAccount);
addCollaterals(collaterals, clientCollateralId, BigDecimal.valueOf(1)); final Integer loanID = applyForLoanApplication(clientID, loanProductID, charges, null, "12,000.00", collaterals);
Assertions.assertNotNull(loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(REQUEST_SPEC, RESPONSE_SPEC, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
final Integer loanProductID = createLoanProduct(false, ACCRUAL_PERIODIC, assetAccount, incomeAccount, expenseAccount, ArrayList<HashMap> loanSchedule = LOAN_TRANSACTION_HELPER.getLoanRepaymentSchedule(REQUEST_SPEC, RESPONSE_SPEC, loanID);
overpaymentAccount); verifyLoanRepaymentSchedule(loanSchedule);
final Integer loanID = applyForLoanApplication(clientID, loanProductID, charges, null, "12,000.00", collaterals);
Assertions.assertNotNull(loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(REQUEST_SPEC, RESPONSE_SPEC, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
ArrayList<HashMap> loanSchedule = LOAN_TRANSACTION_HELPER.getLoanRepaymentSchedule(REQUEST_SPEC, RESPONSE_SPEC, loanID); List<HashMap> loanCharges = LOAN_TRANSACTION_HELPER.getLoanCharges(loanID);
verifyLoanRepaymentSchedule(loanSchedule); validateCharge(percentageDisbursementCharge, loanCharges, "1", "120.00", "0.0", "0.0");
validateCharge(percentageSpecifiedDueDateCharge, loanCharges, "1", "120.00", "0.0", "0.0");
validateCharge(percentageInstallmentFee, loanCharges, "1", "120.00", "0.0", "0.0");
List<HashMap> loanCharges = LOAN_TRANSACTION_HELPER.getLoanCharges(loanID); // check for disbursement fee
validateCharge(percentageDisbursementCharge, loanCharges, "1", "120.00", "0.0", "0.0"); HashMap disbursementDetail = loanSchedule.get(0);
validateCharge(percentageSpecifiedDueDateCharge, loanCharges, "1", "120.00", "0.0", "0.0"); validateNumberForEqual("120.00", String.valueOf(disbursementDetail.get("feeChargesDue")));
validateCharge(percentageInstallmentFee, loanCharges, "1", "120.00", "0.0", "0.0");
// check for disbursement fee // check for charge at specified date and installment fee
HashMap disbursementDetail = loanSchedule.get(0); HashMap firstInstallment = loanSchedule.get(1);
validateNumberForEqual("120.00", String.valueOf(disbursementDetail.get("feeChargesDue"))); validateNumberForEqual("149.11", String.valueOf(firstInstallment.get("feeChargesDue")));
// check for charge at specified date and installment fee // check for installment fee
HashMap firstInstallment = loanSchedule.get(1); HashMap secondInstallment = loanSchedule.get(2);
validateNumberForEqual("149.11", String.valueOf(firstInstallment.get("feeChargesDue"))); validateNumberForEqual("29.70", String.valueOf(secondInstallment.get("feeChargesDue")));
// check for installment fee LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------");
HashMap secondInstallment = loanSchedule.get(2); loanStatusHashMap = LOAN_TRANSACTION_HELPER.approveLoan("20 September 2011", loanID);
validateNumberForEqual("29.70", String.valueOf(secondInstallment.get("feeChargesDue"))); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
loanStatusHashMap = LOAN_TRANSACTION_HELPER.approveLoan("20 September 2011", loanID); String loanDetails = LOAN_TRANSACTION_HELPER.getLoanDetails(REQUEST_SPEC, RESPONSE_SPEC, loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); loanStatusHashMap = LOAN_TRANSACTION_HELPER.disburseLoanWithNetDisbursalAmount("20 September 2011", loanID,
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); ArrayList<HashMap> loanTransactionDetails = LOAN_TRANSACTION_HELPER.getLoanTransactionDetails(REQUEST_SPEC, RESPONSE_SPEC,
GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC, loanID);
GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, true); validateAccrualTransactionForDisbursementCharge(loanTransactionDetails);
String loanDetails = LOAN_TRANSACTION_HELPER.getLoanDetails(REQUEST_SPEC, RESPONSE_SPEC, loanID); final JournalEntry[] assetAccountInitialEntry = {
loanStatusHashMap = LOAN_TRANSACTION_HELPER.disburseLoanWithNetDisbursalAmount("20 September 2011", loanID, new JournalEntry(Float.parseFloat("120.00"), JournalEntry.TransactionType.DEBIT),
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); new JournalEntry(Float.parseFloat("12000.00"), JournalEntry.TransactionType.CREDIT),
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); new JournalEntry(Float.parseFloat("12000.00"), JournalEntry.TransactionType.DEBIT) };
JOURNAL_ENTRY_HELPER.checkJournalEntryForAssetAccount(assetAccount, "20 September 2011", assetAccountInitialEntry);
JOURNAL_ENTRY_HELPER.checkJournalEntryForIncomeAccount(incomeAccount, "20 September 2011",
new JournalEntry(Float.parseFloat("120.00"), JournalEntry.TransactionType.CREDIT));
loanCharges.clear();
loanCharges = LOAN_TRANSACTION_HELPER.getLoanCharges(loanID);
validateCharge(percentageDisbursementCharge, loanCharges, "1", "0.0", "120.00", "0.0");
ArrayList<HashMap> loanTransactionDetails = LOAN_TRANSACTION_HELPER.getLoanTransactionDetails(REQUEST_SPEC, RESPONSE_SPEC, loanID); LOG.info("-------------Make repayment 1-----------");
validateAccrualTransactionForDisbursementCharge(loanTransactionDetails); LOAN_TRANSACTION_HELPER.makeRepayment("20 October 2011", Float.parseFloat("3300.60"), loanID);
final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(Float.parseFloat("120.00"), JournalEntry.TransactionType.DEBIT), loanCharges.clear();
new JournalEntry(Float.parseFloat("12000.00"), JournalEntry.TransactionType.CREDIT), loanCharges = LOAN_TRANSACTION_HELPER.getLoanCharges(loanID);
new JournalEntry(Float.parseFloat("12000.00"), JournalEntry.TransactionType.DEBIT) }; validateCharge(percentageDisbursementCharge, loanCharges, "1", "0.00", "120.00", "0.0");
JOURNAL_ENTRY_HELPER.checkJournalEntryForAssetAccount(assetAccount, "20 September 2011", assetAccountInitialEntry); validateCharge(percentageSpecifiedDueDateCharge, loanCharges, "1", "0.00", "120.0", "0.0");
JOURNAL_ENTRY_HELPER.checkJournalEntryForIncomeAccount(incomeAccount, "20 September 2011", validateCharge(percentageInstallmentFee, loanCharges, "1", "90.89", "29.11", "0.0");
new JournalEntry(Float.parseFloat("120.00"), JournalEntry.TransactionType.CREDIT));
loanCharges.clear();
loanCharges = LOAN_TRANSACTION_HELPER.getLoanCharges(loanID);
validateCharge(percentageDisbursementCharge, loanCharges, "1", "0.0", "120.00", "0.0");
LOG.info("-------------Make repayment 1-----------"); JOURNAL_ENTRY_HELPER.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011",
LOAN_TRANSACTION_HELPER.makeRepayment("20 October 2011", Float.parseFloat("3300.60"), loanID); new JournalEntry(Float.parseFloat("3300.60"), JournalEntry.TransactionType.DEBIT),
loanCharges.clear(); new JournalEntry(Float.parseFloat("3300.60"), JournalEntry.TransactionType.CREDIT));
loanCharges = LOAN_TRANSACTION_HELPER.getLoanCharges(loanID);
validateCharge(percentageDisbursementCharge, loanCharges, "1", "0.00", "120.00", "0.0");
validateCharge(percentageSpecifiedDueDateCharge, loanCharges, "1", "0.00", "120.0", "0.0");
validateCharge(percentageInstallmentFee, loanCharges, "1", "90.89", "29.11", "0.0");
JOURNAL_ENTRY_HELPER.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011", LOAN_TRANSACTION_HELPER.addChargesForLoan(loanID, LoanTransactionHelper
new JournalEntry(Float.parseFloat("3300.60"), JournalEntry.TransactionType.DEBIT), .getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(percentageSpecifiedDueDateCharge), "29 October 2011", "1"));
new JournalEntry(Float.parseFloat("3300.60"), JournalEntry.TransactionType.CREDIT)); loanSchedule.clear();
loanSchedule = LOAN_TRANSACTION_HELPER.getLoanRepaymentSchedule(REQUEST_SPEC, RESPONSE_SPEC, loanID);
LOAN_TRANSACTION_HELPER.addChargesForLoan(loanID, LoanTransactionHelper secondInstallment = loanSchedule.get(2);
.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(percentageSpecifiedDueDateCharge), "29 October 2011", "1")); validateNumberForEqual("149.70", String.valueOf(secondInstallment.get("feeChargesDue")));
loanSchedule.clear(); LOG.info("----------- Waive installment charge for 2nd installment ---------");
loanSchedule = LOAN_TRANSACTION_HELPER.getLoanRepaymentSchedule(REQUEST_SPEC, RESPONSE_SPEC, loanID); LOAN_TRANSACTION_HELPER.waiveChargesForLoan(loanID, (Integer) getloanCharge(percentageInstallmentFee, loanCharges).get("id"),
LoanTransactionHelper.getWaiveChargeJSON(String.valueOf(2)));
loanCharges.clear();
loanCharges = LOAN_TRANSACTION_HELPER.getLoanCharges(loanID);
validateCharge(percentageInstallmentFee, loanCharges, "1", "61.19", "29.11", "29.70");
secondInstallment = loanSchedule.get(2); /*
validateNumberForEqual("149.70", String.valueOf(secondInstallment.get("feeChargesDue"))); * JOURNAL_ENTRY_HELPER.checkJournalEntryForAssetAccount( assetAccount, "20 September 2011", new
LOG.info("----------- Waive installment charge for 2nd installment ---------"); * JournalEntry(Float.parseFloat("29.7"), JournalEntry.TransactionType.CREDIT));
LOAN_TRANSACTION_HELPER.waiveChargesForLoan(loanID, (Integer) getloanCharge(percentageInstallmentFee, loanCharges).get("id"), * JOURNAL_ENTRY_HELPER.checkJournalEntryForExpenseAccount (expenseAccount, "20 September 2011", new
LoanTransactionHelper.getWaiveChargeJSON(String.valueOf(2))); * JournalEntry(Float.parseFloat("29.7"), JournalEntry.TransactionType.DEBIT));
loanCharges.clear(); */
loanCharges = LOAN_TRANSACTION_HELPER.getLoanCharges(loanID);
validateCharge(percentageInstallmentFee, loanCharges, "1", "61.19", "29.11", "29.70");
/* final String jobName = "Add Accrual Transactions";
* JOURNAL_ENTRY_HELPER.checkJournalEntryForAssetAccount( assetAccount, "20 September 2011", new
* JournalEntry(Float.parseFloat("29.7"), JournalEntry.TransactionType.CREDIT));
* JOURNAL_ENTRY_HELPER.checkJournalEntryForExpenseAccount (expenseAccount, "20 September 2011", new
* JournalEntry(Float.parseFloat("29.7"), JournalEntry.TransactionType.DEBIT));
*/
final String jobName = "Add Accrual Transactions"; SCHEDULER_JOB_HELPER.executeAndAwaitJob(jobName);
SCHEDULER_JOB_HELPER.executeAndAwaitJob(jobName); loanSchedule.clear();
loanSchedule = LOAN_TRANSACTION_HELPER.getLoanRepaymentSchedule(REQUEST_SPEC, RESPONSE_SPEC, loanID);
checkAccrualTransactions(loanSchedule, loanID);
loanSchedule.clear(); LOG.info("----------Make repayment 2------------");
loanSchedule = LOAN_TRANSACTION_HELPER.getLoanRepaymentSchedule(REQUEST_SPEC, RESPONSE_SPEC, loanID); LOAN_TRANSACTION_HELPER.makeRepayment("20 November 2011", Float.parseFloat("3271.49"), loanID);
checkAccrualTransactions(loanSchedule, loanID); JOURNAL_ENTRY_HELPER.checkJournalEntryForAssetAccount(assetAccount, "20 November 2011",
new JournalEntry(Float.parseFloat("3271.49"), JournalEntry.TransactionType.DEBIT),
new JournalEntry(Float.parseFloat("3271.49"), JournalEntry.TransactionType.CREDIT));
LOG.info("----------Make repayment 2------------"); loanSchedule.clear();
LOAN_TRANSACTION_HELPER.makeRepayment("20 November 2011", Float.parseFloat("3271.49"), loanID); loanSchedule = LOAN_TRANSACTION_HELPER.getLoanRepaymentSchedule(REQUEST_SPEC, RESPONSE_SPEC, loanID);
JOURNAL_ENTRY_HELPER.checkJournalEntryForAssetAccount(assetAccount, "20 November 2011", secondInstallment = loanSchedule.get(2);
new JournalEntry(Float.parseFloat("3271.49"), JournalEntry.TransactionType.DEBIT), validateNumberForEqual("0", String.valueOf(secondInstallment.get("totalOutstandingForPeriod")));
new JournalEntry(Float.parseFloat("3271.49"), JournalEntry.TransactionType.CREDIT));
loanSchedule.clear(); LOG.info("--------------Waive interest---------------");
loanSchedule = LOAN_TRANSACTION_HELPER.getLoanRepaymentSchedule(REQUEST_SPEC, RESPONSE_SPEC, loanID); LOAN_TRANSACTION_HELPER.waiveInterest("20 December 2011", String.valueOf(61.79), loanID);
secondInstallment = loanSchedule.get(2);
validateNumberForEqual("0", String.valueOf(secondInstallment.get("totalOutstandingForPeriod")));
LOG.info("--------------Waive interest---------------"); loanSchedule.clear();
LOAN_TRANSACTION_HELPER.waiveInterest("20 December 2011", String.valueOf(61.79), loanID); loanSchedule = LOAN_TRANSACTION_HELPER.getLoanRepaymentSchedule(REQUEST_SPEC, RESPONSE_SPEC, loanID);
HashMap thirdInstallment = loanSchedule.get(3);
validateNumberForEqual("60.59", String.valueOf(thirdInstallment.get("interestOutstanding")));
loanSchedule.clear(); JOURNAL_ENTRY_HELPER.checkJournalEntryForAssetAccount(assetAccount, "20 December 2011",
loanSchedule = LOAN_TRANSACTION_HELPER.getLoanRepaymentSchedule(REQUEST_SPEC, RESPONSE_SPEC, loanID); new JournalEntry(Float.parseFloat("61.79"), JournalEntry.TransactionType.CREDIT));
HashMap thirdInstallment = loanSchedule.get(3); JOURNAL_ENTRY_HELPER.checkJournalEntryForExpenseAccount(expenseAccount, "20 December 2011",
validateNumberForEqual("60.59", String.valueOf(thirdInstallment.get("interestOutstanding"))); new JournalEntry(Float.parseFloat("61.79"), JournalEntry.TransactionType.DEBIT));
JOURNAL_ENTRY_HELPER.checkJournalEntryForAssetAccount(assetAccount, "20 December 2011", Integer percentagePenaltySpecifiedDueDate = ChargesHelper.createCharges(REQUEST_SPEC, RESPONSE_SPEC,
new JournalEntry(Float.parseFloat("61.79"), JournalEntry.TransactionType.CREDIT)); ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1", true));
JOURNAL_ENTRY_HELPER.checkJournalEntryForExpenseAccount(expenseAccount, "20 December 2011", LOAN_TRANSACTION_HELPER.addChargesForLoan(loanID, LoanTransactionHelper
new JournalEntry(Float.parseFloat("61.79"), JournalEntry.TransactionType.DEBIT)); .getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(percentagePenaltySpecifiedDueDate), "29 September 2011", "1"));
loanCharges.clear();
loanCharges = LOAN_TRANSACTION_HELPER.getLoanCharges(loanID);
validateCharge(percentagePenaltySpecifiedDueDate, loanCharges, "1", "0.00", "120.0", "0.0");
Integer percentagePenaltySpecifiedDueDate = ChargesHelper.createCharges(REQUEST_SPEC, RESPONSE_SPEC, loanSchedule.clear();
ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1", true)); loanSchedule = LOAN_TRANSACTION_HELPER.getLoanRepaymentSchedule(REQUEST_SPEC, RESPONSE_SPEC, loanID);
LOAN_TRANSACTION_HELPER.addChargesForLoan(loanID, LoanTransactionHelper secondInstallment = loanSchedule.get(2);
.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(percentagePenaltySpecifiedDueDate), "29 September 2011", "1")); validateNumberForEqual("120", String.valueOf(secondInstallment.get("totalOutstandingForPeriod")));
loanCharges.clear();
loanCharges = LOAN_TRANSACTION_HELPER.getLoanCharges(loanID);
validateCharge(percentagePenaltySpecifiedDueDate, loanCharges, "1", "0.00", "120.0", "0.0");
loanSchedule.clear(); // checking the journal entry as applied penalty has been collected
loanSchedule = LOAN_TRANSACTION_HELPER.getLoanRepaymentSchedule(REQUEST_SPEC, RESPONSE_SPEC, loanID); JOURNAL_ENTRY_HELPER.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011",
secondInstallment = loanSchedule.get(2); new JournalEntry(Float.parseFloat("3300.60"), JournalEntry.TransactionType.DEBIT),
validateNumberForEqual("120", String.valueOf(secondInstallment.get("totalOutstandingForPeriod"))); new JournalEntry(Float.parseFloat("3300.60"), JournalEntry.TransactionType.CREDIT));
// checking the journal entry as applied penalty has been collected LOG.info("----------Make repayment 3 advance------------");
JOURNAL_ENTRY_HELPER.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011", LOAN_TRANSACTION_HELPER.makeRepayment("20 November 2011", Float.parseFloat("3301.78"), loanID);
new JournalEntry(Float.parseFloat("3300.60"), JournalEntry.TransactionType.DEBIT), JOURNAL_ENTRY_HELPER.checkJournalEntryForAssetAccount(assetAccount, "20 November 2011",
new JournalEntry(Float.parseFloat("3300.60"), JournalEntry.TransactionType.CREDIT)); new JournalEntry(Float.parseFloat("3301.78"), JournalEntry.TransactionType.DEBIT),
new JournalEntry(Float.parseFloat("3301.78"), JournalEntry.TransactionType.CREDIT));
LOG.info("----------Make repayment 3 advance------------"); LOAN_TRANSACTION_HELPER.addChargesForLoan(loanID, LoanTransactionHelper
LOAN_TRANSACTION_HELPER.makeRepayment("20 November 2011", Float.parseFloat("3301.78"), loanID); .getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(percentagePenaltySpecifiedDueDate), "10 January 2012", "1"));
JOURNAL_ENTRY_HELPER.checkJournalEntryForAssetAccount(assetAccount, "20 November 2011", loanSchedule.clear();
new JournalEntry(Float.parseFloat("3301.78"), JournalEntry.TransactionType.DEBIT), loanSchedule = LOAN_TRANSACTION_HELPER.getLoanRepaymentSchedule(REQUEST_SPEC, RESPONSE_SPEC, loanID);
new JournalEntry(Float.parseFloat("3301.78"), JournalEntry.TransactionType.CREDIT)); HashMap fourthInstallment = loanSchedule.get(4);
validateNumberForEqual("120", String.valueOf(fourthInstallment.get("penaltyChargesOutstanding")));
validateNumberForEqual("3240.58", String.valueOf(fourthInstallment.get("totalOutstandingForPeriod")));
LOAN_TRANSACTION_HELPER.addChargesForLoan(loanID, LoanTransactionHelper LOG.info("----------Pay applied penalty ------------");
.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(percentagePenaltySpecifiedDueDate), "10 January 2012", "1")); LOAN_TRANSACTION_HELPER.makeRepayment("20 January 2012", Float.parseFloat("120"), loanID);
loanSchedule.clear(); JOURNAL_ENTRY_HELPER.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012",
loanSchedule = LOAN_TRANSACTION_HELPER.getLoanRepaymentSchedule(REQUEST_SPEC, RESPONSE_SPEC, loanID); new JournalEntry(Float.parseFloat("120"), JournalEntry.TransactionType.DEBIT),
HashMap fourthInstallment = loanSchedule.get(4); new JournalEntry(Float.parseFloat("120"), JournalEntry.TransactionType.CREDIT));
validateNumberForEqual("120", String.valueOf(fourthInstallment.get("penaltyChargesOutstanding"))); loanSchedule.clear();
validateNumberForEqual("3240.58", String.valueOf(fourthInstallment.get("totalOutstandingForPeriod"))); loanSchedule = LOAN_TRANSACTION_HELPER.getLoanRepaymentSchedule(REQUEST_SPEC, RESPONSE_SPEC, loanID);
fourthInstallment = loanSchedule.get(4);
validateNumberForEqual("0", String.valueOf(fourthInstallment.get("penaltyChargesOutstanding")));
validateNumberForEqual("3120.58", String.valueOf(fourthInstallment.get("totalOutstandingForPeriod")));
LOG.info("----------Pay applied penalty ------------"); LOG.info("----------Make repayment 4 ------------");
LOAN_TRANSACTION_HELPER.makeRepayment("20 January 2012", Float.parseFloat("120"), loanID); LOAN_TRANSACTION_HELPER.makeRepayment("20 January 2012", Float.parseFloat("3120.58"), loanID);
JOURNAL_ENTRY_HELPER.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012", JOURNAL_ENTRY_HELPER.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012",
new JournalEntry(Float.parseFloat("120"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.parseFloat("3120.58"), JournalEntry.TransactionType.DEBIT),
new JournalEntry(Float.parseFloat("120"), JournalEntry.TransactionType.CREDIT)); new JournalEntry(Float.parseFloat("3120.58"), JournalEntry.TransactionType.CREDIT));
loanSchedule.clear(); loanStatusHashMap = LOAN_TRANSACTION_HELPER.getLoanDetail(REQUEST_SPEC, RESPONSE_SPEC, loanID, "status");
loanSchedule = LOAN_TRANSACTION_HELPER.getLoanRepaymentSchedule(REQUEST_SPEC, RESPONSE_SPEC, loanID); LoanStatusChecker.verifyLoanAccountIsClosed(loanStatusHashMap);
fourthInstallment = loanSchedule.get(4); } finally {
validateNumberForEqual("0", String.valueOf(fourthInstallment.get("penaltyChargesOutstanding"))); GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC,
validateNumberForEqual("3120.58", String.valueOf(fourthInstallment.get("totalOutstandingForPeriod"))); GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, false);
}
LOG.info("----------Make repayment 4 ------------");
LOAN_TRANSACTION_HELPER.makeRepayment("20 January 2012", Float.parseFloat("3120.58"), loanID);
JOURNAL_ENTRY_HELPER.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012",
new JournalEntry(Float.parseFloat("3120.58"), JournalEntry.TransactionType.DEBIT),
new JournalEntry(Float.parseFloat("3120.58"), JournalEntry.TransactionType.CREDIT));
loanStatusHashMap = LOAN_TRANSACTION_HELPER.getLoanDetail(REQUEST_SPEC, RESPONSE_SPEC, loanID, "status");
LoanStatusChecker.verifyLoanAccountIsClosed(loanStatusHashMap);
} }
/*** /***
@@ -3434,56 +3440,60 @@ public class ClientLoanIntegrationTest {
@Test @Test
public void testInteroperationLoanRepaymentAPI() { public void testInteroperationLoanRepaymentAPI() {
try {
DateFormat dateFormat = new SimpleDateFormat(DATETIME_PATTERN, Locale.US);
dateFormat.setTimeZone(Utils.getTimeZoneOfTenant());
GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(REQUEST_SPEC, RESPONSE_SPEC, "42", true);
Calendar startDate = Calendar.getInstance(Utils.getTimeZoneOfTenant());
startDate.add(Calendar.MONTH, -8);
DateFormat dateFormat = new SimpleDateFormat(DATETIME_PATTERN, Locale.US); Calendar firstRepaymentDate = (Calendar) startDate.clone();
dateFormat.setTimeZone(Utils.getTimeZoneOfTenant()); firstRepaymentDate.add(Calendar.MONTH, 1);
GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(REQUEST_SPEC, RESPONSE_SPEC, "42", true); firstRepaymentDate.add(Calendar.DAY_OF_MONTH,
Calendar startDate = Calendar.getInstance(Utils.getTimeZoneOfTenant()); firstRepaymentDate.getActualMaximum(Calendar.DAY_OF_MONTH) - Calendar.DAY_OF_MONTH);
startDate.add(Calendar.MONTH, -8); String firstRepayment = dateFormat.format(firstRepaymentDate.getTime());
Calendar firstRepaymentDate = (Calendar) startDate.clone(); final String loanDisbursementDate = dateFormat.format(startDate.getTime());
firstRepaymentDate.add(Calendar.MONTH, 1); final Integer clientID = ClientHelper.createClient(REQUEST_SPEC, RESPONSE_SPEC);
firstRepaymentDate.add(Calendar.DAY_OF_MONTH, firstRepaymentDate.getActualMaximum(Calendar.DAY_OF_MONTH) - Calendar.DAY_OF_MONTH); ClientHelper.verifyClientCreatedOnServer(REQUEST_SPEC, RESPONSE_SPEC, clientID);
String firstRepayment = dateFormat.format(firstRepaymentDate.getTime()); final Integer loanProductID = createLoanProductWithInterestRecalculationAndCompoundingDetails(
LoanProductTestBuilder.INTEREST_PRINCIPAL_PENALTIES_FEES_ORDER_STRATEGY,
LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_NONE,
LoanProductTestBuilder.RECALCULATION_STRATEGY_REDUCE_NUMBER_OF_INSTALLMENTS,
LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_SAME_AS_REPAYMENT_PERIOD,
LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE, null, "12");
final String loanDisbursementDate = dateFormat.format(startDate.getTime()); final Integer loanID = applyForLoanApplicationForInterestRecalculation(clientID, loanProductID, loanDisbursementDate,
final Integer clientID = ClientHelper.createClient(REQUEST_SPEC, RESPONSE_SPEC); LoanApplicationTestBuilder.INTEREST_PRINCIPAL_PENALTIES_FEES_ORDER_STRATEGY, firstRepayment);
ClientHelper.verifyClientCreatedOnServer(REQUEST_SPEC, RESPONSE_SPEC, clientID);
final Integer loanProductID = createLoanProductWithInterestRecalculationAndCompoundingDetails(
LoanProductTestBuilder.INTEREST_PRINCIPAL_PENALTIES_FEES_ORDER_STRATEGY,
LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_NONE,
LoanProductTestBuilder.RECALCULATION_STRATEGY_REDUCE_NUMBER_OF_INSTALLMENTS,
LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_SAME_AS_REPAYMENT_PERIOD,
LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE, null, "12");
final Integer loanID = applyForLoanApplicationForInterestRecalculation(clientID, loanProductID, loanDisbursementDate, Assertions.assertNotNull(loanID);
LoanApplicationTestBuilder.INTEREST_PRINCIPAL_PENALTIES_FEES_ORDER_STRATEGY, firstRepayment); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(REQUEST_SPEC, RESPONSE_SPEC, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
Assertions.assertNotNull(loanID); LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------");
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(REQUEST_SPEC, RESPONSE_SPEC, loanID); loanStatusHashMap = LOAN_TRANSACTION_HELPER.approveLoan(loanDisbursementDate, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
loanStatusHashMap = LOAN_TRANSACTION_HELPER.approveLoan(loanDisbursementDate, loanID); String loanDetails = LOAN_TRANSACTION_HELPER.getLoanDetails(REQUEST_SPEC, RESPONSE_SPEC, loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); loanStatusHashMap = LOAN_TRANSACTION_HELPER.disburseLoanWithNetDisbursalAmount(loanDisbursementDate, loanID,
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); ArrayList<HashMap> loanSchedule = LOAN_TRANSACTION_HELPER.getLoanRepaymentSchedule(REQUEST_SPEC, RESPONSE_SPEC, loanID);
String loanDetails = LOAN_TRANSACTION_HELPER.getLoanDetails(REQUEST_SPEC, RESPONSE_SPEC, loanID); Assertions.assertNotNull(loanSchedule);
loanStatusHashMap = LOAN_TRANSACTION_HELPER.disburseLoanWithNetDisbursalAmount(loanDisbursementDate, loanID, startDate.add(Calendar.DAY_OF_MONTH, 2);
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); String loanFirstRepaymentDate = dateFormat.format(startDate.getTime());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
ArrayList<HashMap> loanSchedule = LOAN_TRANSACTION_HELPER.getLoanRepaymentSchedule(REQUEST_SPEC, RESPONSE_SPEC, loanID); Float earlyPayment = Float.parseFloat("3000");
Assertions.assertNotNull(loanSchedule); String accountNo = JsonPath.from(loanDetails).get("accountNo").toString();
startDate.add(Calendar.DAY_OF_MONTH, 2);
String loanFirstRepaymentDate = dateFormat.format(startDate.getTime());
Float earlyPayment = Float.parseFloat("3000"); HashMap loanRepayment = LOAN_TRANSACTION_HELPER.makeRepaymentWithAccountNo(loanFirstRepaymentDate, earlyPayment, accountNo);
String accountNo = JsonPath.from(loanDetails).get("accountNo").toString(); assertNotNull(loanRepayment);
} finally {
HashMap loanRepayment = LOAN_TRANSACTION_HELPER.makeRepaymentWithAccountNo(loanFirstRepaymentDate, earlyPayment, accountNo); GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(REQUEST_SPEC, RESPONSE_SPEC, "42", false);
assertNotNull(loanRepayment); }
} }
@Test @Test
@@ -4917,134 +4927,140 @@ public class ClientLoanIntegrationTest {
@Test @Test
public void testLoanScheduleWithInterestRecalculationMakePrepaymentAfterRepayment() { public void testLoanScheduleWithInterestRecalculationMakePrepaymentAfterRepayment() {
try {
DateFormat dateFormat = new SimpleDateFormat(DATETIME_PATTERN, Locale.US);
dateFormat.setTimeZone(Utils.getTimeZoneOfTenant());
GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(REQUEST_SPEC, RESPONSE_SPEC, "42", true);
Calendar startDate = Calendar.getInstance(Utils.getTimeZoneOfTenant());
Calendar currentDate = Calendar.getInstance(Utils.getTimeZoneOfTenant());
startDate.add(Calendar.MONTH, -8);
DateFormat dateFormat = new SimpleDateFormat(DATETIME_PATTERN, Locale.US); Calendar firstRepaymentDate = (Calendar) startDate.clone();
dateFormat.setTimeZone(Utils.getTimeZoneOfTenant()); firstRepaymentDate.add(Calendar.MONTH, 1);
GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(REQUEST_SPEC, RESPONSE_SPEC, "42", true); firstRepaymentDate.add(Calendar.DAY_OF_MONTH,
Calendar startDate = Calendar.getInstance(Utils.getTimeZoneOfTenant()); firstRepaymentDate.getActualMaximum(Calendar.DAY_OF_MONTH) - Calendar.DAY_OF_MONTH);
Calendar currentDate = Calendar.getInstance(Utils.getTimeZoneOfTenant()); String firstRepayment = dateFormat.format(firstRepaymentDate.getTime());
startDate.add(Calendar.MONTH, -8);
Calendar firstRepaymentDate = (Calendar) startDate.clone(); final String loanDisbursementDate = dateFormat.format(startDate.getTime());
firstRepaymentDate.add(Calendar.MONTH, 1); final Integer clientID = ClientHelper.createClient(REQUEST_SPEC, RESPONSE_SPEC);
firstRepaymentDate.add(Calendar.DAY_OF_MONTH, firstRepaymentDate.getActualMaximum(Calendar.DAY_OF_MONTH) - Calendar.DAY_OF_MONTH); ClientHelper.verifyClientCreatedOnServer(REQUEST_SPEC, RESPONSE_SPEC, clientID);
String firstRepayment = dateFormat.format(firstRepaymentDate.getTime()); final Integer loanProductID = createLoanProductWithInterestRecalculationAndCompoundingDetails(
LoanProductTestBuilder.INTEREST_PRINCIPAL_PENALTIES_FEES_ORDER_STRATEGY,
LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_NONE,
LoanProductTestBuilder.RECALCULATION_STRATEGY_REDUCE_NUMBER_OF_INSTALLMENTS,
LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_SAME_AS_REPAYMENT_PERIOD,
LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE, null, "12");
final String loanDisbursementDate = dateFormat.format(startDate.getTime()); final Integer loanID = applyForLoanApplicationForInterestRecalculation(clientID, loanProductID, loanDisbursementDate,
final Integer clientID = ClientHelper.createClient(REQUEST_SPEC, RESPONSE_SPEC); LoanApplicationTestBuilder.INTEREST_PRINCIPAL_PENALTIES_FEES_ORDER_STRATEGY, firstRepayment);
ClientHelper.verifyClientCreatedOnServer(REQUEST_SPEC, RESPONSE_SPEC, clientID);
final Integer loanProductID = createLoanProductWithInterestRecalculationAndCompoundingDetails(
LoanProductTestBuilder.INTEREST_PRINCIPAL_PENALTIES_FEES_ORDER_STRATEGY,
LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_NONE,
LoanProductTestBuilder.RECALCULATION_STRATEGY_REDUCE_NUMBER_OF_INSTALLMENTS,
LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_SAME_AS_REPAYMENT_PERIOD,
LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE, null, "12");
final Integer loanID = applyForLoanApplicationForInterestRecalculation(clientID, loanProductID, loanDisbursementDate, Assertions.assertNotNull(loanID);
LoanApplicationTestBuilder.INTEREST_PRINCIPAL_PENALTIES_FEES_ORDER_STRATEGY, firstRepayment); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(REQUEST_SPEC, RESPONSE_SPEC, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
Assertions.assertNotNull(loanID); LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------");
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(REQUEST_SPEC, RESPONSE_SPEC, loanID); loanStatusHashMap = LOAN_TRANSACTION_HELPER.approveLoan(loanDisbursementDate, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
loanStatusHashMap = LOAN_TRANSACTION_HELPER.approveLoan(loanDisbursementDate, loanID); String loanDetails = LOAN_TRANSACTION_HELPER.getLoanDetails(REQUEST_SPEC, RESPONSE_SPEC, loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); loanStatusHashMap = LOAN_TRANSACTION_HELPER.disburseLoanWithNetDisbursalAmount(loanDisbursementDate, loanID,
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); ArrayList<HashMap> loanSchedule = LOAN_TRANSACTION_HELPER.getLoanRepaymentSchedule(REQUEST_SPEC, RESPONSE_SPEC, loanID);
String loanDetails = LOAN_TRANSACTION_HELPER.getLoanDetails(REQUEST_SPEC, RESPONSE_SPEC, loanID); Assertions.assertNotNull(loanSchedule);
loanStatusHashMap = LOAN_TRANSACTION_HELPER.disburseLoanWithNetDisbursalAmount(loanDisbursementDate, loanID, startDate.add(Calendar.DAY_OF_MONTH, 2);
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); String loanFirstRepaymentDate = dateFormat.format(startDate.getTime());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); //
Float earlyPayment = Float.parseFloat("3000");
LOAN_TRANSACTION_HELPER.makeRepayment(loanFirstRepaymentDate, earlyPayment, loanID);
ArrayList<HashMap> loanSchedule = LOAN_TRANSACTION_HELPER.getLoanRepaymentSchedule(REQUEST_SPEC, RESPONSE_SPEC, loanID); HashMap prepayDetail = LOAN_TRANSACTION_HELPER.getPrepayAmount(REQUEST_SPEC, RESPONSE_SPEC, loanID);
Assertions.assertNotNull(loanSchedule); String prepayAmount = String.valueOf(prepayDetail.get("amount"));
startDate.add(Calendar.DAY_OF_MONTH, 2); String loanPrepaymentDate = dateFormat.format(currentDate.getTime());
String loanFirstRepaymentDate = dateFormat.format(startDate.getTime()); LOAN_TRANSACTION_HELPER.makeRepayment(loanPrepaymentDate, Float.parseFloat(prepayAmount), loanID);
// loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(REQUEST_SPEC, RESPONSE_SPEC, loanID);
Float earlyPayment = Float.parseFloat("3000"); LoanStatusChecker.verifyLoanAccountIsClosed(loanStatusHashMap);
LOAN_TRANSACTION_HELPER.makeRepayment(loanFirstRepaymentDate, earlyPayment, loanID); } finally {
GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(REQUEST_SPEC, RESPONSE_SPEC, "42", false);
HashMap prepayDetail = LOAN_TRANSACTION_HELPER.getPrepayAmount(REQUEST_SPEC, RESPONSE_SPEC, loanID); }
String prepayAmount = String.valueOf(prepayDetail.get("amount"));
String loanPrepaymentDate = dateFormat.format(currentDate.getTime());
LOAN_TRANSACTION_HELPER.makeRepayment(loanPrepaymentDate, Float.parseFloat(prepayAmount), loanID);
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(REQUEST_SPEC, RESPONSE_SPEC, loanID);
LoanStatusChecker.verifyLoanAccountIsClosed(loanStatusHashMap);
GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(REQUEST_SPEC, RESPONSE_SPEC, "42", false);
} }
@Test @Test
public void testLoanScheduleWithInterestRecalculationMakeAdvancePaymentTillSettlement() { public void testLoanScheduleWithInterestRecalculationMakeAdvancePaymentTillSettlement() {
try {
final ResponseSpecification errorResponse = new ResponseSpecBuilder().expectStatusCode(403).build();
final LoanTransactionHelper validationErrorHelper = new LoanTransactionHelper(REQUEST_SPEC, errorResponse);
DateFormat dateFormat = new SimpleDateFormat(DATETIME_PATTERN, Locale.US);
dateFormat.setTimeZone(Utils.getTimeZoneOfTenant());
GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(REQUEST_SPEC, RESPONSE_SPEC, "42", true);
Calendar startDate = Calendar.getInstance(Utils.getTimeZoneOfTenant());
Calendar currentDate = Calendar.getInstance(Utils.getTimeZoneOfTenant());
startDate.add(Calendar.MONTH, -8);
final ResponseSpecification errorResponse = new ResponseSpecBuilder().expectStatusCode(403).build(); Calendar firstRepaymentDate = (Calendar) startDate.clone();
final LoanTransactionHelper validationErrorHelper = new LoanTransactionHelper(REQUEST_SPEC, errorResponse); firstRepaymentDate.add(Calendar.MONTH, 1);
DateFormat dateFormat = new SimpleDateFormat(DATETIME_PATTERN, Locale.US); firstRepaymentDate.add(Calendar.DAY_OF_MONTH,
dateFormat.setTimeZone(Utils.getTimeZoneOfTenant()); firstRepaymentDate.getActualMaximum(Calendar.DAY_OF_MONTH) - Calendar.DAY_OF_MONTH);
GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(REQUEST_SPEC, RESPONSE_SPEC, "42", true); String firstRepayment = dateFormat.format(firstRepaymentDate.getTime());
Calendar startDate = Calendar.getInstance(Utils.getTimeZoneOfTenant());
Calendar currentDate = Calendar.getInstance(Utils.getTimeZoneOfTenant());
startDate.add(Calendar.MONTH, -8);
Calendar firstRepaymentDate = (Calendar) startDate.clone(); final String loanDisbursementDate = dateFormat.format(startDate.getTime());
firstRepaymentDate.add(Calendar.MONTH, 1); final Integer clientID = ClientHelper.createClient(REQUEST_SPEC, RESPONSE_SPEC);
firstRepaymentDate.add(Calendar.DAY_OF_MONTH, firstRepaymentDate.getActualMaximum(Calendar.DAY_OF_MONTH) - Calendar.DAY_OF_MONTH); ClientHelper.verifyClientCreatedOnServer(REQUEST_SPEC, RESPONSE_SPEC, clientID);
String firstRepayment = dateFormat.format(firstRepaymentDate.getTime()); final Integer loanProductID = createLoanProductWithInterestRecalculationAndCompoundingDetails(
LoanProductTestBuilder.INTEREST_PRINCIPAL_PENALTIES_FEES_ORDER_STRATEGY,
LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_NONE,
LoanProductTestBuilder.RECALCULATION_STRATEGY_REDUCE_NUMBER_OF_INSTALLMENTS,
LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_SAME_AS_REPAYMENT_PERIOD,
LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE, null, "12");
final String loanDisbursementDate = dateFormat.format(startDate.getTime()); final Integer loanID = applyForLoanApplicationForInterestRecalculation(clientID, loanProductID, loanDisbursementDate,
final Integer clientID = ClientHelper.createClient(REQUEST_SPEC, RESPONSE_SPEC); LoanApplicationTestBuilder.INTEREST_PRINCIPAL_PENALTIES_FEES_ORDER_STRATEGY, firstRepayment);
ClientHelper.verifyClientCreatedOnServer(REQUEST_SPEC, RESPONSE_SPEC, clientID);
final Integer loanProductID = createLoanProductWithInterestRecalculationAndCompoundingDetails(
LoanProductTestBuilder.INTEREST_PRINCIPAL_PENALTIES_FEES_ORDER_STRATEGY,
LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_NONE,
LoanProductTestBuilder.RECALCULATION_STRATEGY_REDUCE_NUMBER_OF_INSTALLMENTS,
LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_SAME_AS_REPAYMENT_PERIOD,
LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE, null, "12");
final Integer loanID = applyForLoanApplicationForInterestRecalculation(clientID, loanProductID, loanDisbursementDate, Assertions.assertNotNull(loanID);
LoanApplicationTestBuilder.INTEREST_PRINCIPAL_PENALTIES_FEES_ORDER_STRATEGY, firstRepayment); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(REQUEST_SPEC, RESPONSE_SPEC, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
Assertions.assertNotNull(loanID); LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------");
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(REQUEST_SPEC, RESPONSE_SPEC, loanID); loanStatusHashMap = LOAN_TRANSACTION_HELPER.approveLoan(loanDisbursementDate, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
loanStatusHashMap = LOAN_TRANSACTION_HELPER.approveLoan(loanDisbursementDate, loanID); String loanDetails = LOAN_TRANSACTION_HELPER.getLoanDetails(REQUEST_SPEC, RESPONSE_SPEC, loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); loanStatusHashMap = LOAN_TRANSACTION_HELPER.disburseLoanWithNetDisbursalAmount(loanDisbursementDate, loanID,
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); ArrayList<HashMap> loanSchedule = LOAN_TRANSACTION_HELPER.getLoanRepaymentSchedule(REQUEST_SPEC, RESPONSE_SPEC, loanID);
String loanDetails = LOAN_TRANSACTION_HELPER.getLoanDetails(REQUEST_SPEC, RESPONSE_SPEC, loanID); Assertions.assertNotNull(loanSchedule);
loanStatusHashMap = LOAN_TRANSACTION_HELPER.disburseLoanWithNetDisbursalAmount(loanDisbursementDate, loanID, Calendar repaymentDate = (Calendar) firstRepaymentDate.clone();
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); startDate.add(Calendar.DAY_OF_MONTH, 2);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); String loanFirstRepaymentDate = dateFormat.format(startDate.getTime());
//
Float earlyPayment = Float.parseFloat("3000");
String retrieveDueDate = null;
Float amount = null;
LOAN_TRANSACTION_HELPER.makeRepayment(loanFirstRepaymentDate, earlyPayment, loanID);
for (int i = 1; i < loanSchedule.size(); i++) {
ArrayList<HashMap> loanSchedule = LOAN_TRANSACTION_HELPER.getLoanRepaymentSchedule(REQUEST_SPEC, RESPONSE_SPEC, loanID); retrieveDueDate = dateFormat.format(repaymentDate.getTime());
Assertions.assertNotNull(loanSchedule); amount = (Float) loanSchedule.get(i).get("principalOriginalDue") + (Float) loanSchedule.get(i).get("interestOriginalDue");
Calendar repaymentDate = (Calendar) firstRepaymentDate.clone(); if (currentDate.after(repaymentDate)) {
startDate.add(Calendar.DAY_OF_MONTH, 2); LOAN_TRANSACTION_HELPER.makeRepayment(retrieveDueDate, amount, loanID);
String loanFirstRepaymentDate = dateFormat.format(startDate.getTime()); } else {
// break;
Float earlyPayment = Float.parseFloat("3000"); }
String retrieveDueDate = null; repaymentDate.add(Calendar.MONTH, 1);
Float amount = null;
LOAN_TRANSACTION_HELPER.makeRepayment(loanFirstRepaymentDate, earlyPayment, loanID);
for (int i = 1; i < loanSchedule.size(); i++) {
retrieveDueDate = dateFormat.format(repaymentDate.getTime());
amount = (Float) loanSchedule.get(i).get("principalOriginalDue") + (Float) loanSchedule.get(i).get("interestOriginalDue");
if (currentDate.after(repaymentDate)) {
LOAN_TRANSACTION_HELPER.makeRepayment(retrieveDueDate, amount, loanID);
} else {
break;
} }
repaymentDate.add(Calendar.MONTH, 1); HashMap savingsAccountErrorData = validationErrorHelper.makeRepayment(retrieveDueDate, amount, loanID);
ArrayList<HashMap> error = (ArrayList<HashMap>) savingsAccountErrorData.get("errors");
assertEquals("error.msg.loan.transaction.cannot.be.a.future.date", error.get(0).get("userMessageGlobalisationCode"));
} finally {
GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(REQUEST_SPEC, RESPONSE_SPEC, "42", false);
} }
HashMap savingsAccountErrorData = validationErrorHelper.makeRepayment(retrieveDueDate, amount, loanID);
ArrayList<HashMap> error = (ArrayList<HashMap>) savingsAccountErrorData.get("errors");
assertEquals("error.msg.loan.transaction.cannot.be.a.future.date", error.get(0).get("userMessageGlobalisationCode"));
GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(REQUEST_SPEC, RESPONSE_SPEC, "42", false);
} }
@Test @Test
@@ -5722,6 +5738,8 @@ public class ClientLoanIntegrationTest {
assertTrue(loanDetails.getStatus().getOverpaid()); assertTrue(loanDetails.getStatus().getOverpaid());
} finally { } finally {
GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, Boolean.FALSE); GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, Boolean.FALSE);
GlobalConfigurationHelper.manageConfigurations(REQUEST_SPEC, RESPONSE_SPEC,
GlobalConfigurationHelper.ENABLE_AUTOGENERATED_EXTERNAL_ID, false);
} }
} }
@@ -6256,65 +6274,69 @@ public class ClientLoanIntegrationTest {
.dateFormat(DATETIME_PATTERN).transactionDate("08 September 2022").locale("en").transactionAmount(3007.0)); .dateFormat(DATETIME_PATTERN).transactionDate("08 September 2022").locale("en").transactionAmount(3007.0));
} finally { } finally {
GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, Boolean.FALSE); GlobalConfigurationHelper.updateIsBusinessDateEnabled(REQUEST_SPEC, RESPONSE_SPEC, Boolean.FALSE);
GlobalConfigurationHelper.updateIsAutomaticExternalIdGenerationEnabled(REQUEST_SPEC, RESPONSE_SPEC, false);
} }
} }
@Test @Test
public void testCloseOpenMaturityDate() { public void testCloseOpenMaturityDate() {
GlobalConfigurationHelper.updateIsAutomaticExternalIdGenerationEnabled(REQUEST_SPEC, RESPONSE_SPEC, true); try {
final Account assetAccount = ACCOUNT_HELPER.createAssetAccount(); GlobalConfigurationHelper.updateIsAutomaticExternalIdGenerationEnabled(REQUEST_SPEC, RESPONSE_SPEC, true);
final Account incomeAccount = ACCOUNT_HELPER.createIncomeAccount(); final Account assetAccount = ACCOUNT_HELPER.createAssetAccount();
final Account expenseAccount = ACCOUNT_HELPER.createExpenseAccount(); final Account incomeAccount = ACCOUNT_HELPER.createIncomeAccount();
final Account overpaymentAccount = ACCOUNT_HELPER.createLiabilityAccount(); final Account expenseAccount = ACCOUNT_HELPER.createExpenseAccount();
final Account overpaymentAccount = ACCOUNT_HELPER.createLiabilityAccount();
final Integer loanProductID = createLoanProductWithPeriodicAccrualAccountingNoInterest(assetAccount, incomeAccount, expenseAccount, final Integer loanProductID = createLoanProductWithPeriodicAccrualAccountingNoInterest(assetAccount, incomeAccount,
overpaymentAccount); expenseAccount, overpaymentAccount);
final Integer clientID = ClientHelper.createClient(REQUEST_SPEC, RESPONSE_SPEC, "01 January 2011"); final Integer clientID = ClientHelper.createClient(REQUEST_SPEC, RESPONSE_SPEC, "01 January 2011");
final Integer loanID = applyForLoanApplication(clientID, loanProductID); final Integer loanID = applyForLoanApplication(clientID, loanProductID);
HashMap<String, Object> loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(REQUEST_SPEC, RESPONSE_SPEC, loanID); HashMap<String, Object> loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(REQUEST_SPEC, RESPONSE_SPEC, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
loanStatusHashMap = LOAN_TRANSACTION_HELPER.approveLoan("02 September 2022", loanID); loanStatusHashMap = LOAN_TRANSACTION_HELPER.approveLoan("02 September 2022", loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
loanStatusHashMap = LOAN_TRANSACTION_HELPER.disburseLoanWithNetDisbursalAmount("03 September 2022", loanID, "1000"); loanStatusHashMap = LOAN_TRANSACTION_HELPER.disburseLoanWithNetDisbursalAmount("03 September 2022", loanID, "1000");
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
GetLoansLoanIdResponse loanDetails = LOAN_TRANSACTION_HELPER.getLoanDetails((long) loanID); GetLoansLoanIdResponse loanDetails = LOAN_TRANSACTION_HELPER.getLoanDetails((long) loanID);
LocalDate expectedMaturityDate = loanDetails.getTimeline().getExpectedMaturityDate(); LocalDate expectedMaturityDate = loanDetails.getTimeline().getExpectedMaturityDate();
LocalDate actualMaturityDate = loanDetails.getTimeline().getActualMaturityDate(); LocalDate actualMaturityDate = loanDetails.getTimeline().getActualMaturityDate();
assertTrue(expectedMaturityDate.isEqual(actualMaturityDate)); assertTrue(expectedMaturityDate.isEqual(actualMaturityDate));
LOAN_TRANSACTION_HELPER.makeRepayment("04 September 2022", Float.parseFloat("500"), loanID); LOAN_TRANSACTION_HELPER.makeRepayment("04 September 2022", Float.parseFloat("500"), loanID);
LOAN_TRANSACTION_HELPER.makeRepayment("05 September 2022", Float.parseFloat("700"), loanID); LOAN_TRANSACTION_HELPER.makeRepayment("05 September 2022", Float.parseFloat("700"), loanID);
loanDetails = LOAN_TRANSACTION_HELPER.getLoanDetails((long) loanID); loanDetails = LOAN_TRANSACTION_HELPER.getLoanDetails((long) loanID);
expectedMaturityDate = loanDetails.getTimeline().getExpectedMaturityDate(); expectedMaturityDate = loanDetails.getTimeline().getExpectedMaturityDate();
actualMaturityDate = loanDetails.getTimeline().getActualMaturityDate(); actualMaturityDate = loanDetails.getTimeline().getActualMaturityDate();
assertNotNull(expectedMaturityDate); assertNotNull(expectedMaturityDate);
assertNull(actualMaturityDate); assertNull(actualMaturityDate);
LOAN_TRANSACTION_HELPER.reverseLoanTransaction((long) loanID, loanDetails.getTransactions().get(1).getId(), LOAN_TRANSACTION_HELPER.reverseLoanTransaction((long) loanID, loanDetails.getTransactions().get(1).getId(),
new PostLoansLoanIdTransactionsTransactionIdRequest().dateFormat(DATETIME_PATTERN).transactionDate("04 September 2022") new PostLoansLoanIdTransactionsTransactionIdRequest().dateFormat(DATETIME_PATTERN).transactionDate("04 September 2022")
.transactionAmount(0.0).locale("en")); .transactionAmount(0.0).locale("en"));
loanDetails = LOAN_TRANSACTION_HELPER.getLoanDetails((long) loanID); loanDetails = LOAN_TRANSACTION_HELPER.getLoanDetails((long) loanID);
expectedMaturityDate = loanDetails.getTimeline().getExpectedMaturityDate(); expectedMaturityDate = loanDetails.getTimeline().getExpectedMaturityDate();
actualMaturityDate = loanDetails.getTimeline().getActualMaturityDate(); actualMaturityDate = loanDetails.getTimeline().getActualMaturityDate();
assertNotNull(expectedMaturityDate); assertNotNull(expectedMaturityDate);
assertNotNull(actualMaturityDate); assertNotNull(actualMaturityDate);
assertTrue(expectedMaturityDate.isEqual(actualMaturityDate));
assertTrue(expectedMaturityDate.isEqual(actualMaturityDate));
} finally {
GlobalConfigurationHelper.updateIsAutomaticExternalIdGenerationEnabled(REQUEST_SPEC, RESPONSE_SPEC, false);
}
} }
@Test @Test
@@ -2235,7 +2235,7 @@ public class ClientSavingsIntegrationTest {
Integer releaseTransactionId = this.savingsAccountHelper.releaseAmount(savingsId, holdTransactionId); Integer releaseTransactionId = this.savingsAccountHelper.releaseAmount(savingsId, holdTransactionId);
Date today = Date.from(Utils.getLocalDateOfTenant().atStartOfDay(Utils.getZoneIdOfTenant()).toInstant()); Date today = Date.from(Utils.getLocalDateOfTenant().atStartOfDay(Utils.getZoneIdOfTenant()).toInstant());
String todayDate = today.toString(); String todayDate = today.toString();
SimpleDateFormat dt1 = new SimpleDateFormat("dd MMM yyyy"); SimpleDateFormat dt1 = new SimpleDateFormat("dd MMMM yyyy");
todayDate = dt1.format(today).toString(); todayDate = dt1.format(today).toString();
withdrawTransactionId = (Integer) this.savingsAccountHelper.withdrawalFromSavingsAccount(savingsId, "300", todayDate, withdrawTransactionId = (Integer) this.savingsAccountHelper.withdrawalFromSavingsAccount(savingsId, "300", todayDate,
CommonConstants.RESPONSE_RESOURCE_ID); CommonConstants.RESPONSE_RESOURCE_ID);
@@ -50,7 +50,7 @@ import org.junit.jupiter.api.Test;
public class SavingsAccountTransactionTest { public class SavingsAccountTransactionTest {
public static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL"; public static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL";
public static final String DEFAULT_DATE_FORMAT = "dd MMM yyyy"; public static final String DEFAULT_DATE_FORMAT = "dd MMMM yyyy";
final String startDateString = "03 June 2023"; final String startDateString = "03 June 2023";
final String depositDateString = "05 June 2023"; final String depositDateString = "05 June 2023";
final String withdrawDateString = "10 June 2023"; final String withdrawDateString = "10 June 2023";
@@ -62,7 +62,7 @@ import org.springframework.data.domain.Sort;
public class SavingsAccountTransactionsSearchIntegrationTest { public class SavingsAccountTransactionsSearchIntegrationTest {
public static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL"; public static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL";
public static final String DEFAULT_DATE_FORMAT = "dd MMM yyyy"; public static final String DEFAULT_DATE_FORMAT = "dd MMMM yyyy";
public static final Locale DEFAULT_LOCALE = Locale.ENGLISH; public static final Locale DEFAULT_LOCALE = Locale.ENGLISH;
final String startDate = "01 May 2023"; final String startDate = "01 May 2023";
final String firstDepositDate = "05 May 2023"; final String firstDepositDate = "05 May 2023";
@@ -44,8 +44,7 @@ public class SavingsAccountsExternalIdTest extends IntegrationTest {
public static final String EXTERNAL_ID = UUID.randomUUID().toString(); public static final String EXTERNAL_ID = UUID.randomUUID().toString();
private final String dateFormat = "dd MMMM yyyy"; private final String dateFormat = "dd MMMM yyyy";
private final String locale = "en"; private final String locale = "en";
private final String formattedDate = LocalDate.now(ZoneId.systemDefault()).minusDays(5) private final String formattedDate = LocalDate.now(ZoneId.systemDefault()).minusDays(5).format(DateTimeFormatter.ofPattern(dateFormat));
.format(DateTimeFormatter.ofPattern("dd MMM yyyy"));
@Test @Test
@Order(1) @Order(1)
@@ -42,7 +42,7 @@ public class SavingsAccountsTest extends IntegrationTest {
private static final Logger LOG = LoggerFactory.getLogger(SavingsAccountsTest.class); private static final Logger LOG = LoggerFactory.getLogger(SavingsAccountsTest.class);
private final String dateFormat = "dd MMMM yyyy"; private final String dateFormat = "dd MMMM yyyy";
private final String locale = "en"; private final String locale = "en";
private final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMM yyyy"); private final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormat);
private final String formattedDate = simpleDateFormat.format(new Date()); private final String formattedDate = simpleDateFormat.format(new Date());
private int savingId = 1; private int savingId = 1;
@@ -150,7 +150,7 @@ public class CenterDomain implements Comparable<CenterDomain> {
if (active) { if (active) {
map.put("active", "true"); map.put("active", "true");
map.put("locale", "en"); map.put("locale", "en");
map.put("dateFormat", "dd MMM yyyy"); map.put("dateFormat", "dd MMMM yyyy");
map.put("activationDate", activationDate); map.put("activationDate", activationDate);
} else { } else {
map.put("active", "false"); map.put("active", "false");
@@ -113,7 +113,7 @@ public final class CenterHelper {
if (activationDate != null) { if (activationDate != null) {
hm.put("active", true); hm.put("active", true);
hm.put("locale", "en"); hm.put("locale", "en");
hm.put("dateFormat", "dd MMM yyyy"); hm.put("dateFormat", "dd MMMM yyyy");
hm.put("activationDate", activationDate); hm.put("activationDate", activationDate);
} }
@@ -58,7 +58,7 @@ public class DividendsIntegrationTests {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Test @Test
public void testCreateDividends() { public void testCreateDividends() {
DateFormat simple = new SimpleDateFormat("dd MMM yyyy"); DateFormat simple = new SimpleDateFormat("dd MMMM yyyy");
final Integer productId = createShareProduct(); final Integer productId = createShareProduct();
ArrayList<Integer> shareAccounts = new ArrayList<>(); ArrayList<Integer> shareAccounts = new ArrayList<>();
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
@@ -109,12 +109,12 @@ public class DividendsIntegrationTests {
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
cal.set(startdateList.get(0), startdateList.get(1) - 1, startdateList.get(2)); cal.set(startdateList.get(0), startdateList.get(1) - 1, startdateList.get(2));
Date startDate = cal.getTime(); Date startDate = cal.getTime();
Assertions.assertEquals("01 Jan 2015", simple.format(startDate)); Assertions.assertEquals("01 January 2015", simple.format(startDate));
List<Integer> enddateList = (List<Integer>) dividend.get("dividendPeriodEndDate"); List<Integer> enddateList = (List<Integer>) dividend.get("dividendPeriodEndDate");
cal = Calendar.getInstance(); cal = Calendar.getInstance();
cal.set(enddateList.get(0), enddateList.get(1) - 1, enddateList.get(2)); cal.set(enddateList.get(0), enddateList.get(1) - 1, enddateList.get(2));
Date endDate = cal.getTime(); Date endDate = cal.getTime();
Assertions.assertEquals("01 Apr 2016", simple.format(endDate)); Assertions.assertEquals("01 April 2016", simple.format(endDate));
Map<String, Object> dividenddetails = ShareDividendsTransactionHelper.retrieveDividendDetails(productId, dividendId, requestSpec, Map<String, Object> dividenddetails = ShareDividendsTransactionHelper.retrieveDividendDetails(productId, dividendId, requestSpec,
responseSpec); responseSpec);
@@ -151,12 +151,12 @@ public class DividendsIntegrationTests {
cal = Calendar.getInstance(); cal = Calendar.getInstance();
cal.set(startdateList.get(0), startdateList.get(1) - 1, startdateList.get(2)); cal.set(startdateList.get(0), startdateList.get(1) - 1, startdateList.get(2));
startDate = cal.getTime(); startDate = cal.getTime();
Assertions.assertEquals("01 Jan 2015", simple.format(startDate)); Assertions.assertEquals("01 January 2015", simple.format(startDate));
enddateList = (List<Integer>) dividend.get("dividendPeriodEndDate"); enddateList = (List<Integer>) dividend.get("dividendPeriodEndDate");
cal = Calendar.getInstance(); cal = Calendar.getInstance();
cal.set(enddateList.get(0), enddateList.get(1) - 1, enddateList.get(2)); cal.set(enddateList.get(0), enddateList.get(1) - 1, enddateList.get(2));
endDate = cal.getTime(); endDate = cal.getTime();
Assertions.assertEquals("01 Apr 2016", simple.format(endDate)); Assertions.assertEquals("01 April 2016", simple.format(endDate));
dividenddetails = ShareDividendsTransactionHelper.retrieveDividendDetails(productId, dividendId, requestSpec, responseSpec); dividenddetails = ShareDividendsTransactionHelper.retrieveDividendDetails(productId, dividendId, requestSpec, responseSpec);
Assertions.assertEquals("5", String.valueOf(dividenddetails.get("totalFilteredRecords"))); Assertions.assertEquals("5", String.valueOf(dividenddetails.get("totalFilteredRecords")));
@@ -383,7 +383,7 @@ public class ShareAccountIntegrationTests {
Map<String, Object> shareAccountDataForUpdate = new HashMap<>(); Map<String, Object> shareAccountDataForUpdate = new HashMap<>();
shareAccountDataForUpdate.put("requestedShares", 30); shareAccountDataForUpdate.put("requestedShares", 30);
shareAccountDataForUpdate.put("applicationDate", "02 Mar 2016"); shareAccountDataForUpdate.put("applicationDate", "02 March 2016");
shareAccountDataForUpdate.put("dateFormat", "dd MMMM yyyy"); shareAccountDataForUpdate.put("dateFormat", "dd MMMM yyyy");
shareAccountDataForUpdate.put("locale", "en_GB"); shareAccountDataForUpdate.put("locale", "en_GB");
shareAccountDataForUpdate.put("charges", charges); shareAccountDataForUpdate.put("charges", charges);
@@ -394,7 +394,7 @@ public class ShareAccountIntegrationTests {
List<Map<String, Object>> transactions = (List<Map<String, Object>>) shareAccountData.get("purchasedShares"); List<Map<String, Object>> transactions = (List<Map<String, Object>>) shareAccountData.get("purchasedShares");
Assertions.assertNotNull(transactions); Assertions.assertNotNull(transactions);
Assertions.assertEquals(2, transactions.size()); Assertions.assertEquals(2, transactions.size());
DateFormat simple = new SimpleDateFormat("dd MMM yyyy"); DateFormat simple = new SimpleDateFormat("dd MMMM yyyy");
for (int i = 0; i < transactions.size(); i++) { for (int i = 0; i < transactions.size(); i++) {
Map<String, Object> transaction = transactions.get(i); Map<String, Object> transaction = transactions.get(i);
Map<String, Object> transactionTypeMap = (Map<String, Object>) transaction.get("type"); Map<String, Object> transactionTypeMap = (Map<String, Object>) transaction.get("type");
@@ -409,7 +409,7 @@ public class ShareAccountIntegrationTests {
Assertions.assertEquals("60.0", String.valueOf(transaction.get("amountPaid"))); Assertions.assertEquals("60.0", String.valueOf(transaction.get("amountPaid")));
Assertions.assertEquals("2.0", String.valueOf(transaction.get("chargeAmount"))); Assertions.assertEquals("2.0", String.valueOf(transaction.get("chargeAmount")));
Assertions.assertEquals("2.0", String.valueOf(transaction.get("purchasedPrice"))); Assertions.assertEquals("2.0", String.valueOf(transaction.get("purchasedPrice")));
Assertions.assertEquals("02 Mar 2016", simple.format(date)); Assertions.assertEquals("02 March 2016", simple.format(date));
} else if (transactionType.equals("charge.payment")) { } else if (transactionType.equals("charge.payment")) {
Assertions.assertEquals("2.0", String.valueOf(transaction.get("amount"))); Assertions.assertEquals("2.0", String.valueOf(transaction.get("amount")));
Assertions.assertEquals("0", String.valueOf(transaction.get("amountPaid"))); Assertions.assertEquals("0", String.valueOf(transaction.get("amountPaid")));
@@ -444,7 +444,7 @@ public class ShareAccountIntegrationTests {
Map<String, Object> approveMap = new HashMap<>(); Map<String, Object> approveMap = new HashMap<>();
approveMap.put("note", "Share Account Approval Note"); approveMap.put("note", "Share Account Approval Note");
approveMap.put("dateFormat", "dd MMMM yyyy"); approveMap.put("dateFormat", "dd MMMM yyyy");
approveMap.put("approvedDate", "01 Jan 2016"); approveMap.put("approvedDate", "01 January 2016");
approveMap.put("locale", "en"); approveMap.put("locale", "en");
String approve = new Gson().toJson(approveMap); String approve = new Gson().toJson(approveMap);
ShareAccountTransactionHelper.postCommand("approve", shareAccountId, approve, requestSpec, responseSpec); ShareAccountTransactionHelper.postCommand("approve", shareAccountId, approve, requestSpec, responseSpec);
@@ -456,7 +456,7 @@ public class ShareAccountIntegrationTests {
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
cal.set(dateList.get(0), dateList.get(1) - 1, dateList.get(2)); cal.set(dateList.get(0), dateList.get(1) - 1, dateList.get(2));
Date approvedDate = cal.getTime(); Date approvedDate = cal.getTime();
Assertions.assertEquals("01 Jan 2016", simple.format(approvedDate)); Assertions.assertEquals("01 January 2016", simple.format(approvedDate));
// charges verification // charges verification
chargesList = (List<Map<String, Object>>) shareAccountData.get("charges"); chargesList = (List<Map<String, Object>>) shareAccountData.get("charges");
@@ -483,7 +483,7 @@ public class ShareAccountIntegrationTests {
Map<String, Object> activateMap = new HashMap<>(); Map<String, Object> activateMap = new HashMap<>();
activateMap.put("dateFormat", "dd MMMM yyyy"); activateMap.put("dateFormat", "dd MMMM yyyy");
activateMap.put("activatedDate", "01 Jan 2016"); activateMap.put("activatedDate", "01 January 2016");
activateMap.put("locale", "en"); activateMap.put("locale", "en");
String activateJson = new Gson().toJson(activateMap); String activateJson = new Gson().toJson(activateMap);
ShareAccountTransactionHelper.postCommand("activate", shareAccountId, activateJson, requestSpec, responseSpec); ShareAccountTransactionHelper.postCommand("activate", shareAccountId, activateJson, requestSpec, responseSpec);
@@ -495,7 +495,7 @@ public class ShareAccountIntegrationTests {
cal = Calendar.getInstance(); cal = Calendar.getInstance();
cal.set(dateList.get(0), dateList.get(1) - 1, dateList.get(2)); cal.set(dateList.get(0), dateList.get(1) - 1, dateList.get(2));
Date activatedDate = cal.getTime(); Date activatedDate = cal.getTime();
Assertions.assertEquals("01 Jan 2016", simple.format(activatedDate)); Assertions.assertEquals("01 January 2016", simple.format(activatedDate));
transactions = (List<Map<String, Object>>) shareAccountData.get("purchasedShares"); transactions = (List<Map<String, Object>>) shareAccountData.get("purchasedShares");
Assertions.assertNotNull(transactions); Assertions.assertNotNull(transactions);
@@ -514,12 +514,12 @@ public class ShareAccountIntegrationTests {
Assertions.assertEquals("62.0", String.valueOf(transaction.get("amountPaid"))); Assertions.assertEquals("62.0", String.valueOf(transaction.get("amountPaid")));
Assertions.assertEquals("2.0", String.valueOf(transaction.get("chargeAmount"))); Assertions.assertEquals("2.0", String.valueOf(transaction.get("chargeAmount")));
Assertions.assertEquals("2.0", String.valueOf(transaction.get("purchasedPrice"))); Assertions.assertEquals("2.0", String.valueOf(transaction.get("purchasedPrice")));
Assertions.assertEquals("02 Mar 2016", simple.format(date)); Assertions.assertEquals("02 March 2016", simple.format(date));
} else if (transactionType.equals("charge.payment")) { } else if (transactionType.equals("charge.payment")) {
Assertions.assertEquals("2.0", String.valueOf(transaction.get("amount"))); Assertions.assertEquals("2.0", String.valueOf(transaction.get("amount")));
Assertions.assertEquals("2.0", String.valueOf(transaction.get("amountPaid"))); Assertions.assertEquals("2.0", String.valueOf(transaction.get("amountPaid")));
Assertions.assertEquals("0", String.valueOf(transaction.get("chargeAmount"))); Assertions.assertEquals("0", String.valueOf(transaction.get("chargeAmount")));
Assertions.assertEquals("01 Jan 2016", simple.format(date)); Assertions.assertEquals("01 January 2016", simple.format(date));
} }
} }
@@ -552,7 +552,7 @@ public class ShareAccountIntegrationTests {
// apply additional shares // apply additional shares
Map<String, Object> additionalSharesRequestMap = new HashMap<>(); Map<String, Object> additionalSharesRequestMap = new HashMap<>();
additionalSharesRequestMap.put("requestedDate", "01 Apr 2016"); additionalSharesRequestMap.put("requestedDate", "01 April 2016");
additionalSharesRequestMap.put("dateFormat", "dd MMMM yyyy"); additionalSharesRequestMap.put("dateFormat", "dd MMMM yyyy");
additionalSharesRequestMap.put("locale", "en"); additionalSharesRequestMap.put("locale", "en");
additionalSharesRequestMap.put("requestedShares", "15"); additionalSharesRequestMap.put("requestedShares", "15");
@@ -573,13 +573,13 @@ public class ShareAccountIntegrationTests {
Date date = cal.getTime(); Date date = cal.getTime();
String transactionType = (String) transactionTypeMap.get("code"); String transactionType = (String) transactionTypeMap.get("code");
String transactionDate = simple.format(date); String transactionDate = simple.format(date);
if (transactionType.equals("purchasedSharesType.purchased") && transactionDate.equals("02 Mar 2016")) { if (transactionType.equals("purchasedSharesType.purchased") && transactionDate.equals("02 March 2016")) {
Assertions.assertEquals("30", String.valueOf(transaction.get("numberOfShares"))); Assertions.assertEquals("30", String.valueOf(transaction.get("numberOfShares")));
Assertions.assertEquals("62.0", String.valueOf(transaction.get("amount"))); Assertions.assertEquals("62.0", String.valueOf(transaction.get("amount")));
Assertions.assertEquals("62.0", String.valueOf(transaction.get("amountPaid"))); Assertions.assertEquals("62.0", String.valueOf(transaction.get("amountPaid")));
Assertions.assertEquals("2.0", String.valueOf(transaction.get("chargeAmount"))); Assertions.assertEquals("2.0", String.valueOf(transaction.get("chargeAmount")));
Assertions.assertEquals("2.0", String.valueOf(transaction.get("purchasedPrice"))); Assertions.assertEquals("2.0", String.valueOf(transaction.get("purchasedPrice")));
} else if (transactionType.equals("purchasedSharesType.purchased") && transactionDate.equals("01 Apr 2016")) { } else if (transactionType.equals("purchasedSharesType.purchased") && transactionDate.equals("01 April 2016")) {
addtionalSharesRequestId = String.valueOf(transaction.get("id")); addtionalSharesRequestId = String.valueOf(transaction.get("id"));
Assertions.assertEquals("15", String.valueOf(transaction.get("numberOfShares"))); Assertions.assertEquals("15", String.valueOf(transaction.get("numberOfShares")));
Assertions.assertEquals("32.0", String.valueOf(transaction.get("amount"))); Assertions.assertEquals("32.0", String.valueOf(transaction.get("amount")));
@@ -593,7 +593,7 @@ public class ShareAccountIntegrationTests {
Assertions.assertEquals("2.0", String.valueOf(transaction.get("amount"))); Assertions.assertEquals("2.0", String.valueOf(transaction.get("amount")));
Assertions.assertEquals("2.0", String.valueOf(transaction.get("amountPaid"))); Assertions.assertEquals("2.0", String.valueOf(transaction.get("amountPaid")));
Assertions.assertEquals("0", String.valueOf(transaction.get("chargeAmount"))); Assertions.assertEquals("0", String.valueOf(transaction.get("chargeAmount")));
Assertions.assertEquals("01 Jan 2016", transactionDate); Assertions.assertEquals("01 January 2016", transactionDate);
} }
} }
@@ -648,13 +648,13 @@ public class ShareAccountIntegrationTests {
Date date = cal.getTime(); Date date = cal.getTime();
String transactionType = (String) transactionTypeMap.get("code"); String transactionType = (String) transactionTypeMap.get("code");
String transactionDate = simple.format(date); String transactionDate = simple.format(date);
if (transactionType.equals("purchasedSharesType.purchased") && transactionDate.equals("02 Mar 2016")) { if (transactionType.equals("purchasedSharesType.purchased") && transactionDate.equals("02 March 2016")) {
Assertions.assertEquals("30", String.valueOf(transaction.get("numberOfShares"))); Assertions.assertEquals("30", String.valueOf(transaction.get("numberOfShares")));
Assertions.assertEquals("62.0", String.valueOf(transaction.get("amount"))); Assertions.assertEquals("62.0", String.valueOf(transaction.get("amount")));
Assertions.assertEquals("62.0", String.valueOf(transaction.get("amountPaid"))); Assertions.assertEquals("62.0", String.valueOf(transaction.get("amountPaid")));
Assertions.assertEquals("2.0", String.valueOf(transaction.get("chargeAmount"))); Assertions.assertEquals("2.0", String.valueOf(transaction.get("chargeAmount")));
Assertions.assertEquals("2.0", String.valueOf(transaction.get("purchasedPrice"))); Assertions.assertEquals("2.0", String.valueOf(transaction.get("purchasedPrice")));
} else if (transactionType.equals("purchasedSharesType.purchased") && transactionDate.equals("01 Apr 2016")) { } else if (transactionType.equals("purchasedSharesType.purchased") && transactionDate.equals("01 April 2016")) {
Assertions.assertEquals("15", String.valueOf(transaction.get("numberOfShares"))); Assertions.assertEquals("15", String.valueOf(transaction.get("numberOfShares")));
Assertions.assertEquals("32.0", String.valueOf(transaction.get("amount"))); Assertions.assertEquals("32.0", String.valueOf(transaction.get("amount")));
Assertions.assertEquals("32.0", String.valueOf(transaction.get("amountPaid"))); Assertions.assertEquals("32.0", String.valueOf(transaction.get("amountPaid")));
@@ -667,7 +667,7 @@ public class ShareAccountIntegrationTests {
Assertions.assertEquals("2.0", String.valueOf(transaction.get("amount"))); Assertions.assertEquals("2.0", String.valueOf(transaction.get("amount")));
Assertions.assertEquals("2.0", String.valueOf(transaction.get("amountPaid"))); Assertions.assertEquals("2.0", String.valueOf(transaction.get("amountPaid")));
Assertions.assertEquals("0", String.valueOf(transaction.get("chargeAmount"))); Assertions.assertEquals("0", String.valueOf(transaction.get("chargeAmount")));
Assertions.assertEquals("01 Jan 2016", transactionDate); Assertions.assertEquals("01 January 2016", transactionDate);
} }
} }
@@ -843,13 +843,13 @@ public class ShareAccountIntegrationTests {
Date date = cal.getTime(); Date date = cal.getTime();
String transactionType = (String) transactionTypeMap.get("code"); String transactionType = (String) transactionTypeMap.get("code");
String transactionDate = simple.format(date); String transactionDate = simple.format(date);
if (transactionType.equals("purchasedSharesType.purchased") && transactionDate.equals("02 Mar 2016")) { if (transactionType.equals("purchasedSharesType.purchased") && transactionDate.equals("02 March 2016")) {
Assertions.assertEquals("30", String.valueOf(transaction.get("numberOfShares"))); Assertions.assertEquals("30", String.valueOf(transaction.get("numberOfShares")));
Assertions.assertEquals("62.0", String.valueOf(transaction.get("amount"))); Assertions.assertEquals("62.0", String.valueOf(transaction.get("amount")));
Assertions.assertEquals("62.0", String.valueOf(transaction.get("amountPaid"))); Assertions.assertEquals("62.0", String.valueOf(transaction.get("amountPaid")));
Assertions.assertEquals("2.0", String.valueOf(transaction.get("chargeAmount"))); Assertions.assertEquals("2.0", String.valueOf(transaction.get("chargeAmount")));
Assertions.assertEquals("2.0", String.valueOf(transaction.get("purchasedPrice"))); Assertions.assertEquals("2.0", String.valueOf(transaction.get("purchasedPrice")));
} else if (transactionType.equals("purchasedSharesType.purchased") && transactionDate.equals("01 Apr 2016")) { } else if (transactionType.equals("purchasedSharesType.purchased") && transactionDate.equals("01 April 2016")) {
Assertions.assertEquals("15", String.valueOf(transaction.get("numberOfShares"))); Assertions.assertEquals("15", String.valueOf(transaction.get("numberOfShares")));
Assertions.assertEquals("32.0", String.valueOf(transaction.get("amount"))); Assertions.assertEquals("32.0", String.valueOf(transaction.get("amount")));
Assertions.assertEquals("32.0", String.valueOf(transaction.get("amountPaid"))); Assertions.assertEquals("32.0", String.valueOf(transaction.get("amountPaid")));
@@ -868,7 +868,7 @@ public class ShareAccountIntegrationTests {
Assertions.assertEquals("2.0", String.valueOf(transaction.get("amount"))); Assertions.assertEquals("2.0", String.valueOf(transaction.get("amount")));
Assertions.assertEquals("2.0", String.valueOf(transaction.get("amountPaid"))); Assertions.assertEquals("2.0", String.valueOf(transaction.get("amountPaid")));
Assertions.assertEquals("0", String.valueOf(transaction.get("chargeAmount"))); Assertions.assertEquals("0", String.valueOf(transaction.get("chargeAmount")));
Assertions.assertEquals("01 Jan 2016", transactionDate); Assertions.assertEquals("01 January 2016", transactionDate);
} }
} }
@@ -921,13 +921,13 @@ public class ShareAccountIntegrationTests {
Date date = cal.getTime(); Date date = cal.getTime();
String transactionType = (String) transactionTypeMap.get("code"); String transactionType = (String) transactionTypeMap.get("code");
String transactionDate = simple.format(date); String transactionDate = simple.format(date);
if (transactionType.equals("purchasedSharesType.purchased") && transactionDate.equals("02 Mar 2016")) { if (transactionType.equals("purchasedSharesType.purchased") && transactionDate.equals("02 March 2016")) {
Assertions.assertEquals("30", String.valueOf(transaction.get("numberOfShares"))); Assertions.assertEquals("30", String.valueOf(transaction.get("numberOfShares")));
Assertions.assertEquals("62.0", String.valueOf(transaction.get("amount"))); Assertions.assertEquals("62.0", String.valueOf(transaction.get("amount")));
Assertions.assertEquals("62.0", String.valueOf(transaction.get("amountPaid"))); Assertions.assertEquals("62.0", String.valueOf(transaction.get("amountPaid")));
Assertions.assertEquals("2.0", String.valueOf(transaction.get("chargeAmount"))); Assertions.assertEquals("2.0", String.valueOf(transaction.get("chargeAmount")));
Assertions.assertEquals("2.0", String.valueOf(transaction.get("purchasedPrice"))); Assertions.assertEquals("2.0", String.valueOf(transaction.get("purchasedPrice")));
} else if (transactionType.equals("purchasedSharesType.purchased") && transactionDate.equals("01 Apr 2016")) { } else if (transactionType.equals("purchasedSharesType.purchased") && transactionDate.equals("01 April 2016")) {
Assertions.assertEquals("15", String.valueOf(transaction.get("numberOfShares"))); Assertions.assertEquals("15", String.valueOf(transaction.get("numberOfShares")));
Assertions.assertEquals("32.0", String.valueOf(transaction.get("amount"))); Assertions.assertEquals("32.0", String.valueOf(transaction.get("amount")));
Assertions.assertEquals("32.0", String.valueOf(transaction.get("amountPaid"))); Assertions.assertEquals("32.0", String.valueOf(transaction.get("amountPaid")));
@@ -953,7 +953,7 @@ public class ShareAccountIntegrationTests {
Assertions.assertEquals("2.0", String.valueOf(transaction.get("amount"))); Assertions.assertEquals("2.0", String.valueOf(transaction.get("amount")));
Assertions.assertEquals("2.0", String.valueOf(transaction.get("amountPaid"))); Assertions.assertEquals("2.0", String.valueOf(transaction.get("amountPaid")));
Assertions.assertEquals("0", String.valueOf(transaction.get("chargeAmount"))); Assertions.assertEquals("0", String.valueOf(transaction.get("chargeAmount")));
Assertions.assertEquals("01 Jan 2016", transactionDate); Assertions.assertEquals("01 January 2016", transactionDate);
} }
} }
// charges verification // charges verification
@@ -990,16 +990,16 @@ public class ShareAccountIntegrationTests {
private Integer createShareAccount(final Integer clientId, final Integer productId, final Integer savingsAccountId) { private Integer createShareAccount(final Integer clientId, final Integer productId, final Integer savingsAccountId) {
String josn = new ShareAccountHelper().withClientId(String.valueOf(clientId)).withProductId(String.valueOf(productId)) String josn = new ShareAccountHelper().withClientId(String.valueOf(clientId)).withProductId(String.valueOf(productId))
.withExternalId("External1").withSavingsAccountId(String.valueOf(savingsAccountId)).withSubmittedDate("01 Jan 2016") .withExternalId("External1").withSavingsAccountId(String.valueOf(savingsAccountId)).withSubmittedDate("01 January 2016")
.withApplicationDate("01 Jan 2016").withRequestedShares("25").build(); .withApplicationDate("01 January 2016").withRequestedShares("25").build();
return ShareAccountTransactionHelper.createShareAccount(josn, requestSpec, responseSpec); return ShareAccountTransactionHelper.createShareAccount(josn, requestSpec, responseSpec);
} }
private Integer createShareAccount(final Integer clientId, final Integer productId, final Integer savingsAccountId, private Integer createShareAccount(final Integer clientId, final Integer productId, final Integer savingsAccountId,
List<Map<String, Object>> charges) { List<Map<String, Object>> charges) {
String josn = new ShareAccountHelper().withClientId(String.valueOf(clientId)).withProductId(String.valueOf(productId)) String josn = new ShareAccountHelper().withClientId(String.valueOf(clientId)).withProductId(String.valueOf(productId))
.withExternalId("External1").withSavingsAccountId(String.valueOf(savingsAccountId)).withSubmittedDate("01 Jan 2016") .withExternalId("External1").withSavingsAccountId(String.valueOf(savingsAccountId)).withSubmittedDate("01 January 2016")
.withApplicationDate("01 Jan 2016").withRequestedShares("25").withCharges(charges).build(); .withApplicationDate("01 January 2016").withRequestedShares("25").withCharges(charges).build();
return ShareAccountTransactionHelper.createShareAccount(josn, requestSpec, responseSpec); return ShareAccountTransactionHelper.createShareAccount(josn, requestSpec, responseSpec);
} }