merge release 1.10.1 to develop branch
This commit is contained in:
@@ -5,6 +5,7 @@ See VERSIONING (https://github.com/openMF/mifosx/blob/master/VERSIONING.md) for
|
||||
|
||||
Releases
|
||||
===============
|
||||
1. 20 Sep 2013 - 1.10.1.RELEASE
|
||||
1. 19 Sep 2013 - 1.10.0.RELEASE
|
||||
1. 18 Sep 2013 - 1.9.2.RELEASE
|
||||
1. 10 Sep 2013 - 1.9.1.RELEASE
|
||||
@@ -37,6 +38,21 @@ Releases
|
||||
1. 05 April 2013 - 0.11.1.beta
|
||||
1. 05 April 2013 - 0.11.0.beta
|
||||
|
||||
|
||||
1.10.1.RELEASE
|
||||
=============
|
||||
Bug Release
|
||||
|
||||
Platform & API
|
||||
|
||||
Bug
|
||||
- [MIFOSX-675] - Not able to create savings account with/without charges.
|
||||
- [MIFOSX-680] - Duplicate entries for Payment channels to Fund source mapping
|
||||
|
||||
Reference App
|
||||
- [MIFOSX-683] - Update Reference UI to allow manual payments of Loan fees from savings
|
||||
|
||||
|
||||
1.10.0.RELEASE
|
||||
=============
|
||||
Feature Release
|
||||
|
||||
@@ -90,7 +90,7 @@
|
||||
<body>
|
||||
<div id="page-wrapper">
|
||||
<div id="flybar">
|
||||
<div id="nav-logo">1.10.0.RELEASE API</div>
|
||||
<div id="nav-logo">1.10.1.RELEASE API</div>
|
||||
<div class="flybar-nav">
|
||||
<h2 class="flybar-button">Overview</h2>
|
||||
<div class="flybar-menu-overview">
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
delete from acc_product_mapping where financial_account_type=10 and payment_type is not null;
|
||||
@@ -1,2 +1,2 @@
|
||||
releaseVersion=1.10.0.RELEASE
|
||||
releaseVersion=1.10.1.RELEASE
|
||||
|
||||
|
||||
+87
-101
@@ -1,6 +1,5 @@
|
||||
package org.mifosplatform.integrationtests;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -24,173 +23,160 @@ import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class AccountingScenarioIntegrationTest {
|
||||
|
||||
private RequestSpecification requestSpec;
|
||||
private ResponseSpecification responseSpec;
|
||||
|
||||
private final String DATE_OF_JOINING = "01 January 2011";
|
||||
|
||||
private final Float LP_PRINCIPAL=10000.0f;
|
||||
private final Float LP_PRINCIPAL = 10000.0f;
|
||||
private final String LP_REPAYMENTS = "5";
|
||||
private final String LP_REPAYMENT_PERIOD = "2";
|
||||
private final String LP_INTEREST_RATE="1";
|
||||
private final String EXPECTED_DISBURSAL_DATE="04 March 2011";
|
||||
private final String LOAN_APPLICATION_SUBMISSION_DATE= "3 March 2011";
|
||||
private final String LOAN_TERM_FREQUENCY= "10";
|
||||
private final String LP_INTEREST_RATE = "1";
|
||||
private final String EXPECTED_DISBURSAL_DATE = "04 March 2011";
|
||||
private final String LOAN_APPLICATION_SUBMISSION_DATE = "3 March 2011";
|
||||
private final String LOAN_TERM_FREQUENCY = "10";
|
||||
private final String INDIVIDUAL_LOAN = "individual";
|
||||
|
||||
private final String REPAYMENT_DATE[]={"","04 May 2011","04 July 2011","04 September 2011","04 November 2011","04 January 2012"};
|
||||
private final Float REPAYMENT_AMOUNT [] = {.0f,2200.0f,3000.0f,900.0f,2000.0f,2500.0f};
|
||||
private final String REPAYMENT_DATE[] = { "", "04 May 2011", "04 July 2011", "04 September 2011", "04 November 2011", "04 January 2012" };
|
||||
private final Float REPAYMENT_AMOUNT[] = { .0f, 2200.0f, 3000.0f, 900.0f, 2000.0f, 2500.0f };
|
||||
|
||||
private final Float AMOUNT_TO_BE_WAIVE = 400.0f;
|
||||
private LoanTransactionHelper loanTransactionHelper;
|
||||
private AccountHelper accountHelper;
|
||||
private JournalEntryHelper journalEntryHelper;
|
||||
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
Utils.initializeRESTAssured();
|
||||
requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||
requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||
responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
|
||||
loanTransactionHelper = new LoanTransactionHelper(requestSpec,responseSpec);
|
||||
accountHelper = new AccountHelper(requestSpec, responseSpec);
|
||||
journalEntryHelper = new JournalEntryHelper(requestSpec, responseSpec);
|
||||
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
||||
this.accountHelper = new AccountHelper(this.requestSpec, this.responseSpec);
|
||||
this.journalEntryHelper = new JournalEntryHelper(this.requestSpec, this.responseSpec);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkAccountingFlow() {
|
||||
Account assetAccount = accountHelper.createAssetAccount();
|
||||
Account incomeAccount = accountHelper.createIncomeAccount();
|
||||
Account expenseAccount= accountHelper.createExpenseAccount();
|
||||
final Account assetAccount = this.accountHelper.createAssetAccount();
|
||||
final Account incomeAccount = this.accountHelper.createIncomeAccount();
|
||||
final Account expenseAccount = this.accountHelper.createExpenseAccount();
|
||||
|
||||
Integer loanProductID = createLoanProduct(assetAccount,incomeAccount,expenseAccount);
|
||||
final Integer loanProductID = createLoanProduct(assetAccount, incomeAccount, expenseAccount);
|
||||
|
||||
Integer clientID = ClientHelper.createClient(requestSpec, responseSpec, DATE_OF_JOINING);
|
||||
Integer loanID = applyForLoanApplication(clientID, loanProductID);
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, this.DATE_OF_JOINING);
|
||||
final Integer loanID = applyForLoanApplication(clientID, loanProductID);
|
||||
|
||||
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(requestSpec, responseSpec, loanID);
|
||||
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
|
||||
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
|
||||
|
||||
loanStatusHashMap = loanTransactionHelper.approveLoan(EXPECTED_DISBURSAL_DATE, loanID);
|
||||
loanStatusHashMap = this.loanTransactionHelper.approveLoan(this.EXPECTED_DISBURSAL_DATE, loanID);
|
||||
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
|
||||
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
|
||||
|
||||
loanStatusHashMap = loanTransactionHelper.disburseLoan(EXPECTED_DISBURSAL_DATE, loanID);
|
||||
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(this.EXPECTED_DISBURSAL_DATE, loanID);
|
||||
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
|
||||
|
||||
|
||||
//CHECK ACCOUNT ENTRIES
|
||||
// CHECK ACCOUNT ENTRIES
|
||||
System.out.println("Entries ......");
|
||||
final float PRINCIPAL_VALUE_FOR_EACH_PERIOD = 2000.0f;
|
||||
final float TOTAL_INTEREST =1000.0f;
|
||||
JournalEntry[] assetAccountInitialEntry =
|
||||
{ new JournalEntry(TOTAL_INTEREST, JournalEntry.TransactionType.DEBIT),
|
||||
new JournalEntry(LP_PRINCIPAL, JournalEntry.TransactionType.CREDIT),
|
||||
new JournalEntry(LP_PRINCIPAL, JournalEntry.TransactionType.DEBIT),
|
||||
};
|
||||
journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, EXPECTED_DISBURSAL_DATE, assetAccountInitialEntry);
|
||||
final float TOTAL_INTEREST = 1000.0f;
|
||||
final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(TOTAL_INTEREST, JournalEntry.TransactionType.DEBIT),
|
||||
new JournalEntry(this.LP_PRINCIPAL, JournalEntry.TransactionType.CREDIT),
|
||||
new JournalEntry(this.LP_PRINCIPAL, JournalEntry.TransactionType.DEBIT), };
|
||||
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.EXPECTED_DISBURSAL_DATE, assetAccountInitialEntry);
|
||||
System.out.println("CHECKING INCOME: ******************************************");
|
||||
JournalEntry incomeJournalEntry = new JournalEntry(TOTAL_INTEREST, JournalEntry.TransactionType.CREDIT);
|
||||
journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount,EXPECTED_DISBURSAL_DATE, incomeJournalEntry);
|
||||
final JournalEntry incomeJournalEntry = new JournalEntry(TOTAL_INTEREST, JournalEntry.TransactionType.CREDIT);
|
||||
this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, this.EXPECTED_DISBURSAL_DATE, incomeJournalEntry);
|
||||
|
||||
//MAKE 1
|
||||
// MAKE 1
|
||||
System.out.println("Repayment 1 ......");
|
||||
loanTransactionHelper.makeRepayment(REPAYMENT_DATE[1], REPAYMENT_AMOUNT[1], loanID);
|
||||
float FIRST_INTEREST = 200.0f;
|
||||
float FIRST_PRINCIPAL = 2000.0f;
|
||||
float expected_value = LP_PRINCIPAL- PRINCIPAL_VALUE_FOR_EACH_PERIOD;
|
||||
loanTransactionHelper.verifyRepaymentScheduleEntryFor(1, expected_value, loanID);
|
||||
JournalEntry[] assetAccountFirstEntry=
|
||||
{ new JournalEntry(REPAYMENT_AMOUNT[1], JournalEntry.TransactionType.DEBIT),
|
||||
new JournalEntry(FIRST_INTEREST, JournalEntry.TransactionType.CREDIT),
|
||||
new JournalEntry(FIRST_PRINCIPAL, JournalEntry.TransactionType.CREDIT),
|
||||
};
|
||||
journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, REPAYMENT_DATE[1],assetAccountFirstEntry);
|
||||
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[1], this.REPAYMENT_AMOUNT[1], loanID);
|
||||
final float FIRST_INTEREST = 200.0f;
|
||||
final float FIRST_PRINCIPAL = 2000.0f;
|
||||
float expected_value = this.LP_PRINCIPAL - PRINCIPAL_VALUE_FOR_EACH_PERIOD;
|
||||
this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(1, expected_value, loanID);
|
||||
final JournalEntry[] assetAccountFirstEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[1], JournalEntry.TransactionType.DEBIT),
|
||||
new JournalEntry(FIRST_INTEREST, JournalEntry.TransactionType.CREDIT),
|
||||
new JournalEntry(FIRST_PRINCIPAL, JournalEntry.TransactionType.CREDIT), };
|
||||
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[1], assetAccountFirstEntry);
|
||||
System.out.println("Repayment 1 Done......");
|
||||
|
||||
//REPAYMENT 2
|
||||
// REPAYMENT 2
|
||||
System.out.println("Repayment 2 ......");
|
||||
loanTransactionHelper.makeRepayment(REPAYMENT_DATE[2], REPAYMENT_AMOUNT[2], loanID);
|
||||
float SECOND_AND_THIRD_INTEREST = 400.0f;
|
||||
float SECOND_PRINCIPAL = REPAYMENT_AMOUNT[2]-SECOND_AND_THIRD_INTEREST;
|
||||
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[2], this.REPAYMENT_AMOUNT[2], loanID);
|
||||
final float SECOND_AND_THIRD_INTEREST = 400.0f;
|
||||
final float SECOND_PRINCIPAL = this.REPAYMENT_AMOUNT[2] - SECOND_AND_THIRD_INTEREST;
|
||||
expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD;
|
||||
loanTransactionHelper.verifyRepaymentScheduleEntryFor(2,expected_value,loanID);
|
||||
JournalEntry[] assetAccountSecondEntry = { new JournalEntry(REPAYMENT_AMOUNT[2], JournalEntry.TransactionType.DEBIT),
|
||||
new JournalEntry(SECOND_AND_THIRD_INTEREST, JournalEntry.TransactionType.CREDIT),
|
||||
new JournalEntry(SECOND_PRINCIPAL, JournalEntry.TransactionType.CREDIT),
|
||||
};
|
||||
journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, REPAYMENT_DATE[2], assetAccountSecondEntry);
|
||||
this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(2, expected_value, loanID);
|
||||
final JournalEntry[] assetAccountSecondEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[2], JournalEntry.TransactionType.DEBIT),
|
||||
new JournalEntry(SECOND_AND_THIRD_INTEREST, JournalEntry.TransactionType.CREDIT),
|
||||
new JournalEntry(SECOND_PRINCIPAL, JournalEntry.TransactionType.CREDIT), };
|
||||
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[2], assetAccountSecondEntry);
|
||||
System.out.println("Repayment 2 Done ......");
|
||||
|
||||
//WAIVE INTEREST
|
||||
// WAIVE INTEREST
|
||||
System.out.println("Waive Interest ......");
|
||||
loanTransactionHelper.waiveInterest(REPAYMENT_DATE[4], AMOUNT_TO_BE_WAIVE.toString(), loanID);
|
||||
this.loanTransactionHelper.waiveInterest(this.REPAYMENT_DATE[4], this.AMOUNT_TO_BE_WAIVE.toString(), loanID);
|
||||
|
||||
JournalEntry waivedEntry = new JournalEntry(AMOUNT_TO_BE_WAIVE, JournalEntry.TransactionType.CREDIT);
|
||||
journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, REPAYMENT_DATE[4],waivedEntry);
|
||||
final JournalEntry waivedEntry = new JournalEntry(this.AMOUNT_TO_BE_WAIVE, JournalEntry.TransactionType.CREDIT);
|
||||
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[4], waivedEntry);
|
||||
|
||||
JournalEntry expenseJournalEntry = new JournalEntry(AMOUNT_TO_BE_WAIVE, JournalEntry.TransactionType.DEBIT);
|
||||
journalEntryHelper.checkJournalEntryForExpenseAccount(expenseAccount, REPAYMENT_DATE[4], expenseJournalEntry);
|
||||
final JournalEntry expenseJournalEntry = new JournalEntry(this.AMOUNT_TO_BE_WAIVE, JournalEntry.TransactionType.DEBIT);
|
||||
this.journalEntryHelper.checkJournalEntryForExpenseAccount(expenseAccount, this.REPAYMENT_DATE[4], expenseJournalEntry);
|
||||
System.out.println("Waive Interest Done......");
|
||||
|
||||
//REPAYMENT 3
|
||||
// REPAYMENT 3
|
||||
System.out.println("Repayment 3 ......");
|
||||
loanTransactionHelper.makeRepayment(REPAYMENT_DATE[3], REPAYMENT_AMOUNT[3], loanID);
|
||||
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[3], this.REPAYMENT_AMOUNT[3], loanID);
|
||||
expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD;
|
||||
JournalEntry[] assetAccountThirdEntry = {
|
||||
new JournalEntry(REPAYMENT_AMOUNT[3], JournalEntry.TransactionType.DEBIT),
|
||||
new JournalEntry(REPAYMENT_AMOUNT[3], JournalEntry.TransactionType.CREDIT)
|
||||
};
|
||||
loanTransactionHelper.verifyRepaymentScheduleEntryFor(3, expected_value, loanID);
|
||||
journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, REPAYMENT_DATE[3], assetAccountThirdEntry);
|
||||
final JournalEntry[] assetAccountThirdEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[3], JournalEntry.TransactionType.DEBIT),
|
||||
new JournalEntry(this.REPAYMENT_AMOUNT[3], JournalEntry.TransactionType.CREDIT) };
|
||||
this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(3, expected_value, loanID);
|
||||
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[3], assetAccountThirdEntry);
|
||||
System.out.println("Repayment 3 Done ......");
|
||||
|
||||
//REPAYMENT 4
|
||||
// REPAYMENT 4
|
||||
System.out.println("Repayment 4 ......");
|
||||
loanTransactionHelper.makeRepayment(REPAYMENT_DATE[4], REPAYMENT_AMOUNT[4], loanID);
|
||||
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[4], this.REPAYMENT_AMOUNT[4], loanID);
|
||||
expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD;
|
||||
loanTransactionHelper.verifyRepaymentScheduleEntryFor(4, expected_value, loanID);
|
||||
JournalEntry[] assetAccountFourthEntry = { new JournalEntry(REPAYMENT_AMOUNT[4], JournalEntry.TransactionType.DEBIT),
|
||||
new JournalEntry(REPAYMENT_AMOUNT[4], JournalEntry.TransactionType.CREDIT)
|
||||
};
|
||||
journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount,REPAYMENT_DATE[4],assetAccountFourthEntry);
|
||||
this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(4, expected_value, loanID);
|
||||
final JournalEntry[] assetAccountFourthEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[4], JournalEntry.TransactionType.DEBIT),
|
||||
new JournalEntry(this.REPAYMENT_AMOUNT[4], JournalEntry.TransactionType.CREDIT) };
|
||||
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[4], assetAccountFourthEntry);
|
||||
System.out.println("Repayment 4 Done ......");
|
||||
|
||||
//Repayment 5
|
||||
// Repayment 5
|
||||
System.out.println("Repayment 5 ......");
|
||||
JournalEntry[] assetAccountFifthEntry = { new JournalEntry(REPAYMENT_AMOUNT[5], JournalEntry.TransactionType.DEBIT),
|
||||
new JournalEntry(REPAYMENT_AMOUNT[5], JournalEntry.TransactionType.CREDIT)
|
||||
};
|
||||
final JournalEntry[] assetAccountFifthEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[5], JournalEntry.TransactionType.DEBIT),
|
||||
new JournalEntry(this.REPAYMENT_AMOUNT[5], JournalEntry.TransactionType.CREDIT) };
|
||||
expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD;
|
||||
loanTransactionHelper.makeRepayment(REPAYMENT_DATE[5], REPAYMENT_AMOUNT[5], loanID);
|
||||
loanTransactionHelper.verifyRepaymentScheduleEntryFor(5,expected_value,loanID);
|
||||
journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, REPAYMENT_DATE[5], assetAccountFifthEntry);
|
||||
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[5], this.REPAYMENT_AMOUNT[5], loanID);
|
||||
this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(5, expected_value, loanID);
|
||||
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[5], assetAccountFifthEntry);
|
||||
System.out.println("Repayment 5 Done ......");
|
||||
}
|
||||
|
||||
private Integer createLoanProduct(final Account ... accounts) {
|
||||
private Integer createLoanProduct(final Account... accounts) {
|
||||
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
|
||||
String loanProductJSON = new LoanProductTestBuilder().withPrincipal(LP_PRINCIPAL.toString()).withRepaymentTypeAsMonth()
|
||||
.withRepaymentAfterEvery(LP_REPAYMENT_PERIOD).withNumberOfRepayments(LP_REPAYMENTS).withRepaymentTypeAsMonth()
|
||||
.withinterestRatePerPeriod(LP_INTEREST_RATE).withInterestRateFrequencyTypeAsMonths()
|
||||
.withAmortizationTypeAsEqualPrincipalPayment().withInterestTypeAsFlat()
|
||||
.withAccountingRuleAsAccrualBased(accounts)
|
||||
.build();
|
||||
return loanTransactionHelper.getLoanProductId(loanProductJSON);
|
||||
final String loanProductJSON = new LoanProductTestBuilder().withPrincipal(this.LP_PRINCIPAL.toString()).withRepaymentTypeAsMonth()
|
||||
.withRepaymentAfterEvery(this.LP_REPAYMENT_PERIOD).withNumberOfRepayments(this.LP_REPAYMENTS).withRepaymentTypeAsMonth()
|
||||
.withinterestRatePerPeriod(this.LP_INTEREST_RATE).withInterestRateFrequencyTypeAsMonths()
|
||||
.withAmortizationTypeAsEqualPrincipalPayment().withInterestTypeAsFlat().withAccountingRuleAsAccrualBased(accounts).build();
|
||||
return this.loanTransactionHelper.getLoanProductId(loanProductJSON);
|
||||
}
|
||||
|
||||
private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID) {
|
||||
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
|
||||
String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(LP_PRINCIPAL.toString()).withLoanTermFrequency(LOAN_TERM_FREQUENCY)
|
||||
.withLoanTermFrequencyAsMonths().withNumberOfRepayments(LP_REPAYMENTS).withRepaymentEveryAfter(LP_REPAYMENT_PERIOD)
|
||||
.withRepaymentFrequencyTypeAsMonths().withInterestRatePerPeriod(LP_INTEREST_RATE).withInterestTypeAsFlatBalance()
|
||||
final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(this.LP_PRINCIPAL.toString())
|
||||
.withLoanTermFrequency(this.LOAN_TERM_FREQUENCY).withLoanTermFrequencyAsMonths().withNumberOfRepayments(this.LP_REPAYMENTS)
|
||||
.withRepaymentEveryAfter(this.LP_REPAYMENT_PERIOD).withRepaymentFrequencyTypeAsMonths()
|
||||
.withInterestRatePerPeriod(this.LP_INTEREST_RATE).withInterestTypeAsFlatBalance()
|
||||
.withAmortizationTypeAsEqualPrincipalPayments().withInterestCalculationPeriodTypeSameAsRepaymentPeriod()
|
||||
.withExpectedDisbursementDate(EXPECTED_DISBURSAL_DATE).withSubmittedOnDate(LOAN_APPLICATION_SUBMISSION_DATE)
|
||||
.withLoanType(INDIVIDUAL_LOAN)
|
||||
.build(clientID.toString(), loanProductID.toString());
|
||||
return loanTransactionHelper.getLoanId(loanApplicationJSON);
|
||||
.withExpectedDisbursementDate(this.EXPECTED_DISBURSAL_DATE).withSubmittedOnDate(this.LOAN_APPLICATION_SUBMISSION_DATE)
|
||||
.withLoanType(this.INDIVIDUAL_LOAN).build(clientID.toString(), loanProductID.toString());
|
||||
return this.loanTransactionHelper.getLoanId(loanApplicationJSON);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+14
-13
@@ -34,27 +34,28 @@ public class ClientLoanIntegrationTest {
|
||||
@Before
|
||||
public void setup() {
|
||||
Utils.initializeRESTAssured();
|
||||
requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||
requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||
responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkClientLoanCreateAndDisburseFlow() {
|
||||
loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec);
|
||||
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
Integer clientID = ClientHelper.createClient(requestSpec, responseSpec);
|
||||
ClientHelper.verifyClientCreatedOnServer(requestSpec, responseSpec, clientID);
|
||||
Integer loanProductID = createLoanProduct();
|
||||
Integer loanID = applyForLoanApplication(clientID, loanProductID);
|
||||
ArrayList<HashMap> loanSchedule = loanTransactionHelper.getLoanRepaymentSchedule(requestSpec, responseSpec, loanID);
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID);
|
||||
final Integer loanProductID = createLoanProduct();
|
||||
final Integer loanID = applyForLoanApplication(clientID, loanProductID);
|
||||
final ArrayList<HashMap> loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec,
|
||||
loanID);
|
||||
verifyLoanRepaymentSchedule(loanSchedule);
|
||||
|
||||
}
|
||||
|
||||
private Integer createLoanProduct() {
|
||||
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
|
||||
String loanProductJSON = new LoanProductTestBuilder() //
|
||||
final String loanProductJSON = new LoanProductTestBuilder() //
|
||||
.withPrincipal("12,000.00") //
|
||||
.withNumberOfRepayments("4") //
|
||||
.withRepaymentAfterEvery("1") //
|
||||
@@ -64,12 +65,12 @@ public class ClientLoanIntegrationTest {
|
||||
.withAmortizationTypeAsEqualInstallments() //
|
||||
.withInterestTypeAsDecliningBalance() //
|
||||
.build();
|
||||
return loanTransactionHelper.getLoanProductId(loanProductJSON);
|
||||
return this.loanTransactionHelper.getLoanProductId(loanProductJSON);
|
||||
}
|
||||
|
||||
private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID) {
|
||||
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
|
||||
String loanApplicationJSON = new LoanApplicationTestBuilder() //
|
||||
final String loanApplicationJSON = new LoanApplicationTestBuilder() //
|
||||
.withPrincipal("12,000.00") //
|
||||
.withLoanTermFrequency("4") //
|
||||
.withLoanTermFrequencyAsMonths() //
|
||||
@@ -83,7 +84,7 @@ public class ClientLoanIntegrationTest {
|
||||
.withExpectedDisbursementDate("20 September 2011") //
|
||||
.withSubmittedOnDate("20 September 2011") //
|
||||
.build(clientID.toString(), loanProductID.toString());
|
||||
return loanTransactionHelper.getLoanId(loanApplicationJSON);
|
||||
return this.loanTransactionHelper.getLoanId(loanApplicationJSON);
|
||||
}
|
||||
|
||||
private void verifyLoanRepaymentSchedule(final ArrayList<HashMap> loanSchedule) {
|
||||
|
||||
+17
-18
@@ -22,8 +22,7 @@ import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
/**
|
||||
* Group Loan Integration Test for checking Loan Application Repayment
|
||||
* Schedule.
|
||||
* Group Loan Integration Test for checking Loan Application Repayment Schedule.
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public class GroupLoanIntegrationTest {
|
||||
@@ -35,29 +34,30 @@ public class GroupLoanIntegrationTest {
|
||||
@Before
|
||||
public void setup() {
|
||||
Utils.initializeRESTAssured();
|
||||
requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||
requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||
responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkGroupLoanCreateAndDisburseFlow() {
|
||||
loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec);
|
||||
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
Integer clientID = ClientHelper.createClient(requestSpec, responseSpec);
|
||||
Integer groupID = GroupHelper.createGroup(requestSpec, responseSpec, true);
|
||||
groupID = GroupHelper.associateClient(requestSpec, responseSpec, groupID.toString(),clientID.toString());
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Integer groupID = GroupHelper.createGroup(this.requestSpec, this.responseSpec, true);
|
||||
groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(), clientID.toString());
|
||||
|
||||
Integer loanProductID = createLoanProduct();
|
||||
Integer loanID = applyForLoanApplication(groupID, loanProductID);
|
||||
ArrayList<HashMap> loanSchedule = loanTransactionHelper.getLoanRepaymentSchedule(requestSpec, responseSpec, loanID);
|
||||
final Integer loanProductID = createLoanProduct();
|
||||
final Integer loanID = applyForLoanApplication(groupID, loanProductID);
|
||||
final ArrayList<HashMap> loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec,
|
||||
loanID);
|
||||
verifyLoanRepaymentSchedule(loanSchedule);
|
||||
|
||||
}
|
||||
|
||||
private Integer createLoanProduct() {
|
||||
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
|
||||
String loanProductJSON = new LoanProductTestBuilder() //
|
||||
final String loanProductJSON = new LoanProductTestBuilder() //
|
||||
.withPrincipal("12,000.00") //
|
||||
.withNumberOfRepayments("4") //
|
||||
.withRepaymentAfterEvery("1") //
|
||||
@@ -67,12 +67,12 @@ public class GroupLoanIntegrationTest {
|
||||
.withAmortizationTypeAsEqualInstallments() //
|
||||
.withInterestTypeAsDecliningBalance() //
|
||||
.build();
|
||||
return loanTransactionHelper.getLoanProductId(loanProductJSON);
|
||||
return this.loanTransactionHelper.getLoanProductId(loanProductJSON);
|
||||
}
|
||||
|
||||
private Integer applyForLoanApplication(final Integer groupID, final Integer loanProductID) {
|
||||
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
|
||||
String loanApplicationJSON = new LoanApplicationTestBuilder() //
|
||||
final String loanApplicationJSON = new LoanApplicationTestBuilder() //
|
||||
.withPrincipal("12,000.00") //
|
||||
.withLoanTermFrequency("4") //
|
||||
.withLoanTermFrequencyAsMonths() //
|
||||
@@ -85,10 +85,9 @@ public class GroupLoanIntegrationTest {
|
||||
.withInterestCalculationPeriodTypeSameAsRepaymentPeriod() //
|
||||
.withExpectedDisbursementDate("20 September 2011") //
|
||||
.withSubmittedOnDate("20 September 2011") //
|
||||
.withLoanType("group")
|
||||
.build(groupID.toString(), loanProductID.toString());
|
||||
.withLoanType("group").build(groupID.toString(), loanProductID.toString());
|
||||
System.out.println(loanApplicationJSON);
|
||||
return loanTransactionHelper.getLoanId(loanApplicationJSON);
|
||||
return this.loanTransactionHelper.getLoanId(loanApplicationJSON);
|
||||
}
|
||||
|
||||
private void verifyLoanRepaymentSchedule(final ArrayList<HashMap> loanSchedule) {
|
||||
|
||||
+18
-18
@@ -24,32 +24,32 @@ public class GroupTest {
|
||||
@Before
|
||||
public void setup() {
|
||||
Utils.initializeRESTAssured();
|
||||
requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||
requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||
responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkGroupFunctions() {
|
||||
Integer clientID = ClientHelper.createClient(requestSpec, responseSpec);
|
||||
Integer groupID = GroupHelper.createGroup(requestSpec, responseSpec);
|
||||
GroupHelper.verifyGroupCreatedOnServer(requestSpec, responseSpec, groupID);
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Integer groupID = GroupHelper.createGroup(this.requestSpec, this.responseSpec);
|
||||
GroupHelper.verifyGroupCreatedOnServer(this.requestSpec, this.responseSpec, groupID);
|
||||
|
||||
groupID = GroupHelper.activateGroup(requestSpec, responseSpec, groupID.toString());
|
||||
GroupHelper.verifyGroupActivatedOnServer(requestSpec, responseSpec, groupID, true);
|
||||
groupID = GroupHelper.activateGroup(this.requestSpec, this.responseSpec, groupID.toString());
|
||||
GroupHelper.verifyGroupActivatedOnServer(this.requestSpec, this.responseSpec, groupID, true);
|
||||
|
||||
groupID = GroupHelper.associateClient(requestSpec, responseSpec, groupID.toString(), clientID.toString());
|
||||
GroupHelper.verifyGroupMembers(requestSpec, responseSpec, groupID, clientID);
|
||||
groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(), clientID.toString());
|
||||
GroupHelper.verifyGroupMembers(this.requestSpec, this.responseSpec, groupID, clientID);
|
||||
|
||||
groupID = GroupHelper.disAssociateClient(requestSpec, responseSpec, groupID.toString(), clientID.toString());
|
||||
GroupHelper.verifyEmptyGroupMembers(requestSpec, responseSpec, groupID);
|
||||
groupID = GroupHelper.disAssociateClient(this.requestSpec, this.responseSpec, groupID.toString(), clientID.toString());
|
||||
GroupHelper.verifyEmptyGroupMembers(this.requestSpec, this.responseSpec, groupID);
|
||||
|
||||
String updatedGroupName = GroupHelper.randomNameGenerator("Group-", 5);
|
||||
groupID = GroupHelper.updateGroup(requestSpec, responseSpec, updatedGroupName, groupID.toString());
|
||||
GroupHelper.verifyGroupDetails(requestSpec, responseSpec, groupID, "name", updatedGroupName);
|
||||
final String updatedGroupName = GroupHelper.randomNameGenerator("Group-", 5);
|
||||
groupID = GroupHelper.updateGroup(this.requestSpec, this.responseSpec, updatedGroupName, groupID.toString());
|
||||
GroupHelper.verifyGroupDetails(this.requestSpec, this.responseSpec, groupID, "name", updatedGroupName);
|
||||
|
||||
groupID = GroupHelper.createGroup(requestSpec, responseSpec);
|
||||
GroupHelper.deleteGroup(requestSpec, responseSpec, groupID.toString());
|
||||
GroupHelper.verifyGroupDeleted(requestSpec, responseSpec, groupID);
|
||||
groupID = GroupHelper.createGroup(this.requestSpec, this.responseSpec);
|
||||
GroupHelper.deleteGroup(this.requestSpec, this.responseSpec, groupID.toString());
|
||||
GroupHelper.verifyGroupDeleted(this.requestSpec, this.responseSpec, groupID);
|
||||
}
|
||||
}
|
||||
+52
-51
@@ -18,9 +18,9 @@ import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
/**
|
||||
* Client Loan Integration Test for checking Loan Disbursement with Waive
|
||||
* Interest and Write-Off.
|
||||
*/
|
||||
* Client Loan Integration Test for checking Loan Disbursement with Waive
|
||||
* Interest and Write-Off.
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes" })
|
||||
public class LoanWithWaiveInterestAndWriteOffIntegrationTest {
|
||||
|
||||
@@ -28,107 +28,108 @@ public class LoanWithWaiveInterestAndWriteOffIntegrationTest {
|
||||
private RequestSpecification requestSpec;
|
||||
|
||||
private final String LP_PRINCIPAL = "12,000.00", LP_REPAYMENTS = "2", LP_REPAYMENT_PERIOD = "6", LP_INTEREST_RATE = "1",
|
||||
PRINCIPAL = "4,500.00", LOAN_TERM_FREQUENCY = "18", NUMBER_OF_REPAYMENTS = "9", REPAYMENT_PERIOD = "2",
|
||||
DISBURSEMENT_DATE = "30 October 2010", LOAN_APPLICATION_SUBMISSION_DATE = "23 September 2010",
|
||||
EXPECTED_DISBURSAL_DATE = "28 October 2010", RATE_OF_INTEREST_PER_PERIOD = "2",
|
||||
DATE_OF_JOINING = "04 March 2009",INTEREST_VALUE_AMOUNT = "40.00";
|
||||
PRINCIPAL = "4,500.00", LOAN_TERM_FREQUENCY = "18", NUMBER_OF_REPAYMENTS = "9", REPAYMENT_PERIOD = "2",
|
||||
DISBURSEMENT_DATE = "30 October 2010", LOAN_APPLICATION_SUBMISSION_DATE = "23 September 2010",
|
||||
EXPECTED_DISBURSAL_DATE = "28 October 2010", RATE_OF_INTEREST_PER_PERIOD = "2", DATE_OF_JOINING = "04 March 2009",
|
||||
INTEREST_VALUE_AMOUNT = "40.00";
|
||||
private LoanTransactionHelper loanTransactionHelper;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
Utils.initializeRESTAssured();
|
||||
requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||
requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||
responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
loanTransactionHelper = new LoanTransactionHelper(requestSpec,responseSpec);
|
||||
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkClientLoanCreateAndDisburseFlow() {
|
||||
// CREATE CLIENT
|
||||
Integer clientID = ClientHelper.createClient(requestSpec, responseSpec, DATE_OF_JOINING);
|
||||
ClientHelper.verifyClientCreatedOnServer(requestSpec, responseSpec, clientID);
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, this.DATE_OF_JOINING);
|
||||
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID);
|
||||
|
||||
// CREATE LOAN PRODUCT
|
||||
Integer loanProductID = createLoanProduct();
|
||||
final Integer loanProductID = createLoanProduct();
|
||||
// APPLY FOR LOAN
|
||||
Integer loanID = applyForLoanApplication(clientID, loanProductID);
|
||||
final Integer loanID = applyForLoanApplication(clientID, loanProductID);
|
||||
|
||||
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(requestSpec, responseSpec, loanID);
|
||||
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
|
||||
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
|
||||
|
||||
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------");
|
||||
loanStatusHashMap = loanTransactionHelper.approveLoan("28 September 2010", loanID);
|
||||
loanStatusHashMap = this.loanTransactionHelper.approveLoan("28 September 2010", loanID);
|
||||
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
|
||||
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
|
||||
|
||||
// UNDO APPROVAL
|
||||
loanStatusHashMap = loanTransactionHelper.undoApproval(loanID);
|
||||
loanStatusHashMap = this.loanTransactionHelper.undoApproval(loanID);
|
||||
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
|
||||
|
||||
System.out.println("-----------------------------------RE-APPROVE LOAN-----------------------------------------");
|
||||
loanStatusHashMap = loanTransactionHelper.approveLoan("1 October 2010", loanID);
|
||||
loanStatusHashMap = this.loanTransactionHelper.approveLoan("1 October 2010", loanID);
|
||||
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
|
||||
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
|
||||
|
||||
// DISBURSE
|
||||
loanStatusHashMap = loanTransactionHelper.disburseLoan(DISBURSEMENT_DATE, loanID);
|
||||
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(this.DISBURSEMENT_DATE, loanID);
|
||||
System.out.println("DISBURSE " + loanStatusHashMap);
|
||||
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
|
||||
|
||||
// PERFORM REPAYMENTS AND CHECK LOAN STATUS
|
||||
loanTransactionHelper.verifyRepaymentScheduleEntryFor(1, 4000.0F, loanID);
|
||||
loanTransactionHelper.makeRepayment("1 January 2011", 540.0f, loanID);
|
||||
this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(1, 4000.0F, loanID);
|
||||
this.loanTransactionHelper.makeRepayment("1 January 2011", 540.0f, loanID);
|
||||
|
||||
//UNDO DISBURSE LOAN
|
||||
loanStatusHashMap=loanTransactionHelper.undoDisbursal(loanID);
|
||||
// UNDO DISBURSE LOAN
|
||||
loanStatusHashMap = this.loanTransactionHelper.undoDisbursal(loanID);
|
||||
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
|
||||
|
||||
//DIBURSE AGAIN
|
||||
loanStatusHashMap = loanTransactionHelper.disburseLoan(DISBURSEMENT_DATE, loanID);
|
||||
// DIBURSE AGAIN
|
||||
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(this.DISBURSEMENT_DATE, loanID);
|
||||
System.out.println("DISBURSE " + loanStatusHashMap);
|
||||
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
|
||||
|
||||
//MAKE REPAYMENTS
|
||||
// MAKE REPAYMENTS
|
||||
final float repayment_with_interest = 540.0f;
|
||||
final float repayment_without_interest = 500.0f;
|
||||
|
||||
loanTransactionHelper.verifyRepaymentScheduleEntryFor(1, 4000.0F, loanID);
|
||||
loanTransactionHelper.makeRepayment("1 January 2011",repayment_with_interest, loanID);
|
||||
loanTransactionHelper.makeRepayment("1 March 2011", repayment_with_interest, loanID);
|
||||
loanTransactionHelper.waiveInterest("1 May 2011", INTEREST_VALUE_AMOUNT, loanID);
|
||||
loanTransactionHelper.makeRepayment("1 May 2011", repayment_without_interest, loanID);
|
||||
loanTransactionHelper.makeRepayment("1 July 2011", repayment_with_interest, loanID);
|
||||
loanTransactionHelper.waiveInterest("1 September 2011", INTEREST_VALUE_AMOUNT, loanID);
|
||||
loanTransactionHelper.makeRepayment("1 September 2011", repayment_without_interest, loanID);
|
||||
loanTransactionHelper.makeRepayment("1 November 2011", repayment_with_interest, loanID);
|
||||
loanTransactionHelper.waiveInterest("1 January 2012", INTEREST_VALUE_AMOUNT, loanID);
|
||||
loanTransactionHelper.makeRepayment("1 January 2012", repayment_without_interest, loanID);
|
||||
loanTransactionHelper.verifyRepaymentScheduleEntryFor(7, 1000.0f, loanID);
|
||||
this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(1, 4000.0F, loanID);
|
||||
this.loanTransactionHelper.makeRepayment("1 January 2011", repayment_with_interest, loanID);
|
||||
this.loanTransactionHelper.makeRepayment("1 March 2011", repayment_with_interest, loanID);
|
||||
this.loanTransactionHelper.waiveInterest("1 May 2011", this.INTEREST_VALUE_AMOUNT, loanID);
|
||||
this.loanTransactionHelper.makeRepayment("1 May 2011", repayment_without_interest, loanID);
|
||||
this.loanTransactionHelper.makeRepayment("1 July 2011", repayment_with_interest, loanID);
|
||||
this.loanTransactionHelper.waiveInterest("1 September 2011", this.INTEREST_VALUE_AMOUNT, loanID);
|
||||
this.loanTransactionHelper.makeRepayment("1 September 2011", repayment_without_interest, loanID);
|
||||
this.loanTransactionHelper.makeRepayment("1 November 2011", repayment_with_interest, loanID);
|
||||
this.loanTransactionHelper.waiveInterest("1 January 2012", this.INTEREST_VALUE_AMOUNT, loanID);
|
||||
this.loanTransactionHelper.makeRepayment("1 January 2012", repayment_without_interest, loanID);
|
||||
this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(7, 1000.0f, loanID);
|
||||
|
||||
// WRITE OFF LOAN AND CHECK ACCOUNT IS CLOSED
|
||||
LoanStatusChecker.verifyLoanAccountIsClosed(loanTransactionHelper.writeOffLoan("1 March 2012", loanID));
|
||||
LoanStatusChecker.verifyLoanAccountIsClosed(this.loanTransactionHelper.writeOffLoan("1 March 2012", loanID));
|
||||
|
||||
}
|
||||
|
||||
private Integer createLoanProduct() {
|
||||
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
|
||||
String loanProductJSON = new LoanProductTestBuilder().withPrincipal(LP_PRINCIPAL).withRepaymentTypeAsMonth()
|
||||
.withRepaymentAfterEvery(LP_REPAYMENT_PERIOD).withNumberOfRepayments(LP_REPAYMENTS).withRepaymentTypeAsMonth()
|
||||
.withinterestRatePerPeriod(LP_INTEREST_RATE).withInterestRateFrequencyTypeAsMonths()
|
||||
final String loanProductJSON = new LoanProductTestBuilder().withPrincipal(this.LP_PRINCIPAL).withRepaymentTypeAsMonth()
|
||||
.withRepaymentAfterEvery(this.LP_REPAYMENT_PERIOD).withNumberOfRepayments(this.LP_REPAYMENTS).withRepaymentTypeAsMonth()
|
||||
.withinterestRatePerPeriod(this.LP_INTEREST_RATE).withInterestRateFrequencyTypeAsMonths()
|
||||
.withAmortizationTypeAsEqualPrincipalPayment().withInterestTypeAsFlat().build();
|
||||
|
||||
return loanTransactionHelper.getLoanProductId(loanProductJSON);
|
||||
return this.loanTransactionHelper.getLoanProductId(loanProductJSON);
|
||||
}
|
||||
|
||||
private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID) {
|
||||
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
|
||||
String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(PRINCIPAL).withLoanTermFrequency(LOAN_TERM_FREQUENCY)
|
||||
.withLoanTermFrequencyAsMonths().withNumberOfRepayments(NUMBER_OF_REPAYMENTS).withRepaymentEveryAfter(REPAYMENT_PERIOD)
|
||||
.withRepaymentFrequencyTypeAsMonths().withInterestRatePerPeriod(RATE_OF_INTEREST_PER_PERIOD).withInterestTypeAsFlatBalance()
|
||||
.withAmortizationTypeAsEqualInstallments().withInterestCalculationPeriodTypeSameAsRepaymentPeriod()
|
||||
.withExpectedDisbursementDate(EXPECTED_DISBURSAL_DATE).withSubmittedOnDate(LOAN_APPLICATION_SUBMISSION_DATE)
|
||||
.build(clientID.toString(), loanProductID.toString());
|
||||
return loanTransactionHelper.getLoanId(loanApplicationJSON);
|
||||
final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(this.PRINCIPAL)
|
||||
.withLoanTermFrequency(this.LOAN_TERM_FREQUENCY).withLoanTermFrequencyAsMonths()
|
||||
.withNumberOfRepayments(this.NUMBER_OF_REPAYMENTS).withRepaymentEveryAfter(this.REPAYMENT_PERIOD)
|
||||
.withRepaymentFrequencyTypeAsMonths().withInterestRatePerPeriod(this.RATE_OF_INTEREST_PER_PERIOD)
|
||||
.withInterestTypeAsFlatBalance().withAmortizationTypeAsEqualInstallments()
|
||||
.withInterestCalculationPeriodTypeSameAsRepaymentPeriod().withExpectedDisbursementDate(this.EXPECTED_DISBURSAL_DATE)
|
||||
.withSubmittedOnDate(this.LOAN_APPLICATION_SUBMISSION_DATE).build(clientID.toString(), loanProductID.toString());
|
||||
return this.loanTransactionHelper.getLoanId(loanApplicationJSON);
|
||||
}
|
||||
}
|
||||
|
||||
+12
-12
@@ -27,33 +27,33 @@ public class LoanWithdrawnByApplicantIntegrationTest {
|
||||
@Before
|
||||
public void setup() {
|
||||
Utils.initializeRESTAssured();
|
||||
requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||
requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||
responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
|
||||
loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec);
|
||||
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loanWithdrawnByApplicant() {
|
||||
Integer clientID = ClientHelper.createClient(requestSpec, responseSpec, "01 January 2012");
|
||||
Integer loanProductID = loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder().build());
|
||||
Integer loanID = applyForLoanApplication(clientID, loanProductID);
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2012");
|
||||
final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder().build());
|
||||
final Integer loanID = applyForLoanApplication(clientID, loanProductID);
|
||||
|
||||
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(requestSpec, responseSpec, loanID);
|
||||
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
|
||||
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
|
||||
|
||||
loanTransactionHelper.withdrawLoanApplicationByClient("03 April 2012", loanID);
|
||||
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(requestSpec, responseSpec, loanID);
|
||||
this.loanTransactionHelper.withdrawLoanApplicationByClient("03 April 2012", loanID);
|
||||
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
|
||||
LoanStatusChecker.verifyLoanAccountIsNotActive(loanStatusHashMap);
|
||||
|
||||
}
|
||||
|
||||
private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID) {
|
||||
String loanApplication = new LoanApplicationTestBuilder().withPrincipal("5000").withLoanTermFrequency("5")
|
||||
final String loanApplication = new LoanApplicationTestBuilder().withPrincipal("5000").withLoanTermFrequency("5")
|
||||
.withLoanTermFrequencyAsMonths().withNumberOfRepayments("5").withRepaymentEveryAfter("1")
|
||||
.withRepaymentFrequencyTypeAsMonths().withInterestRatePerPeriod("2").withExpectedDisbursementDate("04 April 2012")
|
||||
.withSubmittedOnDate("02 April 2012").build(clientID.toString(), loanProductID.toString());
|
||||
return loanTransactionHelper.getLoanId(loanApplication);
|
||||
return this.loanTransactionHelper.getLoanId(loanApplication);
|
||||
}
|
||||
}
|
||||
|
||||
+7
-7
@@ -27,20 +27,20 @@ public class XBRLIntegrationTest {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
Utils.initializeRESTAssured();
|
||||
requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||
requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||
responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldRetrieveTaxonomyList() {
|
||||
xbrlHelper = new XBRLIntegrationTestHelper(requestSpec, responseSpec);
|
||||
this.xbrlHelper = new XBRLIntegrationTestHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
ArrayList<HashMap> taxonomyList = xbrlHelper.getTaxonomyList();
|
||||
this.verifyTaxonomyList(taxonomyList);
|
||||
final ArrayList<HashMap> taxonomyList = this.xbrlHelper.getTaxonomyList();
|
||||
verifyTaxonomyList(taxonomyList);
|
||||
}
|
||||
|
||||
private void verifyTaxonomyList(ArrayList<HashMap> taxonomyList) {
|
||||
private void verifyTaxonomyList(final ArrayList<HashMap> taxonomyList) {
|
||||
System.out.println("--------------------VERIFYING TAXONOMY LIST--------------------------");
|
||||
assertEquals("Checking for the 1st taxonomy", "AdministrativeExpense", taxonomyList.get(0).get("name"));
|
||||
}
|
||||
|
||||
+4
-4
@@ -23,7 +23,7 @@ public class ClientHelper {
|
||||
}
|
||||
|
||||
public static String getTestClientAsJSON(final String dateOfJoining) {
|
||||
HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
map.put("officeId", "1");
|
||||
map.put("firstname", randomNameGenerator("Client_FirstName_", 5));
|
||||
map.put("lastname", randomNameGenerator("Client_LastName_", 4));
|
||||
@@ -39,9 +39,9 @@ public class ClientHelper {
|
||||
public static void verifyClientCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer generatedClientID) {
|
||||
System.out.println("------------------------------CHECK CLIENT DETAILS------------------------------------\n");
|
||||
String CLIENT_URL = "/mifosng-provider/api/v1/clients/" + generatedClientID + "?tenantIdentifier=default";
|
||||
Integer responseClientID = Utils.performServerGet(requestSpec, responseSpec, CLIENT_URL, "id");
|
||||
assertEquals("ERROR IN CREATING THE CLIENT",generatedClientID, responseClientID);
|
||||
final String CLIENT_URL = "/mifosng-provider/api/v1/clients/" + generatedClientID + "?tenantIdentifier=default";
|
||||
final Integer responseClientID = Utils.performServerGet(requestSpec, responseSpec, CLIENT_URL, "id");
|
||||
assertEquals("ERROR IN CREATING THE CLIENT", generatedClientID, responseClientID);
|
||||
}
|
||||
|
||||
public static String randomNameGenerator(final String prefix, final int lenOfRandomSuffix) {
|
||||
|
||||
+28
-22
@@ -35,40 +35,42 @@ public class GroupHelper {
|
||||
|
||||
public static Integer associateClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String groupId, final String clientMember) {
|
||||
String GROUP_ASSOCIATE_URL = "/mifosng-provider/api/v1/groups/" + groupId + "?command=associateClients&tenantIdentifier=default";
|
||||
final String GROUP_ASSOCIATE_URL = "/mifosng-provider/api/v1/groups/" + groupId
|
||||
+ "?command=associateClients&tenantIdentifier=default";
|
||||
System.out.println("---------------------------------Associate Client To A GROUP---------------------------------------------");
|
||||
return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSOCIATE_URL, associateClientAsJSON(clientMember), "groupId");
|
||||
}
|
||||
|
||||
public static Integer disAssociateClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String groupId, final String clientMember) {
|
||||
String GROUP_ASSOCIATE_URL = "/mifosng-provider/api/v1/groups/" + groupId + "?command=disassociateClients&tenantIdentifier=default";
|
||||
final String GROUP_ASSOCIATE_URL = "/mifosng-provider/api/v1/groups/" + groupId
|
||||
+ "?command=disassociateClients&tenantIdentifier=default";
|
||||
System.out.println("---------------------------------Disassociate Client To A GROUP---------------------------------------------");
|
||||
return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSOCIATE_URL, associateClientAsJSON(clientMember), "groupId");
|
||||
}
|
||||
|
||||
public static Integer activateGroup(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String groupId) {
|
||||
String GROUP_ASSOCIATE_URL = "/mifosng-provider/api/v1/groups/" + groupId + "?command=activate&tenantIdentifier=default";
|
||||
final String GROUP_ASSOCIATE_URL = "/mifosng-provider/api/v1/groups/" + groupId + "?command=activate&tenantIdentifier=default";
|
||||
System.out.println("---------------------------------Activate A GROUP---------------------------------------------");
|
||||
return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSOCIATE_URL, activateGroupAsJSON(""), "groupId");
|
||||
}
|
||||
|
||||
public static Integer updateGroup(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String name,
|
||||
final String groupId) {
|
||||
String GROUP_ASSOCIATE_URL = "/mifosng-provider/api/v1/groups/" + groupId + "?tenantIdentifier=default";
|
||||
final String GROUP_ASSOCIATE_URL = "/mifosng-provider/api/v1/groups/" + groupId + "?tenantIdentifier=default";
|
||||
System.out.println("---------------------------------UPDATE GROUP---------------------------------------------");
|
||||
return Utils.performServerPut(requestSpec, responseSpec, GROUP_ASSOCIATE_URL, updateGroupAsJSON(name), "groupId");
|
||||
}
|
||||
|
||||
public static Integer deleteGroup(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String groupId) {
|
||||
String GROUP_ASSOCIATE_URL = "/mifosng-provider/api/v1/groups/" + groupId + "?tenantIdentifier=default";
|
||||
final String GROUP_ASSOCIATE_URL = "/mifosng-provider/api/v1/groups/" + groupId + "?tenantIdentifier=default";
|
||||
System.out.println("---------------------------------DELETE GROUP---------------------------------------------");
|
||||
return Utils.performServerDelete(requestSpec, responseSpec, GROUP_ASSOCIATE_URL, "groupId");
|
||||
}
|
||||
|
||||
public static String getTestGroupAsJSON(final boolean active, final String activationDate) {
|
||||
HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
map.put("officeId", "1");
|
||||
map.put("name", randomNameGenerator("Group_Name_", 5));
|
||||
map.put("externalId", randomIDGenerator("ID_", 7));
|
||||
@@ -77,16 +79,17 @@ public class GroupHelper {
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("locale", "en");
|
||||
map.put("activationDate", activationDate);
|
||||
} else
|
||||
} else {
|
||||
map.put("active", "false");
|
||||
}
|
||||
|
||||
System.out.println("map : " + map);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
public static String associateClientAsJSON(final String clientMember) {
|
||||
HashMap<String, List<String>> map = new HashMap<String, List<String>>();
|
||||
List<String> list = new ArrayList<String>();
|
||||
final HashMap<String, List<String>> map = new HashMap<String, List<String>>();
|
||||
final List<String> list = new ArrayList<String>();
|
||||
list.add(clientMember);
|
||||
map.put("clientMembers", list);
|
||||
System.out.println("map : " + map);
|
||||
@@ -94,19 +97,20 @@ public class GroupHelper {
|
||||
}
|
||||
|
||||
public static String activateGroupAsJSON(final String activationDate) {
|
||||
HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("locale", "en");
|
||||
if (activationDate != "")
|
||||
if (activationDate != "") {
|
||||
map.put("activationDate", activationDate);
|
||||
else
|
||||
} else {
|
||||
map.put("activationDate", "04 March 2011");
|
||||
}
|
||||
System.out.println("map : " + map);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
public static String updateGroupAsJSON(final String name) {
|
||||
HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
map.put("name", name);
|
||||
System.out.println("map : " + map);
|
||||
return new Gson().toJson(map);
|
||||
@@ -115,24 +119,24 @@ public class GroupHelper {
|
||||
public static void verifyGroupCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer generatedGroupID) {
|
||||
System.out.println("------------------------------CHECK GROUP DETAILS------------------------------------\n");
|
||||
String GROUP_URL = "/mifosng-provider/api/v1/groups/" + generatedGroupID + "?tenantIdentifier=default";
|
||||
Integer responseGroupID = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "id");
|
||||
final String GROUP_URL = "/mifosng-provider/api/v1/groups/" + generatedGroupID + "?tenantIdentifier=default";
|
||||
final Integer responseGroupID = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "id");
|
||||
assertEquals("ERROR IN CREATING THE GROUP", generatedGroupID, responseGroupID);
|
||||
}
|
||||
|
||||
public static void verifyGroupDetails(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer generatedGroupID, final String field, final String expectedValue) {
|
||||
System.out.println("------------------------------CHECK GROUP DETAILS------------------------------------\n");
|
||||
String GROUP_URL = "/mifosng-provider/api/v1/groups/" + generatedGroupID + "?tenantIdentifier=default";
|
||||
String responseValue = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, field);
|
||||
final String GROUP_URL = "/mifosng-provider/api/v1/groups/" + generatedGroupID + "?tenantIdentifier=default";
|
||||
final String responseValue = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, field);
|
||||
assertEquals("ERROR IN CREATING THE GROUP", expectedValue, responseValue);
|
||||
}
|
||||
|
||||
public static void verifyGroupActivatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer generatedGroupID, final boolean generatedGroupStatus) {
|
||||
System.out.println("------------------------------CHECK GROUP STATUS------------------------------------\n");
|
||||
String GROUP_URL = "/mifosng-provider/api/v1/groups/" + generatedGroupID + "?tenantIdentifier=default";
|
||||
Boolean responseGroupStatus = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "active");
|
||||
final String GROUP_URL = "/mifosng-provider/api/v1/groups/" + generatedGroupID + "?tenantIdentifier=default";
|
||||
final Boolean responseGroupStatus = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "active");
|
||||
assertEquals("ERROR IN ACTIVATING THE GROUP", generatedGroupStatus, responseGroupStatus);
|
||||
}
|
||||
|
||||
@@ -140,7 +144,8 @@ public class GroupHelper {
|
||||
final Integer generatedGroupID, final Integer groupMember) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
System.out.println("------------------------------CHECK GROUP MEMBERS------------------------------------\n");
|
||||
String GROUP_URL = "/mifosng-provider/api/v1/groups/" + generatedGroupID + "?associations=clientMembers&tenantIdentifier=default";
|
||||
final String GROUP_URL = "/mifosng-provider/api/v1/groups/" + generatedGroupID
|
||||
+ "?associations=clientMembers&tenantIdentifier=default";
|
||||
list = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "clientMembers");
|
||||
assertTrue("ERROR IN GROUP MEMBER", list.toString().contains("id=" + groupMember.toString()));
|
||||
}
|
||||
@@ -149,7 +154,8 @@ public class GroupHelper {
|
||||
final Integer generatedGroupID) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
System.out.println("------------------------------CHECK EMPTY GROUP MEMBER LIST------------------------------------\n");
|
||||
String GROUP_URL = "/mifosng-provider/api/v1/groups/" + generatedGroupID + "?associations=clientMembers&tenantIdentifier=default";
|
||||
final String GROUP_URL = "/mifosng-provider/api/v1/groups/" + generatedGroupID
|
||||
+ "?associations=clientMembers&tenantIdentifier=default";
|
||||
list = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "clientMembers");
|
||||
assertEquals("GROUP MEMBER LIST NOT EMPTY", list, null);
|
||||
}
|
||||
@@ -158,7 +164,7 @@ public class GroupHelper {
|
||||
final Integer generatedGroupID) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
System.out.println("------------------------------CHECK GROUP DELETED------------------------------------\n");
|
||||
String GROUP_URL = "/mifosng-provider/api/v1/groups/?tenantIdentifier=default";
|
||||
final String GROUP_URL = "/mifosng-provider/api/v1/groups/?tenantIdentifier=default";
|
||||
list = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "pageItems");
|
||||
|
||||
assertFalse("GROUP NOT DELETED", list.toString().contains("id=" + generatedGroupID.toString()));
|
||||
|
||||
+28
-38
@@ -6,6 +6,10 @@ import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.http.conn.HttpHostConnectException;
|
||||
|
||||
@@ -14,19 +18,13 @@ import com.jayway.restassured.path.json.JsonPath;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
import java.lang.System;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Random;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class Utils {
|
||||
|
||||
private static final String LOGIN_URL = "/mifosng-provider/api/v1/authentication?username=mifos&password=password&tenantIdentifier=default";
|
||||
|
||||
|
||||
public static void initializeRESTAssured() {
|
||||
RestAssured.baseURI ="https://localhost";
|
||||
RestAssured.baseURI = "https://localhost";
|
||||
RestAssured.port = 8443;
|
||||
RestAssured.keystore("../keystore.jks", "openmf");
|
||||
}
|
||||
@@ -34,14 +32,13 @@ public class Utils {
|
||||
public static String loginIntoServerAndGetBase64EncodedAuthenticationKey() {
|
||||
try {
|
||||
System.out.println("-----------------------------------LOGIN-----------------------------------------");
|
||||
String json = RestAssured.post(LOGIN_URL).asString();
|
||||
final String json = RestAssured.post(LOGIN_URL).asString();
|
||||
assertThat("Failed to login into mifosx platform", StringUtils.isBlank(json), is(false));
|
||||
return JsonPath.with(json).get("base64EncodedAuthenticationKey");
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
if (e instanceof HttpHostConnectException) {
|
||||
HttpHostConnectException hh = (HttpHostConnectException) e;
|
||||
fail("Failed to connect to mifosx platform:"+hh.getMessage());
|
||||
final HttpHostConnectException hh = (HttpHostConnectException) e;
|
||||
fail("Failed to connect to mifosx platform:" + hh.getMessage());
|
||||
}
|
||||
|
||||
throw new RuntimeException(e);
|
||||
@@ -49,58 +46,51 @@ public class Utils {
|
||||
}
|
||||
|
||||
public static <T> T performServerGet(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String getURL, final String jsonAttributeToGetBack) {
|
||||
String json = given().spec(requestSpec)
|
||||
.expect().spec(responseSpec).log().ifError()
|
||||
.when().get(getURL).andReturn().asString();
|
||||
final String getURL, final String jsonAttributeToGetBack) {
|
||||
final String json = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(getURL).andReturn().asString();
|
||||
return (T) from(json).get(jsonAttributeToGetBack);
|
||||
}
|
||||
|
||||
public static <T> T performServerPost(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String postURL, final String jsonBodyToSend, final String jsonAttributeToGetBack) {
|
||||
String json = given().spec(requestSpec).body(jsonBodyToSend)
|
||||
.expect().spec(responseSpec).log().ifError()
|
||||
.when().post(postURL)
|
||||
final String postURL, final String jsonBodyToSend, final String jsonAttributeToGetBack) {
|
||||
final String json = given().spec(requestSpec).body(jsonBodyToSend).expect().spec(responseSpec).log().ifError().when().post(postURL)
|
||||
.andReturn().asString();
|
||||
return (T) from(json).get(jsonAttributeToGetBack);
|
||||
}
|
||||
|
||||
public static <T> T performServerPut(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String putURL, final String jsonBodyToSend, final String jsonAttributeToGetBack) {
|
||||
String json = given().spec(requestSpec).body(jsonBodyToSend)
|
||||
.expect().spec(responseSpec).log().ifError()
|
||||
.when().put(putURL)
|
||||
final String putURL, final String jsonBodyToSend, final String jsonAttributeToGetBack) {
|
||||
final String json = given().spec(requestSpec).body(jsonBodyToSend).expect().spec(responseSpec).log().ifError().when().put(putURL)
|
||||
.andReturn().asString();
|
||||
return (T) from(json).get(jsonAttributeToGetBack);
|
||||
}
|
||||
|
||||
public static <T> T performServerDelete(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String deleteURL, final String jsonAttributeToGetBack) {
|
||||
String json = given().spec(requestSpec)
|
||||
.expect().spec(responseSpec).log().ifError()
|
||||
.when().delete(deleteURL)
|
||||
.andReturn().asString();
|
||||
final String deleteURL, final String jsonAttributeToGetBack) {
|
||||
final String json = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().delete(deleteURL).andReturn()
|
||||
.asString();
|
||||
return (T) from(json).get(jsonAttributeToGetBack);
|
||||
}
|
||||
|
||||
public static String convertDateToURLFormat(String dateToBeConvert){
|
||||
SimpleDateFormat oldFormat = new SimpleDateFormat("dd MMMMMM yyyy");
|
||||
SimpleDateFormat newFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String reformattedStr="";
|
||||
public static String convertDateToURLFormat(final String dateToBeConvert) {
|
||||
final SimpleDateFormat oldFormat = new SimpleDateFormat("dd MMMMMM yyyy");
|
||||
final SimpleDateFormat newFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String reformattedStr = "";
|
||||
try {
|
||||
reformattedStr = newFormat.format(oldFormat.parse(dateToBeConvert));
|
||||
} catch (ParseException e) {
|
||||
} catch (final ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return reformattedStr;
|
||||
}
|
||||
|
||||
public static String randomStringGenerator(final String prefix, final int len, final String sourceSetString) {
|
||||
int lengthOfSource = sourceSetString.length();
|
||||
Random rnd = new Random();
|
||||
StringBuilder sb = new StringBuilder(len);
|
||||
for (int i = 0; i < len; i++)
|
||||
final int lengthOfSource = sourceSetString.length();
|
||||
final Random rnd = new Random();
|
||||
final StringBuilder sb = new StringBuilder(len);
|
||||
for (int i = 0; i < len; i++) {
|
||||
sb.append((sourceSetString).charAt(rnd.nextInt(lengthOfSource)));
|
||||
}
|
||||
return (prefix + (sb.toString()));
|
||||
}
|
||||
|
||||
|
||||
+9
-9
@@ -3,33 +3,33 @@ package org.mifosplatform.integrationtests.common.accounting;
|
||||
public class Account {
|
||||
|
||||
public enum AccountType {
|
||||
ASSET("1"), INCOME("4"), EXPENSE("5"), LIABILITY("2"),EQUITY("3");
|
||||
ASSET("1"), INCOME("4"), EXPENSE("5"), LIABILITY("2"), EQUITY("3");
|
||||
|
||||
private final String accountValue ;
|
||||
private final String accountValue;
|
||||
|
||||
AccountType(final String accountValue){
|
||||
this.accountValue=accountValue;
|
||||
AccountType(final String accountValue) {
|
||||
this.accountValue = accountValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return accountValue;
|
||||
return this.accountValue;
|
||||
}
|
||||
}
|
||||
|
||||
private final AccountType accountType;
|
||||
private final Integer accountID;
|
||||
|
||||
|
||||
public Account(Integer accountID, AccountType accountType) {
|
||||
public Account(final Integer accountID, final AccountType accountType) {
|
||||
this.accountID = accountID;
|
||||
this.accountType = accountType;
|
||||
}
|
||||
|
||||
public AccountType getAccountType(){
|
||||
public AccountType getAccountType() {
|
||||
return this.accountType;
|
||||
}
|
||||
|
||||
public Integer getAccountID(){
|
||||
public Integer getAccountID() {
|
||||
return this.accountID;
|
||||
}
|
||||
}
|
||||
|
||||
+19
-19
@@ -1,41 +1,41 @@
|
||||
package org.mifosplatform.integrationtests.common.accounting;
|
||||
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
|
||||
public class AccountHelper {
|
||||
|
||||
private final String CREATE_GL_ACCOUNT_URL = "/mifosng-provider/api/v1/glaccounts?tenantIdentifier=default";
|
||||
private final String GL_ACCOUNT_ID_RESPONSE = "resourceId";
|
||||
|
||||
private RequestSpecification requestSpec;
|
||||
private ResponseSpecification responseSpec;
|
||||
private final RequestSpecification requestSpec;
|
||||
private final ResponseSpecification responseSpec;
|
||||
|
||||
public AccountHelper(RequestSpecification requestSpec, ResponseSpecification responseSpec) {
|
||||
public AccountHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
this.requestSpec = requestSpec;
|
||||
this.responseSpec = responseSpec;
|
||||
}
|
||||
|
||||
public Account createAssetAccount(){
|
||||
String assetAccountJSON= new GLAccountBuilder()
|
||||
.withAccountTypeAsAsset()
|
||||
.build();
|
||||
Integer accountID = Utils.performServerPost(requestSpec, responseSpec, CREATE_GL_ACCOUNT_URL, assetAccountJSON, GL_ACCOUNT_ID_RESPONSE);
|
||||
public Account createAssetAccount() {
|
||||
final String assetAccountJSON = new GLAccountBuilder().withAccountTypeAsAsset().build();
|
||||
final Integer accountID = Utils.performServerPost(this.requestSpec, this.responseSpec, this.CREATE_GL_ACCOUNT_URL,
|
||||
assetAccountJSON, this.GL_ACCOUNT_ID_RESPONSE);
|
||||
return new Account(accountID, Account.AccountType.ASSET);
|
||||
}
|
||||
public Account createIncomeAccount(){
|
||||
String assetAccountJSON= new GLAccountBuilder()
|
||||
.withAccountTypeAsIncome()
|
||||
.build();
|
||||
Integer accountID = Utils.performServerPost(requestSpec, responseSpec, CREATE_GL_ACCOUNT_URL, assetAccountJSON, GL_ACCOUNT_ID_RESPONSE);
|
||||
|
||||
public Account createIncomeAccount() {
|
||||
final String assetAccountJSON = new GLAccountBuilder().withAccountTypeAsIncome().build();
|
||||
final Integer accountID = Utils.performServerPost(this.requestSpec, this.responseSpec, this.CREATE_GL_ACCOUNT_URL,
|
||||
assetAccountJSON, this.GL_ACCOUNT_ID_RESPONSE);
|
||||
return new Account(accountID, Account.AccountType.INCOME);
|
||||
}
|
||||
public Account createExpenseAccount(){
|
||||
String assetAccountJSON= new GLAccountBuilder()
|
||||
.withAccountTypeAsExpense()
|
||||
.build();
|
||||
Integer accountID = Utils.performServerPost(requestSpec, responseSpec, CREATE_GL_ACCOUNT_URL, assetAccountJSON, GL_ACCOUNT_ID_RESPONSE);
|
||||
|
||||
public Account createExpenseAccount() {
|
||||
final String assetAccountJSON = new GLAccountBuilder().withAccountTypeAsExpense().build();
|
||||
final Integer accountID = Utils.performServerPost(this.requestSpec, this.responseSpec, this.CREATE_GL_ACCOUNT_URL,
|
||||
assetAccountJSON, this.GL_ACCOUNT_ID_RESPONSE);
|
||||
return new Account(accountID, Account.AccountType.EXPENSE);
|
||||
}
|
||||
|
||||
|
||||
+7
-7
@@ -29,7 +29,7 @@ public class GLAccountBuilder {
|
||||
private static String description = "DEFAULT_DESCRIPTION";
|
||||
|
||||
public String build() {
|
||||
HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
map.put("name", GLAccountBuilder.name);
|
||||
map.put("glCode", GLAccountBuilder.GLCode);
|
||||
map.put("manualEntriesAllowed", GLAccountBuilder.manualEntriesAllowed);
|
||||
@@ -43,12 +43,12 @@ public class GLAccountBuilder {
|
||||
GLAccountBuilder.accountType = ASSET_ACCOUNT;
|
||||
GLAccountBuilder.GLCode = Utils.randomStringGenerator("ASSET_", 2);
|
||||
GLAccountBuilder.GLCode += Calendar.getInstance().getTimeInMillis() + ""; // Added
|
||||
// unique
|
||||
// timestamp
|
||||
// for
|
||||
// avoiding
|
||||
// random
|
||||
// collisions
|
||||
// unique
|
||||
// timestamp
|
||||
// for
|
||||
// avoiding
|
||||
// random
|
||||
// collisions
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
+7
-8
@@ -1,11 +1,9 @@
|
||||
package org.mifosplatform.integrationtests.common.accounting;
|
||||
|
||||
|
||||
public class JournalEntry {
|
||||
|
||||
public enum TransactionType {
|
||||
CREDIT("CREDIT"),
|
||||
DEBIT("DEBIT");
|
||||
CREDIT("CREDIT"), DEBIT("DEBIT");
|
||||
|
||||
private TransactionType(final String type) {
|
||||
this.type = type;
|
||||
@@ -15,22 +13,23 @@ public class JournalEntry {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return type;
|
||||
return this.type;
|
||||
}
|
||||
}
|
||||
|
||||
private final Float transactionAmount;
|
||||
private final TransactionType transactionType;
|
||||
|
||||
public JournalEntry(float transactionAmount, TransactionType type){
|
||||
this.transactionAmount=transactionAmount;
|
||||
public JournalEntry(final float transactionAmount, final TransactionType type) {
|
||||
this.transactionAmount = transactionAmount;
|
||||
this.transactionType = type;
|
||||
}
|
||||
|
||||
public Float getTransactionAmount(){
|
||||
public Float getTransactionAmount() {
|
||||
return this.transactionAmount;
|
||||
}
|
||||
|
||||
public String getTransactionType(){
|
||||
public String getTransactionType() {
|
||||
return this.transactionType.toString();
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -35,7 +35,7 @@ public class JournalEntryHelper {
|
||||
}
|
||||
|
||||
private String getEntryValueFromJournalEntry(final ArrayList<HashMap> entryResponse, final int entryNumber) {
|
||||
HashMap map = (HashMap) entryResponse.get(entryNumber).get("entryType");
|
||||
final HashMap map = (HashMap) entryResponse.get(entryNumber).get("entryType");
|
||||
return (String) map.get("value");
|
||||
}
|
||||
|
||||
@@ -44,8 +44,8 @@ public class JournalEntryHelper {
|
||||
}
|
||||
|
||||
private void checkJournalEntry(final Account account, final String date, final JournalEntry... accountEntries) {
|
||||
String url = createURLForGettingAccountEntries(account, date);
|
||||
ArrayList<HashMap> response = Utils.performServerGet(requestSpec, responseSpec, url, "pageItems");
|
||||
final String url = createURLForGettingAccountEntries(account, date);
|
||||
final ArrayList<HashMap> response = Utils.performServerGet(this.requestSpec, this.responseSpec, url, "pageItems");
|
||||
for (int i = 0; i < accountEntries.length; i++) {
|
||||
assertThat(getEntryValueFromJournalEntry(response, i), equalTo(accountEntries[i].getTransactionType()));
|
||||
assertThat(getTransactionAmountFromJournalEntry(response, i), equalTo(accountEntries[i].getTransactionAmount()));
|
||||
|
||||
+19
-18
@@ -35,28 +35,29 @@ public class LoanApplicationTestBuilder {
|
||||
|
||||
public String build(final String ID, final String loanProductId) {
|
||||
|
||||
HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("locale", "en_GB");
|
||||
if (loanType == "group")
|
||||
if (this.loanType == "group") {
|
||||
map.put("groupId", ID);
|
||||
else
|
||||
} else {
|
||||
map.put("clientId", ID);
|
||||
}
|
||||
map.put("productId", loanProductId);
|
||||
map.put("principal", principal);
|
||||
map.put("loanTermFrequency", loanTermFrequency);
|
||||
map.put("loanTermFrequencyType", loanTermFrequencyType);
|
||||
map.put("numberOfRepayments", numberOfRepayment);
|
||||
map.put("repaymentEvery", repaymentPeriod);
|
||||
map.put("repaymentFrequencyType", repaymentFrequencyType);
|
||||
map.put("interestRatePerPeriod", interestRate);
|
||||
map.put("amortizationType", amortizationType);
|
||||
map.put("interestType", interestType);
|
||||
map.put("interestCalculationPeriodType", interestCalculationPeriodType);
|
||||
map.put("transactionProcessingStrategyId", transactionProcessingID);
|
||||
map.put("expectedDisbursementDate", expectedDisbursmentDate);
|
||||
map.put("submittedOnDate", submittedOnDate);
|
||||
map.put("loanType", loanType);
|
||||
map.put("principal", this.principal);
|
||||
map.put("loanTermFrequency", this.loanTermFrequency);
|
||||
map.put("loanTermFrequencyType", this.loanTermFrequencyType);
|
||||
map.put("numberOfRepayments", this.numberOfRepayment);
|
||||
map.put("repaymentEvery", this.repaymentPeriod);
|
||||
map.put("repaymentFrequencyType", this.repaymentFrequencyType);
|
||||
map.put("interestRatePerPeriod", this.interestRate);
|
||||
map.put("amortizationType", this.amortizationType);
|
||||
map.put("interestType", this.interestType);
|
||||
map.put("interestCalculationPeriodType", this.interestCalculationPeriodType);
|
||||
map.put("transactionProcessingStrategyId", this.transactionProcessingID);
|
||||
map.put("expectedDisbursementDate", this.expectedDisbursmentDate);
|
||||
map.put("submittedOnDate", this.submittedOnDate);
|
||||
map.put("loanType", this.loanType);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
@@ -160,7 +161,7 @@ public class LoanApplicationTestBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanApplicationTestBuilder withLoanType(final String loanType){
|
||||
public LoanApplicationTestBuilder withLoanType(final String loanType) {
|
||||
this.loanType = loanType;
|
||||
return this;
|
||||
}
|
||||
|
||||
+111
-112
@@ -3,11 +3,13 @@ package org.mifosplatform.integrationtests.common.loans;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import org.mifosplatform.integrationtests.common.ClientHelper;
|
||||
import org.mifosplatform.integrationtests.common.accounting.Account;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class LoanProductTestBuilder {
|
||||
|
||||
private static final String LOCALE = "en_GB";
|
||||
private static final String DIGITS_AFTER_DECIMAL = "2";
|
||||
private static final String INR = "INR";
|
||||
@@ -15,227 +17,224 @@ public class LoanProductTestBuilder {
|
||||
private static final String WEEK = "1";
|
||||
private static final String MONTHS = "2";
|
||||
private static final String YEARS = "3";
|
||||
private static final String CALCULATION_PERIOD_SAME_AS_REPAYMENT_PERIOD="1";
|
||||
private static final String EQUAL_PRINCIPAL_PAYMENTS="0";
|
||||
private static final String EQUAL_INSTALLMENTS="1";
|
||||
private static final String DECLINING_BALANCE="0";
|
||||
private static final String FLAT_BALANCE="1";
|
||||
private static final String MIFOS_STANDARD_STRATEGY ="1";
|
||||
private static final String CALCULATION_PERIOD_SAME_AS_REPAYMENT_PERIOD = "1";
|
||||
private static final String EQUAL_PRINCIPAL_PAYMENTS = "0";
|
||||
private static final String EQUAL_INSTALLMENTS = "1";
|
||||
private static final String DECLINING_BALANCE = "0";
|
||||
private static final String FLAT_BALANCE = "1";
|
||||
private static final String MIFOS_STANDARD_STRATEGY = "1";
|
||||
// private static final String HEAVENS_FAMILY_STRATEGY ="2";
|
||||
// private static final String CREO_CORE_STRATEGY ="3";
|
||||
// private static final String RBI_INDIA_STRATEGY ="4";
|
||||
private static final String NONE ="1";
|
||||
private static final String CASH_BASED ="2";
|
||||
private static final String ACCRUAL_BASED ="3";
|
||||
|
||||
private static final String NONE = "1";
|
||||
private static final String CASH_BASED = "2";
|
||||
private static final String ACCRUAL_BASED = "3";
|
||||
|
||||
private String nameOfLoanProduct = ClientHelper.randomNameGenerator("LOAN_PRODUCT_", 6);
|
||||
private String principal = "10000.00";
|
||||
private String numberOfRepayments = "5";
|
||||
private String repaymentFrequency = MONTHS;
|
||||
private String repaymentPeriod = "1";
|
||||
private String interestRatePerPeriod= "2";
|
||||
private String interestRatePerPeriod = "2";
|
||||
private String interestRateFrequencyType = MONTHS;
|
||||
private String interestType = FLAT_BALANCE;
|
||||
private String interestCalculationPeriodType=CALCULATION_PERIOD_SAME_AS_REPAYMENT_PERIOD;
|
||||
private String inArrearsTolerance="0";
|
||||
private final String transactionProcessingStrategy=MIFOS_STANDARD_STRATEGY;
|
||||
private String accountingRule =NONE;
|
||||
private String interestCalculationPeriodType = CALCULATION_PERIOD_SAME_AS_REPAYMENT_PERIOD;
|
||||
private String inArrearsTolerance = "0";
|
||||
private final String transactionProcessingStrategy = MIFOS_STANDARD_STRATEGY;
|
||||
private String accountingRule = NONE;
|
||||
private final String currencyCode = INR;
|
||||
private String amortizationType= EQUAL_INSTALLMENTS;
|
||||
private String amortizationType = EQUAL_INSTALLMENTS;
|
||||
private String minPrincipal = "1000.00";
|
||||
private String maxPrincipal = "100000.00";
|
||||
private Account[] accountList = null;
|
||||
|
||||
public String build() {
|
||||
HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
|
||||
map.put("name", nameOfLoanProduct);
|
||||
map.put("currencyCode", currencyCode);
|
||||
map.put("name", this.nameOfLoanProduct);
|
||||
map.put("currencyCode", this.currencyCode);
|
||||
map.put("locale", LOCALE);
|
||||
map.put("digitsAfterDecimal",DIGITS_AFTER_DECIMAL);
|
||||
map.put("principal", principal);
|
||||
map.put("numberOfRepayments", numberOfRepayments);
|
||||
map.put("repaymentEvery",repaymentPeriod );
|
||||
map.put("repaymentFrequencyType", repaymentFrequency);
|
||||
map.put("interestRatePerPeriod", interestRatePerPeriod);
|
||||
map.put("interestRateFrequencyType", interestRateFrequencyType);
|
||||
map.put("amortizationType",amortizationType);
|
||||
map.put("interestType", interestType);
|
||||
map.put("interestCalculationPeriodType", interestCalculationPeriodType);
|
||||
map.put("inArrearsTolerance", inArrearsTolerance);
|
||||
map.put("transactionProcessingStrategyId", transactionProcessingStrategy);
|
||||
map.put("accountingRule", accountingRule);
|
||||
map.put("minPrincipal",minPrincipal);
|
||||
map.put("maxPrincipal",maxPrincipal);
|
||||
map.put("digitsAfterDecimal", DIGITS_AFTER_DECIMAL);
|
||||
map.put("principal", this.principal);
|
||||
map.put("numberOfRepayments", this.numberOfRepayments);
|
||||
map.put("repaymentEvery", this.repaymentPeriod);
|
||||
map.put("repaymentFrequencyType", this.repaymentFrequency);
|
||||
map.put("interestRatePerPeriod", this.interestRatePerPeriod);
|
||||
map.put("interestRateFrequencyType", this.interestRateFrequencyType);
|
||||
map.put("amortizationType", this.amortizationType);
|
||||
map.put("interestType", this.interestType);
|
||||
map.put("interestCalculationPeriodType", this.interestCalculationPeriodType);
|
||||
map.put("inArrearsTolerance", this.inArrearsTolerance);
|
||||
map.put("transactionProcessingStrategyId", this.transactionProcessingStrategy);
|
||||
map.put("accountingRule", this.accountingRule);
|
||||
map.put("minPrincipal", this.minPrincipal);
|
||||
map.put("maxPrincipal", this.maxPrincipal);
|
||||
|
||||
if(accountingRule.equals(ACCRUAL_BASED)){
|
||||
if (this.accountingRule.equals(ACCRUAL_BASED)) {
|
||||
map.putAll(getAccountMappingForAccrualBased());
|
||||
}else if(accountingRule.equals(CASH_BASED)){
|
||||
} else if (this.accountingRule.equals(CASH_BASED)) {
|
||||
map.putAll(getAccountMappingForCashBased());
|
||||
}
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
|
||||
public LoanProductTestBuilder withMinPrincipal(final String minPrincipal){
|
||||
this.minPrincipal=minPrincipal;
|
||||
return this;
|
||||
}
|
||||
public LoanProductTestBuilder withMaxPrincipal(final String maxPrincipal){
|
||||
this.maxPrincipal=maxPrincipal;
|
||||
public LoanProductTestBuilder withMinPrincipal(final String minPrincipal) {
|
||||
this.minPrincipal = minPrincipal;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanProductTestBuilder withLoanName(final String loanName){
|
||||
this.nameOfLoanProduct=loanName;
|
||||
public LoanProductTestBuilder withMaxPrincipal(final String maxPrincipal) {
|
||||
this.maxPrincipal = maxPrincipal;
|
||||
return this;
|
||||
}
|
||||
public LoanProductTestBuilder withPrincipal(final String principal){
|
||||
|
||||
public LoanProductTestBuilder withLoanName(final String loanName) {
|
||||
this.nameOfLoanProduct = loanName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanProductTestBuilder withPrincipal(final String principal) {
|
||||
this.principal = principal;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanProductTestBuilder withNumberOfRepayments(final String numberOfRepayment){
|
||||
public LoanProductTestBuilder withNumberOfRepayments(final String numberOfRepayment) {
|
||||
this.numberOfRepayments = numberOfRepayment;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public LoanProductTestBuilder withRepaymentTypeAsMonth(){
|
||||
public LoanProductTestBuilder withRepaymentTypeAsMonth() {
|
||||
this.repaymentFrequency = MONTHS;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanProductTestBuilder withRepaymentTypeAsWeek(){
|
||||
public LoanProductTestBuilder withRepaymentTypeAsWeek() {
|
||||
this.repaymentFrequency = WEEK;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanProductTestBuilder withRepaymentTypeAsDays(){
|
||||
public LoanProductTestBuilder withRepaymentTypeAsDays() {
|
||||
this.repaymentFrequency = DAYS;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanProductTestBuilder withRepaymentAfterEvery(final String repaymentAfterEvery){
|
||||
this.repaymentPeriod=repaymentAfterEvery;
|
||||
public LoanProductTestBuilder withRepaymentAfterEvery(final String repaymentAfterEvery) {
|
||||
this.repaymentPeriod = repaymentAfterEvery;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanProductTestBuilder withInterestRateFrequencyTypeAsMonths(){
|
||||
this.interestRateFrequencyType=MONTHS;
|
||||
public LoanProductTestBuilder withInterestRateFrequencyTypeAsMonths() {
|
||||
this.interestRateFrequencyType = MONTHS;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanProductTestBuilder withInterestRateFrequencyTypeAsYear(){
|
||||
this.interestRateFrequencyType=YEARS;
|
||||
public LoanProductTestBuilder withInterestRateFrequencyTypeAsYear() {
|
||||
this.interestRateFrequencyType = YEARS;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanProductTestBuilder withinterestRatePerPeriod(final String interestRatePerPeriod) {
|
||||
this.interestRatePerPeriod=interestRatePerPeriod;
|
||||
this.interestRatePerPeriod = interestRatePerPeriod;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanProductTestBuilder withAmortizationTypeAsEqualPrincipalPayment(){
|
||||
public LoanProductTestBuilder withAmortizationTypeAsEqualPrincipalPayment() {
|
||||
this.amortizationType = EQUAL_PRINCIPAL_PAYMENTS;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanProductTestBuilder withAmortizationTypeAsEqualInstallments(){
|
||||
public LoanProductTestBuilder withAmortizationTypeAsEqualInstallments() {
|
||||
this.amortizationType = EQUAL_INSTALLMENTS;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanProductTestBuilder withInterestTypeAsFlat(){
|
||||
this.interestType=FLAT_BALANCE;
|
||||
public LoanProductTestBuilder withInterestTypeAsFlat() {
|
||||
this.interestType = FLAT_BALANCE;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanProductTestBuilder withInterestTypeAsDecliningBalance (){
|
||||
this.interestType=DECLINING_BALANCE;
|
||||
public LoanProductTestBuilder withInterestTypeAsDecliningBalance() {
|
||||
this.interestType = DECLINING_BALANCE;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanProductTestBuilder withInterestCalculationPeriodTypeAsDays (){
|
||||
this.interestCalculationPeriodType=DAYS;
|
||||
public LoanProductTestBuilder withInterestCalculationPeriodTypeAsDays() {
|
||||
this.interestCalculationPeriodType = DAYS;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanProductTestBuilder withInterestCalculationPeriodTypeAsRepaymentPeriod (){
|
||||
this.interestCalculationPeriodType=CALCULATION_PERIOD_SAME_AS_REPAYMENT_PERIOD;
|
||||
public LoanProductTestBuilder withInterestCalculationPeriodTypeAsRepaymentPeriod() {
|
||||
this.interestCalculationPeriodType = CALCULATION_PERIOD_SAME_AS_REPAYMENT_PERIOD;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanProductTestBuilder withInArrearsTolerance (final String amountCanBeWaved){
|
||||
public LoanProductTestBuilder withInArrearsTolerance(final String amountCanBeWaved) {
|
||||
this.inArrearsTolerance = amountCanBeWaved;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanProductTestBuilder withAccountingRuleAsNone (){
|
||||
this.accountingRule= NONE;
|
||||
public LoanProductTestBuilder withAccountingRuleAsNone() {
|
||||
this.accountingRule = NONE;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanProductTestBuilder withAccountingRuleAsCashBased (Account [] account_list){
|
||||
this.accountingRule= CASH_BASED;
|
||||
public LoanProductTestBuilder withAccountingRuleAsCashBased(final Account[] account_list) {
|
||||
this.accountingRule = CASH_BASED;
|
||||
this.accountList = account_list;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanProductTestBuilder withAccountingRuleAsAccrualBased (Account[] account_list){
|
||||
this.accountingRule= ACCRUAL_BASED;
|
||||
public LoanProductTestBuilder withAccountingRuleAsAccrualBased(final Account[] account_list) {
|
||||
this.accountingRule = ACCRUAL_BASED;
|
||||
this.accountList = account_list;
|
||||
return this;
|
||||
}
|
||||
|
||||
private Map<String,String> getAccountMappingForCashBased() {
|
||||
Map<String,String> map = new HashMap<String, String>();
|
||||
for (int i=0;i<this.accountList.length;i++)
|
||||
{
|
||||
if(accountList[i].getAccountType().equals(Account.AccountType.ASSET)){
|
||||
String ID = accountList[i].getAccountID().toString();
|
||||
map.put("fundSourceAccountId",ID);
|
||||
map.put("loanPortfolioAccountId",ID);
|
||||
map.put("transfersInSuspenseAccountId",ID);
|
||||
private Map<String, String> getAccountMappingForCashBased() {
|
||||
final Map<String, String> map = new HashMap<String, String>();
|
||||
for (int i = 0; i < this.accountList.length; i++) {
|
||||
if (this.accountList[i].getAccountType().equals(Account.AccountType.ASSET)) {
|
||||
final String ID = this.accountList[i].getAccountID().toString();
|
||||
map.put("fundSourceAccountId", ID);
|
||||
map.put("loanPortfolioAccountId", ID);
|
||||
map.put("transfersInSuspenseAccountId", ID);
|
||||
}
|
||||
if(accountList[i].getAccountType().equals(Account.AccountType.INCOME)){
|
||||
String ID = accountList[i].getAccountID().toString();
|
||||
map.put("interestOnLoanAccountId",ID);
|
||||
map.put("incomeFromFeeAccountId",ID);
|
||||
map.put("incomeFromPenaltyAccountId",ID);
|
||||
if (this.accountList[i].getAccountType().equals(Account.AccountType.INCOME)) {
|
||||
final String ID = this.accountList[i].getAccountID().toString();
|
||||
map.put("interestOnLoanAccountId", ID);
|
||||
map.put("incomeFromFeeAccountId", ID);
|
||||
map.put("incomeFromPenaltyAccountId", ID);
|
||||
}
|
||||
if(accountList[i].getAccountType().equals(Account.AccountType.EXPENSE)){
|
||||
String ID = accountList[i].getAccountID().toString();
|
||||
map.put("writeOffAccountId",ID);
|
||||
if (this.accountList[i].getAccountType().equals(Account.AccountType.EXPENSE)) {
|
||||
final String ID = this.accountList[i].getAccountID().toString();
|
||||
map.put("writeOffAccountId", ID);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private Map<String, String> getAccountMappingForAccrualBased() {
|
||||
Map<String,String> map = new HashMap<String, String>();
|
||||
for (int i=0;i<this.accountList.length;i++)
|
||||
{
|
||||
if(accountList[i].getAccountType().equals(Account.AccountType.ASSET)){
|
||||
String ID = accountList[i].getAccountID().toString();
|
||||
map.put("fundSourceAccountId",ID);
|
||||
map.put("loanPortfolioAccountId",ID);
|
||||
map.put("transfersInSuspenseAccountId",ID);
|
||||
map.put("receivableInterestAccountId",ID);
|
||||
map.put("receivableFeeAccountId",ID);
|
||||
map.put("receivablePenaltyAccountId",ID);
|
||||
final Map<String, String> map = new HashMap<String, String>();
|
||||
for (int i = 0; i < this.accountList.length; i++) {
|
||||
if (this.accountList[i].getAccountType().equals(Account.AccountType.ASSET)) {
|
||||
final String ID = this.accountList[i].getAccountID().toString();
|
||||
map.put("fundSourceAccountId", ID);
|
||||
map.put("loanPortfolioAccountId", ID);
|
||||
map.put("transfersInSuspenseAccountId", ID);
|
||||
map.put("receivableInterestAccountId", ID);
|
||||
map.put("receivableFeeAccountId", ID);
|
||||
map.put("receivablePenaltyAccountId", ID);
|
||||
|
||||
}
|
||||
if(accountList[i].getAccountType().equals(Account.AccountType.INCOME)){
|
||||
String ID = accountList[i].getAccountID().toString();
|
||||
map.put("interestOnLoanAccountId",ID);
|
||||
map.put("incomeFromFeeAccountId",ID);
|
||||
map.put("incomeFromPenaltyAccountId",ID);
|
||||
if (this.accountList[i].getAccountType().equals(Account.AccountType.INCOME)) {
|
||||
final String ID = this.accountList[i].getAccountID().toString();
|
||||
map.put("interestOnLoanAccountId", ID);
|
||||
map.put("incomeFromFeeAccountId", ID);
|
||||
map.put("incomeFromPenaltyAccountId", ID);
|
||||
}
|
||||
if(accountList[i].getAccountType().equals(Account.AccountType.EXPENSE)){
|
||||
String ID = accountList[i].getAccountID().toString();
|
||||
map.put("writeOffAccountId",ID);
|
||||
if (this.accountList[i].getAccountType().equals(Account.AccountType.EXPENSE)) {
|
||||
final String ID = this.accountList[i].getAccountID().toString();
|
||||
map.put("writeOffAccountId", ID);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-3
@@ -5,9 +5,10 @@ import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class LoanStatusChecker {
|
||||
@@ -32,13 +33,13 @@ public class LoanStatusChecker {
|
||||
assertTrue(getStatus(loanStatusHashMap, "closed"));
|
||||
}
|
||||
|
||||
public static void verifyLoanAccountIsNotActive(final HashMap loanStatusHashMap) {
|
||||
public static void verifyLoanAccountIsNotActive(final HashMap loanStatusHashMap) {
|
||||
assertFalse(getStatus(loanStatusHashMap, "active"));
|
||||
}
|
||||
|
||||
public static HashMap getStatusOfLoan(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer loanID) {
|
||||
String url = "/mifosng-provider/api/v1/loans/" + loanID + "?tenantIdentifier=default";
|
||||
final String url = "/mifosng-provider/api/v1/loans/" + loanID + "?tenantIdentifier=default";
|
||||
return Utils.performServerGet(requestSpec, responseSpec, url, "status");
|
||||
}
|
||||
|
||||
|
||||
+39
-41
@@ -28,58 +28,53 @@ public class LoanTransactionHelper {
|
||||
private static final String MAKE_REPAYMENT_COMMAND = "repayment";
|
||||
private static final String WITHDRAW_LOAN_APPLICATION_COMMAND = "withdrawnByApplicant";
|
||||
|
||||
|
||||
public LoanTransactionHelper(final RequestSpecification requestSpec,final ResponseSpecification responseSpec){
|
||||
this.requestSpec = requestSpec;
|
||||
public LoanTransactionHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
this.requestSpec = requestSpec;
|
||||
this.responseSpec = responseSpec;
|
||||
}
|
||||
|
||||
public Integer getLoanProductId(final String loanProductJSON) {
|
||||
return Utils.performServerPost(requestSpec, responseSpec, CREATE_LOAN_PRODUCT_URL, loanProductJSON, "resourceId");
|
||||
return Utils.performServerPost(this.requestSpec, this.responseSpec, CREATE_LOAN_PRODUCT_URL, loanProductJSON, "resourceId");
|
||||
}
|
||||
|
||||
public Integer getLoanId(final String loanApplicationJSON) {
|
||||
return Utils.performServerPost(requestSpec, responseSpec, APPLY_LOAN_URL, loanApplicationJSON, "loanId");
|
||||
return Utils.performServerPost(this.requestSpec, this.responseSpec, APPLY_LOAN_URL, loanApplicationJSON, "loanId");
|
||||
}
|
||||
|
||||
public ArrayList getLoanRepaymentSchedule(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer loanID) {
|
||||
String URL = "/mifosng-provider/api/v1/loans/" + loanID + "?associations=repaymentSchedule&tenantIdentifier=default";
|
||||
HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "repaymentSchedule");
|
||||
final String URL = "/mifosng-provider/api/v1/loans/" + loanID + "?associations=repaymentSchedule&tenantIdentifier=default";
|
||||
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "repaymentSchedule");
|
||||
return (ArrayList) response.get("periods");
|
||||
}
|
||||
|
||||
public HashMap approveLoan(final String approvalDate, final Integer loanID) {
|
||||
return performLoanTransaction(createLoanOperationURL(APPROVE_LOAN_COMMAND, loanID),
|
||||
getApproveLoanAsJSON(approvalDate));
|
||||
public HashMap approveLoan(final String approvalDate, final Integer loanID) {
|
||||
return performLoanTransaction(createLoanOperationURL(APPROVE_LOAN_COMMAND, loanID), getApproveLoanAsJSON(approvalDate));
|
||||
}
|
||||
|
||||
public HashMap undoApproval(final Integer loanID) {
|
||||
String undoBodyJson = "{'note':'UNDO APPROVAL'}";
|
||||
public HashMap undoApproval(final Integer loanID) {
|
||||
final String undoBodyJson = "{'note':'UNDO APPROVAL'}";
|
||||
return performLoanTransaction(createLoanOperationURL(UNDO_APPROVAL_LOAN_COMMAND, loanID), undoBodyJson);
|
||||
}
|
||||
|
||||
public HashMap disburseLoan(final String date,
|
||||
final Integer loanID) {
|
||||
return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID),
|
||||
getDisburseLoanAsJSON(date));
|
||||
public HashMap disburseLoan(final String date, final Integer loanID) {
|
||||
return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID), getDisburseLoanAsJSON(date));
|
||||
}
|
||||
|
||||
public HashMap undoDisbursal(final Integer loanID){
|
||||
String undoDisburseJson = "{'note' : 'UNDO DISBURSAL'}";
|
||||
public HashMap undoDisbursal(final Integer loanID) {
|
||||
final String undoDisburseJson = "{'note' : 'UNDO DISBURSAL'}";
|
||||
System.out.println("IN DISBURSE LOAN");
|
||||
String url =createLoanOperationURL(UNDO_DISBURSE_LOAN_COMMAND,loanID);
|
||||
final String url = createLoanOperationURL(UNDO_DISBURSE_LOAN_COMMAND, loanID);
|
||||
System.out.println("IN DISBURSE LOAN URL " + url);
|
||||
return performLoanTransaction(createLoanOperationURL(UNDO_DISBURSE_LOAN_COMMAND, loanID), undoDisburseJson);
|
||||
}
|
||||
public HashMap writeOffLoan(final String date,
|
||||
final Integer loanID) {
|
||||
return performLoanTransaction(createLoanTransactionURL(WRITE_OFF_LOAN_COMMAND, loanID),
|
||||
getWriteOffBodyAsJSON(date));
|
||||
|
||||
public HashMap writeOffLoan(final String date, final Integer loanID) {
|
||||
return performLoanTransaction(createLoanTransactionURL(WRITE_OFF_LOAN_COMMAND, loanID), getWriteOffBodyAsJSON(date));
|
||||
}
|
||||
|
||||
public HashMap waiveInterest(final String date, final String amountToBeWaived, final Integer loanID) {
|
||||
return performLoanTransaction(createLoanTransactionURL(WAIVE_INTEREST_COMMAND, loanID),
|
||||
getWaiveBodyAsJSON(date, amountToBeWaived));
|
||||
public HashMap waiveInterest(final String date, final String amountToBeWaived, final Integer loanID) {
|
||||
return performLoanTransaction(createLoanTransactionURL(WAIVE_INTEREST_COMMAND, loanID), getWaiveBodyAsJSON(date, amountToBeWaived));
|
||||
}
|
||||
|
||||
public HashMap makeRepayment(final String date, final Float amountToBePaid, final Integer loanID) {
|
||||
@@ -88,12 +83,12 @@ public class LoanTransactionHelper {
|
||||
}
|
||||
|
||||
public HashMap withdrawLoanApplicationByClient(final String date, final Integer loanID) {
|
||||
return performLoanTransaction(createLoanOperationURL(WITHDRAW_LOAN_APPLICATION_COMMAND,loanID),
|
||||
return performLoanTransaction(createLoanOperationURL(WITHDRAW_LOAN_APPLICATION_COMMAND, loanID),
|
||||
getWithdrawLoanApplicationBodyAsJSON(date));
|
||||
}
|
||||
|
||||
private String getDisburseLoanAsJSON(final String actualDisbursementDate) {
|
||||
HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
map.put("locale", "en");
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("actualDisbursementDate", actualDisbursementDate);
|
||||
@@ -102,7 +97,7 @@ public class LoanTransactionHelper {
|
||||
}
|
||||
|
||||
private String getApproveLoanAsJSON(final String approvalDate) {
|
||||
HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
map.put("locale", "en");
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("approvedOnDate", approvalDate);
|
||||
@@ -111,7 +106,7 @@ public class LoanTransactionHelper {
|
||||
}
|
||||
|
||||
private String getRepaymentBodyAsJSON(final String transactionDate, final Float transactionAmount) {
|
||||
HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
map.put("locale", "en");
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("transactionDate", transactionDate);
|
||||
@@ -121,7 +116,7 @@ public class LoanTransactionHelper {
|
||||
}
|
||||
|
||||
private String getWriteOffBodyAsJSON(final String transactionDate) {
|
||||
HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("locale", "en");
|
||||
map.put("note", " LOAN WRITE OFF!!!");
|
||||
@@ -130,7 +125,7 @@ public class LoanTransactionHelper {
|
||||
}
|
||||
|
||||
private String getWaiveBodyAsJSON(final String transactionDate, final String amountToBeWaived) {
|
||||
HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
map.put("locale", "en");
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("transactionDate", transactionDate);
|
||||
@@ -139,8 +134,8 @@ public class LoanTransactionHelper {
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
private String getWithdrawLoanApplicationBodyAsJSON(final String withdrawDate){
|
||||
HashMap<String, String> map = new HashMap<String, String>();
|
||||
private String getWithdrawLoanApplicationBodyAsJSON(final String withdrawDate) {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
map.put("locale", "en");
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("withdrawnOnDate", withdrawDate);
|
||||
@@ -148,8 +143,9 @@ public class LoanTransactionHelper {
|
||||
return new Gson().toJson(map);
|
||||
|
||||
}
|
||||
|
||||
public String getLoanCalculationBodyAsJSON(final String productID) {
|
||||
HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("locale", "en_GB");
|
||||
map.put("productId", productID);
|
||||
@@ -169,24 +165,26 @@ public class LoanTransactionHelper {
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
private String createLoanOperationURL(final String command, final Integer loanID) {
|
||||
private String createLoanOperationURL(final String command, final Integer loanID) {
|
||||
return "/mifosng-provider/api/v1/loans/" + loanID + "?command=" + command + "&tenantIdentifier=default";
|
||||
}
|
||||
|
||||
private String createLoanTransactionURL(final String command, final Integer loanID) {
|
||||
private String createLoanTransactionURL(final String command, final Integer loanID) {
|
||||
return "/mifosng-provider/api/v1/loans/" + loanID + "/transactions?command=" + command + "&tenantIdentifier=default";
|
||||
}
|
||||
|
||||
private HashMap performLoanTransaction(final String postURLForLoanTransaction, final String jsonToBeSent) {
|
||||
private HashMap performLoanTransaction(final String postURLForLoanTransaction, final String jsonToBeSent) {
|
||||
|
||||
HashMap response = Utils.performServerPost(requestSpec, responseSpec, postURLForLoanTransaction, jsonToBeSent, "changes");
|
||||
final HashMap response = Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForLoanTransaction, jsonToBeSent,
|
||||
"changes");
|
||||
return (HashMap) response.get("status");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void verifyRepaymentScheduleEntryFor(final int repaymentNumber, final float expectedPrincipalOutstanding, final Integer loanID) {
|
||||
System.out.println("---------------------------GETTING LOAN REPAYMENT SCHEDULE--------------------------------");
|
||||
ArrayList<HashMap> repaymentPeriods = getLoanRepaymentSchedule(requestSpec, responseSpec, loanID);
|
||||
assertEquals("Mismatch in Principal Loan Balance Outstanding ", expectedPrincipalOutstanding, repaymentPeriods.get(repaymentNumber).get("principalLoanBalanceOutstanding"));
|
||||
final ArrayList<HashMap> repaymentPeriods = getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID);
|
||||
assertEquals("Mismatch in Principal Loan Balance Outstanding ", expectedPrincipalOutstanding, repaymentPeriods.get(repaymentNumber)
|
||||
.get("principalLoanBalanceOutstanding"));
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -17,19 +17,19 @@ public class XBRLIntegrationTestHelper {
|
||||
private static final String GET_TAXONOMY_LIST_URL = "/mifosng-provider/api/v1/mixtaxonomy?tenantIdentifier=default";
|
||||
private static final String TAXONOMY_MAPPING_URL = "/mifosng-provider/api/v1/mixmapping?tenantIdentifier=default";
|
||||
|
||||
public XBRLIntegrationTestHelper(RequestSpecification requestSpec, ResponseSpecification responseSpec) {
|
||||
public XBRLIntegrationTestHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
this.requestSpec = requestSpec;
|
||||
this.responseSpec = responseSpec;
|
||||
}
|
||||
|
||||
public ArrayList getTaxonomyList() {
|
||||
ArrayList response = Utils.performServerGet(requestSpec, responseSpec, GET_TAXONOMY_LIST_URL, "");
|
||||
final ArrayList response = Utils.performServerGet(this.requestSpec, this.responseSpec, GET_TAXONOMY_LIST_URL, "");
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
public HashMap getTaxonomyMapping() {
|
||||
HashMap response = Utils.performServerGet(requestSpec, responseSpec, TAXONOMY_MAPPING_URL, "config");
|
||||
final HashMap response = Utils.performServerGet(this.requestSpec, this.responseSpec, TAXONOMY_MAPPING_URL, "config");
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -76,7 +76,7 @@ public class GLClosuresApiResource {
|
||||
|
||||
this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermission);
|
||||
final List<GLClosureData> glClosureDatas = this.glClosureReadPlatformService.retrieveAllGLClosures(officeId);
|
||||
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.apiJsonSerializerService.serialize(settings, glClosureDatas, RESPONSE_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
+7
-6
@@ -50,20 +50,21 @@ public class AccountingDropdownReadPlatformServiceImpl implements AccountingDrop
|
||||
|
||||
@Override
|
||||
public Map<String, List<GLAccountData>> retrieveAccountMappingOptionsForLoanProducts() {
|
||||
Map<String, List<GLAccountData>> accountOptions = new HashMap<String, List<GLAccountData>>();
|
||||
List<GLAccountData> assetAccountOptions = accountReadPlatformService.retrieveAllEnabledDetailGLAccounts(GLAccountType.ASSET);
|
||||
final Map<String, List<GLAccountData>> accountOptions = new HashMap<String, List<GLAccountData>>();
|
||||
List<GLAccountData> assetAccountOptions = this.accountReadPlatformService.retrieveAllEnabledDetailGLAccounts(GLAccountType.ASSET);
|
||||
if (assetAccountOptions.isEmpty()) {
|
||||
assetAccountOptions = null;
|
||||
}
|
||||
accountOptions.put("assetAccountOptions", assetAccountOptions);
|
||||
|
||||
List<GLAccountData> incomeAccountOptions = accountReadPlatformService.retrieveAllEnabledDetailGLAccounts(GLAccountType.INCOME);
|
||||
List<GLAccountData> incomeAccountOptions = this.accountReadPlatformService.retrieveAllEnabledDetailGLAccounts(GLAccountType.INCOME);
|
||||
if (incomeAccountOptions.isEmpty()) {
|
||||
incomeAccountOptions = null;
|
||||
}
|
||||
accountOptions.put("incomeAccountOptions", incomeAccountOptions);
|
||||
|
||||
List<GLAccountData> expenseAccountOptions = accountReadPlatformService.retrieveAllEnabledDetailGLAccounts(GLAccountType.EXPENSE);
|
||||
List<GLAccountData> expenseAccountOptions = this.accountReadPlatformService
|
||||
.retrieveAllEnabledDetailGLAccounts(GLAccountType.EXPENSE);
|
||||
if (expenseAccountOptions.isEmpty()) {
|
||||
expenseAccountOptions = null;
|
||||
}
|
||||
@@ -73,8 +74,8 @@ public class AccountingDropdownReadPlatformServiceImpl implements AccountingDrop
|
||||
|
||||
@Override
|
||||
public Map<String, List<GLAccountData>> retrieveAccountMappingOptionsForSavingsProducts() {
|
||||
Map<String, List<GLAccountData>> accountOptions = retrieveAccountMappingOptionsForLoanProducts();
|
||||
List<GLAccountData> liabilityAccountOptions = accountReadPlatformService
|
||||
final Map<String, List<GLAccountData>> accountOptions = retrieveAccountMappingOptionsForLoanProducts();
|
||||
List<GLAccountData> liabilityAccountOptions = this.accountReadPlatformService
|
||||
.retrieveAllEnabledDetailGLAccounts(GLAccountType.LIABILITY);
|
||||
if (liabilityAccountOptions.isEmpty()) {
|
||||
liabilityAccountOptions = null;
|
||||
|
||||
+1
-1
@@ -85,7 +85,7 @@ public class AccountingEnumerations {
|
||||
}
|
||||
|
||||
public static EnumOptionData accountingRuleType(final AccountingRuleType type) {
|
||||
EnumOptionData optionData = new EnumOptionData(type.getValue().longValue(), type.getCode(), type.toString());
|
||||
final EnumOptionData optionData = new EnumOptionData(type.getValue().longValue(), type.getCode(), type.toString());
|
||||
return optionData;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -19,13 +19,13 @@ public enum AccountingRuleType {
|
||||
|
||||
private static final Map<Integer, AccountingRuleType> intToEnumMap = new HashMap<Integer, AccountingRuleType>();
|
||||
static {
|
||||
for (AccountingRuleType type : AccountingRuleType.values()) {
|
||||
for (final AccountingRuleType type : AccountingRuleType.values()) {
|
||||
intToEnumMap.put(type.value, type);
|
||||
}
|
||||
}
|
||||
|
||||
public static AccountingRuleType fromInt(final Integer ruleTypeValue) {
|
||||
AccountingRuleType type = intToEnumMap.get(ruleTypeValue);
|
||||
final AccountingRuleType type = intToEnumMap.get(ruleTypeValue);
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
+5
-3
@@ -71,8 +71,9 @@ public class GLAccountCommand {
|
||||
|
||||
baseDataValidator.reset().parameter(GLAccountJsonInputParams.MANUAL_ENTRIES_ALLOWED.getValue()).value(this.manualEntriesAllowed)
|
||||
.notBlank();
|
||||
|
||||
baseDataValidator.reset().parameter(GLAccountJsonInputParams.TAGID.getValue()).value(this.tagId).ignoreIfNull().longGreaterThanZero();
|
||||
|
||||
baseDataValidator.reset().parameter(GLAccountJsonInputParams.TAGID.getValue()).value(this.tagId).ignoreIfNull()
|
||||
.longGreaterThanZero();
|
||||
|
||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist",
|
||||
"Validation errors exist.", dataValidationErrors); }
|
||||
@@ -106,7 +107,8 @@ public class GLAccountCommand {
|
||||
|
||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist",
|
||||
"Validation errors exist.", dataValidationErrors); }
|
||||
baseDataValidator.reset().parameter(GLAccountJsonInputParams.TAGID.getValue()).value(this.tagId).ignoreIfNull().longGreaterThanZero();
|
||||
baseDataValidator.reset().parameter(GLAccountJsonInputParams.TAGID.getValue()).value(this.tagId).ignoreIfNull()
|
||||
.longGreaterThanZero();
|
||||
}
|
||||
|
||||
public boolean isHeaderAccount() {
|
||||
|
||||
+6
-6
@@ -83,7 +83,7 @@ public class GLAccount extends AbstractPersistable<Long> {
|
||||
this.tagId = tagId;
|
||||
}
|
||||
|
||||
public static GLAccount fromJson(final GLAccount parent, final JsonCommand command, CodeValue glAccountTagType) {
|
||||
public static GLAccount fromJson(final GLAccount parent, final JsonCommand command, final CodeValue glAccountTagType) {
|
||||
final String name = command.stringValueOfParameterNamed(GLAccountJsonInputParams.NAME.getValue());
|
||||
final String glCode = command.stringValueOfParameterNamed(GLAccountJsonInputParams.GL_CODE.getValue());
|
||||
final boolean disabled = command.booleanPrimitiveValueOfParameterNamed(GLAccountJsonInputParams.DISABLED.getValue());
|
||||
@@ -211,8 +211,8 @@ public class GLAccount extends AbstractPersistable<Long> {
|
||||
|
||||
public void generateHierarchy() {
|
||||
|
||||
if (parent != null) {
|
||||
this.hierarchy = this.parent.hierarchyOf(this.getId());
|
||||
if (this.parent != null) {
|
||||
this.hierarchy = this.parent.hierarchyOf(getId());
|
||||
} else {
|
||||
this.hierarchy = ".";
|
||||
}
|
||||
@@ -226,12 +226,12 @@ public class GLAccount extends AbstractPersistable<Long> {
|
||||
return GLAccountUsage.DETAIL.getValue().equals(this.usage);
|
||||
}
|
||||
|
||||
public void updateTagId(CodeValue tagID) {
|
||||
public void updateTagId(final CodeValue tagID) {
|
||||
this.tagId = tagID;
|
||||
}
|
||||
|
||||
public void updateParentAccount(GLAccount parentAccount) {
|
||||
public void updateParentAccount(final GLAccount parentAccount) {
|
||||
this.parent = parentAccount;
|
||||
this.generateHierarchy();
|
||||
generateHierarchy();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -58,7 +58,7 @@ public final class GLAccountCommandFromApiJsonDeserializer extends AbstractFromA
|
||||
final Integer usage = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(GLAccountJsonInputParams.USAGE.getValue(), element);
|
||||
final String description = this.fromApiJsonHelper.extractStringNamed(GLAccountJsonInputParams.DESCRIPTION.getValue(), element);
|
||||
final Long tagId = this.fromApiJsonHelper.extractLongNamed(GLAccountJsonInputParams.TAGID.getValue(), element);
|
||||
|
||||
|
||||
return new GLAccountCommand(id, name, parentId, glCode, disabled, manualEntriesAllowed, type, usage, description, tagId);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -75,7 +75,7 @@ public class GLAccountWritePlatformServiceJpaRepositoryImpl implements GLAccount
|
||||
CodeValue glAccountTagType = null;
|
||||
final Long tagId = command.longValueOfParameterNamed(GLAccountJsonInputParams.TAGID.getValue());
|
||||
final Long type = command.longValueOfParameterNamed(GLAccountJsonInputParams.TYPE.getValue());
|
||||
GLAccountType accountType = GLAccountType.fromInt(type.intValue());
|
||||
final GLAccountType accountType = GLAccountType.fromInt(type.intValue());
|
||||
|
||||
if (tagId != null) {
|
||||
glAccountTagType = retrieveTagId(tagId, accountType);
|
||||
@@ -113,7 +113,7 @@ public class GLAccountWritePlatformServiceJpaRepositoryImpl implements GLAccount
|
||||
|
||||
// is the new parent valid
|
||||
if (changesOnly.containsKey(GLAccountJsonInputParams.PARENT_ID.getValue())) {
|
||||
GLAccount parentAccount = validateParentGLAccount(parentId);
|
||||
final GLAccount parentAccount = validateParentGLAccount(parentId);
|
||||
glAccount.updateParentAccount(parentAccount);
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ public class GLAccountWritePlatformServiceJpaRepositoryImpl implements GLAccount
|
||||
"Unknown data integrity issue with resource GL Account: " + realCause.getMessage());
|
||||
}
|
||||
|
||||
private CodeValue retrieveTagId(Long tagId, GLAccountType accountType) {
|
||||
private CodeValue retrieveTagId(final Long tagId, final GLAccountType accountType) {
|
||||
CodeValue glAccountTagType = null;
|
||||
if (accountType.isAssetType()) {
|
||||
glAccountTagType = this.codeValueRepositoryWrapper.findOneByCodeNameAndIdWithNotFoundDetection(
|
||||
|
||||
+3
-3
@@ -26,9 +26,9 @@ public class DateParam {
|
||||
this.dateAsString = dateStr;
|
||||
}
|
||||
|
||||
public Date getDate(String parameterName,String dateFormat, String localeAsString) {
|
||||
Locale locale = JsonParserHelper.localeFromString(localeAsString);
|
||||
LocalDate localDate = JsonParserHelper.convertFrom(dateAsString, parameterName, dateFormat, locale);
|
||||
public Date getDate(final String parameterName, final String dateFormat, final String localeAsString) {
|
||||
final Locale locale = JsonParserHelper.localeFromString(localeAsString);
|
||||
final LocalDate localDate = JsonParserHelper.convertFrom(this.dateAsString, parameterName, dateFormat, locale);
|
||||
return localDate.toDate();
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -94,9 +94,9 @@ public class JournalEntriesApiResource {
|
||||
|
||||
final SearchParameters searchParameters = SearchParameters.forJournalEntries(officeId, offset, limit, orderBy, sortOrder);
|
||||
|
||||
Page<JournalEntryData> glJournalEntries = this.journalEntryReadPlatformService.retrieveAll(searchParameters, glAccountId,
|
||||
final Page<JournalEntryData> glJournalEntries = this.journalEntryReadPlatformService.retrieveAll(searchParameters, glAccountId,
|
||||
onlyManualEntries, fromDate, toDate, transactionId);
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.apiJsonSerializerService.serialize(settings, glJournalEntries, RESPONSE_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ public class ChargePaymentDTO {
|
||||
private final BigDecimal amount;
|
||||
private final Long loanChargeId;
|
||||
|
||||
public ChargePaymentDTO(Long chargeId, Long loanChargeId, BigDecimal amount) {
|
||||
public ChargePaymentDTO(final Long chargeId, final Long loanChargeId, final BigDecimal amount) {
|
||||
this.chargeId = chargeId;
|
||||
this.amount = amount;
|
||||
this.loanChargeId = loanChargeId;
|
||||
|
||||
+2
-1
@@ -63,7 +63,8 @@ public class JournalEntryData {
|
||||
final Long glAccountId, final String glAccountCode, final EnumOptionData glAccountClassification,
|
||||
final LocalDate transactionDate, final EnumOptionData entryType, final BigDecimal amount, final String transactionId,
|
||||
final Boolean manualEntry, final EnumOptionData entityType, final Long entityId, final Long createdByUserId,
|
||||
final LocalDate createdDate, final String createdByUserName, final String comments, final Boolean reversed, final String referenceNumber) {
|
||||
final LocalDate createdDate, final String createdByUserName, final String comments, final Boolean reversed,
|
||||
final String referenceNumber) {
|
||||
this.id = id;
|
||||
this.officeId = officeId;
|
||||
this.officeName = officeName;
|
||||
|
||||
+1
-1
@@ -82,7 +82,7 @@ public class LoanDTO {
|
||||
return this.currencyCode;
|
||||
}
|
||||
|
||||
public void setCurrencyCode(String currencyCode) {
|
||||
public void setCurrencyCode(final String currencyCode) {
|
||||
this.currencyCode = currencyCode;
|
||||
}
|
||||
|
||||
|
||||
+7
-7
@@ -33,7 +33,7 @@ public class SavingsDTO {
|
||||
return this.savingsId;
|
||||
}
|
||||
|
||||
public void setSavingsId(Long savingsId) {
|
||||
public void setSavingsId(final Long savingsId) {
|
||||
this.savingsId = savingsId;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class SavingsDTO {
|
||||
return this.savingsProductId;
|
||||
}
|
||||
|
||||
public void setSavingsProductId(Long savingsProductId) {
|
||||
public void setSavingsProductId(final Long savingsProductId) {
|
||||
this.savingsProductId = savingsProductId;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class SavingsDTO {
|
||||
return this.officeId;
|
||||
}
|
||||
|
||||
public void setOfficeId(Long officeId) {
|
||||
public void setOfficeId(final Long officeId) {
|
||||
this.officeId = officeId;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class SavingsDTO {
|
||||
return this.cashBasedAccountingEnabled;
|
||||
}
|
||||
|
||||
public void setCashBasedAccountingEnabled(boolean cashBasedAccountingEnabled) {
|
||||
public void setCashBasedAccountingEnabled(final boolean cashBasedAccountingEnabled) {
|
||||
this.cashBasedAccountingEnabled = cashBasedAccountingEnabled;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ public class SavingsDTO {
|
||||
return this.accrualBasedAccountingEnabled;
|
||||
}
|
||||
|
||||
public void setAccrualBasedAccountingEnabled(boolean accrualBasedAccountingEnabled) {
|
||||
public void setAccrualBasedAccountingEnabled(final boolean accrualBasedAccountingEnabled) {
|
||||
this.accrualBasedAccountingEnabled = accrualBasedAccountingEnabled;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class SavingsDTO {
|
||||
return this.newSavingsTransactions;
|
||||
}
|
||||
|
||||
public void setNewSavingsTransactions(List<SavingsTransactionDTO> newSavingsTransactions) {
|
||||
public void setNewSavingsTransactions(final List<SavingsTransactionDTO> newSavingsTransactions) {
|
||||
this.newSavingsTransactions = newSavingsTransactions;
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class SavingsDTO {
|
||||
return this.currencyCode;
|
||||
}
|
||||
|
||||
public void setCurrencyCode(String currencyCode) {
|
||||
public void setCurrencyCode(final String currencyCode) {
|
||||
this.currencyCode = currencyCode;
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -16,8 +16,7 @@ public class JournalEntryInvalidException extends AbstractPlatformDomainRuleExce
|
||||
|
||||
/*** enum of reasons for invalid Journal Entry **/
|
||||
public static enum GL_JOURNAL_ENTRY_INVALID_REASON {
|
||||
FUTURE_DATE, ACCOUNTING_CLOSED, NO_DEBITS_OR_CREDITS, DEBIT_CREDIT_SUM_MISMATCH_WITH_AMOUNT, DEBIT_CREDIT_SUM_MISMATCH, DEBIT_CREDIT_ACCOUNT_OR_AMOUNT_EMPTY, GL_ACCOUNT_DISABLED, GL_ACCOUNT_MANUAL_ENTRIES_NOT_PERMITTED,
|
||||
INVALID_DEBIT_OR_CREDIT_ACCOUNTS;
|
||||
FUTURE_DATE, ACCOUNTING_CLOSED, NO_DEBITS_OR_CREDITS, DEBIT_CREDIT_SUM_MISMATCH_WITH_AMOUNT, DEBIT_CREDIT_SUM_MISMATCH, DEBIT_CREDIT_ACCOUNT_OR_AMOUNT_EMPTY, GL_ACCOUNT_DISABLED, GL_ACCOUNT_MANUAL_ENTRIES_NOT_PERMITTED, INVALID_DEBIT_OR_CREDIT_ACCOUNTS;
|
||||
|
||||
public String errorMessage() {
|
||||
if (name().toString().equalsIgnoreCase("FUTURE_DATE")) {
|
||||
|
||||
+5
-5
@@ -13,10 +13,10 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class AccountingProcessorForLoanFactory {
|
||||
|
||||
private ApplicationContext applicationContext;
|
||||
private final ApplicationContext applicationContext;
|
||||
|
||||
@Autowired
|
||||
public AccountingProcessorForLoanFactory(ApplicationContext applicationContext) {
|
||||
public AccountingProcessorForLoanFactory(final ApplicationContext applicationContext) {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
@@ -25,12 +25,12 @@ public class AccountingProcessorForLoanFactory {
|
||||
AccountingProcessorForLoan accountingProcessorForLoan = null;
|
||||
|
||||
if (loanDTO.isCashBasedAccountingEnabled()) {
|
||||
accountingProcessorForLoan = applicationContext
|
||||
.getBean("cashBasedAccountingProcessorForLoan", AccountingProcessorForLoan.class);
|
||||
accountingProcessorForLoan = this.applicationContext.getBean("cashBasedAccountingProcessorForLoan",
|
||||
AccountingProcessorForLoan.class);
|
||||
}
|
||||
|
||||
else if (loanDTO.isAccrualBasedAccountingEnabled()) {
|
||||
accountingProcessorForLoan = applicationContext.getBean("accrualBasedAccountingProcessorForLoan",
|
||||
accountingProcessorForLoan = this.applicationContext.getBean("accrualBasedAccountingProcessorForLoan",
|
||||
AccountingProcessorForLoan.class);
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -13,10 +13,10 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class AccountingProcessorForSavingsFactory {
|
||||
|
||||
private ApplicationContext applicationContext;
|
||||
private final ApplicationContext applicationContext;
|
||||
|
||||
@Autowired
|
||||
public AccountingProcessorForSavingsFactory(ApplicationContext applicationContext) {
|
||||
public AccountingProcessorForSavingsFactory(final ApplicationContext applicationContext) {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class AccountingProcessorForSavingsFactory {
|
||||
AccountingProcessorForSavings accountingProcessorForSavings = null;
|
||||
|
||||
if (savingsDTO.isCashBasedAccountingEnabled()) {
|
||||
accountingProcessorForSavings = applicationContext.getBean("cashBasedAccountingProcessorForSavings",
|
||||
accountingProcessorForSavings = this.applicationContext.getBean("cashBasedAccountingProcessorForSavings",
|
||||
AccountingProcessorForSavings.class);
|
||||
}
|
||||
|
||||
|
||||
+26
-26
@@ -84,8 +84,8 @@ public class AccountingProcessorHelper {
|
||||
final boolean reversed = (Boolean) map.get("reversed");
|
||||
final Long paymentTypeId = (Long) map.get("paymentTypeId");
|
||||
|
||||
List<ChargePaymentDTO> feePayments = new ArrayList<ChargePaymentDTO>();
|
||||
List<ChargePaymentDTO> penaltyPayments = new ArrayList<ChargePaymentDTO>();
|
||||
final List<ChargePaymentDTO> feePayments = new ArrayList<ChargePaymentDTO>();
|
||||
final List<ChargePaymentDTO> penaltyPayments = new ArrayList<ChargePaymentDTO>();
|
||||
// extract charge payment details (if exists)
|
||||
if (map.containsKey("loanChargesPaid")) {
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -95,7 +95,7 @@ public class AccountingProcessorHelper {
|
||||
final Long loanChargeId = (Long) loanChargePaid.get("chargeId");
|
||||
final boolean isPenalty = (Boolean) loanChargePaid.get("isPenalty");
|
||||
final BigDecimal chargeAmountPaid = (BigDecimal) loanChargePaid.get("amount");
|
||||
ChargePaymentDTO chargePaymentDTO = new ChargePaymentDTO(chargeId, loanChargeId, chargeAmountPaid);
|
||||
final ChargePaymentDTO chargePaymentDTO = new ChargePaymentDTO(chargeId, loanChargeId, chargeAmountPaid);
|
||||
if (isPenalty) {
|
||||
penaltyPayments.add(chargePaymentDTO);
|
||||
} else {
|
||||
@@ -254,7 +254,7 @@ public class AccountingProcessorHelper {
|
||||
public void createCreditJournalEntryOrReversalForLoan(final Office office, final String currencyCode,
|
||||
final CASH_ACCOUNTS_FOR_LOAN accountMappingType, final Long loanProductId, final Long paymentTypeId, final Long loanId,
|
||||
final String transactionId, final Date transactionDate, final BigDecimal amount, final Boolean isReversal) {
|
||||
int accountMappingTypeId = accountMappingType.getValue();
|
||||
final int accountMappingTypeId = accountMappingType.getValue();
|
||||
createCreditJournalEntryOrReversalForLoan(office, currencyCode, accountMappingTypeId, loanProductId, paymentTypeId, loanId,
|
||||
transactionId, transactionDate, amount, isReversal);
|
||||
}
|
||||
@@ -262,7 +262,7 @@ public class AccountingProcessorHelper {
|
||||
public void createCreditJournalEntryOrReversalForLoan(final Office office, final String currencyCode,
|
||||
final ACCRUAL_ACCOUNTS_FOR_LOAN accountMappingType, final Long loanProductId, final Long paymentTypeId, final Long loanId,
|
||||
final String transactionId, final Date transactionDate, final BigDecimal amount, final Boolean isReversal) {
|
||||
int accountMappingTypeId = accountMappingType.getValue();
|
||||
final int accountMappingTypeId = accountMappingType.getValue();
|
||||
createCreditJournalEntryOrReversalForLoan(office, currencyCode, accountMappingTypeId, loanProductId, paymentTypeId, loanId,
|
||||
transactionId, transactionDate, amount, isReversal);
|
||||
}
|
||||
@@ -270,7 +270,7 @@ public class AccountingProcessorHelper {
|
||||
public void createDebitJournalEntryOrReversalForLoan(final Office office, final String currencyCode,
|
||||
final CASH_ACCOUNTS_FOR_LOAN accountMappingType, final Long loanProductId, final Long paymentTypeId, final Long loanId,
|
||||
final String transactionId, final Date transactionDate, final BigDecimal amount, final Boolean isReversal) {
|
||||
int accountMappingTypeId = accountMappingType.getValue();
|
||||
final int accountMappingTypeId = accountMappingType.getValue();
|
||||
createDebitJournalEntryOrReversalForLoan(office, currencyCode, accountMappingTypeId, loanProductId, paymentTypeId, loanId,
|
||||
transactionId, transactionDate, amount, isReversal);
|
||||
}
|
||||
@@ -278,7 +278,7 @@ public class AccountingProcessorHelper {
|
||||
public void createDebitJournalEntryOrReversalForLoan(final Office office, final String currencyCode,
|
||||
final ACCRUAL_ACCOUNTS_FOR_LOAN accountMappingType, final Long loanProductId, final Long paymentTypeId, final Long loanId,
|
||||
final String transactionId, final Date transactionDate, final BigDecimal amount, final Boolean isReversal) {
|
||||
int accountMappingTypeId = accountMappingType.getValue();
|
||||
final int accountMappingTypeId = accountMappingType.getValue();
|
||||
createDebitJournalEntryOrReversalForLoan(office, currencyCode, accountMappingTypeId, loanProductId, paymentTypeId, loanId,
|
||||
transactionId, transactionDate, amount, isReversal);
|
||||
}
|
||||
@@ -298,19 +298,19 @@ public class AccountingProcessorHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public GLClosure getLatestClosureByBranch(long officeId) {
|
||||
public GLClosure getLatestClosureByBranch(final long officeId) {
|
||||
return this.closureRepository.getLatestGLClosureByBranch(officeId);
|
||||
}
|
||||
|
||||
public Office getOfficeById(long officeId) {
|
||||
public Office getOfficeById(final long officeId) {
|
||||
return this.officeRepository.findOne(officeId);
|
||||
}
|
||||
|
||||
private void createJournalEntriesForLoan(final Office office, final String currencyCode, final int accountTypeToDebitId,
|
||||
final int accountTypeToCreditId, final Long loanProductId, final Long paymentTypeId, final Long loanId,
|
||||
final String transactionId, final Date transactionDate, final BigDecimal amount) {
|
||||
GLAccount debitAccount = getLinkedGLAccountForLoanProduct(loanProductId, accountTypeToDebitId, paymentTypeId);
|
||||
GLAccount creditAccount = getLinkedGLAccountForLoanProduct(loanProductId, accountTypeToCreditId, paymentTypeId);
|
||||
final GLAccount debitAccount = getLinkedGLAccountForLoanProduct(loanProductId, accountTypeToDebitId, paymentTypeId);
|
||||
final GLAccount creditAccount = getLinkedGLAccountForLoanProduct(loanProductId, accountTypeToCreditId, paymentTypeId);
|
||||
createDebitJournalEntryForLoan(office, currencyCode, debitAccount, loanId, transactionId, transactionDate, amount);
|
||||
createCreditJournalEntryForLoan(office, currencyCode, creditAccount, loanId, transactionId, transactionDate, amount);
|
||||
}
|
||||
@@ -318,8 +318,8 @@ public class AccountingProcessorHelper {
|
||||
private void createJournalEntriesForSavings(final Office office, final String currencyCode, final int accountTypeToDebitId,
|
||||
final int accountTypeToCreditId, final Long savingsProductId, final Long paymentTypeId, final Long savingsId,
|
||||
final String transactionId, final Date transactionDate, final BigDecimal amount) {
|
||||
GLAccount debitAccount = getLinkedGLAccountForSavingsProduct(savingsProductId, accountTypeToDebitId, paymentTypeId);
|
||||
GLAccount creditAccount = getLinkedGLAccountForSavingsProduct(savingsProductId, accountTypeToCreditId, paymentTypeId);
|
||||
final GLAccount debitAccount = getLinkedGLAccountForSavingsProduct(savingsProductId, accountTypeToDebitId, paymentTypeId);
|
||||
final GLAccount creditAccount = getLinkedGLAccountForSavingsProduct(savingsProductId, accountTypeToCreditId, paymentTypeId);
|
||||
createDebitJournalEntryForSavings(office, currencyCode, debitAccount, savingsId, transactionId, transactionDate, amount);
|
||||
createCreditJournalEntryForSavings(office, currencyCode, creditAccount, savingsId, transactionId, transactionDate, amount);
|
||||
}
|
||||
@@ -327,7 +327,7 @@ public class AccountingProcessorHelper {
|
||||
private void createDebitJournalEntryOrReversalForLoan(final Office office, final String currencyCode, final int accountMappingTypeId,
|
||||
final Long loanProductId, final Long paymentTypeId, final Long loanId, final String transactionId, final Date transactionDate,
|
||||
final BigDecimal amount, final Boolean isReversal) {
|
||||
GLAccount account = getLinkedGLAccountForLoanProduct(loanProductId, accountMappingTypeId, paymentTypeId);
|
||||
final GLAccount account = getLinkedGLAccountForLoanProduct(loanProductId, accountMappingTypeId, paymentTypeId);
|
||||
if (isReversal) {
|
||||
createCreditJournalEntryForLoan(office, currencyCode, account, loanId, transactionId, transactionDate, amount);
|
||||
} else {
|
||||
@@ -343,25 +343,25 @@ public class AccountingProcessorHelper {
|
||||
* Map to track each account and the net credit to be made for a
|
||||
* particular account
|
||||
***/
|
||||
Map<GLAccount, BigDecimal> creditDetailsMap = new LinkedHashMap<GLAccount, BigDecimal>();
|
||||
for (ChargePaymentDTO chargePaymentDTO : chargePaymentDTOs) {
|
||||
Long chargeId = chargePaymentDTO.getChargeId();
|
||||
GLAccount chargeSpecificAccount = getLinkedGLAccountForLoanCharges(loanProductId, accountMappingTypeId, chargeId);
|
||||
final Map<GLAccount, BigDecimal> creditDetailsMap = new LinkedHashMap<GLAccount, BigDecimal>();
|
||||
for (final ChargePaymentDTO chargePaymentDTO : chargePaymentDTOs) {
|
||||
final Long chargeId = chargePaymentDTO.getChargeId();
|
||||
final GLAccount chargeSpecificAccount = getLinkedGLAccountForLoanCharges(loanProductId, accountMappingTypeId, chargeId);
|
||||
BigDecimal chargeSpecificAmount = chargePaymentDTO.getAmount();
|
||||
|
||||
// adjust net credit amount if the account is already present in the
|
||||
// map
|
||||
if (creditDetailsMap.containsKey(chargeSpecificAccount)) {
|
||||
BigDecimal existingAmount = creditDetailsMap.get(chargeSpecificAccount);
|
||||
final BigDecimal existingAmount = creditDetailsMap.get(chargeSpecificAccount);
|
||||
chargeSpecificAmount = chargeSpecificAmount.add(existingAmount);
|
||||
}
|
||||
creditDetailsMap.put(chargeSpecificAccount, chargeSpecificAmount);
|
||||
}
|
||||
|
||||
BigDecimal totalCreditedAmount = BigDecimal.ZERO;
|
||||
for (Map.Entry<GLAccount, BigDecimal> entry : creditDetailsMap.entrySet()) {
|
||||
GLAccount account = entry.getKey();
|
||||
BigDecimal amount = entry.getValue();
|
||||
for (final Map.Entry<GLAccount, BigDecimal> entry : creditDetailsMap.entrySet()) {
|
||||
final GLAccount account = entry.getKey();
|
||||
final BigDecimal amount = entry.getValue();
|
||||
totalCreditedAmount = totalCreditedAmount.add(amount);
|
||||
if (isReversal) {
|
||||
createDebitJournalEntryForLoan(office, currencyCode, account, loanId, transactionId, transactionDate, amount);
|
||||
@@ -381,7 +381,7 @@ public class AccountingProcessorHelper {
|
||||
private void createCreditJournalEntryOrReversalForLoan(final Office office, final String currencyCode, final int accountMappingTypeId,
|
||||
final Long loanProductId, final Long paymentTypeId, final Long loanId, final String transactionId, final Date transactionDate,
|
||||
final BigDecimal amount, final Boolean isReversal) {
|
||||
GLAccount account = getLinkedGLAccountForLoanProduct(loanProductId, accountMappingTypeId, paymentTypeId);
|
||||
final GLAccount account = getLinkedGLAccountForLoanProduct(loanProductId, accountMappingTypeId, paymentTypeId);
|
||||
if (isReversal) {
|
||||
createDebitJournalEntryForLoan(office, currencyCode, account, loanId, transactionId, transactionDate, amount);
|
||||
} else {
|
||||
@@ -430,7 +430,7 @@ public class AccountingProcessorHelper {
|
||||
* both cash and accrual accounts
|
||||
***/
|
||||
if (accountMappingTypeId == CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue()) {
|
||||
ProductToGLAccountMapping paymentChannelSpecificAccountMapping = this.accountMappingRepository
|
||||
final ProductToGLAccountMapping paymentChannelSpecificAccountMapping = this.accountMappingRepository
|
||||
.findByProductIdAndProductTypeAndFinancialAccountTypeAndPaymentTypeId(loanProductId,
|
||||
PortfolioProductType.LOAN.getValue(), accountMappingTypeId, paymentTypeId);
|
||||
if (paymentChannelSpecificAccountMapping != null) {
|
||||
@@ -454,7 +454,7 @@ public class AccountingProcessorHelper {
|
||||
// Vishwas TODO: remove this condition as it should always be true
|
||||
if (accountMappingTypeId == CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_FEES.getValue()
|
||||
|| accountMappingTypeId == CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_PENALTIES.getValue()) {
|
||||
ProductToGLAccountMapping chargeSpecificIncomeAccountMapping = this.accountMappingRepository
|
||||
final ProductToGLAccountMapping chargeSpecificIncomeAccountMapping = this.accountMappingRepository
|
||||
.findByProductIdAndProductTypeAndFinancialAccountTypeAndChargeId(loanProductId, PortfolioProductType.LOAN.getValue(),
|
||||
accountMappingTypeId, chargeId);
|
||||
if (chargeSpecificIncomeAccountMapping != null) {
|
||||
@@ -474,7 +474,7 @@ public class AccountingProcessorHelper {
|
||||
* both cash and accrual accounts
|
||||
***/
|
||||
if (accountMappingTypeId == CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue()) {
|
||||
ProductToGLAccountMapping paymentChannelSpecificAccountMapping = this.accountMappingRepository
|
||||
final ProductToGLAccountMapping paymentChannelSpecificAccountMapping = this.accountMappingRepository
|
||||
.findByProductIdAndProductTypeAndFinancialAccountTypeAndPaymentTypeId(savingsProductId,
|
||||
PortfolioProductType.SAVING.getValue(), accountMappingTypeId, paymentTypeId);
|
||||
if (paymentChannelSpecificAccountMapping != null) {
|
||||
|
||||
+19
-18
@@ -32,7 +32,7 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
||||
final Office office = this.helper.getOfficeById(loanDTO.getOfficeId());
|
||||
for (final LoanTransactionDTO loanTransactionDTO : loanDTO.getNewLoanTransactions()) {
|
||||
final Date transactionDate = loanTransactionDTO.getTransactionDate();
|
||||
helper.checkForBranchClosures(latestGLClosure, transactionDate);
|
||||
this.helper.checkForBranchClosures(latestGLClosure, transactionDate);
|
||||
|
||||
/** Handle Disbursements **/
|
||||
if (loanTransactionDTO.getTransactionType().isDisbursement()) {
|
||||
@@ -54,7 +54,8 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
||||
* Repayments and Repayments at disbursement
|
||||
***/
|
||||
else if (loanTransactionDTO.getTransactionType().isRepayment()
|
||||
|| loanTransactionDTO.getTransactionType().isRepaymentAtDisbursement() || loanTransactionDTO.getTransactionType().isChargePayment()) {
|
||||
|| loanTransactionDTO.getTransactionType().isRepaymentAtDisbursement()
|
||||
|| loanTransactionDTO.getTransactionType().isChargePayment()) {
|
||||
createJournalEntriesForRepaymentsAndWriteOffs(loanDTO, loanTransactionDTO, office, false, loanTransactionDTO
|
||||
.getTransactionType().isRepaymentAtDisbursement() || loanTransactionDTO.getTransactionType().isChargePayment());
|
||||
}
|
||||
@@ -91,7 +92,7 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
||||
|
||||
// create journal entries for the disbursement (or disbursement
|
||||
// reversal)
|
||||
helper.createAccrualBasedJournalEntriesAndReversalsForLoan(office, currencyCode, ACCRUAL_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO,
|
||||
this.helper.createAccrualBasedJournalEntriesAndReversalsForLoan(office, currencyCode, ACCRUAL_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO,
|
||||
ACCRUAL_ACCOUNTS_FOR_LOAN.FUND_SOURCE, loanProductId, paymentTypeId, loanId, transactionId, transactionDate,
|
||||
disbursalAmount, isReversed);
|
||||
|
||||
@@ -122,9 +123,9 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
||||
|
||||
// create journal entries for recognising interest (or reversal)
|
||||
if (amount != null && !(amount.compareTo(BigDecimal.ZERO) == 0)) {
|
||||
helper.createAccrualBasedJournalEntriesAndReversalsForLoan(office, currencyCode, ACCRUAL_ACCOUNTS_FOR_LOAN.INTEREST_RECEIVABLE,
|
||||
ACCRUAL_ACCOUNTS_FOR_LOAN.INTEREST_ON_LOANS, loanProductId, paymentTypeId, loanId, transactionId, transactionDate,
|
||||
amount, isReversed);
|
||||
this.helper.createAccrualBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
|
||||
ACCRUAL_ACCOUNTS_FOR_LOAN.INTEREST_RECEIVABLE, ACCRUAL_ACCOUNTS_FOR_LOAN.INTEREST_ON_LOANS, loanProductId,
|
||||
paymentTypeId, loanId, transactionId, transactionDate, amount, isReversed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,14 +192,14 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
||||
// handle principal payment or writeOff (and reversals)
|
||||
if (principalAmount != null && !(principalAmount.compareTo(BigDecimal.ZERO) == 0)) {
|
||||
totalDebitAmount = totalDebitAmount.add(principalAmount);
|
||||
helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, ACCRUAL_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO, loanProductId,
|
||||
paymentTypeId, loanId, transactionId, transactionDate, principalAmount, isReversal);
|
||||
this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, ACCRUAL_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO,
|
||||
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, principalAmount, isReversal);
|
||||
}
|
||||
|
||||
// handle interest payment of writeOff (and reversals)
|
||||
if (interestAmount != null && !(interestAmount.compareTo(BigDecimal.ZERO) == 0)) {
|
||||
totalDebitAmount = totalDebitAmount.add(interestAmount);
|
||||
helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, ACCRUAL_ACCOUNTS_FOR_LOAN.INTEREST_RECEIVABLE,
|
||||
this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, ACCRUAL_ACCOUNTS_FOR_LOAN.INTEREST_RECEIVABLE,
|
||||
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, interestAmount, isReversal);
|
||||
}
|
||||
|
||||
@@ -212,14 +213,14 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
||||
feeAccountToCredit = ACCRUAL_ACCOUNTS_FOR_LOAN.INCOME_FROM_FEES;
|
||||
}
|
||||
|
||||
helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, feeAccountToCredit, loanProductId, paymentTypeId,
|
||||
this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, feeAccountToCredit, loanProductId, paymentTypeId,
|
||||
loanId, transactionId, transactionDate, feesAmount, isReversal);
|
||||
}
|
||||
|
||||
// handle penalties payment of writeOff (and reversals)
|
||||
if (penaltiesAmount != null && !(penaltiesAmount.compareTo(BigDecimal.ZERO) == 0)) {
|
||||
totalDebitAmount = totalDebitAmount.add(penaltiesAmount);
|
||||
helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, ACCRUAL_ACCOUNTS_FOR_LOAN.PENALTIES_RECEIVABLE,
|
||||
this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, ACCRUAL_ACCOUNTS_FOR_LOAN.PENALTIES_RECEIVABLE,
|
||||
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, penaltiesAmount, isReversal);
|
||||
}
|
||||
|
||||
@@ -228,11 +229,11 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
||||
* reversals)
|
||||
***/
|
||||
if (writeOff) {
|
||||
helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, ACCRUAL_ACCOUNTS_FOR_LOAN.LOSSES_WRITTEN_OFF,
|
||||
this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, ACCRUAL_ACCOUNTS_FOR_LOAN.LOSSES_WRITTEN_OFF,
|
||||
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, totalDebitAmount, isReversal);
|
||||
} else {
|
||||
helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, ACCRUAL_ACCOUNTS_FOR_LOAN.FUND_SOURCE, loanProductId,
|
||||
paymentTypeId, loanId, transactionId, transactionDate, totalDebitAmount, isReversal);
|
||||
this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, ACCRUAL_ACCOUNTS_FOR_LOAN.FUND_SOURCE,
|
||||
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, totalDebitAmount, isReversal);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,13 +270,13 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
||||
|
||||
// create journal entries for the fees application (or reversal)
|
||||
if (feesAmount != null && !(feesAmount.compareTo(BigDecimal.ZERO) == 0)) {
|
||||
helper.createAccrualBasedJournalEntriesAndReversalsForLoan(office, currencyCode, ACCRUAL_ACCOUNTS_FOR_LOAN.FEES_RECEIVABLE,
|
||||
ACCRUAL_ACCOUNTS_FOR_LOAN.INCOME_FROM_FEES, loanProductId, paymentTypeId, loanId, transactionId, transactionDate,
|
||||
feesAmount, isReversed);
|
||||
this.helper.createAccrualBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
|
||||
ACCRUAL_ACCOUNTS_FOR_LOAN.FEES_RECEIVABLE, ACCRUAL_ACCOUNTS_FOR_LOAN.INCOME_FROM_FEES, loanProductId, paymentTypeId,
|
||||
loanId, transactionId, transactionDate, feesAmount, isReversed);
|
||||
}
|
||||
// create journal entries for the penalties application (or reversal)
|
||||
else if (penaltiesAmount != null && !(penaltiesAmount.compareTo(BigDecimal.ZERO) == 0)) {
|
||||
helper.createAccrualBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
|
||||
this.helper.createAccrualBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
|
||||
ACCRUAL_ACCOUNTS_FOR_LOAN.PENALTIES_RECEIVABLE, ACCRUAL_ACCOUNTS_FOR_LOAN.INCOME_FROM_PENALTIES, loanProductId,
|
||||
paymentTypeId, loanId, transactionId, transactionDate, penaltiesAmount, isReversed);
|
||||
}
|
||||
|
||||
+16
-16
@@ -27,7 +27,7 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createJournalEntriesForLoan(LoanDTO loanDTO) {
|
||||
public void createJournalEntriesForLoan(final LoanDTO loanDTO) {
|
||||
final GLClosure latestGLClosure = this.helper.getLatestClosureByBranch(loanDTO.getOfficeId());
|
||||
// final Office office =
|
||||
// this.helper.getOfficeById(loanDTO.getOfficeId());
|
||||
@@ -40,7 +40,7 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
|
||||
final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId();
|
||||
final Long loanId = loanDTO.getLoanId();
|
||||
|
||||
helper.checkForBranchClosures(latestGLClosure, transactionDate);
|
||||
this.helper.checkForBranchClosures(latestGLClosure, transactionDate);
|
||||
|
||||
/** Handle Disbursements and reversals of disbursements **/
|
||||
if (loanTransactionDTO.getTransactionType().isDisbursement()) {
|
||||
@@ -51,7 +51,7 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
|
||||
* Repayments and Repayments at disbursement
|
||||
***/
|
||||
else if (loanTransactionDTO.getTransactionType().isRepayment()
|
||||
|| loanTransactionDTO.getTransactionType().isRepaymentAtDisbursement()
|
||||
|| loanTransactionDTO.getTransactionType().isRepaymentAtDisbursement()
|
||||
|| loanTransactionDTO.getTransactionType().isChargePayment()) {
|
||||
createJournalEntriesForRepayments(loanDTO, loanTransactionDTO, office);
|
||||
}
|
||||
@@ -62,9 +62,9 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
|
||||
**/
|
||||
else if (loanTransactionDTO.getTransactionType().isWriteOff() && !loanTransactionDTO.isReversed()) {
|
||||
final BigDecimal principalAmount = loanTransactionDTO.getPrincipal();
|
||||
helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.LOSSES_WRITTEN_OFF,
|
||||
CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO, loanProductId, paymentTypeId, loanId, transactionId, transactionDate,
|
||||
principalAmount, false);
|
||||
this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
|
||||
CASH_ACCOUNTS_FOR_LOAN.LOSSES_WRITTEN_OFF, CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO, loanProductId, paymentTypeId,
|
||||
loanId, transactionId, transactionDate, principalAmount, false);
|
||||
} else if (loanTransactionDTO.getTransactionType().isInitiateTransfer()
|
||||
|| loanTransactionDTO.getTransactionType().isApproveTransfer()
|
||||
|| loanTransactionDTO.getTransactionType().isWithdrawTransfer()) {
|
||||
@@ -98,7 +98,7 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
|
||||
final boolean isReversal = loanTransactionDTO.isReversed();
|
||||
final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId();
|
||||
|
||||
helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO,
|
||||
this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO,
|
||||
CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE, loanProductId, paymentTypeId, loanId, transactionId, transactionDate, disbursalAmount,
|
||||
isReversal);
|
||||
}
|
||||
@@ -132,32 +132,32 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
|
||||
|
||||
if (principalAmount != null && !(principalAmount.compareTo(BigDecimal.ZERO) == 0)) {
|
||||
totalDebitAmount = totalDebitAmount.add(principalAmount);
|
||||
helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO, loanProductId,
|
||||
paymentTypeId, loanId, transactionId, transactionDate, principalAmount, isReversal);
|
||||
this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO,
|
||||
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, principalAmount, isReversal);
|
||||
}
|
||||
|
||||
if (interestAmount != null && !(interestAmount.compareTo(BigDecimal.ZERO) == 0)) {
|
||||
totalDebitAmount = totalDebitAmount.add(interestAmount);
|
||||
helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.INTEREST_ON_LOANS, loanProductId,
|
||||
paymentTypeId, loanId, transactionId, transactionDate, interestAmount, isReversal);
|
||||
this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.INTEREST_ON_LOANS,
|
||||
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, interestAmount, isReversal);
|
||||
}
|
||||
|
||||
if (feesAmount != null && !(feesAmount.compareTo(BigDecimal.ZERO) == 0)) {
|
||||
totalDebitAmount = totalDebitAmount.add(feesAmount);
|
||||
helper.createCreditJournalEntryOrReversalForLoanCharges(office, currencyCode,
|
||||
this.helper.createCreditJournalEntryOrReversalForLoanCharges(office, currencyCode,
|
||||
CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_FEES.getValue(), loanProductId, loanId, transactionId, transactionDate, feesAmount,
|
||||
isReversal, loanTransactionDTO.getFeePayments());
|
||||
}
|
||||
|
||||
if (penaltiesAmount != null && !(penaltiesAmount.compareTo(BigDecimal.ZERO) == 0)) {
|
||||
totalDebitAmount = totalDebitAmount.add(penaltiesAmount);
|
||||
helper.createCreditJournalEntryOrReversalForLoanCharges(office, currencyCode,
|
||||
this.helper.createCreditJournalEntryOrReversalForLoanCharges(office, currencyCode,
|
||||
CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_PENALTIES.getValue(), loanProductId, loanId, transactionId, transactionDate,
|
||||
penaltiesAmount, isReversal, loanTransactionDTO.getPenaltyPayments());
|
||||
}
|
||||
|
||||
/*** create a single debit entry (or reversal) for the entire amount **/
|
||||
helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE, loanProductId,
|
||||
this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE, loanProductId,
|
||||
paymentTypeId, loanId, transactionId, transactionDate, totalDebitAmount, isReversal);
|
||||
}
|
||||
|
||||
@@ -188,12 +188,12 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
|
||||
// final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId();
|
||||
|
||||
if (loanTransactionDTO.getTransactionType().isInitiateTransfer()) {
|
||||
helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.TRANSFERS_SUSPENSE,
|
||||
this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.TRANSFERS_SUSPENSE,
|
||||
CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO, loanProductId, null, loanId, transactionId, transactionDate, principalAmount,
|
||||
isReversal);
|
||||
} else if (loanTransactionDTO.getTransactionType().isApproveTransfer()
|
||||
|| loanTransactionDTO.getTransactionType().isWithdrawTransfer()) {
|
||||
helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO,
|
||||
this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO,
|
||||
CASH_ACCOUNTS_FOR_LOAN.TRANSFERS_SUSPENSE, loanProductId, null, loanId, transactionId, transactionDate,
|
||||
principalAmount, isReversal);
|
||||
}
|
||||
|
||||
+14
-14
@@ -27,7 +27,7 @@ public class CashBasedAccountingProcessorForSavings implements AccountingProcess
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createJournalEntriesForSavings(SavingsDTO savingsDTO) {
|
||||
public void createJournalEntriesForSavings(final SavingsDTO savingsDTO) {
|
||||
final GLClosure latestGLClosure = this.helper.getLatestClosureByBranch(savingsDTO.getOfficeId());
|
||||
final Long savingsProductId = savingsDTO.getSavingsProductId();
|
||||
final Long savingsId = savingsDTO.getSavingsId();
|
||||
@@ -40,20 +40,20 @@ public class CashBasedAccountingProcessorForSavings implements AccountingProcess
|
||||
final boolean isReversal = savingsTransactionDTO.isReversed();
|
||||
final BigDecimal amount = savingsTransactionDTO.getAmount();
|
||||
|
||||
helper.checkForBranchClosures(latestGLClosure, transactionDate);
|
||||
this.helper.checkForBranchClosures(latestGLClosure, transactionDate);
|
||||
|
||||
/** Handle Deposits and reversals of deposits **/
|
||||
if (savingsTransactionDTO.getTransactionType().isDeposit()) {
|
||||
helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_REFERENCE, CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL, savingsProductId,
|
||||
paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||
}
|
||||
|
||||
/** Handle withdrawals and reversals of withdrawals **/
|
||||
else if (savingsTransactionDTO.getTransactionType().isWithdrawal()) {
|
||||
helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL,
|
||||
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_REFERENCE, savingsProductId, paymentTypeId, savingsId, transactionId,
|
||||
transactionDate, amount, isReversal);
|
||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL, CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_REFERENCE, savingsProductId,
|
||||
paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,29 +61,29 @@ public class CashBasedAccountingProcessorForSavings implements AccountingProcess
|
||||
* Applications
|
||||
**/
|
||||
else if (savingsTransactionDTO.getTransactionType().isInterestPosting()) {
|
||||
helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||
CASH_ACCOUNTS_FOR_SAVINGS.INTEREST_ON_SAVINGS, CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL, savingsProductId,
|
||||
paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||
}
|
||||
|
||||
/** Handle Fees Deductions and reversals of Fees Deductions **/
|
||||
else if (savingsTransactionDTO.getTransactionType().isFeeDeduction()) {
|
||||
helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL,
|
||||
CASH_ACCOUNTS_FOR_SAVINGS.INCOME_FROM_FEES, savingsProductId, paymentTypeId, savingsId, transactionId,
|
||||
transactionDate, amount, isReversal);
|
||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL, CASH_ACCOUNTS_FOR_SAVINGS.INCOME_FROM_FEES, savingsProductId,
|
||||
paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||
}
|
||||
|
||||
/** Handle Transfers proposal **/
|
||||
else if (savingsTransactionDTO.getTransactionType().isInitiateTransfer()) {
|
||||
helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL,
|
||||
CASH_ACCOUNTS_FOR_SAVINGS.TRANSFERS_SUSPENSE, savingsProductId, paymentTypeId, savingsId, transactionId,
|
||||
transactionDate, amount, isReversal);
|
||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL, CASH_ACCOUNTS_FOR_SAVINGS.TRANSFERS_SUSPENSE, savingsProductId,
|
||||
paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||
}
|
||||
|
||||
/** Handle Transfer Withdrawal or Acceptance **/
|
||||
else if (savingsTransactionDTO.getTransactionType().isWithdrawTransfer()
|
||||
|| savingsTransactionDTO.getTransactionType().isApproveTransfer()) {
|
||||
helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||
CASH_ACCOUNTS_FOR_SAVINGS.TRANSFERS_SUSPENSE, CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL, savingsProductId,
|
||||
paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||
}
|
||||
|
||||
+2
-2
@@ -100,9 +100,9 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat
|
||||
public Page<JournalEntryData> retrieveAll(final SearchParameters searchParameters, final Long glAccountId,
|
||||
final Boolean onlyManualEntries, final Date fromDate, final Date toDate, final String transactionId) {
|
||||
|
||||
StringBuilder sqlBuilder = new StringBuilder(200);
|
||||
final StringBuilder sqlBuilder = new StringBuilder(200);
|
||||
sqlBuilder.append("select SQL_CALC_FOUND_ROWS ");
|
||||
sqlBuilder.append(journalEntryMapper.schema());
|
||||
sqlBuilder.append(this.journalEntryMapper.schema());
|
||||
|
||||
final Object[] objectArray = new Object[5];
|
||||
int arrayPos = 0;
|
||||
|
||||
+3
-2
@@ -172,14 +172,15 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
|
||||
}
|
||||
}
|
||||
|
||||
private void validateDebitOrCreditArrayForExistingGLAccount(GLAccount glaccount, SingleDebitOrCreditEntryCommand[] creditOrDebits) {
|
||||
private void validateDebitOrCreditArrayForExistingGLAccount(final GLAccount glaccount,
|
||||
final SingleDebitOrCreditEntryCommand[] creditOrDebits) {
|
||||
/**
|
||||
* If a glaccount is assigned for a rule the credits or debits array
|
||||
* should have only one entry and it must be same as existing account
|
||||
*/
|
||||
if (creditOrDebits.length != 1) { throw new JournalEntryInvalidException(
|
||||
GL_JOURNAL_ENTRY_INVALID_REASON.INVALID_DEBIT_OR_CREDIT_ACCOUNTS, null, null, null); }
|
||||
for (SingleDebitOrCreditEntryCommand creditOrDebit : creditOrDebits) {
|
||||
for (final SingleDebitOrCreditEntryCommand creditOrDebit : creditOrDebits) {
|
||||
if (!glaccount.getId().equals(creditOrDebit.getGlAccountId())) { throw new JournalEntryInvalidException(
|
||||
GL_JOURNAL_ENTRY_INVALID_REASON.INVALID_DEBIT_OR_CREDIT_ACCOUNTS, null, null, null); }
|
||||
}
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ public class ChargeToGLAccountMapper {
|
||||
@SuppressWarnings("unused")
|
||||
private final long incomeAccountId;
|
||||
|
||||
public ChargeToGLAccountMapper(long chargeId, long incomeAccountId) {
|
||||
public ChargeToGLAccountMapper(final long chargeId, final long incomeAccountId) {
|
||||
this.chargeId = chargeId;
|
||||
this.incomeAccountId = incomeAccountId;
|
||||
}
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ public class PaymentTypeToGLAccountMapper {
|
||||
@SuppressWarnings("unused")
|
||||
private final long fundSourceAccountId;
|
||||
|
||||
public PaymentTypeToGLAccountMapper(long paymentTypeId, long fundSourceAccountId) {
|
||||
public PaymentTypeToGLAccountMapper(final long paymentTypeId, final long fundSourceAccountId) {
|
||||
this.paymentTypeId = paymentTypeId;
|
||||
this.fundSourceAccountId = fundSourceAccountId;
|
||||
}
|
||||
|
||||
+2
-2
@@ -113,7 +113,7 @@ public class ProductToGLAccountMapping extends AbstractPersistable<Long> {
|
||||
return this.paymentType;
|
||||
}
|
||||
|
||||
public void setPaymentType(CodeValue paymentType) {
|
||||
public void setPaymentType(final CodeValue paymentType) {
|
||||
this.paymentType = paymentType;
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ public class ProductToGLAccountMapping extends AbstractPersistable<Long> {
|
||||
return this.charge;
|
||||
}
|
||||
|
||||
public void setCharge(Charge charge) {
|
||||
public void setCharge(final Charge charge) {
|
||||
this.charge = charge;
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -151,28 +151,28 @@ public final class ProductToGLAccountMappingFromApiJsonDeserializer {
|
||||
|
||||
if (isCashBasedAccounting(accountingRuleType)) {
|
||||
|
||||
final Long savingsControlAccountId = fromApiJsonHelper.extractLongNamed(
|
||||
final Long savingsControlAccountId = this.fromApiJsonHelper.extractLongNamed(
|
||||
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_CONTROL.getValue(), element);
|
||||
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_CONTROL.getValue())
|
||||
.value(savingsControlAccountId).notNull().integerGreaterThanZero();
|
||||
|
||||
final Long savingsReferenceAccountId = fromApiJsonHelper.extractLongNamed(
|
||||
final Long savingsReferenceAccountId = this.fromApiJsonHelper.extractLongNamed(
|
||||
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_REFERENCE.getValue(), element);
|
||||
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_REFERENCE.getValue())
|
||||
.value(savingsReferenceAccountId).notNull().integerGreaterThanZero();
|
||||
|
||||
final Long transfersInSuspenseAccountId = fromApiJsonHelper.extractLongNamed(
|
||||
final Long transfersInSuspenseAccountId = this.fromApiJsonHelper.extractLongNamed(
|
||||
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(), element);
|
||||
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue())
|
||||
.value(transfersInSuspenseAccountId).notNull().integerGreaterThanZero();
|
||||
|
||||
final Long interestOnSavingsAccountId = fromApiJsonHelper.extractLongNamed(
|
||||
final Long interestOnSavingsAccountId = this.fromApiJsonHelper.extractLongNamed(
|
||||
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_SAVINGS.getValue(), element);
|
||||
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_SAVINGS.getValue())
|
||||
.value(interestOnSavingsAccountId).notNull().integerGreaterThanZero();
|
||||
|
||||
final Long incomeFromFeeId = fromApiJsonHelper.extractLongNamed(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(),
|
||||
element);
|
||||
final Long incomeFromFeeId = this.fromApiJsonHelper.extractLongNamed(
|
||||
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), element);
|
||||
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue()).value(incomeFromFeeId)
|
||||
.notNull().integerGreaterThanZero();
|
||||
|
||||
|
||||
+35
-35
@@ -97,8 +97,8 @@ public class ProductToGLAccountMappingHelper {
|
||||
* @param changes
|
||||
*/
|
||||
public void savePaymentChannelToFundSourceMappings(final JsonCommand command, final JsonElement element, final Long productId,
|
||||
Map<String, Object> changes, final PortfolioProductType portfolioProductType) {
|
||||
JsonArray paymentChannelMappingArray = fromApiJsonHelper.extractJsonArrayNamed(
|
||||
final Map<String, Object> changes, final PortfolioProductType portfolioProductType) {
|
||||
final JsonArray paymentChannelMappingArray = this.fromApiJsonHelper.extractJsonArrayNamed(
|
||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(), element);
|
||||
if (paymentChannelMappingArray != null) {
|
||||
if (changes != null) {
|
||||
@@ -124,7 +124,7 @@ public class ProductToGLAccountMappingHelper {
|
||||
* @param changes
|
||||
*/
|
||||
public void saveChargesToIncomeAccountMappings(final JsonCommand command, final JsonElement element, final Long productId,
|
||||
Map<String, Object> changes, final PortfolioProductType portfolioProductType, final boolean isPenalty) {
|
||||
final Map<String, Object> changes, final PortfolioProductType portfolioProductType, final boolean isPenalty) {
|
||||
String arrayName;
|
||||
if (isPenalty) {
|
||||
arrayName = LOAN_PRODUCT_ACCOUNTING_PARAMS.PENALTY_INCOME_ACCOUNT_MAPPING.getValue();
|
||||
@@ -132,7 +132,7 @@ public class ProductToGLAccountMappingHelper {
|
||||
arrayName = LOAN_PRODUCT_ACCOUNTING_PARAMS.FEE_INCOME_ACCOUNT_MAPPING.getValue();
|
||||
}
|
||||
|
||||
JsonArray chargeToIncomeAccountMappingArray = fromApiJsonHelper.extractJsonArrayNamed(arrayName, element);
|
||||
final JsonArray chargeToIncomeAccountMappingArray = this.fromApiJsonHelper.extractJsonArrayNamed(arrayName, element);
|
||||
if (chargeToIncomeAccountMappingArray != null) {
|
||||
if (changes != null) {
|
||||
changes.put(LOAN_PRODUCT_ACCOUNTING_PARAMS.FEE_INCOME_ACCOUNT_MAPPING.getValue(),
|
||||
@@ -154,33 +154,33 @@ public class ProductToGLAccountMappingHelper {
|
||||
* @param changes
|
||||
*/
|
||||
public void updateChargeToIncomeAccountMappings(final JsonCommand command, final JsonElement element, final Long productId,
|
||||
Map<String, Object> changes, final PortfolioProductType portfolioProductType, boolean isPenalty) {
|
||||
final Map<String, Object> changes, final PortfolioProductType portfolioProductType, final boolean isPenalty) {
|
||||
// find all existing payment Channel to Fund source Mappings
|
||||
List<ProductToGLAccountMapping> existingChargeToIncomeAccountMappings;
|
||||
String arrayFragmentName;
|
||||
|
||||
if (isPenalty) {
|
||||
existingChargeToIncomeAccountMappings = accountMappingRepository.findAllPenaltyToIncomeAccountMappings(productId,
|
||||
existingChargeToIncomeAccountMappings = this.accountMappingRepository.findAllPenaltyToIncomeAccountMappings(productId,
|
||||
portfolioProductType.getValue());
|
||||
arrayFragmentName = LOAN_PRODUCT_ACCOUNTING_PARAMS.PENALTY_INCOME_ACCOUNT_MAPPING.getValue();
|
||||
} else {
|
||||
existingChargeToIncomeAccountMappings = accountMappingRepository.findAllFeeToIncomeAccountMappings(productId,
|
||||
existingChargeToIncomeAccountMappings = this.accountMappingRepository.findAllFeeToIncomeAccountMappings(productId,
|
||||
portfolioProductType.getValue());
|
||||
arrayFragmentName = LOAN_PRODUCT_ACCOUNTING_PARAMS.FEE_INCOME_ACCOUNT_MAPPING.getValue();
|
||||
}
|
||||
|
||||
JsonArray chargeToIncomeAccountMappingArray = fromApiJsonHelper.extractJsonArrayNamed(arrayFragmentName, element);
|
||||
final JsonArray chargeToIncomeAccountMappingArray = this.fromApiJsonHelper.extractJsonArrayNamed(arrayFragmentName, element);
|
||||
/**
|
||||
* Variable stores a map representation of charges (key) and their
|
||||
* associated income Id's (value) extracted from the passed in
|
||||
* Jsoncommand
|
||||
**/
|
||||
Map<Long, Long> inputChargeToIncomeAccountMap = new HashMap<Long, Long>();
|
||||
final Map<Long, Long> inputChargeToIncomeAccountMap = new HashMap<Long, Long>();
|
||||
/***
|
||||
* Variable stores all charges which have already been mapped to Income
|
||||
* Accounts in the system
|
||||
**/
|
||||
Set<Long> existingCharges = new HashSet<Long>();
|
||||
final Set<Long> existingCharges = new HashSet<Long>();
|
||||
if (chargeToIncomeAccountMappingArray != null) {
|
||||
if (changes != null) {
|
||||
changes.put(arrayFragmentName, command.jsonFragment(arrayFragmentName));
|
||||
@@ -195,7 +195,7 @@ public class ProductToGLAccountMappingHelper {
|
||||
|
||||
// If input map is empty, delete all existing mappings
|
||||
if (inputChargeToIncomeAccountMap.size() == 0) {
|
||||
accountMappingRepository.deleteInBatch(existingChargeToIncomeAccountMappings);
|
||||
this.accountMappingRepository.deleteInBatch(existingChargeToIncomeAccountMappings);
|
||||
}/**
|
||||
* Else, <br/>
|
||||
* update existing mappings OR <br/>
|
||||
@@ -206,30 +206,30 @@ public class ProductToGLAccountMappingHelper {
|
||||
*
|
||||
**/
|
||||
else {
|
||||
for (ProductToGLAccountMapping chargeToIncomeAccountMapping : existingChargeToIncomeAccountMappings) {
|
||||
Long currentCharge = chargeToIncomeAccountMapping.getCharge().getId();
|
||||
for (final ProductToGLAccountMapping chargeToIncomeAccountMapping : existingChargeToIncomeAccountMappings) {
|
||||
final Long currentCharge = chargeToIncomeAccountMapping.getCharge().getId();
|
||||
existingCharges.add(currentCharge);
|
||||
// update existing mappings (if required)
|
||||
if (inputChargeToIncomeAccountMap.containsKey(currentCharge)) {
|
||||
Long newGLAccountId = inputChargeToIncomeAccountMap.get(currentCharge);
|
||||
final Long newGLAccountId = inputChargeToIncomeAccountMap.get(currentCharge);
|
||||
if (newGLAccountId != chargeToIncomeAccountMapping.getGlAccount().getId()) {
|
||||
final GLAccount glAccount = getAccountByIdAndType(LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_ACCOUNT_ID.getValue(),
|
||||
GLAccountType.INCOME, newGLAccountId);
|
||||
chargeToIncomeAccountMapping.setGlAccount(glAccount);
|
||||
accountMappingRepository.save(chargeToIncomeAccountMapping);
|
||||
this.accountMappingRepository.save(chargeToIncomeAccountMapping);
|
||||
}
|
||||
}// deleted payment type
|
||||
else {
|
||||
accountMappingRepository.delete(chargeToIncomeAccountMapping);
|
||||
this.accountMappingRepository.delete(chargeToIncomeAccountMapping);
|
||||
}
|
||||
}
|
||||
// create new mappings
|
||||
Set<Long> incomingCharges = inputChargeToIncomeAccountMap.keySet();
|
||||
final Set<Long> incomingCharges = inputChargeToIncomeAccountMap.keySet();
|
||||
incomingCharges.removeAll(existingCharges);
|
||||
// incomingPaymentTypes now only contains the newly added
|
||||
// payment Type mappings
|
||||
for (Long newCharge : incomingCharges) {
|
||||
Long newGLAccountId = inputChargeToIncomeAccountMap.get(newCharge);
|
||||
for (final Long newCharge : incomingCharges) {
|
||||
final Long newGLAccountId = inputChargeToIncomeAccountMap.get(newCharge);
|
||||
saveChargeToFundSourceMapping(productId, newCharge, newGLAccountId, portfolioProductType, isPenalty);
|
||||
}
|
||||
}
|
||||
@@ -243,22 +243,22 @@ public class ProductToGLAccountMappingHelper {
|
||||
* @param changes
|
||||
*/
|
||||
public void updatePaymentChannelToFundSourceMappings(final JsonCommand command, final JsonElement element, final Long productId,
|
||||
Map<String, Object> changes, final PortfolioProductType portfolioProductType) {
|
||||
final Map<String, Object> changes, final PortfolioProductType portfolioProductType) {
|
||||
// find all existing payment Channel to Fund source Mappings
|
||||
List<ProductToGLAccountMapping> existingPaymentChannelToFundSourceMappings = accountMappingRepository
|
||||
final List<ProductToGLAccountMapping> existingPaymentChannelToFundSourceMappings = this.accountMappingRepository
|
||||
.findAllPaymentTypeToFundSourceMappings(productId, portfolioProductType.getValue());
|
||||
JsonArray paymentChannelMappingArray = fromApiJsonHelper.extractJsonArrayNamed(
|
||||
final JsonArray paymentChannelMappingArray = this.fromApiJsonHelper.extractJsonArrayNamed(
|
||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(), element);
|
||||
/**
|
||||
* Variable stores a map representation of Payment channels (key) and
|
||||
* their fund sources (value) extracted from the passed in Jsoncommand
|
||||
**/
|
||||
Map<Long, Long> inputPaymentChannelFundSourceMap = new HashMap<Long, Long>();
|
||||
final Map<Long, Long> inputPaymentChannelFundSourceMap = new HashMap<Long, Long>();
|
||||
/***
|
||||
* Variable stores all payment types which have already been mapped to
|
||||
* Fund Sources in the system
|
||||
**/
|
||||
Set<Long> existingPaymentTypes = new HashSet<Long>();
|
||||
final Set<Long> existingPaymentTypes = new HashSet<Long>();
|
||||
if (paymentChannelMappingArray != null) {
|
||||
if (changes != null) {
|
||||
changes.put(LOAN_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(),
|
||||
@@ -274,7 +274,7 @@ public class ProductToGLAccountMappingHelper {
|
||||
|
||||
// If input map is empty, delete all existing mappings
|
||||
if (inputPaymentChannelFundSourceMap.size() == 0) {
|
||||
accountMappingRepository.deleteInBatch(existingPaymentChannelToFundSourceMappings);
|
||||
this.accountMappingRepository.deleteInBatch(existingPaymentChannelToFundSourceMappings);
|
||||
}/**
|
||||
* Else, <br/>
|
||||
* update existing mappings OR <br/>
|
||||
@@ -285,30 +285,30 @@ public class ProductToGLAccountMappingHelper {
|
||||
*
|
||||
**/
|
||||
else {
|
||||
for (ProductToGLAccountMapping existingPaymentChannelToFundSourceMapping : existingPaymentChannelToFundSourceMappings) {
|
||||
Long currentPaymentChannelId = existingPaymentChannelToFundSourceMapping.getPaymentType().getId();
|
||||
for (final ProductToGLAccountMapping existingPaymentChannelToFundSourceMapping : existingPaymentChannelToFundSourceMappings) {
|
||||
final Long currentPaymentChannelId = existingPaymentChannelToFundSourceMapping.getPaymentType().getId();
|
||||
existingPaymentTypes.add(currentPaymentChannelId);
|
||||
// update existing mappings (if required)
|
||||
if (inputPaymentChannelFundSourceMap.containsKey(currentPaymentChannelId)) {
|
||||
Long newGLAccountId = inputPaymentChannelFundSourceMap.get(currentPaymentChannelId);
|
||||
final Long newGLAccountId = inputPaymentChannelFundSourceMap.get(currentPaymentChannelId);
|
||||
if (newGLAccountId != existingPaymentChannelToFundSourceMapping.getGlAccount().getId()) {
|
||||
final GLAccount glAccount = getAccountByIdAndType(LOAN_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue(),
|
||||
GLAccountType.ASSET, newGLAccountId);
|
||||
existingPaymentChannelToFundSourceMapping.setGlAccount(glAccount);
|
||||
accountMappingRepository.save(existingPaymentChannelToFundSourceMapping);
|
||||
this.accountMappingRepository.save(existingPaymentChannelToFundSourceMapping);
|
||||
}
|
||||
}// deleted payment type
|
||||
else {
|
||||
accountMappingRepository.delete(existingPaymentChannelToFundSourceMapping);
|
||||
this.accountMappingRepository.delete(existingPaymentChannelToFundSourceMapping);
|
||||
}
|
||||
}
|
||||
// create new mappings
|
||||
Set<Long> incomingPaymentTypes = inputPaymentChannelFundSourceMap.keySet();
|
||||
final Set<Long> incomingPaymentTypes = inputPaymentChannelFundSourceMap.keySet();
|
||||
incomingPaymentTypes.removeAll(existingPaymentTypes);
|
||||
// incomingPaymentTypes now only contains the newly added
|
||||
// payment Type mappings
|
||||
for (Long newPaymentType : incomingPaymentTypes) {
|
||||
Long newGLAccountId = inputPaymentChannelFundSourceMap.get(newPaymentType);
|
||||
for (final Long newPaymentType : incomingPaymentTypes) {
|
||||
final Long newGLAccountId = inputPaymentChannelFundSourceMap.get(newPaymentType);
|
||||
savePaymentChannelToFundSourceMapping(productId, newPaymentType, newGLAccountId, portfolioProductType);
|
||||
}
|
||||
}
|
||||
@@ -321,7 +321,7 @@ public class ProductToGLAccountMappingHelper {
|
||||
*/
|
||||
private void savePaymentChannelToFundSourceMapping(final Long productId, final Long paymentTypeId,
|
||||
final Long paymentTypeSpecificFundAccountId, final PortfolioProductType portfolioProductType) {
|
||||
CodeValue paymentType = codeValueRepositoryWrapper.findOneByCodeNameAndIdWithNotFoundDetection(
|
||||
final CodeValue paymentType = this.codeValueRepositoryWrapper.findOneByCodeNameAndIdWithNotFoundDetection(
|
||||
PaymentDetailConstants.paymentTypeCodeName, paymentTypeId);
|
||||
final GLAccount glAccount = getAccountByIdAndType(LOAN_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue(), GLAccountType.ASSET,
|
||||
paymentTypeSpecificFundAccountId);
|
||||
@@ -336,7 +336,7 @@ public class ProductToGLAccountMappingHelper {
|
||||
*/
|
||||
private void saveChargeToFundSourceMapping(final Long productId, final Long chargeId, final Long incomeAccountId,
|
||||
final PortfolioProductType portfolioProductType, final boolean isPenalty) {
|
||||
Charge charge = chargeRepositoryWrapper.findOneWithNotFoundDetection(chargeId);
|
||||
final Charge charge = this.chargeRepositoryWrapper.findOneWithNotFoundDetection(chargeId);
|
||||
|
||||
// TODO Vishwas: Need to validate if given charge is fee or Penalty
|
||||
// based on input condition
|
||||
|
||||
+11
-11
@@ -145,7 +145,7 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> fetchAccountMappingDetailsForSavingsProduct(Long savingsProductId, Integer accountingType) {
|
||||
public Map<String, Object> fetchAccountMappingDetailsForSavingsProduct(final Long savingsProductId, final Integer accountingType) {
|
||||
final Map<String, Object> accountMappingDetails = new LinkedHashMap<String, Object>(8);
|
||||
|
||||
final ProductToGLAccountMappingMapper rm = new ProductToGLAccountMappingMapper();
|
||||
@@ -180,12 +180,12 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PaymentTypeToGLAccountMapper> fetchPaymentTypeToFundSourceMappingsForLoanProduct(Long loanProductId) {
|
||||
public List<PaymentTypeToGLAccountMapper> fetchPaymentTypeToFundSourceMappingsForLoanProduct(final Long loanProductId) {
|
||||
return fetchPaymentTypeToFundSourceMappings(PortfolioProductType.LOAN, loanProductId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PaymentTypeToGLAccountMapper> fetchPaymentTypeToFundSourceMappingsForSavingsProduct(Long savingsProductId) {
|
||||
public List<PaymentTypeToGLAccountMapper> fetchPaymentTypeToFundSourceMappingsForSavingsProduct(final Long savingsProductId) {
|
||||
return fetchPaymentTypeToFundSourceMappings(PortfolioProductType.SAVING, savingsProductId);
|
||||
}
|
||||
|
||||
@@ -194,8 +194,8 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
|
||||
* @param paymentTypeToGLAccountMappers
|
||||
* @return
|
||||
*/
|
||||
private List<PaymentTypeToGLAccountMapper> fetchPaymentTypeToFundSourceMappings(PortfolioProductType portfolioProductType,
|
||||
Long loanProductId) {
|
||||
private List<PaymentTypeToGLAccountMapper> fetchPaymentTypeToFundSourceMappings(final PortfolioProductType portfolioProductType,
|
||||
final Long loanProductId) {
|
||||
final ProductToGLAccountMappingMapper rm = new ProductToGLAccountMappingMapper();
|
||||
final String sql = "select " + rm.schema() + " and product_id = ? and payment_type is not null";
|
||||
|
||||
@@ -209,24 +209,24 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
|
||||
}
|
||||
final Long glAccountId = (Long) productToGLAccountMap.get("glAccountId");
|
||||
final Long paymentTypeId = (Long) productToGLAccountMap.get("paymentTypeId");
|
||||
PaymentTypeToGLAccountMapper paymentTypeToGLAccountMapper = new PaymentTypeToGLAccountMapper(paymentTypeId, glAccountId);
|
||||
final PaymentTypeToGLAccountMapper paymentTypeToGLAccountMapper = new PaymentTypeToGLAccountMapper(paymentTypeId, glAccountId);
|
||||
paymentTypeToGLAccountMappers.add(paymentTypeToGLAccountMapper);
|
||||
}
|
||||
return paymentTypeToGLAccountMappers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ChargeToGLAccountMapper> fetchFeeToIncomeAccountMappingsForLoanProduct(Long loanProductId) {
|
||||
public List<ChargeToGLAccountMapper> fetchFeeToIncomeAccountMappingsForLoanProduct(final Long loanProductId) {
|
||||
return fetchChargeToIncomeAccountMappings(PortfolioProductType.LOAN, loanProductId, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ChargeToGLAccountMapper> fetchPenaltyToIncomeAccountMappingsForLoanProduct(Long loanProductId) {
|
||||
public List<ChargeToGLAccountMapper> fetchPenaltyToIncomeAccountMappingsForLoanProduct(final Long loanProductId) {
|
||||
return fetchChargeToIncomeAccountMappings(PortfolioProductType.LOAN, loanProductId, true);
|
||||
}
|
||||
|
||||
private List<ChargeToGLAccountMapper> fetchChargeToIncomeAccountMappings(PortfolioProductType portfolioProductType, Long loanProductId,
|
||||
boolean penalty) {
|
||||
private List<ChargeToGLAccountMapper> fetchChargeToIncomeAccountMappings(final PortfolioProductType portfolioProductType,
|
||||
final Long loanProductId, final boolean penalty) {
|
||||
final ProductToGLAccountMappingMapper rm = new ProductToGLAccountMappingMapper();
|
||||
String sql = "select " + rm.schema() + " and product_id = ? and mapping.charge_id is not null and charge.is_penalty=";
|
||||
if (penalty) {
|
||||
@@ -244,7 +244,7 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
|
||||
}
|
||||
final Long glAccountId = (Long) chargeToIncomeAccountMap.get("glAccountId");
|
||||
final Long chargeId = (Long) chargeToIncomeAccountMap.get("chargeId");
|
||||
ChargeToGLAccountMapper chargeToGLAccountMapper = new ChargeToGLAccountMapper(chargeId, glAccountId);
|
||||
final ChargeToGLAccountMapper chargeToGLAccountMapper = new ChargeToGLAccountMapper(chargeId, glAccountId);
|
||||
chargeToGLAccountMappers.add(chargeToGLAccountMapper);
|
||||
}
|
||||
return chargeToGLAccountMappers;
|
||||
|
||||
+43
-42
@@ -37,8 +37,8 @@ public class ProductToGLAccountMappingWritePlatformServiceImpl implements Produc
|
||||
@Autowired
|
||||
public ProductToGLAccountMappingWritePlatformServiceImpl(final FromJsonHelper fromApiJsonHelper,
|
||||
final ProductToGLAccountMappingFromApiJsonDeserializer deserializer,
|
||||
LoanProductToGLAccountMappingHelper loanProductToGLAccountMappingHelper,
|
||||
SavingsProductToGLAccountMappingHelper savingsProductToGLAccountMappingHelper) {
|
||||
final LoanProductToGLAccountMappingHelper loanProductToGLAccountMappingHelper,
|
||||
final SavingsProductToGLAccountMappingHelper savingsProductToGLAccountMappingHelper) {
|
||||
this.fromApiJsonHelper = fromApiJsonHelper;
|
||||
this.deserializer = deserializer;
|
||||
this.loanProductToGLAccountMappingHelper = loanProductToGLAccountMappingHelper;
|
||||
@@ -57,84 +57,84 @@ public class ProductToGLAccountMappingWritePlatformServiceImpl implements Produc
|
||||
break;
|
||||
case CASH_BASED:
|
||||
// asset
|
||||
loanProductToGLAccountMappingHelper
|
||||
this.loanProductToGLAccountMappingHelper
|
||||
.saveLoanToAssetAccountMapping(element, LOAN_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue(), loanProductId,
|
||||
CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue());
|
||||
loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.LOAN_PORTFOLIO.getValue(), loanProductId,
|
||||
CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO.getValue());
|
||||
loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(), loanProductId,
|
||||
CASH_ACCOUNTS_FOR_LOAN.TRANSFERS_SUSPENSE.getValue());
|
||||
|
||||
// income
|
||||
loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_LOANS.getValue(), loanProductId,
|
||||
CASH_ACCOUNTS_FOR_LOAN.INTEREST_ON_LOANS.getValue());
|
||||
loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), loanProductId,
|
||||
CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_FEES.getValue());
|
||||
loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue(), loanProductId,
|
||||
CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_PENALTIES.getValue());
|
||||
|
||||
// expenses
|
||||
loanProductToGLAccountMappingHelper.saveLoanToExpenseAccountMapping(element,
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToExpenseAccountMapping(element,
|
||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue(), loanProductId,
|
||||
CASH_ACCOUNTS_FOR_LOAN.LOSSES_WRITTEN_OFF.getValue());
|
||||
|
||||
// advanced accounting mappings
|
||||
loanProductToGLAccountMappingHelper.savePaymentChannelToFundSourceMappings(command, element, loanProductId, null);
|
||||
loanProductToGLAccountMappingHelper.saveChargesToIncomeAccountMappings(command, element, loanProductId, null);
|
||||
this.loanProductToGLAccountMappingHelper.savePaymentChannelToFundSourceMappings(command, element, loanProductId, null);
|
||||
this.loanProductToGLAccountMappingHelper.saveChargesToIncomeAccountMappings(command, element, loanProductId, null);
|
||||
break;
|
||||
case ACCRUAL_BASED:
|
||||
|
||||
// assets (including receivables)
|
||||
loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue(), loanProductId,
|
||||
ACCRUAL_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue());
|
||||
loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.LOAN_PORTFOLIO.getValue(), loanProductId,
|
||||
ACCRUAL_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO.getValue());
|
||||
loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(), loanProductId,
|
||||
ACCRUAL_ACCOUNTS_FOR_LOAN.TRANSFERS_SUSPENSE.getValue());
|
||||
loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.INTEREST_RECEIVABLE.getValue(), loanProductId,
|
||||
ACCRUAL_ACCOUNTS_FOR_LOAN.INTEREST_RECEIVABLE.getValue());
|
||||
loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.FEES_RECEIVABLE.getValue(), loanProductId,
|
||||
ACCRUAL_ACCOUNTS_FOR_LOAN.FEES_RECEIVABLE.getValue());
|
||||
loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.PENALTIES_RECEIVABLE.getValue(), loanProductId,
|
||||
ACCRUAL_ACCOUNTS_FOR_LOAN.PENALTIES_RECEIVABLE.getValue());
|
||||
|
||||
// income
|
||||
loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_LOANS.getValue(), loanProductId,
|
||||
ACCRUAL_ACCOUNTS_FOR_LOAN.INTEREST_ON_LOANS.getValue());
|
||||
loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), loanProductId,
|
||||
ACCRUAL_ACCOUNTS_FOR_LOAN.INCOME_FROM_FEES.getValue());
|
||||
loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue(), loanProductId,
|
||||
ACCRUAL_ACCOUNTS_FOR_LOAN.INCOME_FROM_PENALTIES.getValue());
|
||||
|
||||
// expenses
|
||||
loanProductToGLAccountMappingHelper.saveLoanToExpenseAccountMapping(element,
|
||||
this.loanProductToGLAccountMappingHelper.saveLoanToExpenseAccountMapping(element,
|
||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue(), loanProductId,
|
||||
ACCRUAL_ACCOUNTS_FOR_LOAN.LOSSES_WRITTEN_OFF.getValue());
|
||||
|
||||
// advanced accounting mappings
|
||||
loanProductToGLAccountMappingHelper.savePaymentChannelToFundSourceMappings(command, element, loanProductId, null);
|
||||
loanProductToGLAccountMappingHelper.saveChargesToIncomeAccountMappings(command, element, loanProductId, null);
|
||||
this.loanProductToGLAccountMappingHelper.savePaymentChannelToFundSourceMappings(command, element, loanProductId, null);
|
||||
this.loanProductToGLAccountMappingHelper.saveChargesToIncomeAccountMappings(command, element, loanProductId, null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void createSavingProductToGLAccountMapping(Long savingProductId, JsonCommand command) {
|
||||
public void createSavingProductToGLAccountMapping(final Long savingProductId, final JsonCommand command) {
|
||||
final JsonElement element = this.fromApiJsonHelper.parse(command.json());
|
||||
final Integer accountingRuleTypeId = this.fromApiJsonHelper.extractIntegerNamed(accountingRuleParamName, element,
|
||||
Locale.getDefault());
|
||||
@@ -145,30 +145,30 @@ public class ProductToGLAccountMappingWritePlatformServiceImpl implements Produc
|
||||
break;
|
||||
case CASH_BASED:
|
||||
// asset
|
||||
savingsProductToGLAccountMappingHelper.saveSavingsToAssetAccountMapping(element,
|
||||
this.savingsProductToGLAccountMappingHelper.saveSavingsToAssetAccountMapping(element,
|
||||
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_REFERENCE.getValue(), savingProductId,
|
||||
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_REFERENCE.getValue());
|
||||
|
||||
// income
|
||||
savingsProductToGLAccountMappingHelper.saveSavingsToIncomeAccountMapping(element,
|
||||
this.savingsProductToGLAccountMappingHelper.saveSavingsToIncomeAccountMapping(element,
|
||||
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), savingProductId,
|
||||
CASH_ACCOUNTS_FOR_SAVINGS.INCOME_FROM_FEES.getValue());
|
||||
|
||||
// expenses
|
||||
savingsProductToGLAccountMappingHelper.saveSavingsToExpenseAccountMapping(element,
|
||||
this.savingsProductToGLAccountMappingHelper.saveSavingsToExpenseAccountMapping(element,
|
||||
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_SAVINGS.getValue(), savingProductId,
|
||||
CASH_ACCOUNTS_FOR_SAVINGS.INTEREST_ON_SAVINGS.getValue());
|
||||
|
||||
// liability
|
||||
savingsProductToGLAccountMappingHelper.saveSavingsToLiabilityAccountMapping(element,
|
||||
this.savingsProductToGLAccountMappingHelper.saveSavingsToLiabilityAccountMapping(element,
|
||||
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_CONTROL.getValue(), savingProductId,
|
||||
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL.getValue());
|
||||
savingsProductToGLAccountMappingHelper.saveSavingsToLiabilityAccountMapping(element,
|
||||
this.savingsProductToGLAccountMappingHelper.saveSavingsToLiabilityAccountMapping(element,
|
||||
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(), savingProductId,
|
||||
CASH_ACCOUNTS_FOR_SAVINGS.TRANSFERS_SUSPENSE.getValue());
|
||||
|
||||
// advanced accounting mappings
|
||||
savingsProductToGLAccountMappingHelper.savePaymentChannelToFundSourceMappings(command, element, savingProductId, null);
|
||||
this.savingsProductToGLAccountMappingHelper.savePaymentChannelToFundSourceMappings(command, element, savingProductId, null);
|
||||
break;
|
||||
/*** Do not have accrual based accounting for now ***/
|
||||
case ACCRUAL_BASED:
|
||||
@@ -195,23 +195,23 @@ public class ProductToGLAccountMappingWritePlatformServiceImpl implements Produc
|
||||
***/
|
||||
if (accountingRuleChanged) {
|
||||
this.deserializer.validateForLoanProductCreate(command.json());
|
||||
loanProductToGLAccountMappingHelper.deleteLoanProductToGLAccountMapping(loanProductId);
|
||||
this.loanProductToGLAccountMappingHelper.deleteLoanProductToGLAccountMapping(loanProductId);
|
||||
createLoanProductToGLAccountMapping(loanProductId, command);
|
||||
changes = loanProductToGLAccountMappingHelper.populateChangesForNewLoanProductToGLAccountMappingCreation(element,
|
||||
changes = this.loanProductToGLAccountMappingHelper.populateChangesForNewLoanProductToGLAccountMappingCreation(element,
|
||||
accountingRuleType);
|
||||
}/*** else examine and update individual changes ***/
|
||||
else {
|
||||
loanProductToGLAccountMappingHelper.handleChangesToLoanProductToGLAccountMappings(loanProductId, changes, element,
|
||||
this.loanProductToGLAccountMappingHelper.handleChangesToLoanProductToGLAccountMappings(loanProductId, changes, element,
|
||||
accountingRuleType);
|
||||
loanProductToGLAccountMappingHelper.updatePaymentChannelToFundSourceMappings(command, element, loanProductId, changes);
|
||||
loanProductToGLAccountMappingHelper.updateChargesToIncomeAccountMappings(command, element, loanProductId, changes);
|
||||
this.loanProductToGLAccountMappingHelper.updatePaymentChannelToFundSourceMappings(command, element, loanProductId, changes);
|
||||
this.loanProductToGLAccountMappingHelper.updateChargesToIncomeAccountMappings(command, element, loanProductId, changes);
|
||||
}
|
||||
return changes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> updateSavingsProductToGLAccountMapping(Long savingsProductId, JsonCommand command,
|
||||
boolean accountingRuleChanged, int accountingRuleTypeId) {
|
||||
public Map<String, Object> updateSavingsProductToGLAccountMapping(final Long savingsProductId, final JsonCommand command,
|
||||
final boolean accountingRuleChanged, final int accountingRuleTypeId) {
|
||||
/***
|
||||
* Variable tracks all accounting mapping properties that have been
|
||||
* updated
|
||||
@@ -226,15 +226,16 @@ public class ProductToGLAccountMappingWritePlatformServiceImpl implements Produc
|
||||
***/
|
||||
if (accountingRuleChanged) {
|
||||
this.deserializer.validateForSavingsProductCreate(command.json());
|
||||
savingsProductToGLAccountMappingHelper.deleteSavingsProductToGLAccountMapping(savingsProductId);
|
||||
this.savingsProductToGLAccountMappingHelper.deleteSavingsProductToGLAccountMapping(savingsProductId);
|
||||
createSavingProductToGLAccountMapping(savingsProductId, command);
|
||||
changes = savingsProductToGLAccountMappingHelper.populateChangesForNewSavingsProductToGLAccountMappingCreation(element,
|
||||
changes = this.savingsProductToGLAccountMappingHelper.populateChangesForNewSavingsProductToGLAccountMappingCreation(element,
|
||||
accountingRuleType);
|
||||
}/*** else examine and update individual changes ***/
|
||||
else {
|
||||
savingsProductToGLAccountMappingHelper.handleChangesToSavingsProductToGLAccountMappings(savingsProductId, changes, element,
|
||||
accountingRuleType);
|
||||
savingsProductToGLAccountMappingHelper.updatePaymentChannelToFundSourceMappings(command, element, savingsProductId, changes);
|
||||
this.savingsProductToGLAccountMappingHelper.handleChangesToSavingsProductToGLAccountMappings(savingsProductId, changes,
|
||||
element, accountingRuleType);
|
||||
this.savingsProductToGLAccountMappingHelper.updatePaymentChannelToFundSourceMappings(command, element, savingsProductId,
|
||||
changes);
|
||||
}
|
||||
return changes;
|
||||
}
|
||||
|
||||
+5
-5
@@ -28,9 +28,9 @@ import com.google.gson.JsonElement;
|
||||
public class SavingsProductToGLAccountMappingHelper extends ProductToGLAccountMappingHelper {
|
||||
|
||||
@Autowired
|
||||
public SavingsProductToGLAccountMappingHelper(GLAccountRepository glAccountRepository,
|
||||
ProductToGLAccountMappingRepository glAccountMappingRepository, FromJsonHelper fromApiJsonHelper,
|
||||
CodeValueRepositoryWrapper codeValueRepositoryWrapper, ChargeRepositoryWrapper chargeRepositoryWrapper) {
|
||||
public SavingsProductToGLAccountMappingHelper(final GLAccountRepository glAccountRepository,
|
||||
final ProductToGLAccountMappingRepository glAccountMappingRepository, final FromJsonHelper fromApiJsonHelper,
|
||||
final CodeValueRepositoryWrapper codeValueRepositoryWrapper, final ChargeRepositoryWrapper chargeRepositoryWrapper) {
|
||||
super(glAccountRepository, glAccountMappingRepository, fromApiJsonHelper, codeValueRepositoryWrapper, chargeRepositoryWrapper);
|
||||
}
|
||||
|
||||
@@ -85,12 +85,12 @@ public class SavingsProductToGLAccountMappingHelper extends ProductToGLAccountMa
|
||||
/*** Abstractions for payments channel related to savings products ***/
|
||||
|
||||
public void savePaymentChannelToFundSourceMappings(final JsonCommand command, final JsonElement element, final Long productId,
|
||||
Map<String, Object> changes) {
|
||||
final Map<String, Object> changes) {
|
||||
savePaymentChannelToFundSourceMappings(command, element, productId, changes, PortfolioProductType.SAVING);
|
||||
}
|
||||
|
||||
public void updatePaymentChannelToFundSourceMappings(final JsonCommand command, final JsonElement element, final Long productId,
|
||||
Map<String, Object> changes) {
|
||||
final Map<String, Object> changes) {
|
||||
updatePaymentChannelToFundSourceMappings(command, element, productId, changes, PortfolioProductType.SAVING);
|
||||
}
|
||||
|
||||
|
||||
+17
-11
@@ -107,22 +107,24 @@ public class AccountingRuleApiResource {
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String retrieveAllAccountingRules(@Context final UriInfo uriInfo) {
|
||||
|
||||
final AppUser currentUser = context.authenticatedUser();
|
||||
|
||||
final AppUser currentUser = this.context.authenticatedUser();
|
||||
currentUser.validateHasReadPermission(this.resourceNameForPermission);
|
||||
|
||||
|
||||
final String hierarchy = currentUser.getOffice().getHierarchy();
|
||||
final String hierarchySearchString = hierarchy + "%";
|
||||
|
||||
|
||||
final Set<String> associationParameters = ApiParameterHelper.extractAssociationsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
boolean isAssociationParametersExists = false;
|
||||
if (!associationParameters.isEmpty()) {
|
||||
if (associationParameters.contains("all")) {
|
||||
isAssociationParametersExists = true; // If true, retrieve additional fields for journal entry form.
|
||||
isAssociationParametersExists = true; // If true, retrieve
|
||||
// additional fields for
|
||||
// journal entry form.
|
||||
}
|
||||
}
|
||||
final List<AccountingRuleData> accountingRuleDatas = this.accountingRuleReadPlatformService.retrieveAllAccountingRules(hierarchySearchString,
|
||||
isAssociationParametersExists);
|
||||
final List<AccountingRuleData> accountingRuleDatas = this.accountingRuleReadPlatformService.retrieveAllAccountingRules(
|
||||
hierarchySearchString, isAssociationParametersExists);
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.apiJsonSerializerService.serialize(settings, accountingRuleDatas, RESPONSE_DATA_PARAMETERS);
|
||||
@@ -189,10 +191,14 @@ public class AccountingRuleApiResource {
|
||||
final Collection<CodeValueData> allowedTagOptions = this.codeValueReadPlatformService
|
||||
.retrieveCodeValuesByCode(AccountingConstants.ASSESTS_TAG_OPTION_CODE_NAME);
|
||||
|
||||
allowedTagOptions.addAll(this.codeValueReadPlatformService.retrieveCodeValuesByCode(AccountingConstants.LIABILITIES_TAG_OPTION_CODE_NAME));
|
||||
allowedTagOptions.addAll(this.codeValueReadPlatformService.retrieveCodeValuesByCode(AccountingConstants.EQUITY_TAG_OPTION_CODE_NAME));
|
||||
allowedTagOptions.addAll(this.codeValueReadPlatformService.retrieveCodeValuesByCode(AccountingConstants.INCOME_TAG_OPTION_CODE_NAME));
|
||||
allowedTagOptions.addAll(this.codeValueReadPlatformService.retrieveCodeValuesByCode(AccountingConstants.EXPENSES_TAG_OPTION_CODE_NAME));
|
||||
allowedTagOptions.addAll(this.codeValueReadPlatformService
|
||||
.retrieveCodeValuesByCode(AccountingConstants.LIABILITIES_TAG_OPTION_CODE_NAME));
|
||||
allowedTagOptions.addAll(this.codeValueReadPlatformService
|
||||
.retrieveCodeValuesByCode(AccountingConstants.EQUITY_TAG_OPTION_CODE_NAME));
|
||||
allowedTagOptions.addAll(this.codeValueReadPlatformService
|
||||
.retrieveCodeValuesByCode(AccountingConstants.INCOME_TAG_OPTION_CODE_NAME));
|
||||
allowedTagOptions.addAll(this.codeValueReadPlatformService
|
||||
.retrieveCodeValuesByCode(AccountingConstants.EXPENSES_TAG_OPTION_CODE_NAME));
|
||||
|
||||
if (accountingRuleData == null) {
|
||||
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ public class AccountingTagRuleData {
|
||||
}
|
||||
|
||||
public CodeValueData getTag() {
|
||||
return tag;
|
||||
return this.tag;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -13,10 +13,10 @@ import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRul
|
||||
*/
|
||||
public class AccountingRuleDuplicateException extends AbstractPlatformDomainRuleException {
|
||||
|
||||
public AccountingRuleDuplicateException(String name) {
|
||||
public AccountingRuleDuplicateException(final String name) {
|
||||
super("error.msg.accounting.rule.duplicate", "An accounting rule with the name " + name + " already exists" + name);
|
||||
}
|
||||
|
||||
|
||||
public AccountingRuleDuplicateException() {
|
||||
super("error.msg.accounting.rule.tag.duplicate", "The accounting rule already have the tags which you defined");
|
||||
}
|
||||
|
||||
+2
-1
@@ -141,7 +141,8 @@ public class AccountingRuleReadPlatformServiceImpl implements AccountingRuleRead
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AccountingRuleData> retrieveAllAccountingRules(final String hierarchySearchString, final boolean isAssociationParametersExists) {
|
||||
public List<AccountingRuleData> retrieveAllAccountingRules(final String hierarchySearchString,
|
||||
final boolean isAssociationParametersExists) {
|
||||
final AccountingRuleDataExtractor resultSetExtractor = new AccountingRuleDataExtractor(this.jdbcTemplate,
|
||||
this.glAccountReadPlatformService, isAssociationParametersExists);
|
||||
Object[] arguments = new Object[] {};
|
||||
|
||||
+1
-1
@@ -112,7 +112,7 @@ public class AccountingRuleWritePlatformServiceJpaRepositoryImpl implements Acco
|
||||
// get the GL Accounts or tags to Debit and Credit
|
||||
final String[] debitTags = command.arrayValueOfParameterNamed(AccountingRuleJsonInputParams.DEBIT_ACCOUNT_TAGS.getValue());
|
||||
final String[] creditTags = command.arrayValueOfParameterNamed(AccountingRuleJsonInputParams.CREDIT_ACCOUNT_TAGS.getValue());
|
||||
final Set<String> incomingDebitTags = debitTags == null ? new HashSet<String>(): new HashSet<String>(Arrays.asList(debitTags));
|
||||
final Set<String> incomingDebitTags = debitTags == null ? new HashSet<String>() : new HashSet<String>(Arrays.asList(debitTags));
|
||||
final Set<String> incomingCreditTags = creditTags == null ? new HashSet<String>() : new HashSet<String>(Arrays.asList(creditTags));
|
||||
final Long accountToDebitId = command.longValueOfParameterNamed(AccountingRuleJsonInputParams.ACCOUNT_TO_DEBIT.getValue());
|
||||
final Long accountToCreditId = command.longValueOfParameterNamed(AccountingRuleJsonInputParams.ACCOUNT_TO_CREDIT.getValue());
|
||||
|
||||
+8
-8
@@ -74,17 +74,17 @@ public class AuditsApiResource {
|
||||
@QueryParam("groupId") final Integer groupId, @QueryParam("clientId") final Integer clientId,
|
||||
@QueryParam("loanid") final Integer loanId, @QueryParam("savingsAccountId") final Integer savingsAccountId) {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions);
|
||||
this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions);
|
||||
|
||||
final String extraCriteria = getExtraCriteria(actionName, entityName, resourceId, makerId, makerDateTimeFrom, makerDateTimeTo,
|
||||
checkerId, checkerDateTimeFrom, checkerDateTimeTo, processingResult, officeId, groupId, clientId, loanId, savingsAccountId);
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
|
||||
final Collection<AuditData> auditEntries = this.auditReadPlatformService.retrieveAuditEntries(extraCriteria,
|
||||
settings.isIncludeJson());
|
||||
|
||||
return this.toApiJsonSerializer.serialize(settings, auditEntries, RESPONSE_DATA_PARAMETERS);
|
||||
return this.toApiJsonSerializer.serialize(settings, auditEntries, this.RESPONSE_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
@GET
|
||||
@@ -93,12 +93,12 @@ public class AuditsApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String retrieveAuditEntry(@PathParam("auditId") final Long auditId, @Context final UriInfo uriInfo) {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions);
|
||||
this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions);
|
||||
|
||||
final AuditData auditEntry = this.auditReadPlatformService.retrieveAuditEntry(auditId);
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.toApiJsonSerializer.serialize(settings, auditEntry, RESPONSE_DATA_PARAMETERS);
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.toApiJsonSerializer.serialize(settings, auditEntry, this.RESPONSE_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
@GET
|
||||
@@ -107,9 +107,9 @@ public class AuditsApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String retrieveAuditSearchTemplate(@Context final UriInfo uriInfo) {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions);
|
||||
this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions);
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
|
||||
final AuditSearchData auditSearchData = this.auditReadPlatformService.retrieveSearchTemplate("audit");
|
||||
|
||||
|
||||
+3
-3
@@ -77,12 +77,12 @@ public class MakercheckersApiResource {
|
||||
final String extraCriteria = getExtraCriteria(actionName, entityName, resourceId, makerId, makerDateTimeFrom, makerDateTimeTo,
|
||||
officeId, groupId, clientId, loanId, savingsAccountId);
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
|
||||
final Collection<AuditData> entries = this.readPlatformService.retrieveAllEntriesToBeChecked(extraCriteria,
|
||||
settings.isIncludeJson());
|
||||
|
||||
return this.toApiJsonSerializerAudit.serialize(settings, entries, RESPONSE_DATA_PARAMETERS);
|
||||
return this.toApiJsonSerializerAudit.serialize(settings, entries, this.RESPONSE_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
@GET
|
||||
@@ -91,7 +91,7 @@ public class MakercheckersApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String retrieveAuditSearchTemplate(@Context final UriInfo uriInfo) {
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
|
||||
final AuditSearchData auditSearchData = this.readPlatformService.retrieveSearchTemplate("makerchecker");
|
||||
|
||||
|
||||
+2
-2
@@ -21,11 +21,11 @@ public enum CommandProcessingResultType {
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
return this.code;
|
||||
}
|
||||
|
||||
public static CommandProcessingResultType fromInt(final Integer typeValue) {
|
||||
|
||||
+120
-133
@@ -25,175 +25,162 @@ import org.springframework.data.jpa.domain.AbstractPersistable;
|
||||
@Table(name = "m_portfolio_command_source")
|
||||
public class CommandSource extends AbstractPersistable<Long> {
|
||||
|
||||
@Column(name = "action_name", nullable = true, length = 100)
|
||||
private String actionName;
|
||||
@Column(name = "action_name", nullable = true, length = 100)
|
||||
private String actionName;
|
||||
|
||||
@Column(name = "entity_name", nullable = true, length = 100)
|
||||
private String entityName;
|
||||
@Column(name = "entity_name", nullable = true, length = 100)
|
||||
private String entityName;
|
||||
|
||||
@Column(name = "office_id")
|
||||
private Long officeId;
|
||||
@Column(name = "office_id")
|
||||
private Long officeId;
|
||||
|
||||
@Column(name = "group_id")
|
||||
private Long groupId;
|
||||
@Column(name = "group_id")
|
||||
private Long groupId;
|
||||
|
||||
@Column(name = "client_id")
|
||||
private Long clientId;
|
||||
@Column(name = "client_id")
|
||||
private Long clientId;
|
||||
|
||||
@Column(name = "loan_id")
|
||||
private Long loanId;
|
||||
@Column(name = "loan_id")
|
||||
private Long loanId;
|
||||
|
||||
@Column(name = "savings_account_id")
|
||||
private Long savingsId;
|
||||
@Column(name = "savings_account_id")
|
||||
private Long savingsId;
|
||||
|
||||
@Column(name = "api_get_url", length = 100)
|
||||
private String resourceGetUrl;
|
||||
@Column(name = "api_get_url", length = 100)
|
||||
private String resourceGetUrl;
|
||||
|
||||
@Column(name = "resource_id")
|
||||
private Long resourceId;
|
||||
@Column(name = "resource_id")
|
||||
private Long resourceId;
|
||||
|
||||
@Column(name = "subresource_id")
|
||||
private Long subresourceId;
|
||||
@Column(name = "subresource_id")
|
||||
private Long subresourceId;
|
||||
|
||||
@Column(name = "command_as_json", length = 1000)
|
||||
private String commandAsJson;
|
||||
@Column(name = "command_as_json", length = 1000)
|
||||
private String commandAsJson;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "maker_id", nullable = false)
|
||||
private AppUser maker;
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "maker_id", nullable = false)
|
||||
private AppUser maker;
|
||||
|
||||
@Column(name = "made_on_date", nullable = false)
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date madeOnDate;
|
||||
@Column(name = "made_on_date", nullable = false)
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date madeOnDate;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "checker_id", nullable = true)
|
||||
private AppUser checker;
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "checker_id", nullable = true)
|
||||
private AppUser checker;
|
||||
|
||||
@Column(name = "checked_on_date", nullable = true)
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date checkedOnDate;
|
||||
@Column(name = "checked_on_date", nullable = true)
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date checkedOnDate;
|
||||
|
||||
@Column(name = "processing_result_enum", nullable = false)
|
||||
private Integer processingResult;
|
||||
@Column(name = "processing_result_enum", nullable = false)
|
||||
private Integer processingResult;
|
||||
|
||||
@Column(name = "product_id")
|
||||
private Long productId;
|
||||
@Column(name = "product_id")
|
||||
private Long productId;
|
||||
|
||||
public static CommandSource fullEntryFrom(final CommandWrapper wrapper,
|
||||
final JsonCommand command, final AppUser maker) {
|
||||
return new CommandSource(wrapper.actionName(), wrapper.entityName(),
|
||||
wrapper.getHref(), command.entityId(), command.subentityId(),
|
||||
command.json(), maker, DateTime.now());
|
||||
}
|
||||
public static CommandSource fullEntryFrom(final CommandWrapper wrapper, final JsonCommand command, final AppUser maker) {
|
||||
return new CommandSource(wrapper.actionName(), wrapper.entityName(), wrapper.getHref(), command.entityId(), command.subentityId(),
|
||||
command.json(), maker, DateTime.now());
|
||||
}
|
||||
|
||||
protected CommandSource() {
|
||||
//
|
||||
}
|
||||
protected CommandSource() {
|
||||
//
|
||||
}
|
||||
|
||||
private CommandSource(final String actionName, final String entityName,
|
||||
final String href, final Long resourceId, final Long subresourceId,
|
||||
final String commandSerializedAsJson, final AppUser maker,
|
||||
final DateTime madeOnDateTime) {
|
||||
this.actionName = actionName;
|
||||
this.entityName = entityName;
|
||||
this.resourceGetUrl = href;
|
||||
this.resourceId = resourceId;
|
||||
this.subresourceId = subresourceId;
|
||||
this.commandAsJson = commandSerializedAsJson;
|
||||
this.maker = maker;
|
||||
this.madeOnDate = madeOnDateTime.toDate();
|
||||
this.processingResult = CommandProcessingResultType.PROCESSED
|
||||
.getValue();
|
||||
}
|
||||
private CommandSource(final String actionName, final String entityName, final String href, final Long resourceId,
|
||||
final Long subresourceId, final String commandSerializedAsJson, final AppUser maker, final DateTime madeOnDateTime) {
|
||||
this.actionName = actionName;
|
||||
this.entityName = entityName;
|
||||
this.resourceGetUrl = href;
|
||||
this.resourceId = resourceId;
|
||||
this.subresourceId = subresourceId;
|
||||
this.commandAsJson = commandSerializedAsJson;
|
||||
this.maker = maker;
|
||||
this.madeOnDate = madeOnDateTime.toDate();
|
||||
this.processingResult = CommandProcessingResultType.PROCESSED.getValue();
|
||||
}
|
||||
|
||||
public void markAsChecked(final AppUser checker,
|
||||
final DateTime checkedOnDate) {
|
||||
this.checker = checker;
|
||||
this.checkedOnDate = checkedOnDate.toDate();
|
||||
this.processingResult = CommandProcessingResultType.PROCESSED
|
||||
.getValue();
|
||||
}
|
||||
public void markAsChecked(final AppUser checker, final DateTime checkedOnDate) {
|
||||
this.checker = checker;
|
||||
this.checkedOnDate = checkedOnDate.toDate();
|
||||
this.processingResult = CommandProcessingResultType.PROCESSED.getValue();
|
||||
}
|
||||
|
||||
public void updateResourceId(final Long resourceId) {
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
public void updateResourceId(final Long resourceId) {
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
|
||||
public void updateSubresourceId(final Long subresourceId) {
|
||||
this.subresourceId = subresourceId;
|
||||
}
|
||||
public void updateSubresourceId(final Long subresourceId) {
|
||||
this.subresourceId = subresourceId;
|
||||
}
|
||||
|
||||
public void updateJsonTo(final String json) {
|
||||
this.commandAsJson = json;
|
||||
}
|
||||
public void updateJsonTo(final String json) {
|
||||
this.commandAsJson = json;
|
||||
}
|
||||
|
||||
public Long resourceId() {
|
||||
return this.resourceId;
|
||||
}
|
||||
public Long resourceId() {
|
||||
return this.resourceId;
|
||||
}
|
||||
|
||||
public Long subresourceId() {
|
||||
return this.subresourceId;
|
||||
}
|
||||
public Long subresourceId() {
|
||||
return this.subresourceId;
|
||||
}
|
||||
|
||||
public boolean hasJson() {
|
||||
return StringUtils.isNotBlank(this.commandAsJson);
|
||||
}
|
||||
public boolean hasJson() {
|
||||
return StringUtils.isNotBlank(this.commandAsJson);
|
||||
}
|
||||
|
||||
public String json() {
|
||||
return this.commandAsJson;
|
||||
}
|
||||
public String json() {
|
||||
return this.commandAsJson;
|
||||
}
|
||||
|
||||
public String getActionName() {
|
||||
return this.actionName;
|
||||
}
|
||||
public String getActionName() {
|
||||
return this.actionName;
|
||||
}
|
||||
|
||||
public String getEntityName() {
|
||||
return this.entityName;
|
||||
}
|
||||
public String getEntityName() {
|
||||
return this.entityName;
|
||||
}
|
||||
|
||||
public String getPermissionCode() {
|
||||
return this.actionName + "_" + this.entityName;
|
||||
}
|
||||
public String getPermissionCode() {
|
||||
return this.actionName + "_" + this.entityName;
|
||||
}
|
||||
|
||||
public Long getResourceId() {
|
||||
return this.resourceId;
|
||||
}
|
||||
public Long getResourceId() {
|
||||
return this.resourceId;
|
||||
}
|
||||
|
||||
public Long getSubresourceId() {
|
||||
return this.subresourceId;
|
||||
}
|
||||
public Long getSubresourceId() {
|
||||
return this.subresourceId;
|
||||
}
|
||||
|
||||
public void markAsAwaitingApproval() {
|
||||
this.processingResult = CommandProcessingResultType.AWAITING_APPROVAL
|
||||
.getValue();
|
||||
}
|
||||
public void markAsAwaitingApproval() {
|
||||
this.processingResult = CommandProcessingResultType.AWAITING_APPROVAL.getValue();
|
||||
}
|
||||
|
||||
public boolean isMarkedAsAwaitingApproval() {
|
||||
if (this.processingResult
|
||||
.equals(CommandProcessingResultType.AWAITING_APPROVAL
|
||||
.getValue())) {
|
||||
return true;
|
||||
}
|
||||
public boolean isMarkedAsAwaitingApproval() {
|
||||
if (this.processingResult.equals(CommandProcessingResultType.AWAITING_APPROVAL.getValue())) { return true; }
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void updateForAudit(final Long officeId, final Long groupId,
|
||||
final Long clientId, final Long loanId, final Long savingsId,
|
||||
final Long productId) {
|
||||
this.officeId = officeId;
|
||||
this.groupId = groupId;
|
||||
this.clientId = clientId;
|
||||
this.loanId = loanId;
|
||||
this.savingsId = savingsId;
|
||||
this.productId = productId;
|
||||
}
|
||||
public void updateForAudit(final Long officeId, final Long groupId, final Long clientId, final Long loanId, final Long savingsId,
|
||||
final Long productId) {
|
||||
this.officeId = officeId;
|
||||
this.groupId = groupId;
|
||||
this.clientId = clientId;
|
||||
this.loanId = loanId;
|
||||
this.savingsId = savingsId;
|
||||
this.productId = productId;
|
||||
}
|
||||
|
||||
public String getResourceGetUrl() {
|
||||
return this.resourceGetUrl;
|
||||
}
|
||||
public String getResourceGetUrl() {
|
||||
return this.resourceGetUrl;
|
||||
}
|
||||
|
||||
public Long getProductId() {
|
||||
return this.productId;
|
||||
}
|
||||
public Long getProductId() {
|
||||
return this.productId;
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -185,8 +185,8 @@ public class CommandWrapper {
|
||||
|
||||
public boolean isUpdate() {
|
||||
// permissions resource has special update which involves no resource.
|
||||
return isPermissionResource() && isUpdateOperation() || isCurrencyResource() && isUpdateOperation() || isCacheResource() && isUpdateOperation()
|
||||
|| isUpdateOperation() && this.entityId != null;
|
||||
return isPermissionResource() && isUpdateOperation() || isCurrencyResource() && isUpdateOperation() || isCacheResource()
|
||||
&& isUpdateOperation() || isUpdateOperation() && this.entityId != null;
|
||||
}
|
||||
|
||||
public boolean isUpdateOperation() {
|
||||
@@ -445,7 +445,7 @@ public class CommandWrapper {
|
||||
public boolean isSavingsAccountResource() {
|
||||
return this.entityName.equalsIgnoreCase("SAVINGSACCOUNT");
|
||||
}
|
||||
|
||||
|
||||
public boolean isRejectionOfSavingsAccountApplication() {
|
||||
return this.actionName.equalsIgnoreCase("REJECT") && this.entityName.equalsIgnoreCase("SAVINGSACCOUNT");
|
||||
}
|
||||
@@ -501,7 +501,7 @@ public class CommandWrapper {
|
||||
public boolean isSavingsAccountChargeResource() {
|
||||
return this.entityName.equalsIgnoreCase("SAVINGSACCOUNTCHARGE");
|
||||
}
|
||||
|
||||
|
||||
public boolean isAddSavingsAccountCharge() {
|
||||
return this.actionName.equalsIgnoreCase("CREATE") && this.entityName.equalsIgnoreCase("SAVINGSACCOUNTCHARGE");
|
||||
}
|
||||
@@ -517,11 +517,11 @@ public class CommandWrapper {
|
||||
public boolean isWaiveSavingsAccountCharge() {
|
||||
return this.actionName.equalsIgnoreCase("WAIVE") && this.entityName.equalsIgnoreCase("SAVINGSACCOUNTCHARGE");
|
||||
}
|
||||
|
||||
|
||||
public boolean isPaySavingsAccountCharge() {
|
||||
return this.actionName.equalsIgnoreCase("PAY") && this.entityName.equalsIgnoreCase("SAVINGSACCOUNTCHARGE");
|
||||
}
|
||||
|
||||
|
||||
public boolean isCalendarResource() {
|
||||
return this.entityName.equalsIgnoreCase("CALENDAR");
|
||||
}
|
||||
|
||||
+1
-1
@@ -18,6 +18,6 @@ public class UnsupportedCommandException extends RuntimeException {
|
||||
}
|
||||
|
||||
public String getUnsupportedCommandName() {
|
||||
return unsupportedCommandName;
|
||||
return this.unsupportedCommandName;
|
||||
}
|
||||
}
|
||||
+37
-32
@@ -79,7 +79,9 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
||||
public String schema(final boolean includeJson, final String hierarchy) {
|
||||
|
||||
String commandAsJsonString = "";
|
||||
if (includeJson) commandAsJsonString = ", aud.command_as_json as commandAsJson ";
|
||||
if (includeJson) {
|
||||
commandAsJsonString = ", aud.command_as_json as commandAsJson ";
|
||||
}
|
||||
|
||||
String partSql = " aud.id as id, aud.action_name as actionName, aud.entity_name as entityName,"
|
||||
+ " aud.resource_id as resourceId, aud.subresource_id as subresourceId,"
|
||||
@@ -120,16 +122,16 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
||||
// commandAsJson might not be on the select list of columns
|
||||
try {
|
||||
commandAsJson = rs.getString("commandAsJson");
|
||||
} catch (SQLException e) {
|
||||
} catch (final SQLException e) {
|
||||
commandAsJson = null;
|
||||
}
|
||||
|
||||
String officeName = rs.getString("officeName");
|
||||
String groupLevelName = rs.getString("groupLevelName");
|
||||
String groupName = rs.getString("groupName");
|
||||
String clientName = rs.getString("clientName");
|
||||
String loanAccountNo = rs.getString("loanAccountNo");
|
||||
String savingsAccountNo = rs.getString("savingsAccountNo");
|
||||
final String officeName = rs.getString("officeName");
|
||||
final String groupLevelName = rs.getString("groupLevelName");
|
||||
final String groupName = rs.getString("groupName");
|
||||
final String clientName = rs.getString("clientName");
|
||||
final String loanAccountNo = rs.getString("loanAccountNo");
|
||||
final String savingsAccountNo = rs.getString("savingsAccountNo");
|
||||
|
||||
return new AuditData(id, actionName, entityName, resourceId, subresourceId, maker, madeOnDate, checker, checkedOnDate,
|
||||
processingResult, commandAsJson, officeName, groupLevelName, groupName, clientName, loanAccountNo, savingsAccountNo);
|
||||
@@ -140,7 +142,9 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
||||
public Collection<AuditData> retrieveAuditEntries(final String extraCriteria, final boolean includeJson) {
|
||||
|
||||
String updatedExtraCriteria = "";
|
||||
if (StringUtils.isNotBlank(extraCriteria)) updatedExtraCriteria = " where (" + extraCriteria + ")";
|
||||
if (StringUtils.isNotBlank(extraCriteria)) {
|
||||
updatedExtraCriteria = " where (" + extraCriteria + ")";
|
||||
}
|
||||
|
||||
updatedExtraCriteria += " order by aud.id DESC";
|
||||
return retrieveEntries("audit", updatedExtraCriteria, includeJson);
|
||||
@@ -150,10 +154,11 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
||||
public Collection<AuditData> retrieveAllEntriesToBeChecked(final String extraCriteria, final boolean includeJson) {
|
||||
|
||||
String updatedExtraCriteria = "";
|
||||
if (StringUtils.isNotBlank(extraCriteria))
|
||||
if (StringUtils.isNotBlank(extraCriteria)) {
|
||||
updatedExtraCriteria = " where (" + extraCriteria + ")" + " and aud.processing_result_enum = 2";
|
||||
else
|
||||
} else {
|
||||
updatedExtraCriteria = " where aud.processing_result_enum = 2";
|
||||
}
|
||||
|
||||
updatedExtraCriteria += " order by aud.id";
|
||||
|
||||
@@ -165,8 +170,8 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
||||
if (!(useType.equals("audit") || useType.equals("makerchecker"))) { throw new PlatformDataIntegrityException(
|
||||
"error.msg.invalid.auditSearchTemplate.useType", "Invalid Audit Search Template UseType: " + useType); }
|
||||
|
||||
AppUser currentUser = context.authenticatedUser();
|
||||
String hierarchy = currentUser.getOffice().getHierarchy();
|
||||
final AppUser currentUser = this.context.authenticatedUser();
|
||||
final String hierarchy = currentUser.getOffice().getHierarchy();
|
||||
|
||||
final AuditMapper rm = new AuditMapper();
|
||||
String sql = "select " + rm.schema(includeJson, hierarchy);
|
||||
@@ -194,7 +199,7 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
||||
@Override
|
||||
public AuditData retrieveAuditEntry(final Long auditId) {
|
||||
|
||||
final AppUser currentUser = context.authenticatedUser();
|
||||
final AppUser currentUser = this.context.authenticatedUser();
|
||||
final String hierarchy = currentUser.getOffice().getHierarchy();
|
||||
|
||||
final AuditMapper rm = new AuditMapper();
|
||||
@@ -220,10 +225,10 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
||||
commandAsJsonMap.remove("officeId");
|
||||
|
||||
Long officeId = null;
|
||||
String officeIdStr = auditObject.get("officeId").getAsString();
|
||||
final String officeIdStr = auditObject.get("officeId").getAsString();
|
||||
if (StringUtils.isNotBlank(officeIdStr)) {
|
||||
officeId = Long.valueOf(officeIdStr);
|
||||
OfficeData office = this.officeReadPlatformService.retrieveOffice(officeId);
|
||||
final OfficeData office = this.officeReadPlatformService.retrieveOffice(officeId);
|
||||
commandAsJsonMap.put("officeName", office.name());
|
||||
} else {
|
||||
commandAsJsonMap.put("officeName", "");
|
||||
@@ -234,10 +239,10 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
||||
commandAsJsonMap.remove("clientId");
|
||||
|
||||
Long clientId = null;
|
||||
String clientIdStr = auditObject.get("clientId").getAsString();
|
||||
final String clientIdStr = auditObject.get("clientId").getAsString();
|
||||
if (StringUtils.isNotBlank(clientIdStr)) {
|
||||
clientId = Long.valueOf(clientIdStr);
|
||||
ClientData client = this.clientReadPlatformService.retrieveOne(clientId);
|
||||
final ClientData client = this.clientReadPlatformService.retrieveOne(clientId);
|
||||
commandAsJsonMap.put("clientName", client.displayName());
|
||||
} else {
|
||||
commandAsJsonMap.put("clientName", "");
|
||||
@@ -248,10 +253,10 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
||||
commandAsJsonMap.remove("productId");
|
||||
|
||||
Long productId = null;
|
||||
String productIdStr = auditObject.get("productId").getAsString();
|
||||
final String productIdStr = auditObject.get("productId").getAsString();
|
||||
if (StringUtils.isNotBlank(productIdStr)) {
|
||||
productId = Long.valueOf(productIdStr);
|
||||
LoanProductData loanProduct = this.loanProductReadPlatformService.retrieveLoanProduct(productId);
|
||||
final LoanProductData loanProduct = this.loanProductReadPlatformService.retrieveLoanProduct(productId);
|
||||
commandAsJsonMap.put("productName", loanProduct.getName());
|
||||
} else {
|
||||
commandAsJsonMap.put("productName", "");
|
||||
@@ -262,10 +267,10 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
||||
commandAsJsonMap.remove("loanOfficerId");
|
||||
|
||||
Long loanOfficerId = null;
|
||||
String loanOfficerIdStr = auditObject.get("loanOfficerId").getAsString();
|
||||
final String loanOfficerIdStr = auditObject.get("loanOfficerId").getAsString();
|
||||
if (StringUtils.isNotBlank(loanOfficerIdStr)) {
|
||||
loanOfficerId = Long.valueOf(loanOfficerIdStr);
|
||||
StaffData officer = this.staffReadPlatformService.retrieveStaff(loanOfficerId);
|
||||
final StaffData officer = this.staffReadPlatformService.retrieveStaff(loanOfficerId);
|
||||
commandAsJsonMap.put("loanOfficerName", officer.getDisplayName());
|
||||
} else {
|
||||
commandAsJsonMap.put("loanOfficerName", "");
|
||||
@@ -275,7 +280,7 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
||||
final String[] enumTypes = { "loanTermFrequencyType", "repaymentFrequencyType", "amortizationType", "interestType",
|
||||
"interestCalculationPeriodType", "interestRateFrequencyType" };
|
||||
|
||||
for (String typeName : enumTypes) {
|
||||
for (final String typeName : enumTypes) {
|
||||
if (commandAsJsonMap.containsKey(typeName)) {
|
||||
commandAsJsonMap.remove(typeName);
|
||||
|
||||
@@ -301,25 +306,25 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
||||
if (!(useType.equals("audit") || useType.equals("makerchecker"))) { throw new PlatformDataIntegrityException(
|
||||
"error.msg.invalid.auditSearchTemplate.useType", "Invalid Audit Search Template UseType: " + useType); }
|
||||
|
||||
AppUser currentUser = context.authenticatedUser();
|
||||
final AppUser currentUser = this.context.authenticatedUser();
|
||||
|
||||
final Collection<AppUserData> appUsers = appUserReadPlatformService.retrieveSearchTemplate();
|
||||
final Collection<AppUserData> appUsers = this.appUserReadPlatformService.retrieveSearchTemplate();
|
||||
|
||||
String sql = " SELECT distinct(action_name) as actionName FROM m_permission p ";
|
||||
sql += makercheckerCapabilityOnly(useType, currentUser);
|
||||
sql += " order by if(action_name in ('CREATE', 'DELETE', 'UPDATE'), action_name, 'ZZZ'), action_name";
|
||||
ActionNamesMapper mapper = new ActionNamesMapper();
|
||||
List<String> actionNames = this.jdbcTemplate.query(sql, mapper, new Object[] {});
|
||||
final ActionNamesMapper mapper = new ActionNamesMapper();
|
||||
final List<String> actionNames = this.jdbcTemplate.query(sql, mapper, new Object[] {});
|
||||
|
||||
sql = " select distinct(entity_name) as entityName from m_permission p ";
|
||||
sql += makercheckerCapabilityOnly(useType, currentUser);
|
||||
sql += " order by if(grouping = 'datatable', 'ZZZ', entity_name), entity_name";
|
||||
EntityNamesMapper mapper2 = new EntityNamesMapper();
|
||||
List<String> entityNames = this.jdbcTemplate.query(sql, mapper2, new Object[] {});
|
||||
final EntityNamesMapper mapper2 = new EntityNamesMapper();
|
||||
final List<String> entityNames = this.jdbcTemplate.query(sql, mapper2, new Object[] {});
|
||||
|
||||
Collection<ProcessingResultLookup> processingResults = null;
|
||||
if (useType.equals("audit")) {
|
||||
ProcessingResultsMapper mapper3 = new ProcessingResultsMapper();
|
||||
final ProcessingResultsMapper mapper3 = new ProcessingResultsMapper();
|
||||
processingResults = this.jdbcTemplate.query(mapper3.schema(), mapper3, new Object[] {});
|
||||
}
|
||||
|
||||
@@ -370,8 +375,8 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
||||
|
||||
@Override
|
||||
public ProcessingResultLookup mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
||||
Long id = JdbcSupport.getLong(rs, "id");
|
||||
String processingResult = rs.getString("processingResult");
|
||||
final Long id = JdbcSupport.getLong(rs, "id");
|
||||
final String processingResult = rs.getString("processingResult");
|
||||
|
||||
return new ProcessingResultLookup(id, processingResult);
|
||||
}
|
||||
|
||||
+7
-8
@@ -490,20 +490,20 @@ public class CommandWrapperBuilder {
|
||||
this.href = "/loans/" + loanId + "/charges/" + loanChargeId;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public CommandWrapperBuilder payLoanCharge(final Long loanId, final Long loanChargeId) {
|
||||
this.actionName = "PAY";
|
||||
this.entityName = "LOANCHARGE";
|
||||
this.entityId = loanChargeId;
|
||||
this.loanId = loanId;
|
||||
if(loanChargeId == null){
|
||||
if (loanChargeId == null) {
|
||||
this.href = "/loans/" + loanId;
|
||||
}else{
|
||||
this.href = "/loans/" + loanId + "/charges/" + loanChargeId;
|
||||
} else {
|
||||
this.href = "/loans/" + loanId + "/charges/" + loanChargeId;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public CommandWrapperBuilder deleteLoanCharge(final Long loanId, final Long loanChargeId) {
|
||||
this.actionName = "DELETE";
|
||||
this.entityName = "LOANCHARGE";
|
||||
@@ -866,7 +866,6 @@ public class CommandWrapperBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public CommandWrapperBuilder createAccountTransfer() {
|
||||
this.actionName = "CREATE";
|
||||
this.entityName = "ACCOUNTTRANSFER";
|
||||
@@ -941,7 +940,7 @@ public class CommandWrapperBuilder {
|
||||
this.href = "/savingsaccounts/" + accountId + "?command=applyAnnualFees";
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public CommandWrapperBuilder createSavingsAccountCharge(final Long savingsAccountId) {
|
||||
this.actionName = "CREATE";
|
||||
this.entityName = "SAVINGSACCOUNTCHARGE";
|
||||
@@ -978,7 +977,7 @@ public class CommandWrapperBuilder {
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public CommandWrapperBuilder deleteSavingsAccountCharge(final Long savingsAccountId, final Long savingsAccountChargeId) {
|
||||
this.actionName = "DELETE";
|
||||
this.entityName = "SAVINGSACCOUNTCHARGE";
|
||||
|
||||
+6
-6
@@ -47,7 +47,7 @@ public class PortfolioCommandSourceWritePlatformServiceImpl implements Portfolio
|
||||
|
||||
boolean isApprovedByChecker = false;
|
||||
// check if is update of own account details
|
||||
if (wrapper.isUpdateOfOwnUserDetails(context.authenticatedUser().getId())) {
|
||||
if (wrapper.isUpdateOfOwnUserDetails(this.context.authenticatedUser().getId())) {
|
||||
// then allow this operation to proceed.
|
||||
// maker checker doesnt mean anything here.
|
||||
isApprovedByChecker = true; // set to true in case permissions have
|
||||
@@ -56,7 +56,7 @@ public class PortfolioCommandSourceWritePlatformServiceImpl implements Portfolio
|
||||
} else {
|
||||
// if not user changing their own details - check user has
|
||||
// permission to perform specific task.
|
||||
context.authenticatedUser().validateHasPermissionTo(wrapper.getTaskPermissionName());
|
||||
this.context.authenticatedUser().validateHasPermissionTo(wrapper.getTaskPermissionName());
|
||||
}
|
||||
validateIsUpdateAllowed();
|
||||
|
||||
@@ -70,7 +70,7 @@ public class PortfolioCommandSourceWritePlatformServiceImpl implements Portfolio
|
||||
wrapper.getTransactionId(), wrapper.getHref(), wrapper.getProductId());
|
||||
|
||||
result = this.processAndLogCommandService.processAndLogCommand(wrapper, command, isApprovedByChecker);
|
||||
} catch (RollbackTransactionAsCommandIsNotApprovedByCheckerException e) {
|
||||
} catch (final RollbackTransactionAsCommandIsNotApprovedByCheckerException e) {
|
||||
|
||||
result = this.processAndLogCommandService.logCommand(e.getCommandSourceResult());
|
||||
}
|
||||
@@ -81,7 +81,7 @@ public class PortfolioCommandSourceWritePlatformServiceImpl implements Portfolio
|
||||
@Override
|
||||
public CommandProcessingResult approveEntry(final Long makerCheckerId) {
|
||||
|
||||
CommandSource commandSourceInput = validateMakerCheckerTransaction(makerCheckerId);
|
||||
final CommandSource commandSourceInput = validateMakerCheckerTransaction(makerCheckerId);
|
||||
validateIsUpdateAllowed();
|
||||
|
||||
final CommandWrapper wrapper = CommandWrapper.fromExistingCommand(makerCheckerId, commandSourceInput.getActionName(),
|
||||
@@ -115,13 +115,13 @@ public class PortfolioCommandSourceWritePlatformServiceImpl implements Portfolio
|
||||
if (commandSourceInput == null) { throw new CommandNotFoundException(makerCheckerId); }
|
||||
if (!(commandSourceInput.isMarkedAsAwaitingApproval())) { throw new CommandNotAwaitingApprovalException(makerCheckerId); }
|
||||
|
||||
context.authenticatedUser().validateHasCheckerPermissionTo(commandSourceInput.getPermissionCode());
|
||||
this.context.authenticatedUser().validateHasCheckerPermissionTo(commandSourceInput.getPermissionCode());
|
||||
|
||||
return commandSourceInput;
|
||||
}
|
||||
|
||||
private boolean validateIsUpdateAllowed() {
|
||||
return schedulerJobRunnerReadService.isUpdatesAllowed();
|
||||
return this.schedulerJobRunnerReadService.isUpdatesAllowed();
|
||||
|
||||
}
|
||||
}
|
||||
+6
-7
@@ -111,8 +111,7 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
|
||||
} else {
|
||||
throw new UnsupportedCommandException(wrapper.commandName());
|
||||
}
|
||||
}
|
||||
else if (wrapper.isConfigurationResource()) {
|
||||
} else if (wrapper.isConfigurationResource()) {
|
||||
handler = this.applicationContext.getBean("updateGlobalConfigurationCommandHandler", NewCommandSourceHandler.class);
|
||||
} else if (wrapper.isDatatableResource()) {
|
||||
if (wrapper.isCreateDatatable()) {
|
||||
@@ -442,7 +441,7 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
|
||||
handler = this.applicationContext.getBean("paySavingsAccountChargeCommandHandler", NewCommandSourceHandler.class);
|
||||
} else {
|
||||
throw new UnsupportedCommandException(wrapper.commandName());
|
||||
}
|
||||
}
|
||||
} else if (wrapper.isCalendarResource()) {
|
||||
if (wrapper.isCreate()) {
|
||||
handler = this.applicationContext.getBean("createCalendarCommandHandler", NewCommandSourceHandler.class);
|
||||
@@ -476,7 +475,7 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
|
||||
handler = this.applicationContext.getBean("unassignRoleCommandHandler", NewCommandSourceHandler.class);
|
||||
} else if (wrapper.isUpdateGroupRole()) {
|
||||
handler = this.applicationContext.getBean("updateGroupRoleCommandHandler", NewCommandSourceHandler.class);
|
||||
} else if (wrapper.isAssignStaff()) {
|
||||
} else if (wrapper.isAssignStaff()) {
|
||||
handler = this.applicationContext.getBean("assignGroupStaffCommandHandler", NewCommandSourceHandler.class);
|
||||
} else if (wrapper.isTransferClientsBetweenGroups()) {
|
||||
handler = this.applicationContext.getBean("transferClientsBetweenGroupsCommandHandler", NewCommandSourceHandler.class);
|
||||
@@ -534,9 +533,9 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
|
||||
}
|
||||
|
||||
} else if (wrapper.isXBRLMappingResource()) {
|
||||
if (wrapper.isUpdate()) {
|
||||
handler = this.applicationContext.getBean("updateTaxonomyMappingCommandHandler", NewCommandSourceHandler.class);
|
||||
} else {
|
||||
if (wrapper.isUpdate()) {
|
||||
handler = this.applicationContext.getBean("updateTaxonomyMappingCommandHandler", NewCommandSourceHandler.class);
|
||||
} else {
|
||||
throw new UnsupportedCommandException(wrapper.commandName());
|
||||
}
|
||||
} else if (wrapper.isHolidayResource()) {
|
||||
|
||||
Vendored
+3
-3
@@ -15,8 +15,7 @@ public class CacheEnumerations {
|
||||
}
|
||||
|
||||
public static EnumOptionData cacheType(final CacheType cacheType) {
|
||||
EnumOptionData optionData = new EnumOptionData(CacheType.INVALID.getValue().longValue(), CacheType.INVALID.getCode(),
|
||||
"Invalid");
|
||||
EnumOptionData optionData = new EnumOptionData(CacheType.INVALID.getValue().longValue(), CacheType.INVALID.getCode(), "Invalid");
|
||||
switch (cacheType) {
|
||||
case INVALID:
|
||||
optionData = new EnumOptionData(CacheType.INVALID.getValue().longValue(), CacheType.INVALID.getCode(), "Invalid");
|
||||
@@ -25,7 +24,8 @@ public class CacheEnumerations {
|
||||
optionData = new EnumOptionData(CacheType.NO_CACHE.getValue().longValue(), CacheType.NO_CACHE.getCode(), "No cache");
|
||||
break;
|
||||
case SINGLE_NODE:
|
||||
optionData = new EnumOptionData(CacheType.SINGLE_NODE.getValue().longValue(), CacheType.SINGLE_NODE.getCode(), "Single node");
|
||||
optionData = new EnumOptionData(CacheType.SINGLE_NODE.getValue().longValue(), CacheType.SINGLE_NODE.getCode(),
|
||||
"Single node");
|
||||
break;
|
||||
case MULTI_NODE:
|
||||
optionData = new EnumOptionData(CacheType.MULTI_NODE.getValue().longValue(), CacheType.MULTI_NODE.getCode(), "Multi node");
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ public class CacheWritePlatformServiceJpaRepositoryImpl implements CacheWritePla
|
||||
final Map<String, Object> changes = this.cacheService.switchToCache(ehCacheEnabled, toCacheType);
|
||||
|
||||
if (!changes.isEmpty()) {
|
||||
this.configurationDomainService.updateCache(toCacheType);
|
||||
this.configurationDomainService.updateCache(toCacheType);
|
||||
}
|
||||
|
||||
return changes;
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ import org.springframework.stereotype.Component;
|
||||
/**
|
||||
* At present this implementation of {@link CacheManager} just delegates to the
|
||||
* real {@link CacheManager} to use.
|
||||
*
|
||||
*
|
||||
* By default it is {@link NoOpCacheManager} but we can change that by checking
|
||||
* some persisted configuration in the database on startup and allow user to
|
||||
* switch implementation through UI/API
|
||||
|
||||
+3
-2
@@ -11,7 +11,8 @@ import java.util.Set;
|
||||
public class CodeConstants {
|
||||
|
||||
/***
|
||||
* Enum of all parameters passed in while creating/updating a code and code value
|
||||
* Enum of all parameters passed in while creating/updating a code and code
|
||||
* value
|
||||
***/
|
||||
public static enum CODEVALUE_JSON_INPUT_PARAMS {
|
||||
CODEVALUE_ID("id"), NAME("name"), POSITION("position");
|
||||
@@ -24,7 +25,7 @@ public class CodeConstants {
|
||||
|
||||
private static final Set<String> values = new HashSet<String>();
|
||||
static {
|
||||
for (CODEVALUE_JSON_INPUT_PARAMS type : CODEVALUE_JSON_INPUT_PARAMS.values()) {
|
||||
for (final CODEVALUE_JSON_INPUT_PARAMS type : CODEVALUE_JSON_INPUT_PARAMS.values()) {
|
||||
values.add(type.value);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -77,7 +77,7 @@ public class CodeValuesApiResource {
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.toApiJsonSerializer.serialize(settings, codeValues, this.RESPONSE_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
|
||||
@GET
|
||||
@Path("{codeValueId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@@ -112,7 +112,8 @@ public class CodeValuesApiResource {
|
||||
public String updateCodeValue(@PathParam("codeId") final Long codeId, @PathParam("codeValueId") final Long codeValueId,
|
||||
final String apiRequestBodyAsJson) {
|
||||
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().updateCodeValue(codeId, codeValueId).withJson(apiRequestBodyAsJson).build();
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().updateCodeValue(codeId, codeValueId)
|
||||
.withJson(apiRequestBodyAsJson).build();
|
||||
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
|
||||
+5
-5
@@ -69,12 +69,12 @@ public class CodesApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String retrieveCodes(@Context final UriInfo uriInfo) {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions);
|
||||
this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions);
|
||||
|
||||
final Collection<CodeData> codes = this.readPlatformService.retrieveAllCodes();
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.toApiJsonSerializer.serialize(settings, codes, RESPONSE_DATA_PARAMETERS);
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.toApiJsonSerializer.serialize(settings, codes, this.RESPONSE_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
@POST
|
||||
@@ -97,8 +97,8 @@ public class CodesApiResource {
|
||||
|
||||
final CodeData code = this.readPlatformService.retrieveCode(codeId);
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.toApiJsonSerializer.serialize(settings, code, RESPONSE_DATA_PARAMETERS);
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.toApiJsonSerializer.serialize(settings, code, this.RESPONSE_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
@PUT
|
||||
|
||||
+2
-2
@@ -27,8 +27,8 @@ public class CodeData implements Serializable {
|
||||
this.name = name;
|
||||
this.systemDefined = systemDefined;
|
||||
}
|
||||
|
||||
public Long getCodeId(){
|
||||
|
||||
public Long getCodeId() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -10,7 +10,7 @@ import java.io.Serializable;
|
||||
/**
|
||||
* Immutable data object represent code-value data in system.
|
||||
*/
|
||||
public class CodeValueData implements Serializable{
|
||||
public class CodeValueData implements Serializable {
|
||||
|
||||
private final Long id;
|
||||
|
||||
@@ -35,6 +35,6 @@ public class CodeValueData implements Serializable{
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -59,7 +59,7 @@ public class Code extends AbstractPersistable<Long> {
|
||||
|
||||
public Map<String, Object> update(final JsonCommand command) {
|
||||
|
||||
if (systemDefined) { throw new SystemDefinedCodeCannotBeChangedException(); }
|
||||
if (this.systemDefined) { throw new SystemDefinedCodeCannotBeChangedException(); }
|
||||
|
||||
final Map<String, Object> actualChanges = new LinkedHashMap<String, Object>(1);
|
||||
|
||||
|
||||
+52
-64
@@ -22,85 +22,73 @@ import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.springframework.data.jpa.domain.AbstractPersistable;
|
||||
|
||||
@Entity
|
||||
@Table(name = "m_code_value", uniqueConstraints = { @UniqueConstraint(columnNames = {
|
||||
"code_id", "code_value" }, name = "code_value_duplicate") })
|
||||
@Table(name = "m_code_value", uniqueConstraints = { @UniqueConstraint(columnNames = { "code_id", "code_value" }, name = "code_value_duplicate") })
|
||||
public class CodeValue extends AbstractPersistable<Long> {
|
||||
|
||||
@Column(name = "code_value", length = 100)
|
||||
private String label;
|
||||
@Column(name = "code_value", length = 100)
|
||||
private String label;
|
||||
|
||||
@Column(name = "order_position")
|
||||
private int position;
|
||||
@Column(name = "order_position")
|
||||
private int position;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "code_id", nullable = false)
|
||||
private Code code;
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "code_id", nullable = false)
|
||||
private Code code;
|
||||
|
||||
public static CodeValue createNew(final Code code, final String label,
|
||||
final int position) {
|
||||
return new CodeValue(code, label, position);
|
||||
}
|
||||
public static CodeValue createNew(final Code code, final String label, final int position) {
|
||||
return new CodeValue(code, label, position);
|
||||
}
|
||||
|
||||
protected CodeValue() {
|
||||
//
|
||||
}
|
||||
protected CodeValue() {
|
||||
//
|
||||
}
|
||||
|
||||
private CodeValue(final Code code, final String label, final int position) {
|
||||
this.code = code;
|
||||
this.label = StringUtils.defaultIfEmpty(label, null);
|
||||
this.position = position;
|
||||
}
|
||||
private CodeValue(final Code code, final String label, final int position) {
|
||||
this.code = code;
|
||||
this.label = StringUtils.defaultIfEmpty(label, null);
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public String label() {
|
||||
return this.label;
|
||||
}
|
||||
public String label() {
|
||||
return this.label;
|
||||
}
|
||||
|
||||
public int position() {
|
||||
return this.position;
|
||||
}
|
||||
public int position() {
|
||||
return this.position;
|
||||
}
|
||||
|
||||
public static CodeValue fromJson(final Code code, final JsonCommand command) {
|
||||
public static CodeValue fromJson(final Code code, final JsonCommand command) {
|
||||
|
||||
final String label = command
|
||||
.stringValueOfParameterNamed(CODEVALUE_JSON_INPUT_PARAMS.NAME
|
||||
.getValue());
|
||||
Integer position = command
|
||||
.integerValueSansLocaleOfParameterNamed(CODEVALUE_JSON_INPUT_PARAMS.POSITION
|
||||
.getValue());
|
||||
if (position == null) {
|
||||
position = new Integer(0);
|
||||
}
|
||||
return new CodeValue(code, label, position.intValue());
|
||||
}
|
||||
final String label = command.stringValueOfParameterNamed(CODEVALUE_JSON_INPUT_PARAMS.NAME.getValue());
|
||||
Integer position = command.integerValueSansLocaleOfParameterNamed(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue());
|
||||
if (position == null) {
|
||||
position = new Integer(0);
|
||||
}
|
||||
return new CodeValue(code, label, position.intValue());
|
||||
}
|
||||
|
||||
public Map<String, Object> update(final JsonCommand command) {
|
||||
public Map<String, Object> update(final JsonCommand command) {
|
||||
|
||||
final Map<String, Object> actualChanges = new LinkedHashMap<String, Object>(
|
||||
2);
|
||||
final Map<String, Object> actualChanges = new LinkedHashMap<String, Object>(2);
|
||||
|
||||
final String labelParamName = CODEVALUE_JSON_INPUT_PARAMS.NAME
|
||||
.getValue();
|
||||
if (command.isChangeInStringParameterNamed(labelParamName, this.label)) {
|
||||
final String newValue = command
|
||||
.stringValueOfParameterNamed(labelParamName);
|
||||
actualChanges.put(labelParamName, newValue);
|
||||
this.label = StringUtils.defaultIfEmpty(newValue, null);
|
||||
}
|
||||
final String labelParamName = CODEVALUE_JSON_INPUT_PARAMS.NAME.getValue();
|
||||
if (command.isChangeInStringParameterNamed(labelParamName, this.label)) {
|
||||
final String newValue = command.stringValueOfParameterNamed(labelParamName);
|
||||
actualChanges.put(labelParamName, newValue);
|
||||
this.label = StringUtils.defaultIfEmpty(newValue, null);
|
||||
}
|
||||
|
||||
final String positionParamName = CODEVALUE_JSON_INPUT_PARAMS.POSITION
|
||||
.getValue();
|
||||
if (command.isChangeInIntegerSansLocaleParameterNamed(
|
||||
positionParamName, this.position)) {
|
||||
final Integer newValue = command
|
||||
.integerValueSansLocaleOfParameterNamed(positionParamName);
|
||||
actualChanges.put(positionParamName, newValue);
|
||||
this.position = newValue.intValue();
|
||||
}
|
||||
final String positionParamName = CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue();
|
||||
if (command.isChangeInIntegerSansLocaleParameterNamed(positionParamName, this.position)) {
|
||||
final Integer newValue = command.integerValueSansLocaleOfParameterNamed(positionParamName);
|
||||
actualChanges.put(positionParamName, newValue);
|
||||
this.position = newValue.intValue();
|
||||
}
|
||||
|
||||
return actualChanges;
|
||||
}
|
||||
return actualChanges;
|
||||
}
|
||||
|
||||
public CodeValueData toData() {
|
||||
return CodeValueData.instance(getId(), this.label, this.position);
|
||||
}
|
||||
public CodeValueData toData() {
|
||||
return CodeValueData.instance(getId(), this.label, this.position);
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -8,7 +8,8 @@ package org.mifosplatform.infrastructure.codes.exception;
|
||||
import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException;
|
||||
|
||||
/**
|
||||
* A {@link AbstractPlatformDomainRuleException} thrown when someone attempts to update or delete a system defined code.
|
||||
* A {@link AbstractPlatformDomainRuleException} thrown when someone attempts to
|
||||
* update or delete a system defined code.
|
||||
*/
|
||||
public class SystemDefinedCodeCannotBeChangedException extends AbstractPlatformDomainRuleException {
|
||||
|
||||
|
||||
+7
-7
@@ -46,14 +46,14 @@ public final class CodeCommandFromApiJsonDeserializer {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, supportedParameters);
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, this.supportedParameters);
|
||||
|
||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("code");
|
||||
|
||||
final JsonElement element = fromApiJsonHelper.parse(json);
|
||||
final JsonElement element = this.fromApiJsonHelper.parse(json);
|
||||
|
||||
final String name = fromApiJsonHelper.extractStringNamed("name", element);
|
||||
final String name = this.fromApiJsonHelper.extractStringNamed("name", element);
|
||||
baseDataValidator.reset().parameter("name").value(name).notBlank().notExceedingLengthOf(100);
|
||||
|
||||
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
||||
@@ -63,14 +63,14 @@ public final class CodeCommandFromApiJsonDeserializer {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, supportedParameters);
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, this.supportedParameters);
|
||||
|
||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("code");
|
||||
|
||||
final JsonElement element = fromApiJsonHelper.parse(json);
|
||||
if (fromApiJsonHelper.parameterExists("name", element)) {
|
||||
final String name = fromApiJsonHelper.extractStringNamed("name", element);
|
||||
final JsonElement element = this.fromApiJsonHelper.parse(json);
|
||||
if (this.fromApiJsonHelper.parameterExists("name", element)) {
|
||||
final String name = this.fromApiJsonHelper.extractStringNamed("name", element);
|
||||
baseDataValidator.reset().parameter("name").value(name).notBlank().notExceedingLengthOf(100);
|
||||
}
|
||||
|
||||
|
||||
+4
-6
@@ -56,9 +56,8 @@ public final class CodeValueCommandFromApiJsonDeserializer {
|
||||
baseDataValidator.reset().parameter(CODEVALUE_JSON_INPUT_PARAMS.NAME.getValue()).value(name).notBlank().notExceedingLengthOf(100);
|
||||
|
||||
if (this.fromApiJsonHelper.parameterExists(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue(), element)) {
|
||||
//Validate input value is a valid Integer
|
||||
this.fromApiJsonHelper.extractIntegerSansLocaleNamed(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue(),
|
||||
element);
|
||||
// Validate input value is a valid Integer
|
||||
this.fromApiJsonHelper.extractIntegerSansLocaleNamed(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue(), element);
|
||||
}
|
||||
|
||||
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
||||
@@ -82,9 +81,8 @@ public final class CodeValueCommandFromApiJsonDeserializer {
|
||||
}
|
||||
|
||||
if (this.fromApiJsonHelper.parameterExists(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue(), element)) {
|
||||
//Validate input value is a valid Integer
|
||||
this.fromApiJsonHelper.extractIntegerSansLocaleNamed(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue(),
|
||||
element);
|
||||
// Validate input value is a valid Integer
|
||||
this.fromApiJsonHelper.extractIntegerSansLocaleNamed(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue(), element);
|
||||
}
|
||||
|
||||
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
||||
|
||||
+1
-1
@@ -14,6 +14,6 @@ public interface CodeReadPlatformService {
|
||||
Collection<CodeData> retrieveAllCodes();
|
||||
|
||||
CodeData retrieveCode(Long codeId);
|
||||
|
||||
|
||||
CodeData retriveCode(String codeName);
|
||||
}
|
||||
|
||||
+6
-6
@@ -52,7 +52,7 @@ public class CodeReadPlatformServiceImpl implements CodeReadPlatformService {
|
||||
@Override
|
||||
@Cacheable(value = "codes", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat('CD')")
|
||||
public Collection<CodeData> retrieveAllCodes() {
|
||||
context.authenticatedUser();
|
||||
this.context.authenticatedUser();
|
||||
|
||||
final CodeMapper rm = new CodeMapper();
|
||||
final String sql = "select " + rm.schema() + " order by c.code_name";
|
||||
@@ -63,27 +63,27 @@ public class CodeReadPlatformServiceImpl implements CodeReadPlatformService {
|
||||
@Override
|
||||
public CodeData retrieveCode(final Long codeId) {
|
||||
try {
|
||||
context.authenticatedUser();
|
||||
this.context.authenticatedUser();
|
||||
|
||||
final CodeMapper rm = new CodeMapper();
|
||||
final String sql = "select " + rm.schema() + " where c.id = ?";
|
||||
|
||||
return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { codeId });
|
||||
} catch (EmptyResultDataAccessException e) {
|
||||
} catch (final EmptyResultDataAccessException e) {
|
||||
throw new CodeNotFoundException(codeId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodeData retriveCode(String codeName) {
|
||||
public CodeData retriveCode(final String codeName) {
|
||||
try {
|
||||
context.authenticatedUser();
|
||||
this.context.authenticatedUser();
|
||||
|
||||
final CodeMapper rm = new CodeMapper();
|
||||
final String sql = "select " + rm.schema() + " where c.code_name = ?";
|
||||
|
||||
return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { codeName });
|
||||
} catch (EmptyResultDataAccessException e) {
|
||||
} catch (final EmptyResultDataAccessException e) {
|
||||
throw new CodeNotFoundException(codeName);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -51,7 +51,7 @@ public class CodeValueReadPlatformServiceImpl implements CodeValueReadPlatformSe
|
||||
@Override
|
||||
public Collection<CodeValueData> retrieveCodeValuesByCode(final String code) {
|
||||
|
||||
context.authenticatedUser();
|
||||
this.context.authenticatedUser();
|
||||
|
||||
final CodeValueDataMapper rm = new CodeValueDataMapper();
|
||||
final String sql = "select " + rm.schema() + "where c.code_name like ? order by position";
|
||||
@@ -61,9 +61,9 @@ public class CodeValueReadPlatformServiceImpl implements CodeValueReadPlatformSe
|
||||
|
||||
@Override
|
||||
@Cacheable(value = "code_values", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat(#codeId+'cv')")
|
||||
public Collection<CodeValueData> retrieveAllCodeValues(Long codeId) {
|
||||
public Collection<CodeValueData> retrieveAllCodeValues(final Long codeId) {
|
||||
|
||||
context.authenticatedUser();
|
||||
this.context.authenticatedUser();
|
||||
|
||||
final CodeValueDataMapper rm = new CodeValueDataMapper();
|
||||
final String sql = "select " + rm.schema() + "where cv.code_id = ? order by position";
|
||||
@@ -72,9 +72,9 @@ public class CodeValueReadPlatformServiceImpl implements CodeValueReadPlatformSe
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodeValueData retrieveCodeValue(Long codeValueId) {
|
||||
public CodeValueData retrieveCodeValue(final Long codeValueId) {
|
||||
|
||||
context.authenticatedUser();
|
||||
this.context.authenticatedUser();
|
||||
|
||||
final CodeValueDataMapper rm = new CodeValueDataMapper();
|
||||
final String sql = "select " + rm.schema() + "where cv.id = ? order by position";
|
||||
|
||||
+4
-4
@@ -68,7 +68,7 @@ public class CodeValueWritePlatformServiceJpaRepositoryImpl implements CodeValue
|
||||
.withCommandId(command.commandId()) //
|
||||
.withEntityId(codeValue.getId()) //
|
||||
.build();
|
||||
} catch (DataIntegrityViolationException dve) {
|
||||
} catch (final DataIntegrityViolationException dve) {
|
||||
handleCodeValueDataIntegrityIssues(command, dve);
|
||||
return new CommandProcessingResultBuilder() //
|
||||
.withCommandId(command.commandId()) //
|
||||
@@ -115,7 +115,7 @@ public class CodeValueWritePlatformServiceJpaRepositoryImpl implements CodeValue
|
||||
.withEntityId(codeValueId) //
|
||||
.with(changes) //
|
||||
.build();
|
||||
} catch (DataIntegrityViolationException dve) {
|
||||
} catch (final DataIntegrityViolationException dve) {
|
||||
handleCodeValueDataIntegrityIssues(command, dve);
|
||||
return new CommandProcessingResultBuilder() //
|
||||
.withCommandId(command.commandId()) //
|
||||
@@ -137,7 +137,7 @@ public class CodeValueWritePlatformServiceJpaRepositoryImpl implements CodeValue
|
||||
|
||||
final CodeValue codeValueToDelete = this.codeValueRepositoryWrapper.findOneWithNotFoundDetection(codeValueId);
|
||||
|
||||
boolean removed = code.remove(codeValueToDelete);
|
||||
final boolean removed = code.remove(codeValueToDelete);
|
||||
if (removed) {
|
||||
this.codeRepository.saveAndFlush(code);
|
||||
}
|
||||
@@ -145,7 +145,7 @@ public class CodeValueWritePlatformServiceJpaRepositoryImpl implements CodeValue
|
||||
return new CommandProcessingResultBuilder() //
|
||||
.withEntityId(codeValueId) //
|
||||
.build();
|
||||
} catch (DataIntegrityViolationException dve) {
|
||||
} catch (final DataIntegrityViolationException dve) {
|
||||
logger.error(dve.getMessage(), dve);
|
||||
throw new PlatformDataIntegrityException("error.msg.code.value.unknown.data.integrity.issue",
|
||||
"Unknown data integrity issue with resource: " + dve.getMostSpecificCause().getMessage());
|
||||
|
||||
+7
-7
@@ -48,7 +48,7 @@ public class CodeWritePlatformServiceJpaRepositoryImpl implements CodeWritePlatf
|
||||
public CommandProcessingResult createCode(final JsonCommand command) {
|
||||
|
||||
try {
|
||||
context.authenticatedUser();
|
||||
this.context.authenticatedUser();
|
||||
|
||||
this.fromApiJsonDeserializer.validateForCreate(command.json());
|
||||
|
||||
@@ -56,7 +56,7 @@ public class CodeWritePlatformServiceJpaRepositoryImpl implements CodeWritePlatf
|
||||
this.codeRepository.save(code);
|
||||
|
||||
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(code.getId()).build();
|
||||
} catch (DataIntegrityViolationException dve) {
|
||||
} catch (final DataIntegrityViolationException dve) {
|
||||
handleCodeDataIntegrityIssues(command, dve);
|
||||
return CommandProcessingResult.empty();
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public class CodeWritePlatformServiceJpaRepositoryImpl implements CodeWritePlatf
|
||||
public CommandProcessingResult updateCode(final Long codeId, final JsonCommand command) {
|
||||
|
||||
try {
|
||||
context.authenticatedUser();
|
||||
this.context.authenticatedUser();
|
||||
|
||||
this.fromApiJsonDeserializer.validateForUpdate(command.json());
|
||||
|
||||
@@ -84,7 +84,7 @@ public class CodeWritePlatformServiceJpaRepositoryImpl implements CodeWritePlatf
|
||||
.withEntityId(codeId) //
|
||||
.with(changes) //
|
||||
.build();
|
||||
} catch (DataIntegrityViolationException dve) {
|
||||
} catch (final DataIntegrityViolationException dve) {
|
||||
handleCodeDataIntegrityIssues(command, dve);
|
||||
return null;
|
||||
}
|
||||
@@ -95,7 +95,7 @@ public class CodeWritePlatformServiceJpaRepositoryImpl implements CodeWritePlatf
|
||||
@CacheEvict(value = "codes", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat('cv')")
|
||||
public CommandProcessingResult deleteCode(final Long codeId) {
|
||||
|
||||
context.authenticatedUser();
|
||||
this.context.authenticatedUser();
|
||||
|
||||
final Code code = retrieveCodeBy(codeId);
|
||||
if (code.isSystemDefined()) { throw new SystemDefinedCodeCannotBeChangedException(); }
|
||||
@@ -103,7 +103,7 @@ public class CodeWritePlatformServiceJpaRepositoryImpl implements CodeWritePlatf
|
||||
try {
|
||||
this.codeRepository.delete(code);
|
||||
this.codeRepository.flush();
|
||||
} catch (DataIntegrityViolationException e) {
|
||||
} catch (final DataIntegrityViolationException e) {
|
||||
throw new PlatformDataIntegrityException("error.msg.cund.unknown.data.integrity.issue",
|
||||
"Unknown data integrity issue with resource: " + e.getMostSpecificCause());
|
||||
}
|
||||
@@ -121,7 +121,7 @@ public class CodeWritePlatformServiceJpaRepositoryImpl implements CodeWritePlatf
|
||||
* is.
|
||||
*/
|
||||
private void handleCodeDataIntegrityIssues(final JsonCommand command, final DataIntegrityViolationException dve) {
|
||||
Throwable realCause = dve.getMostSpecificCause();
|
||||
final Throwable realCause = dve.getMostSpecificCause();
|
||||
if (realCause.getMessage().contains("code_name")) {
|
||||
final String name = command.stringValueOfParameterNamed("name");
|
||||
throw new PlatformDataIntegrityException("error.msg.code.duplicate.name", "A code with name '" + name + "' already exists",
|
||||
|
||||
+5
-5
@@ -68,12 +68,12 @@ public class GlobalConfigurationApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String retrieveConfiguration(@Context final UriInfo uriInfo) {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions);
|
||||
this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions);
|
||||
|
||||
final GlobalConfigurationData configurationData = this.readPlatformService.retrieveGlobalConfiguration();
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.toApiJsonSerializer.serialize(settings, configurationData, RESPONSE_DATA_PARAMETERS);
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.toApiJsonSerializer.serialize(settings, configurationData, this.RESPONSE_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
@PUT
|
||||
@@ -81,9 +81,9 @@ public class GlobalConfigurationApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String updateConfiguration(@Context final UriInfo uriInfo) {
|
||||
|
||||
Map<String, String> configurationParameters = ApiParameterHelper.asMap(uriInfo.getQueryParameters());
|
||||
final Map<String, String> configurationParameters = ApiParameterHelper.asMap(uriInfo.getQueryParameters());
|
||||
|
||||
Map<String, Object> globalConfiguration = new HashMap<String, Object>();
|
||||
final Map<String, Object> globalConfiguration = new HashMap<String, Object>();
|
||||
globalConfiguration.put("globalConfiguration", configurationParameters);
|
||||
|
||||
final String apiRequestJson = this.toApiJsonSerializer.serialize(globalConfiguration);
|
||||
|
||||
+2
-2
@@ -11,9 +11,9 @@ package org.mifosplatform.infrastructure.configuration.data;
|
||||
public class GlobalConfigurationPropertyData {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private String name;
|
||||
private final String name;
|
||||
@SuppressWarnings("unused")
|
||||
private boolean enabled;
|
||||
private final boolean enabled;
|
||||
|
||||
public GlobalConfigurationPropertyData(final String name, final boolean enabled) {
|
||||
this.name = name;
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ public class S3CredentialsData {
|
||||
private final String accessKey;
|
||||
private final String secretKey;
|
||||
|
||||
public S3CredentialsData(String bucketName, String accessKey, String secretKey) {
|
||||
public S3CredentialsData(final String bucketName, final String accessKey, final String secretKey) {
|
||||
this.bucketName = bucketName;
|
||||
this.accessKey = accessKey;
|
||||
this.secretKey = secretKey;
|
||||
|
||||
+8
@@ -10,12 +10,20 @@ import org.mifosplatform.infrastructure.cache.domain.CacheType;
|
||||
public interface ConfigurationDomainService {
|
||||
|
||||
boolean isMakerCheckerEnabledForTask(String taskPermissionCode);
|
||||
|
||||
boolean isAmazonS3Enabled();
|
||||
|
||||
boolean isRescheduleFutureRepaymentsEnabled();
|
||||
|
||||
boolean isRescheduleRepaymentsOnHolidaysEnabled();
|
||||
|
||||
boolean allowTransactionsOnHolidayEnabled();
|
||||
|
||||
boolean allowTransactionsOnNonWorkingDayEnabled();
|
||||
|
||||
boolean isConstraintApproachEnabledForDatatables();
|
||||
|
||||
boolean isEhcacheEnabled();
|
||||
|
||||
void updateCache(CacheType cacheType);
|
||||
}
|
||||
+12
-8
@@ -7,8 +7,8 @@ package org.mifosplatform.infrastructure.configuration.domain;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.mifosplatform.infrastructure.cache.domain.CacheType;
|
||||
import org.mifosplatform.infrastructure.cache.domain.PlatformCacheRepository;
|
||||
import org.mifosplatform.infrastructure.cache.domain.PlatformCache;
|
||||
import org.mifosplatform.infrastructure.cache.domain.PlatformCacheRepository;
|
||||
import org.mifosplatform.infrastructure.configuration.exception.GlobalConfigurationPropertyNotFoundException;
|
||||
import org.mifosplatform.useradministration.domain.Permission;
|
||||
import org.mifosplatform.useradministration.domain.PermissionRepository;
|
||||
@@ -26,8 +26,7 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService
|
||||
|
||||
@Autowired
|
||||
public ConfigurationDomainServiceJpa(final PermissionRepository permissionRepository,
|
||||
final GlobalConfigurationRepository globalConfigurationRepository,
|
||||
final PlatformCacheRepository cacheTypeRepository) {
|
||||
final GlobalConfigurationRepository globalConfigurationRepository, final PlatformCacheRepository cacheTypeRepository) {
|
||||
this.permissionRepository = permissionRepository;
|
||||
this.globalConfigurationRepository = globalConfigurationRepository;
|
||||
this.cacheTypeRepository = cacheTypeRepository;
|
||||
@@ -48,20 +47,24 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAmazonS3Enabled(){
|
||||
public boolean isAmazonS3Enabled() {
|
||||
return this.globalConfigurationRepository.findOneByName("amazon-S3").isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRescheduleFutureRepaymentsEnabled() {
|
||||
final String rescheduleRepaymentsConfigurationProperty = "reschedule-future-repayments";
|
||||
final GlobalConfigurationProperty property = this.globalConfigurationRepository.findOneByName(rescheduleRepaymentsConfigurationProperty);
|
||||
final GlobalConfigurationProperty property = this.globalConfigurationRepository
|
||||
.findOneByName(rescheduleRepaymentsConfigurationProperty);
|
||||
if (property == null) { throw new GlobalConfigurationPropertyNotFoundException(rescheduleRepaymentsConfigurationProperty); }
|
||||
return property.isEnabled();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.mifosplatform.infrastructure.configuration.domain.ConfigurationDomainService#isHolidaysEnabled()
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.mifosplatform.infrastructure.configuration.domain.
|
||||
* ConfigurationDomainService#isHolidaysEnabled()
|
||||
*/
|
||||
@Override
|
||||
public boolean isRescheduleRepaymentsOnHolidaysEnabled() {
|
||||
@@ -82,7 +85,8 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService
|
||||
@Override
|
||||
public boolean allowTransactionsOnNonWorkingDayEnabled() {
|
||||
final String allowTransactionsOnNonWorkingDayProperty = "allow-transactions-on-non_workingday";
|
||||
final GlobalConfigurationProperty property = this.globalConfigurationRepository.findOneByName(allowTransactionsOnNonWorkingDayProperty);
|
||||
final GlobalConfigurationProperty property = this.globalConfigurationRepository
|
||||
.findOneByName(allowTransactionsOnNonWorkingDayProperty);
|
||||
if (property == null) { throw new GlobalConfigurationPropertyNotFoundException(allowTransactionsOnNonWorkingDayProperty); }
|
||||
return property.isEnabled();
|
||||
}
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ public class GlobalConfigurationProperty extends AbstractPersistable<Long> {
|
||||
this.name = name;
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
|
||||
public boolean isEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
+2
-2
@@ -47,8 +47,8 @@ public final class GlobalConfigurationCommandFromApiJsonDeserializer extends
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, supportedParameters);
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, this.supportedParameters);
|
||||
|
||||
return fromApiJsonHelper.fromJson(json, UpdateGlobalConfigurationCommand.class);
|
||||
return this.fromApiJsonHelper.fromJson(json, UpdateGlobalConfigurationCommand.class);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -30,16 +30,16 @@ public class ConfigurationReadPlatformServiceImpl implements ConfigurationReadPl
|
||||
this.context = context;
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
|
||||
rm = new GlobalConfigurationRowMapper();
|
||||
this.rm = new GlobalConfigurationRowMapper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GlobalConfigurationData retrieveGlobalConfiguration() {
|
||||
|
||||
context.authenticatedUser();
|
||||
this.context.authenticatedUser();
|
||||
|
||||
final String sql = "SELECT c.name, c.enabled FROM c_configuration c order by c.id";
|
||||
final List<GlobalConfigurationPropertyData> globalConfiguration = this.jdbcTemplate.query(sql, rm, new Object[] {});
|
||||
final List<GlobalConfigurationPropertyData> globalConfiguration = this.jdbcTemplate.query(sql, this.rm, new Object[] {});
|
||||
|
||||
return new GlobalConfigurationData(globalConfiguration);
|
||||
}
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ public class ExternalServicesReadPlatformServiceImpl implements ExternalServices
|
||||
private static final class S3CredentialsDataExtractor implements ResultSetExtractor<S3CredentialsData> {
|
||||
|
||||
@Override
|
||||
public S3CredentialsData extractData(ResultSet rs) throws SQLException, DataAccessException {
|
||||
public S3CredentialsData extractData(final ResultSet rs) throws SQLException, DataAccessException {
|
||||
String accessKey = null;
|
||||
String bucketName = null;
|
||||
String secretKey = null;
|
||||
|
||||
+14
-13
@@ -30,7 +30,8 @@ public class GlobalConfigurationWritePlatformServiceJpaRepositoryImpl implements
|
||||
|
||||
@Autowired
|
||||
public GlobalConfigurationWritePlatformServiceJpaRepositoryImpl(final PlatformSecurityContext context,
|
||||
final GlobalConfigurationRepository codeRepository, final GlobalConfigurationCommandFromApiJsonDeserializer fromApiJsonDeserializer) {
|
||||
final GlobalConfigurationRepository codeRepository,
|
||||
final GlobalConfigurationCommandFromApiJsonDeserializer fromApiJsonDeserializer) {
|
||||
this.context = context;
|
||||
this.repository = codeRepository;
|
||||
this.fromApiJsonDeserializer = fromApiJsonDeserializer;
|
||||
@@ -40,30 +41,30 @@ public class GlobalConfigurationWritePlatformServiceJpaRepositoryImpl implements
|
||||
@Override
|
||||
public CommandProcessingResult update(final JsonCommand command) {
|
||||
|
||||
context.authenticatedUser();
|
||||
|
||||
this.context.authenticatedUser();
|
||||
|
||||
final UpdateGlobalConfigurationCommand configurationCommand = this.fromApiJsonDeserializer.commandFromApiJson(command.json());
|
||||
|
||||
|
||||
final Map<String, Boolean> params = configurationCommand.getGlobalConfiguration();
|
||||
|
||||
|
||||
final Map<String, Object> changes = new LinkedHashMap<String, Object>(params.size());
|
||||
final Map<String, Boolean> propertiesMap = new LinkedHashMap<String, Boolean>(1);
|
||||
for (String propertyName : params.keySet()) {
|
||||
for (final String propertyName : params.keySet()) {
|
||||
final GlobalConfigurationProperty property = retrieveBy(propertyName);
|
||||
|
||||
Boolean value = params.get(propertyName);
|
||||
boolean updated = property.updateTo(value);
|
||||
|
||||
|
||||
final Boolean value = params.get(propertyName);
|
||||
final boolean updated = property.updateTo(value);
|
||||
|
||||
if (updated) {
|
||||
propertiesMap.put(propertyName, value);
|
||||
propertiesMap.put(propertyName, value);
|
||||
this.repository.save(property);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!propertiesMap.isEmpty()) {
|
||||
changes.put("globalConfiguration", propertiesMap);
|
||||
}
|
||||
|
||||
|
||||
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).with(changes).build();
|
||||
}
|
||||
|
||||
|
||||
+16
-16
@@ -58,7 +58,7 @@ public class ApiParameterHelper {
|
||||
public static boolean prettyPrint(final MultivaluedMap<String, String> queryParams) {
|
||||
boolean prettyPrint = false;
|
||||
if (queryParams.getFirst("pretty") != null) {
|
||||
String prettyPrintValue = queryParams.getFirst("pretty");
|
||||
final String prettyPrintValue = queryParams.getFirst("pretty");
|
||||
prettyPrint = "true".equalsIgnoreCase(prettyPrintValue);
|
||||
}
|
||||
return prettyPrint;
|
||||
@@ -67,7 +67,7 @@ public class ApiParameterHelper {
|
||||
public static Locale extractLocale(final MultivaluedMap<String, String> queryParams) {
|
||||
Locale locale = null;
|
||||
if (queryParams.getFirst("locale") != null) {
|
||||
String localeAsString = queryParams.getFirst("locale");
|
||||
final String localeAsString = queryParams.getFirst("locale");
|
||||
locale = JsonParserHelper.localeFromString(localeAsString);
|
||||
}
|
||||
return locale;
|
||||
@@ -76,7 +76,7 @@ public class ApiParameterHelper {
|
||||
public static boolean exportCsv(final MultivaluedMap<String, String> queryParams) {
|
||||
boolean exportCsv = false;
|
||||
if (queryParams.getFirst("exportCSV") != null) {
|
||||
String exportCsvValue = queryParams.getFirst("exportCSV");
|
||||
final String exportCsvValue = queryParams.getFirst("exportCSV");
|
||||
exportCsv = "true".equalsIgnoreCase(exportCsvValue);
|
||||
}
|
||||
return exportCsv;
|
||||
@@ -85,7 +85,7 @@ public class ApiParameterHelper {
|
||||
public static boolean exportPdf(final MultivaluedMap<String, String> queryParams) {
|
||||
boolean exportPDF = false;
|
||||
if (queryParams.getFirst("exportPDF") != null) {
|
||||
String exportPdfValue = queryParams.getFirst("exportPDF");
|
||||
final String exportPdfValue = queryParams.getFirst("exportPDF");
|
||||
exportPDF = "true".equalsIgnoreCase(exportPdfValue);
|
||||
}
|
||||
return exportPDF;
|
||||
@@ -94,7 +94,7 @@ public class ApiParameterHelper {
|
||||
public static boolean parameterType(final MultivaluedMap<String, String> queryParams) {
|
||||
boolean parameterType = false;
|
||||
if (queryParams.getFirst("parameterType") != null) {
|
||||
String parameterTypeValue = queryParams.getFirst("parameterType");
|
||||
final String parameterTypeValue = queryParams.getFirst("parameterType");
|
||||
parameterType = "true".equalsIgnoreCase(parameterTypeValue);
|
||||
}
|
||||
return parameterType;
|
||||
@@ -103,7 +103,7 @@ public class ApiParameterHelper {
|
||||
public static boolean template(final MultivaluedMap<String, String> queryParams) {
|
||||
boolean template = false;
|
||||
if (queryParams.getFirst("template") != null) {
|
||||
String prettyPrintValue = queryParams.getFirst("template");
|
||||
final String prettyPrintValue = queryParams.getFirst("template");
|
||||
template = "true".equalsIgnoreCase(prettyPrintValue);
|
||||
}
|
||||
return template;
|
||||
@@ -112,7 +112,7 @@ public class ApiParameterHelper {
|
||||
public static boolean makerCheckerable(final MultivaluedMap<String, String> queryParams) {
|
||||
boolean makerCheckerable = false;
|
||||
if (queryParams.getFirst("makerCheckerable") != null) {
|
||||
String prettyPrintValue = queryParams.getFirst("makerCheckerable");
|
||||
final String prettyPrintValue = queryParams.getFirst("makerCheckerable");
|
||||
makerCheckerable = "true".equalsIgnoreCase(prettyPrintValue);
|
||||
}
|
||||
return makerCheckerable;
|
||||
@@ -121,7 +121,7 @@ public class ApiParameterHelper {
|
||||
public static boolean includeJson(final MultivaluedMap<String, String> queryParams) {
|
||||
boolean includeJson = false;
|
||||
if (queryParams.getFirst("includeJson") != null) {
|
||||
String includeJsonValue = queryParams.getFirst("includeJson");
|
||||
final String includeJsonValue = queryParams.getFirst("includeJson");
|
||||
includeJson = "true".equalsIgnoreCase(includeJsonValue);
|
||||
}
|
||||
return includeJson;
|
||||
@@ -130,28 +130,28 @@ public class ApiParameterHelper {
|
||||
public static boolean genericResultSet(final MultivaluedMap<String, String> queryParams) {
|
||||
boolean genericResultSet = false;
|
||||
if (queryParams.getFirst("genericResultSet") != null) {
|
||||
String genericResultSetValue = queryParams.getFirst("genericResultSet");
|
||||
final String genericResultSetValue = queryParams.getFirst("genericResultSet");
|
||||
genericResultSet = "true".equalsIgnoreCase(genericResultSetValue);
|
||||
}
|
||||
return genericResultSet;
|
||||
}
|
||||
|
||||
public static boolean genericResultSetPassed(MultivaluedMap<String, String> queryParams) {
|
||||
public static boolean genericResultSetPassed(final MultivaluedMap<String, String> queryParams) {
|
||||
return queryParams.getFirst("genericResultSet") != null;
|
||||
}
|
||||
|
||||
public static String sqlEncodeString(String str) {
|
||||
String singleQuote = "'";
|
||||
String twoSingleQuotes = "''";
|
||||
public static String sqlEncodeString(final String str) {
|
||||
final String singleQuote = "'";
|
||||
final String twoSingleQuotes = "''";
|
||||
return singleQuote + StringUtils.replace(str, singleQuote, twoSingleQuotes, -1) + singleQuote;
|
||||
}
|
||||
|
||||
public static Map<String, String> asMap(MultivaluedMap<String, String> queryParameters) {
|
||||
public static Map<String, String> asMap(final MultivaluedMap<String, String> queryParameters) {
|
||||
|
||||
final Map<String, String> map = new HashMap<String, String>(queryParameters.size());
|
||||
|
||||
for (String parameterName : queryParameters.keySet()) {
|
||||
List<String> values = queryParameters.get(parameterName);
|
||||
for (final String parameterName : queryParameters.keySet()) {
|
||||
final List<String> values = queryParameters.get(parameterName);
|
||||
map.put(parameterName, values.get(0));
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ public class ApiRequestParameterHelper {
|
||||
public ApiRequestJsonSerializationSettings process(final MultivaluedMap<String, String> queryParameters,
|
||||
final Set<String> mandatoryResponseParameters) {
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(queryParameters);
|
||||
final Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(queryParameters);
|
||||
if (!responseParameters.isEmpty()) {
|
||||
responseParameters.addAll(mandatoryResponseParameters);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user