Merge pull request #601 from vishwasbabu/mifosplatform-1.10.1
Mifosplatform 1.10.1
This commit is contained in:
+87
-101
@@ -1,6 +1,5 @@
|
|||||||
package org.mifosplatform.integrationtests;
|
package org.mifosplatform.integrationtests;
|
||||||
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@@ -24,173 +23,160 @@ import com.jayway.restassured.specification.ResponseSpecification;
|
|||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public class AccountingScenarioIntegrationTest {
|
public class AccountingScenarioIntegrationTest {
|
||||||
|
|
||||||
private RequestSpecification requestSpec;
|
private RequestSpecification requestSpec;
|
||||||
private ResponseSpecification responseSpec;
|
private ResponseSpecification responseSpec;
|
||||||
|
|
||||||
private final String DATE_OF_JOINING = "01 January 2011";
|
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_REPAYMENTS = "5";
|
||||||
private final String LP_REPAYMENT_PERIOD = "2";
|
private final String LP_REPAYMENT_PERIOD = "2";
|
||||||
private final String LP_INTEREST_RATE="1";
|
private final String LP_INTEREST_RATE = "1";
|
||||||
private final String EXPECTED_DISBURSAL_DATE="04 March 2011";
|
private final String EXPECTED_DISBURSAL_DATE = "04 March 2011";
|
||||||
private final String LOAN_APPLICATION_SUBMISSION_DATE= "3 March 2011";
|
private final String LOAN_APPLICATION_SUBMISSION_DATE = "3 March 2011";
|
||||||
private final String LOAN_TERM_FREQUENCY= "10";
|
private final String LOAN_TERM_FREQUENCY = "10";
|
||||||
private final String INDIVIDUAL_LOAN = "individual";
|
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 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 REPAYMENT_AMOUNT[] = { .0f, 2200.0f, 3000.0f, 900.0f, 2000.0f, 2500.0f };
|
||||||
|
|
||||||
private final Float AMOUNT_TO_BE_WAIVE = 400.0f;
|
private final Float AMOUNT_TO_BE_WAIVE = 400.0f;
|
||||||
private LoanTransactionHelper loanTransactionHelper;
|
private LoanTransactionHelper loanTransactionHelper;
|
||||||
private AccountHelper accountHelper;
|
private AccountHelper accountHelper;
|
||||||
private JournalEntryHelper journalEntryHelper;
|
private JournalEntryHelper journalEntryHelper;
|
||||||
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
Utils.initializeRESTAssured();
|
Utils.initializeRESTAssured();
|
||||||
requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||||
requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||||
responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||||
|
|
||||||
loanTransactionHelper = new LoanTransactionHelper(requestSpec,responseSpec);
|
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
||||||
accountHelper = new AccountHelper(requestSpec, responseSpec);
|
this.accountHelper = new AccountHelper(this.requestSpec, this.responseSpec);
|
||||||
journalEntryHelper = new JournalEntryHelper(requestSpec, responseSpec);
|
this.journalEntryHelper = new JournalEntryHelper(this.requestSpec, this.responseSpec);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void checkAccountingFlow() {
|
public void checkAccountingFlow() {
|
||||||
Account assetAccount = accountHelper.createAssetAccount();
|
final Account assetAccount = this.accountHelper.createAssetAccount();
|
||||||
Account incomeAccount = accountHelper.createIncomeAccount();
|
final Account incomeAccount = this.accountHelper.createIncomeAccount();
|
||||||
Account expenseAccount= accountHelper.createExpenseAccount();
|
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);
|
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, this.DATE_OF_JOINING);
|
||||||
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);
|
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
|
||||||
|
|
||||||
loanStatusHashMap = loanTransactionHelper.approveLoan(EXPECTED_DISBURSAL_DATE, loanID);
|
loanStatusHashMap = this.loanTransactionHelper.approveLoan(this.EXPECTED_DISBURSAL_DATE, loanID);
|
||||||
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
|
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
|
||||||
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
|
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
|
||||||
|
|
||||||
loanStatusHashMap = loanTransactionHelper.disburseLoan(EXPECTED_DISBURSAL_DATE, loanID);
|
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(this.EXPECTED_DISBURSAL_DATE, loanID);
|
||||||
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
|
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
|
||||||
|
|
||||||
|
// CHECK ACCOUNT ENTRIES
|
||||||
//CHECK ACCOUNT ENTRIES
|
|
||||||
System.out.println("Entries ......");
|
System.out.println("Entries ......");
|
||||||
final float PRINCIPAL_VALUE_FOR_EACH_PERIOD = 2000.0f;
|
final float PRINCIPAL_VALUE_FOR_EACH_PERIOD = 2000.0f;
|
||||||
final float TOTAL_INTEREST =1000.0f;
|
final float TOTAL_INTEREST = 1000.0f;
|
||||||
JournalEntry[] assetAccountInitialEntry =
|
final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(TOTAL_INTEREST, JournalEntry.TransactionType.DEBIT),
|
||||||
{ new JournalEntry(TOTAL_INTEREST, JournalEntry.TransactionType.DEBIT),
|
new JournalEntry(this.LP_PRINCIPAL, JournalEntry.TransactionType.CREDIT),
|
||||||
new JournalEntry(LP_PRINCIPAL, JournalEntry.TransactionType.CREDIT),
|
new JournalEntry(this.LP_PRINCIPAL, JournalEntry.TransactionType.DEBIT), };
|
||||||
new JournalEntry(LP_PRINCIPAL, JournalEntry.TransactionType.DEBIT),
|
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.EXPECTED_DISBURSAL_DATE, assetAccountInitialEntry);
|
||||||
};
|
|
||||||
journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, EXPECTED_DISBURSAL_DATE, assetAccountInitialEntry);
|
|
||||||
System.out.println("CHECKING INCOME: ******************************************");
|
System.out.println("CHECKING INCOME: ******************************************");
|
||||||
JournalEntry incomeJournalEntry = new JournalEntry(TOTAL_INTEREST, JournalEntry.TransactionType.CREDIT);
|
final JournalEntry incomeJournalEntry = new JournalEntry(TOTAL_INTEREST, JournalEntry.TransactionType.CREDIT);
|
||||||
journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount,EXPECTED_DISBURSAL_DATE, incomeJournalEntry);
|
this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, this.EXPECTED_DISBURSAL_DATE, incomeJournalEntry);
|
||||||
|
|
||||||
//MAKE 1
|
// MAKE 1
|
||||||
System.out.println("Repayment 1 ......");
|
System.out.println("Repayment 1 ......");
|
||||||
loanTransactionHelper.makeRepayment(REPAYMENT_DATE[1], REPAYMENT_AMOUNT[1], loanID);
|
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[1], this.REPAYMENT_AMOUNT[1], loanID);
|
||||||
float FIRST_INTEREST = 200.0f;
|
final float FIRST_INTEREST = 200.0f;
|
||||||
float FIRST_PRINCIPAL = 2000.0f;
|
final float FIRST_PRINCIPAL = 2000.0f;
|
||||||
float expected_value = LP_PRINCIPAL- PRINCIPAL_VALUE_FOR_EACH_PERIOD;
|
float expected_value = this.LP_PRINCIPAL - PRINCIPAL_VALUE_FOR_EACH_PERIOD;
|
||||||
loanTransactionHelper.verifyRepaymentScheduleEntryFor(1, expected_value, loanID);
|
this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(1, expected_value, loanID);
|
||||||
JournalEntry[] assetAccountFirstEntry=
|
final JournalEntry[] assetAccountFirstEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[1], JournalEntry.TransactionType.DEBIT),
|
||||||
{ new JournalEntry(REPAYMENT_AMOUNT[1], JournalEntry.TransactionType.DEBIT),
|
new JournalEntry(FIRST_INTEREST, JournalEntry.TransactionType.CREDIT),
|
||||||
new JournalEntry(FIRST_INTEREST, JournalEntry.TransactionType.CREDIT),
|
new JournalEntry(FIRST_PRINCIPAL, JournalEntry.TransactionType.CREDIT), };
|
||||||
new JournalEntry(FIRST_PRINCIPAL, JournalEntry.TransactionType.CREDIT),
|
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[1], assetAccountFirstEntry);
|
||||||
};
|
|
||||||
journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, REPAYMENT_DATE[1],assetAccountFirstEntry);
|
|
||||||
System.out.println("Repayment 1 Done......");
|
System.out.println("Repayment 1 Done......");
|
||||||
|
|
||||||
//REPAYMENT 2
|
// REPAYMENT 2
|
||||||
System.out.println("Repayment 2 ......");
|
System.out.println("Repayment 2 ......");
|
||||||
loanTransactionHelper.makeRepayment(REPAYMENT_DATE[2], REPAYMENT_AMOUNT[2], loanID);
|
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[2], this.REPAYMENT_AMOUNT[2], loanID);
|
||||||
float SECOND_AND_THIRD_INTEREST = 400.0f;
|
final float SECOND_AND_THIRD_INTEREST = 400.0f;
|
||||||
float SECOND_PRINCIPAL = REPAYMENT_AMOUNT[2]-SECOND_AND_THIRD_INTEREST;
|
final float SECOND_PRINCIPAL = this.REPAYMENT_AMOUNT[2] - SECOND_AND_THIRD_INTEREST;
|
||||||
expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD;
|
expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD;
|
||||||
loanTransactionHelper.verifyRepaymentScheduleEntryFor(2,expected_value,loanID);
|
this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(2, expected_value, loanID);
|
||||||
JournalEntry[] assetAccountSecondEntry = { new JournalEntry(REPAYMENT_AMOUNT[2], JournalEntry.TransactionType.DEBIT),
|
final JournalEntry[] assetAccountSecondEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[2], JournalEntry.TransactionType.DEBIT),
|
||||||
new JournalEntry(SECOND_AND_THIRD_INTEREST, JournalEntry.TransactionType.CREDIT),
|
new JournalEntry(SECOND_AND_THIRD_INTEREST, JournalEntry.TransactionType.CREDIT),
|
||||||
new JournalEntry(SECOND_PRINCIPAL, JournalEntry.TransactionType.CREDIT),
|
new JournalEntry(SECOND_PRINCIPAL, JournalEntry.TransactionType.CREDIT), };
|
||||||
};
|
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[2], assetAccountSecondEntry);
|
||||||
journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, REPAYMENT_DATE[2], assetAccountSecondEntry);
|
|
||||||
System.out.println("Repayment 2 Done ......");
|
System.out.println("Repayment 2 Done ......");
|
||||||
|
|
||||||
//WAIVE INTEREST
|
// WAIVE INTEREST
|
||||||
System.out.println("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);
|
final JournalEntry waivedEntry = new JournalEntry(this.AMOUNT_TO_BE_WAIVE, JournalEntry.TransactionType.CREDIT);
|
||||||
journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, REPAYMENT_DATE[4],waivedEntry);
|
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[4], waivedEntry);
|
||||||
|
|
||||||
JournalEntry expenseJournalEntry = new JournalEntry(AMOUNT_TO_BE_WAIVE, JournalEntry.TransactionType.DEBIT);
|
final JournalEntry expenseJournalEntry = new JournalEntry(this.AMOUNT_TO_BE_WAIVE, JournalEntry.TransactionType.DEBIT);
|
||||||
journalEntryHelper.checkJournalEntryForExpenseAccount(expenseAccount, REPAYMENT_DATE[4], expenseJournalEntry);
|
this.journalEntryHelper.checkJournalEntryForExpenseAccount(expenseAccount, this.REPAYMENT_DATE[4], expenseJournalEntry);
|
||||||
System.out.println("Waive Interest Done......");
|
System.out.println("Waive Interest Done......");
|
||||||
|
|
||||||
//REPAYMENT 3
|
// REPAYMENT 3
|
||||||
System.out.println("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;
|
expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD;
|
||||||
JournalEntry[] assetAccountThirdEntry = {
|
final JournalEntry[] assetAccountThirdEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[3], JournalEntry.TransactionType.DEBIT),
|
||||||
new JournalEntry(REPAYMENT_AMOUNT[3], JournalEntry.TransactionType.DEBIT),
|
new JournalEntry(this.REPAYMENT_AMOUNT[3], JournalEntry.TransactionType.CREDIT) };
|
||||||
new JournalEntry(REPAYMENT_AMOUNT[3], JournalEntry.TransactionType.CREDIT)
|
this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(3, expected_value, loanID);
|
||||||
};
|
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[3], assetAccountThirdEntry);
|
||||||
loanTransactionHelper.verifyRepaymentScheduleEntryFor(3, expected_value, loanID);
|
|
||||||
journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, REPAYMENT_DATE[3], assetAccountThirdEntry);
|
|
||||||
System.out.println("Repayment 3 Done ......");
|
System.out.println("Repayment 3 Done ......");
|
||||||
|
|
||||||
//REPAYMENT 4
|
// REPAYMENT 4
|
||||||
System.out.println("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;
|
expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD;
|
||||||
loanTransactionHelper.verifyRepaymentScheduleEntryFor(4, expected_value, loanID);
|
this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(4, expected_value, loanID);
|
||||||
JournalEntry[] assetAccountFourthEntry = { new JournalEntry(REPAYMENT_AMOUNT[4], JournalEntry.TransactionType.DEBIT),
|
final JournalEntry[] assetAccountFourthEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[4], JournalEntry.TransactionType.DEBIT),
|
||||||
new JournalEntry(REPAYMENT_AMOUNT[4], JournalEntry.TransactionType.CREDIT)
|
new JournalEntry(this.REPAYMENT_AMOUNT[4], JournalEntry.TransactionType.CREDIT) };
|
||||||
};
|
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[4], assetAccountFourthEntry);
|
||||||
journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount,REPAYMENT_DATE[4],assetAccountFourthEntry);
|
|
||||||
System.out.println("Repayment 4 Done ......");
|
System.out.println("Repayment 4 Done ......");
|
||||||
|
|
||||||
//Repayment 5
|
// Repayment 5
|
||||||
System.out.println("Repayment 5 ......");
|
System.out.println("Repayment 5 ......");
|
||||||
JournalEntry[] assetAccountFifthEntry = { new JournalEntry(REPAYMENT_AMOUNT[5], JournalEntry.TransactionType.DEBIT),
|
final JournalEntry[] assetAccountFifthEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[5], JournalEntry.TransactionType.DEBIT),
|
||||||
new JournalEntry(REPAYMENT_AMOUNT[5], JournalEntry.TransactionType.CREDIT)
|
new JournalEntry(this.REPAYMENT_AMOUNT[5], JournalEntry.TransactionType.CREDIT) };
|
||||||
};
|
|
||||||
expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD;
|
expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD;
|
||||||
loanTransactionHelper.makeRepayment(REPAYMENT_DATE[5], REPAYMENT_AMOUNT[5], loanID);
|
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[5], this.REPAYMENT_AMOUNT[5], loanID);
|
||||||
loanTransactionHelper.verifyRepaymentScheduleEntryFor(5,expected_value,loanID);
|
this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(5, expected_value, loanID);
|
||||||
journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, REPAYMENT_DATE[5], assetAccountFifthEntry);
|
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[5], assetAccountFifthEntry);
|
||||||
System.out.println("Repayment 5 Done ......");
|
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 ---------------------------------------");
|
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
|
||||||
String loanProductJSON = new LoanProductTestBuilder().withPrincipal(LP_PRINCIPAL.toString()).withRepaymentTypeAsMonth()
|
final String loanProductJSON = new LoanProductTestBuilder().withPrincipal(this.LP_PRINCIPAL.toString()).withRepaymentTypeAsMonth()
|
||||||
.withRepaymentAfterEvery(LP_REPAYMENT_PERIOD).withNumberOfRepayments(LP_REPAYMENTS).withRepaymentTypeAsMonth()
|
.withRepaymentAfterEvery(this.LP_REPAYMENT_PERIOD).withNumberOfRepayments(this.LP_REPAYMENTS).withRepaymentTypeAsMonth()
|
||||||
.withinterestRatePerPeriod(LP_INTEREST_RATE).withInterestRateFrequencyTypeAsMonths()
|
.withinterestRatePerPeriod(this.LP_INTEREST_RATE).withInterestRateFrequencyTypeAsMonths()
|
||||||
.withAmortizationTypeAsEqualPrincipalPayment().withInterestTypeAsFlat()
|
.withAmortizationTypeAsEqualPrincipalPayment().withInterestTypeAsFlat().withAccountingRuleAsAccrualBased(accounts).build();
|
||||||
.withAccountingRuleAsAccrualBased(accounts)
|
return this.loanTransactionHelper.getLoanProductId(loanProductJSON);
|
||||||
.build();
|
|
||||||
return loanTransactionHelper.getLoanProductId(loanProductJSON);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID) {
|
private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID) {
|
||||||
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
|
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
|
||||||
String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(LP_PRINCIPAL.toString()).withLoanTermFrequency(LOAN_TERM_FREQUENCY)
|
final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(this.LP_PRINCIPAL.toString())
|
||||||
.withLoanTermFrequencyAsMonths().withNumberOfRepayments(LP_REPAYMENTS).withRepaymentEveryAfter(LP_REPAYMENT_PERIOD)
|
.withLoanTermFrequency(this.LOAN_TERM_FREQUENCY).withLoanTermFrequencyAsMonths().withNumberOfRepayments(this.LP_REPAYMENTS)
|
||||||
.withRepaymentFrequencyTypeAsMonths().withInterestRatePerPeriod(LP_INTEREST_RATE).withInterestTypeAsFlatBalance()
|
.withRepaymentEveryAfter(this.LP_REPAYMENT_PERIOD).withRepaymentFrequencyTypeAsMonths()
|
||||||
|
.withInterestRatePerPeriod(this.LP_INTEREST_RATE).withInterestTypeAsFlatBalance()
|
||||||
.withAmortizationTypeAsEqualPrincipalPayments().withInterestCalculationPeriodTypeSameAsRepaymentPeriod()
|
.withAmortizationTypeAsEqualPrincipalPayments().withInterestCalculationPeriodTypeSameAsRepaymentPeriod()
|
||||||
.withExpectedDisbursementDate(EXPECTED_DISBURSAL_DATE).withSubmittedOnDate(LOAN_APPLICATION_SUBMISSION_DATE)
|
.withExpectedDisbursementDate(this.EXPECTED_DISBURSAL_DATE).withSubmittedOnDate(this.LOAN_APPLICATION_SUBMISSION_DATE)
|
||||||
.withLoanType(INDIVIDUAL_LOAN)
|
.withLoanType(this.INDIVIDUAL_LOAN).build(clientID.toString(), loanProductID.toString());
|
||||||
.build(clientID.toString(), loanProductID.toString());
|
return this.loanTransactionHelper.getLoanId(loanApplicationJSON);
|
||||||
return loanTransactionHelper.getLoanId(loanApplicationJSON);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+14
-13
@@ -34,27 +34,28 @@ public class ClientLoanIntegrationTest {
|
|||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
Utils.initializeRESTAssured();
|
Utils.initializeRESTAssured();
|
||||||
requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||||
requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||||
responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void checkClientLoanCreateAndDisburseFlow() {
|
public void checkClientLoanCreateAndDisburseFlow() {
|
||||||
loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec);
|
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
||||||
|
|
||||||
Integer clientID = ClientHelper.createClient(requestSpec, responseSpec);
|
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||||
ClientHelper.verifyClientCreatedOnServer(requestSpec, responseSpec, clientID);
|
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID);
|
||||||
Integer loanProductID = createLoanProduct();
|
final Integer loanProductID = createLoanProduct();
|
||||||
Integer loanID = applyForLoanApplication(clientID, loanProductID);
|
final Integer loanID = applyForLoanApplication(clientID, loanProductID);
|
||||||
ArrayList<HashMap> loanSchedule = loanTransactionHelper.getLoanRepaymentSchedule(requestSpec, responseSpec, loanID);
|
final ArrayList<HashMap> loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec,
|
||||||
|
loanID);
|
||||||
verifyLoanRepaymentSchedule(loanSchedule);
|
verifyLoanRepaymentSchedule(loanSchedule);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Integer createLoanProduct() {
|
private Integer createLoanProduct() {
|
||||||
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
|
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
|
||||||
String loanProductJSON = new LoanProductTestBuilder() //
|
final String loanProductJSON = new LoanProductTestBuilder() //
|
||||||
.withPrincipal("12,000.00") //
|
.withPrincipal("12,000.00") //
|
||||||
.withNumberOfRepayments("4") //
|
.withNumberOfRepayments("4") //
|
||||||
.withRepaymentAfterEvery("1") //
|
.withRepaymentAfterEvery("1") //
|
||||||
@@ -64,12 +65,12 @@ public class ClientLoanIntegrationTest {
|
|||||||
.withAmortizationTypeAsEqualInstallments() //
|
.withAmortizationTypeAsEqualInstallments() //
|
||||||
.withInterestTypeAsDecliningBalance() //
|
.withInterestTypeAsDecliningBalance() //
|
||||||
.build();
|
.build();
|
||||||
return loanTransactionHelper.getLoanProductId(loanProductJSON);
|
return this.loanTransactionHelper.getLoanProductId(loanProductJSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID) {
|
private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID) {
|
||||||
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
|
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
|
||||||
String loanApplicationJSON = new LoanApplicationTestBuilder() //
|
final String loanApplicationJSON = new LoanApplicationTestBuilder() //
|
||||||
.withPrincipal("12,000.00") //
|
.withPrincipal("12,000.00") //
|
||||||
.withLoanTermFrequency("4") //
|
.withLoanTermFrequency("4") //
|
||||||
.withLoanTermFrequencyAsMonths() //
|
.withLoanTermFrequencyAsMonths() //
|
||||||
@@ -83,7 +84,7 @@ public class ClientLoanIntegrationTest {
|
|||||||
.withExpectedDisbursementDate("20 September 2011") //
|
.withExpectedDisbursementDate("20 September 2011") //
|
||||||
.withSubmittedOnDate("20 September 2011") //
|
.withSubmittedOnDate("20 September 2011") //
|
||||||
.build(clientID.toString(), loanProductID.toString());
|
.build(clientID.toString(), loanProductID.toString());
|
||||||
return loanTransactionHelper.getLoanId(loanApplicationJSON);
|
return this.loanTransactionHelper.getLoanId(loanApplicationJSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyLoanRepaymentSchedule(final ArrayList<HashMap> loanSchedule) {
|
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;
|
import com.jayway.restassured.specification.ResponseSpecification;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Group Loan Integration Test for checking Loan Application Repayment
|
* Group Loan Integration Test for checking Loan Application Repayment Schedule.
|
||||||
* Schedule.
|
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||||
public class GroupLoanIntegrationTest {
|
public class GroupLoanIntegrationTest {
|
||||||
@@ -35,29 +34,30 @@ public class GroupLoanIntegrationTest {
|
|||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
Utils.initializeRESTAssured();
|
Utils.initializeRESTAssured();
|
||||||
requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||||
requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||||
responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void checkGroupLoanCreateAndDisburseFlow() {
|
public void checkGroupLoanCreateAndDisburseFlow() {
|
||||||
loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec);
|
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
||||||
|
|
||||||
Integer clientID = ClientHelper.createClient(requestSpec, responseSpec);
|
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||||
Integer groupID = GroupHelper.createGroup(requestSpec, responseSpec, true);
|
Integer groupID = GroupHelper.createGroup(this.requestSpec, this.responseSpec, true);
|
||||||
groupID = GroupHelper.associateClient(requestSpec, responseSpec, groupID.toString(),clientID.toString());
|
groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(), clientID.toString());
|
||||||
|
|
||||||
Integer loanProductID = createLoanProduct();
|
final Integer loanProductID = createLoanProduct();
|
||||||
Integer loanID = applyForLoanApplication(groupID, loanProductID);
|
final Integer loanID = applyForLoanApplication(groupID, loanProductID);
|
||||||
ArrayList<HashMap> loanSchedule = loanTransactionHelper.getLoanRepaymentSchedule(requestSpec, responseSpec, loanID);
|
final ArrayList<HashMap> loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec,
|
||||||
|
loanID);
|
||||||
verifyLoanRepaymentSchedule(loanSchedule);
|
verifyLoanRepaymentSchedule(loanSchedule);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Integer createLoanProduct() {
|
private Integer createLoanProduct() {
|
||||||
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
|
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
|
||||||
String loanProductJSON = new LoanProductTestBuilder() //
|
final String loanProductJSON = new LoanProductTestBuilder() //
|
||||||
.withPrincipal("12,000.00") //
|
.withPrincipal("12,000.00") //
|
||||||
.withNumberOfRepayments("4") //
|
.withNumberOfRepayments("4") //
|
||||||
.withRepaymentAfterEvery("1") //
|
.withRepaymentAfterEvery("1") //
|
||||||
@@ -67,12 +67,12 @@ public class GroupLoanIntegrationTest {
|
|||||||
.withAmortizationTypeAsEqualInstallments() //
|
.withAmortizationTypeAsEqualInstallments() //
|
||||||
.withInterestTypeAsDecliningBalance() //
|
.withInterestTypeAsDecliningBalance() //
|
||||||
.build();
|
.build();
|
||||||
return loanTransactionHelper.getLoanProductId(loanProductJSON);
|
return this.loanTransactionHelper.getLoanProductId(loanProductJSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Integer applyForLoanApplication(final Integer groupID, final Integer loanProductID) {
|
private Integer applyForLoanApplication(final Integer groupID, final Integer loanProductID) {
|
||||||
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
|
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
|
||||||
String loanApplicationJSON = new LoanApplicationTestBuilder() //
|
final String loanApplicationJSON = new LoanApplicationTestBuilder() //
|
||||||
.withPrincipal("12,000.00") //
|
.withPrincipal("12,000.00") //
|
||||||
.withLoanTermFrequency("4") //
|
.withLoanTermFrequency("4") //
|
||||||
.withLoanTermFrequencyAsMonths() //
|
.withLoanTermFrequencyAsMonths() //
|
||||||
@@ -85,10 +85,9 @@ public class GroupLoanIntegrationTest {
|
|||||||
.withInterestCalculationPeriodTypeSameAsRepaymentPeriod() //
|
.withInterestCalculationPeriodTypeSameAsRepaymentPeriod() //
|
||||||
.withExpectedDisbursementDate("20 September 2011") //
|
.withExpectedDisbursementDate("20 September 2011") //
|
||||||
.withSubmittedOnDate("20 September 2011") //
|
.withSubmittedOnDate("20 September 2011") //
|
||||||
.withLoanType("group")
|
.withLoanType("group").build(groupID.toString(), loanProductID.toString());
|
||||||
.build(groupID.toString(), loanProductID.toString());
|
|
||||||
System.out.println(loanApplicationJSON);
|
System.out.println(loanApplicationJSON);
|
||||||
return loanTransactionHelper.getLoanId(loanApplicationJSON);
|
return this.loanTransactionHelper.getLoanId(loanApplicationJSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyLoanRepaymentSchedule(final ArrayList<HashMap> loanSchedule) {
|
private void verifyLoanRepaymentSchedule(final ArrayList<HashMap> loanSchedule) {
|
||||||
|
|||||||
+18
-18
@@ -24,32 +24,32 @@ public class GroupTest {
|
|||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
Utils.initializeRESTAssured();
|
Utils.initializeRESTAssured();
|
||||||
requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||||
requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||||
responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void checkGroupFunctions() {
|
public void checkGroupFunctions() {
|
||||||
Integer clientID = ClientHelper.createClient(requestSpec, responseSpec);
|
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||||
Integer groupID = GroupHelper.createGroup(requestSpec, responseSpec);
|
Integer groupID = GroupHelper.createGroup(this.requestSpec, this.responseSpec);
|
||||||
GroupHelper.verifyGroupCreatedOnServer(requestSpec, responseSpec, groupID);
|
GroupHelper.verifyGroupCreatedOnServer(this.requestSpec, this.responseSpec, groupID);
|
||||||
|
|
||||||
groupID = GroupHelper.activateGroup(requestSpec, responseSpec, groupID.toString());
|
groupID = GroupHelper.activateGroup(this.requestSpec, this.responseSpec, groupID.toString());
|
||||||
GroupHelper.verifyGroupActivatedOnServer(requestSpec, responseSpec, groupID, true);
|
GroupHelper.verifyGroupActivatedOnServer(this.requestSpec, this.responseSpec, groupID, true);
|
||||||
|
|
||||||
groupID = GroupHelper.associateClient(requestSpec, responseSpec, groupID.toString(), clientID.toString());
|
groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(), clientID.toString());
|
||||||
GroupHelper.verifyGroupMembers(requestSpec, responseSpec, groupID, clientID);
|
GroupHelper.verifyGroupMembers(this.requestSpec, this.responseSpec, groupID, clientID);
|
||||||
|
|
||||||
groupID = GroupHelper.disAssociateClient(requestSpec, responseSpec, groupID.toString(), clientID.toString());
|
groupID = GroupHelper.disAssociateClient(this.requestSpec, this.responseSpec, groupID.toString(), clientID.toString());
|
||||||
GroupHelper.verifyEmptyGroupMembers(requestSpec, responseSpec, groupID);
|
GroupHelper.verifyEmptyGroupMembers(this.requestSpec, this.responseSpec, groupID);
|
||||||
|
|
||||||
String updatedGroupName = GroupHelper.randomNameGenerator("Group-", 5);
|
final String updatedGroupName = GroupHelper.randomNameGenerator("Group-", 5);
|
||||||
groupID = GroupHelper.updateGroup(requestSpec, responseSpec, updatedGroupName, groupID.toString());
|
groupID = GroupHelper.updateGroup(this.requestSpec, this.responseSpec, updatedGroupName, groupID.toString());
|
||||||
GroupHelper.verifyGroupDetails(requestSpec, responseSpec, groupID, "name", updatedGroupName);
|
GroupHelper.verifyGroupDetails(this.requestSpec, this.responseSpec, groupID, "name", updatedGroupName);
|
||||||
|
|
||||||
groupID = GroupHelper.createGroup(requestSpec, responseSpec);
|
groupID = GroupHelper.createGroup(this.requestSpec, this.responseSpec);
|
||||||
GroupHelper.deleteGroup(requestSpec, responseSpec, groupID.toString());
|
GroupHelper.deleteGroup(this.requestSpec, this.responseSpec, groupID.toString());
|
||||||
GroupHelper.verifyGroupDeleted(requestSpec, responseSpec, groupID);
|
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;
|
import com.jayway.restassured.specification.ResponseSpecification;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Client Loan Integration Test for checking Loan Disbursement with Waive
|
* Client Loan Integration Test for checking Loan Disbursement with Waive
|
||||||
* Interest and Write-Off.
|
* Interest and Write-Off.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({ "rawtypes" })
|
@SuppressWarnings({ "rawtypes" })
|
||||||
public class LoanWithWaiveInterestAndWriteOffIntegrationTest {
|
public class LoanWithWaiveInterestAndWriteOffIntegrationTest {
|
||||||
|
|
||||||
@@ -28,107 +28,108 @@ public class LoanWithWaiveInterestAndWriteOffIntegrationTest {
|
|||||||
private RequestSpecification requestSpec;
|
private RequestSpecification requestSpec;
|
||||||
|
|
||||||
private final String LP_PRINCIPAL = "12,000.00", LP_REPAYMENTS = "2", LP_REPAYMENT_PERIOD = "6", LP_INTEREST_RATE = "1",
|
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",
|
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",
|
DISBURSEMENT_DATE = "30 October 2010", LOAN_APPLICATION_SUBMISSION_DATE = "23 September 2010",
|
||||||
EXPECTED_DISBURSAL_DATE = "28 October 2010", RATE_OF_INTEREST_PER_PERIOD = "2",
|
EXPECTED_DISBURSAL_DATE = "28 October 2010", RATE_OF_INTEREST_PER_PERIOD = "2", DATE_OF_JOINING = "04 March 2009",
|
||||||
DATE_OF_JOINING = "04 March 2009",INTEREST_VALUE_AMOUNT = "40.00";
|
INTEREST_VALUE_AMOUNT = "40.00";
|
||||||
private LoanTransactionHelper loanTransactionHelper;
|
private LoanTransactionHelper loanTransactionHelper;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
Utils.initializeRESTAssured();
|
Utils.initializeRESTAssured();
|
||||||
requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||||
requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||||
responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||||
loanTransactionHelper = new LoanTransactionHelper(requestSpec,responseSpec);
|
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void checkClientLoanCreateAndDisburseFlow() {
|
public void checkClientLoanCreateAndDisburseFlow() {
|
||||||
// CREATE CLIENT
|
// CREATE CLIENT
|
||||||
Integer clientID = ClientHelper.createClient(requestSpec, responseSpec, DATE_OF_JOINING);
|
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, this.DATE_OF_JOINING);
|
||||||
ClientHelper.verifyClientCreatedOnServer(requestSpec, responseSpec, clientID);
|
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID);
|
||||||
|
|
||||||
// CREATE LOAN PRODUCT
|
// CREATE LOAN PRODUCT
|
||||||
Integer loanProductID = createLoanProduct();
|
final Integer loanProductID = createLoanProduct();
|
||||||
// APPLY FOR LOAN
|
// 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);
|
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
|
||||||
|
|
||||||
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------");
|
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------");
|
||||||
loanStatusHashMap = loanTransactionHelper.approveLoan("28 September 2010", loanID);
|
loanStatusHashMap = this.loanTransactionHelper.approveLoan("28 September 2010", loanID);
|
||||||
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
|
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
|
||||||
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
|
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
|
||||||
|
|
||||||
// UNDO APPROVAL
|
// UNDO APPROVAL
|
||||||
loanStatusHashMap = loanTransactionHelper.undoApproval(loanID);
|
loanStatusHashMap = this.loanTransactionHelper.undoApproval(loanID);
|
||||||
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
|
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
|
||||||
|
|
||||||
System.out.println("-----------------------------------RE-APPROVE LOAN-----------------------------------------");
|
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.verifyLoanIsApproved(loanStatusHashMap);
|
||||||
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
|
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
|
||||||
|
|
||||||
// DISBURSE
|
// DISBURSE
|
||||||
loanStatusHashMap = loanTransactionHelper.disburseLoan(DISBURSEMENT_DATE, loanID);
|
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(this.DISBURSEMENT_DATE, loanID);
|
||||||
System.out.println("DISBURSE " + loanStatusHashMap);
|
System.out.println("DISBURSE " + loanStatusHashMap);
|
||||||
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
|
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
|
||||||
|
|
||||||
// PERFORM REPAYMENTS AND CHECK LOAN STATUS
|
// PERFORM REPAYMENTS AND CHECK LOAN STATUS
|
||||||
loanTransactionHelper.verifyRepaymentScheduleEntryFor(1, 4000.0F, loanID);
|
this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(1, 4000.0F, loanID);
|
||||||
loanTransactionHelper.makeRepayment("1 January 2011", 540.0f, loanID);
|
this.loanTransactionHelper.makeRepayment("1 January 2011", 540.0f, loanID);
|
||||||
|
|
||||||
//UNDO DISBURSE LOAN
|
// UNDO DISBURSE LOAN
|
||||||
loanStatusHashMap=loanTransactionHelper.undoDisbursal(loanID);
|
loanStatusHashMap = this.loanTransactionHelper.undoDisbursal(loanID);
|
||||||
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
|
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
|
||||||
|
|
||||||
//DIBURSE AGAIN
|
// DIBURSE AGAIN
|
||||||
loanStatusHashMap = loanTransactionHelper.disburseLoan(DISBURSEMENT_DATE, loanID);
|
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(this.DISBURSEMENT_DATE, loanID);
|
||||||
System.out.println("DISBURSE " + loanStatusHashMap);
|
System.out.println("DISBURSE " + loanStatusHashMap);
|
||||||
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
|
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
|
||||||
|
|
||||||
//MAKE REPAYMENTS
|
// MAKE REPAYMENTS
|
||||||
final float repayment_with_interest = 540.0f;
|
final float repayment_with_interest = 540.0f;
|
||||||
final float repayment_without_interest = 500.0f;
|
final float repayment_without_interest = 500.0f;
|
||||||
|
|
||||||
loanTransactionHelper.verifyRepaymentScheduleEntryFor(1, 4000.0F, loanID);
|
this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(1, 4000.0F, loanID);
|
||||||
loanTransactionHelper.makeRepayment("1 January 2011",repayment_with_interest, loanID);
|
this.loanTransactionHelper.makeRepayment("1 January 2011", repayment_with_interest, loanID);
|
||||||
loanTransactionHelper.makeRepayment("1 March 2011", repayment_with_interest, loanID);
|
this.loanTransactionHelper.makeRepayment("1 March 2011", repayment_with_interest, loanID);
|
||||||
loanTransactionHelper.waiveInterest("1 May 2011", INTEREST_VALUE_AMOUNT, loanID);
|
this.loanTransactionHelper.waiveInterest("1 May 2011", this.INTEREST_VALUE_AMOUNT, loanID);
|
||||||
loanTransactionHelper.makeRepayment("1 May 2011", repayment_without_interest, loanID);
|
this.loanTransactionHelper.makeRepayment("1 May 2011", repayment_without_interest, loanID);
|
||||||
loanTransactionHelper.makeRepayment("1 July 2011", repayment_with_interest, loanID);
|
this.loanTransactionHelper.makeRepayment("1 July 2011", repayment_with_interest, loanID);
|
||||||
loanTransactionHelper.waiveInterest("1 September 2011", INTEREST_VALUE_AMOUNT, loanID);
|
this.loanTransactionHelper.waiveInterest("1 September 2011", this.INTEREST_VALUE_AMOUNT, loanID);
|
||||||
loanTransactionHelper.makeRepayment("1 September 2011", repayment_without_interest, loanID);
|
this.loanTransactionHelper.makeRepayment("1 September 2011", repayment_without_interest, loanID);
|
||||||
loanTransactionHelper.makeRepayment("1 November 2011", repayment_with_interest, loanID);
|
this.loanTransactionHelper.makeRepayment("1 November 2011", repayment_with_interest, loanID);
|
||||||
loanTransactionHelper.waiveInterest("1 January 2012", INTEREST_VALUE_AMOUNT, loanID);
|
this.loanTransactionHelper.waiveInterest("1 January 2012", this.INTEREST_VALUE_AMOUNT, loanID);
|
||||||
loanTransactionHelper.makeRepayment("1 January 2012", repayment_without_interest, loanID);
|
this.loanTransactionHelper.makeRepayment("1 January 2012", repayment_without_interest, loanID);
|
||||||
loanTransactionHelper.verifyRepaymentScheduleEntryFor(7, 1000.0f, loanID);
|
this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(7, 1000.0f, loanID);
|
||||||
|
|
||||||
// WRITE OFF LOAN AND CHECK ACCOUNT IS CLOSED
|
// 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() {
|
private Integer createLoanProduct() {
|
||||||
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
|
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
|
||||||
String loanProductJSON = new LoanProductTestBuilder().withPrincipal(LP_PRINCIPAL).withRepaymentTypeAsMonth()
|
final String loanProductJSON = new LoanProductTestBuilder().withPrincipal(this.LP_PRINCIPAL).withRepaymentTypeAsMonth()
|
||||||
.withRepaymentAfterEvery(LP_REPAYMENT_PERIOD).withNumberOfRepayments(LP_REPAYMENTS).withRepaymentTypeAsMonth()
|
.withRepaymentAfterEvery(this.LP_REPAYMENT_PERIOD).withNumberOfRepayments(this.LP_REPAYMENTS).withRepaymentTypeAsMonth()
|
||||||
.withinterestRatePerPeriod(LP_INTEREST_RATE).withInterestRateFrequencyTypeAsMonths()
|
.withinterestRatePerPeriod(this.LP_INTEREST_RATE).withInterestRateFrequencyTypeAsMonths()
|
||||||
.withAmortizationTypeAsEqualPrincipalPayment().withInterestTypeAsFlat().build();
|
.withAmortizationTypeAsEqualPrincipalPayment().withInterestTypeAsFlat().build();
|
||||||
|
|
||||||
return loanTransactionHelper.getLoanProductId(loanProductJSON);
|
return this.loanTransactionHelper.getLoanProductId(loanProductJSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID) {
|
private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID) {
|
||||||
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
|
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
|
||||||
String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(PRINCIPAL).withLoanTermFrequency(LOAN_TERM_FREQUENCY)
|
final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(this.PRINCIPAL)
|
||||||
.withLoanTermFrequencyAsMonths().withNumberOfRepayments(NUMBER_OF_REPAYMENTS).withRepaymentEveryAfter(REPAYMENT_PERIOD)
|
.withLoanTermFrequency(this.LOAN_TERM_FREQUENCY).withLoanTermFrequencyAsMonths()
|
||||||
.withRepaymentFrequencyTypeAsMonths().withInterestRatePerPeriod(RATE_OF_INTEREST_PER_PERIOD).withInterestTypeAsFlatBalance()
|
.withNumberOfRepayments(this.NUMBER_OF_REPAYMENTS).withRepaymentEveryAfter(this.REPAYMENT_PERIOD)
|
||||||
.withAmortizationTypeAsEqualInstallments().withInterestCalculationPeriodTypeSameAsRepaymentPeriod()
|
.withRepaymentFrequencyTypeAsMonths().withInterestRatePerPeriod(this.RATE_OF_INTEREST_PER_PERIOD)
|
||||||
.withExpectedDisbursementDate(EXPECTED_DISBURSAL_DATE).withSubmittedOnDate(LOAN_APPLICATION_SUBMISSION_DATE)
|
.withInterestTypeAsFlatBalance().withAmortizationTypeAsEqualInstallments()
|
||||||
.build(clientID.toString(), loanProductID.toString());
|
.withInterestCalculationPeriodTypeSameAsRepaymentPeriod().withExpectedDisbursementDate(this.EXPECTED_DISBURSAL_DATE)
|
||||||
return loanTransactionHelper.getLoanId(loanApplicationJSON);
|
.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
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
Utils.initializeRESTAssured();
|
Utils.initializeRESTAssured();
|
||||||
requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||||
requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||||
responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||||
|
|
||||||
loanTransactionHelper = new LoanTransactionHelper(requestSpec, responseSpec);
|
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void loanWithdrawnByApplicant() {
|
public void loanWithdrawnByApplicant() {
|
||||||
Integer clientID = ClientHelper.createClient(requestSpec, responseSpec, "01 January 2012");
|
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2012");
|
||||||
Integer loanProductID = loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder().build());
|
final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder().build());
|
||||||
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);
|
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
|
||||||
|
|
||||||
loanTransactionHelper.withdrawLoanApplicationByClient("03 April 2012", loanID);
|
this.loanTransactionHelper.withdrawLoanApplicationByClient("03 April 2012", loanID);
|
||||||
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(requestSpec, responseSpec, loanID);
|
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
|
||||||
LoanStatusChecker.verifyLoanAccountIsNotActive(loanStatusHashMap);
|
LoanStatusChecker.verifyLoanAccountIsNotActive(loanStatusHashMap);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID) {
|
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")
|
.withLoanTermFrequencyAsMonths().withNumberOfRepayments("5").withRepaymentEveryAfter("1")
|
||||||
.withRepaymentFrequencyTypeAsMonths().withInterestRatePerPeriod("2").withExpectedDisbursementDate("04 April 2012")
|
.withRepaymentFrequencyTypeAsMonths().withInterestRatePerPeriod("2").withExpectedDisbursementDate("04 April 2012")
|
||||||
.withSubmittedOnDate("02 April 2012").build(clientID.toString(), loanProductID.toString());
|
.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
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
Utils.initializeRESTAssured();
|
Utils.initializeRESTAssured();
|
||||||
requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||||
requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||||
responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldRetrieveTaxonomyList() {
|
public void shouldRetrieveTaxonomyList() {
|
||||||
xbrlHelper = new XBRLIntegrationTestHelper(requestSpec, responseSpec);
|
this.xbrlHelper = new XBRLIntegrationTestHelper(this.requestSpec, this.responseSpec);
|
||||||
|
|
||||||
ArrayList<HashMap> taxonomyList = xbrlHelper.getTaxonomyList();
|
final ArrayList<HashMap> taxonomyList = this.xbrlHelper.getTaxonomyList();
|
||||||
this.verifyTaxonomyList(taxonomyList);
|
verifyTaxonomyList(taxonomyList);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyTaxonomyList(ArrayList<HashMap> taxonomyList) {
|
private void verifyTaxonomyList(final ArrayList<HashMap> taxonomyList) {
|
||||||
System.out.println("--------------------VERIFYING TAXONOMY LIST--------------------------");
|
System.out.println("--------------------VERIFYING TAXONOMY LIST--------------------------");
|
||||||
assertEquals("Checking for the 1st taxonomy", "AdministrativeExpense", taxonomyList.get(0).get("name"));
|
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) {
|
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("officeId", "1");
|
||||||
map.put("firstname", randomNameGenerator("Client_FirstName_", 5));
|
map.put("firstname", randomNameGenerator("Client_FirstName_", 5));
|
||||||
map.put("lastname", randomNameGenerator("Client_LastName_", 4));
|
map.put("lastname", randomNameGenerator("Client_LastName_", 4));
|
||||||
@@ -39,9 +39,9 @@ public class ClientHelper {
|
|||||||
public static void verifyClientCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
public static void verifyClientCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||||
final Integer generatedClientID) {
|
final Integer generatedClientID) {
|
||||||
System.out.println("------------------------------CHECK CLIENT DETAILS------------------------------------\n");
|
System.out.println("------------------------------CHECK CLIENT DETAILS------------------------------------\n");
|
||||||
String CLIENT_URL = "/mifosng-provider/api/v1/clients/" + generatedClientID + "?tenantIdentifier=default";
|
final String CLIENT_URL = "/mifosng-provider/api/v1/clients/" + generatedClientID + "?tenantIdentifier=default";
|
||||||
Integer responseClientID = Utils.performServerGet(requestSpec, responseSpec, CLIENT_URL, "id");
|
final Integer responseClientID = Utils.performServerGet(requestSpec, responseSpec, CLIENT_URL, "id");
|
||||||
assertEquals("ERROR IN CREATING THE CLIENT",generatedClientID, responseClientID);
|
assertEquals("ERROR IN CREATING THE CLIENT", generatedClientID, responseClientID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String randomNameGenerator(final String prefix, final int lenOfRandomSuffix) {
|
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,
|
public static Integer associateClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||||
final String groupId, final String clientMember) {
|
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---------------------------------------------");
|
System.out.println("---------------------------------Associate Client To A GROUP---------------------------------------------");
|
||||||
return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSOCIATE_URL, associateClientAsJSON(clientMember), "groupId");
|
return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSOCIATE_URL, associateClientAsJSON(clientMember), "groupId");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Integer disAssociateClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
public static Integer disAssociateClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||||
final String groupId, final String clientMember) {
|
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---------------------------------------------");
|
System.out.println("---------------------------------Disassociate Client To A GROUP---------------------------------------------");
|
||||||
return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSOCIATE_URL, associateClientAsJSON(clientMember), "groupId");
|
return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSOCIATE_URL, associateClientAsJSON(clientMember), "groupId");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Integer activateGroup(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
public static Integer activateGroup(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||||
final String groupId) {
|
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---------------------------------------------");
|
System.out.println("---------------------------------Activate A GROUP---------------------------------------------");
|
||||||
return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSOCIATE_URL, activateGroupAsJSON(""), "groupId");
|
return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSOCIATE_URL, activateGroupAsJSON(""), "groupId");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Integer updateGroup(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String name,
|
public static Integer updateGroup(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String name,
|
||||||
final String groupId) {
|
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---------------------------------------------");
|
System.out.println("---------------------------------UPDATE GROUP---------------------------------------------");
|
||||||
return Utils.performServerPut(requestSpec, responseSpec, GROUP_ASSOCIATE_URL, updateGroupAsJSON(name), "groupId");
|
return Utils.performServerPut(requestSpec, responseSpec, GROUP_ASSOCIATE_URL, updateGroupAsJSON(name), "groupId");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Integer deleteGroup(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String 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---------------------------------------------");
|
System.out.println("---------------------------------DELETE GROUP---------------------------------------------");
|
||||||
return Utils.performServerDelete(requestSpec, responseSpec, GROUP_ASSOCIATE_URL, "groupId");
|
return Utils.performServerDelete(requestSpec, responseSpec, GROUP_ASSOCIATE_URL, "groupId");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getTestGroupAsJSON(final boolean active, final String activationDate) {
|
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("officeId", "1");
|
||||||
map.put("name", randomNameGenerator("Group_Name_", 5));
|
map.put("name", randomNameGenerator("Group_Name_", 5));
|
||||||
map.put("externalId", randomIDGenerator("ID_", 7));
|
map.put("externalId", randomIDGenerator("ID_", 7));
|
||||||
@@ -77,16 +79,17 @@ public class GroupHelper {
|
|||||||
map.put("dateFormat", "dd MMMM yyyy");
|
map.put("dateFormat", "dd MMMM yyyy");
|
||||||
map.put("locale", "en");
|
map.put("locale", "en");
|
||||||
map.put("activationDate", activationDate);
|
map.put("activationDate", activationDate);
|
||||||
} else
|
} else {
|
||||||
map.put("active", "false");
|
map.put("active", "false");
|
||||||
|
}
|
||||||
|
|
||||||
System.out.println("map : " + map);
|
System.out.println("map : " + map);
|
||||||
return new Gson().toJson(map);
|
return new Gson().toJson(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String associateClientAsJSON(final String clientMember) {
|
public static String associateClientAsJSON(final String clientMember) {
|
||||||
HashMap<String, List<String>> map = new HashMap<String, List<String>>();
|
final HashMap<String, List<String>> map = new HashMap<String, List<String>>();
|
||||||
List<String> list = new ArrayList<String>();
|
final List<String> list = new ArrayList<String>();
|
||||||
list.add(clientMember);
|
list.add(clientMember);
|
||||||
map.put("clientMembers", list);
|
map.put("clientMembers", list);
|
||||||
System.out.println("map : " + map);
|
System.out.println("map : " + map);
|
||||||
@@ -94,19 +97,20 @@ public class GroupHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String activateGroupAsJSON(final String activationDate) {
|
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("dateFormat", "dd MMMM yyyy");
|
||||||
map.put("locale", "en");
|
map.put("locale", "en");
|
||||||
if (activationDate != "")
|
if (activationDate != "") {
|
||||||
map.put("activationDate", activationDate);
|
map.put("activationDate", activationDate);
|
||||||
else
|
} else {
|
||||||
map.put("activationDate", "04 March 2011");
|
map.put("activationDate", "04 March 2011");
|
||||||
|
}
|
||||||
System.out.println("map : " + map);
|
System.out.println("map : " + map);
|
||||||
return new Gson().toJson(map);
|
return new Gson().toJson(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String updateGroupAsJSON(final String name) {
|
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);
|
map.put("name", name);
|
||||||
System.out.println("map : " + map);
|
System.out.println("map : " + map);
|
||||||
return new Gson().toJson(map);
|
return new Gson().toJson(map);
|
||||||
@@ -115,24 +119,24 @@ public class GroupHelper {
|
|||||||
public static void verifyGroupCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
public static void verifyGroupCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||||
final Integer generatedGroupID) {
|
final Integer generatedGroupID) {
|
||||||
System.out.println("------------------------------CHECK GROUP DETAILS------------------------------------\n");
|
System.out.println("------------------------------CHECK GROUP DETAILS------------------------------------\n");
|
||||||
String GROUP_URL = "/mifosng-provider/api/v1/groups/" + generatedGroupID + "?tenantIdentifier=default";
|
final String GROUP_URL = "/mifosng-provider/api/v1/groups/" + generatedGroupID + "?tenantIdentifier=default";
|
||||||
Integer responseGroupID = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "id");
|
final Integer responseGroupID = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "id");
|
||||||
assertEquals("ERROR IN CREATING THE GROUP", generatedGroupID, responseGroupID);
|
assertEquals("ERROR IN CREATING THE GROUP", generatedGroupID, responseGroupID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void verifyGroupDetails(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
public static void verifyGroupDetails(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||||
final Integer generatedGroupID, final String field, final String expectedValue) {
|
final Integer generatedGroupID, final String field, final String expectedValue) {
|
||||||
System.out.println("------------------------------CHECK GROUP DETAILS------------------------------------\n");
|
System.out.println("------------------------------CHECK GROUP DETAILS------------------------------------\n");
|
||||||
String GROUP_URL = "/mifosng-provider/api/v1/groups/" + generatedGroupID + "?tenantIdentifier=default";
|
final String GROUP_URL = "/mifosng-provider/api/v1/groups/" + generatedGroupID + "?tenantIdentifier=default";
|
||||||
String responseValue = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, field);
|
final String responseValue = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, field);
|
||||||
assertEquals("ERROR IN CREATING THE GROUP", expectedValue, responseValue);
|
assertEquals("ERROR IN CREATING THE GROUP", expectedValue, responseValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void verifyGroupActivatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
public static void verifyGroupActivatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||||
final Integer generatedGroupID, final boolean generatedGroupStatus) {
|
final Integer generatedGroupID, final boolean generatedGroupStatus) {
|
||||||
System.out.println("------------------------------CHECK GROUP STATUS------------------------------------\n");
|
System.out.println("------------------------------CHECK GROUP STATUS------------------------------------\n");
|
||||||
String GROUP_URL = "/mifosng-provider/api/v1/groups/" + generatedGroupID + "?tenantIdentifier=default";
|
final String GROUP_URL = "/mifosng-provider/api/v1/groups/" + generatedGroupID + "?tenantIdentifier=default";
|
||||||
Boolean responseGroupStatus = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "active");
|
final Boolean responseGroupStatus = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "active");
|
||||||
assertEquals("ERROR IN ACTIVATING THE GROUP", generatedGroupStatus, responseGroupStatus);
|
assertEquals("ERROR IN ACTIVATING THE GROUP", generatedGroupStatus, responseGroupStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,7 +144,8 @@ public class GroupHelper {
|
|||||||
final Integer generatedGroupID, final Integer groupMember) {
|
final Integer generatedGroupID, final Integer groupMember) {
|
||||||
List<String> list = new ArrayList<String>();
|
List<String> list = new ArrayList<String>();
|
||||||
System.out.println("------------------------------CHECK GROUP MEMBERS------------------------------------\n");
|
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");
|
list = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "clientMembers");
|
||||||
assertTrue("ERROR IN GROUP MEMBER", list.toString().contains("id=" + groupMember.toString()));
|
assertTrue("ERROR IN GROUP MEMBER", list.toString().contains("id=" + groupMember.toString()));
|
||||||
}
|
}
|
||||||
@@ -149,7 +154,8 @@ public class GroupHelper {
|
|||||||
final Integer generatedGroupID) {
|
final Integer generatedGroupID) {
|
||||||
List<String> list = new ArrayList<String>();
|
List<String> list = new ArrayList<String>();
|
||||||
System.out.println("------------------------------CHECK EMPTY GROUP MEMBER LIST------------------------------------\n");
|
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");
|
list = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "clientMembers");
|
||||||
assertEquals("GROUP MEMBER LIST NOT EMPTY", list, null);
|
assertEquals("GROUP MEMBER LIST NOT EMPTY", list, null);
|
||||||
}
|
}
|
||||||
@@ -158,7 +164,7 @@ public class GroupHelper {
|
|||||||
final Integer generatedGroupID) {
|
final Integer generatedGroupID) {
|
||||||
List<String> list = new ArrayList<String>();
|
List<String> list = new ArrayList<String>();
|
||||||
System.out.println("------------------------------CHECK GROUP DELETED------------------------------------\n");
|
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");
|
list = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "pageItems");
|
||||||
|
|
||||||
assertFalse("GROUP NOT DELETED", list.toString().contains("id=" + generatedGroupID.toString()));
|
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.assertThat;
|
||||||
import static org.junit.Assert.fail;
|
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.commons.lang.StringUtils;
|
||||||
import org.apache.http.conn.HttpHostConnectException;
|
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.RequestSpecification;
|
||||||
import com.jayway.restassured.specification.ResponseSpecification;
|
import com.jayway.restassured.specification.ResponseSpecification;
|
||||||
|
|
||||||
import java.lang.System;
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public class Utils {
|
public class Utils {
|
||||||
|
|
||||||
private static final String LOGIN_URL = "/mifosng-provider/api/v1/authentication?username=mifos&password=password&tenantIdentifier=default";
|
private static final String LOGIN_URL = "/mifosng-provider/api/v1/authentication?username=mifos&password=password&tenantIdentifier=default";
|
||||||
|
|
||||||
|
|
||||||
public static void initializeRESTAssured() {
|
public static void initializeRESTAssured() {
|
||||||
RestAssured.baseURI ="https://localhost";
|
RestAssured.baseURI = "https://localhost";
|
||||||
RestAssured.port = 8443;
|
RestAssured.port = 8443;
|
||||||
RestAssured.keystore("../keystore.jks", "openmf");
|
RestAssured.keystore("../keystore.jks", "openmf");
|
||||||
}
|
}
|
||||||
@@ -34,14 +32,13 @@ public class Utils {
|
|||||||
public static String loginIntoServerAndGetBase64EncodedAuthenticationKey() {
|
public static String loginIntoServerAndGetBase64EncodedAuthenticationKey() {
|
||||||
try {
|
try {
|
||||||
System.out.println("-----------------------------------LOGIN-----------------------------------------");
|
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));
|
assertThat("Failed to login into mifosx platform", StringUtils.isBlank(json), is(false));
|
||||||
return JsonPath.with(json).get("base64EncodedAuthenticationKey");
|
return JsonPath.with(json).get("base64EncodedAuthenticationKey");
|
||||||
}
|
} catch (final Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
if (e instanceof HttpHostConnectException) {
|
if (e instanceof HttpHostConnectException) {
|
||||||
HttpHostConnectException hh = (HttpHostConnectException) e;
|
final HttpHostConnectException hh = (HttpHostConnectException) e;
|
||||||
fail("Failed to connect to mifosx platform:"+hh.getMessage());
|
fail("Failed to connect to mifosx platform:" + hh.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
@@ -49,58 +46,51 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T performServerGet(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
public static <T> T performServerGet(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||||
final String getURL, final String jsonAttributeToGetBack) {
|
final String getURL, final String jsonAttributeToGetBack) {
|
||||||
String json = given().spec(requestSpec)
|
final String json = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(getURL).andReturn().asString();
|
||||||
.expect().spec(responseSpec).log().ifError()
|
|
||||||
.when().get(getURL).andReturn().asString();
|
|
||||||
return (T) from(json).get(jsonAttributeToGetBack);
|
return (T) from(json).get(jsonAttributeToGetBack);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T performServerPost(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
public static <T> T performServerPost(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||||
final String postURL, final String jsonBodyToSend, final String jsonAttributeToGetBack) {
|
final String postURL, final String jsonBodyToSend, final String jsonAttributeToGetBack) {
|
||||||
String json = given().spec(requestSpec).body(jsonBodyToSend)
|
final String json = given().spec(requestSpec).body(jsonBodyToSend).expect().spec(responseSpec).log().ifError().when().post(postURL)
|
||||||
.expect().spec(responseSpec).log().ifError()
|
|
||||||
.when().post(postURL)
|
|
||||||
.andReturn().asString();
|
.andReturn().asString();
|
||||||
return (T) from(json).get(jsonAttributeToGetBack);
|
return (T) from(json).get(jsonAttributeToGetBack);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T performServerPut(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
public static <T> T performServerPut(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||||
final String putURL, final String jsonBodyToSend, final String jsonAttributeToGetBack) {
|
final String putURL, final String jsonBodyToSend, final String jsonAttributeToGetBack) {
|
||||||
String json = given().spec(requestSpec).body(jsonBodyToSend)
|
final String json = given().spec(requestSpec).body(jsonBodyToSend).expect().spec(responseSpec).log().ifError().when().put(putURL)
|
||||||
.expect().spec(responseSpec).log().ifError()
|
|
||||||
.when().put(putURL)
|
|
||||||
.andReturn().asString();
|
.andReturn().asString();
|
||||||
return (T) from(json).get(jsonAttributeToGetBack);
|
return (T) from(json).get(jsonAttributeToGetBack);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T performServerDelete(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
public static <T> T performServerDelete(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||||
final String deleteURL, final String jsonAttributeToGetBack) {
|
final String deleteURL, final String jsonAttributeToGetBack) {
|
||||||
String json = given().spec(requestSpec)
|
final String json = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().delete(deleteURL).andReturn()
|
||||||
.expect().spec(responseSpec).log().ifError()
|
.asString();
|
||||||
.when().delete(deleteURL)
|
|
||||||
.andReturn().asString();
|
|
||||||
return (T) from(json).get(jsonAttributeToGetBack);
|
return (T) from(json).get(jsonAttributeToGetBack);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String convertDateToURLFormat(String dateToBeConvert){
|
public static String convertDateToURLFormat(final String dateToBeConvert) {
|
||||||
SimpleDateFormat oldFormat = new SimpleDateFormat("dd MMMMMM yyyy");
|
final SimpleDateFormat oldFormat = new SimpleDateFormat("dd MMMMMM yyyy");
|
||||||
SimpleDateFormat newFormat = new SimpleDateFormat("yyyy-MM-dd");
|
final SimpleDateFormat newFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
String reformattedStr="";
|
String reformattedStr = "";
|
||||||
try {
|
try {
|
||||||
reformattedStr = newFormat.format(oldFormat.parse(dateToBeConvert));
|
reformattedStr = newFormat.format(oldFormat.parse(dateToBeConvert));
|
||||||
} catch (ParseException e) {
|
} catch (final ParseException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return reformattedStr;
|
return reformattedStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String randomStringGenerator(final String prefix, final int len, final String sourceSetString) {
|
public static String randomStringGenerator(final String prefix, final int len, final String sourceSetString) {
|
||||||
int lengthOfSource = sourceSetString.length();
|
final int lengthOfSource = sourceSetString.length();
|
||||||
Random rnd = new Random();
|
final Random rnd = new Random();
|
||||||
StringBuilder sb = new StringBuilder(len);
|
final StringBuilder sb = new StringBuilder(len);
|
||||||
for (int i = 0; i < len; i++)
|
for (int i = 0; i < len; i++) {
|
||||||
sb.append((sourceSetString).charAt(rnd.nextInt(lengthOfSource)));
|
sb.append((sourceSetString).charAt(rnd.nextInt(lengthOfSource)));
|
||||||
|
}
|
||||||
return (prefix + (sb.toString()));
|
return (prefix + (sb.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+9
-9
@@ -3,33 +3,33 @@ package org.mifosplatform.integrationtests.common.accounting;
|
|||||||
public class Account {
|
public class Account {
|
||||||
|
|
||||||
public enum AccountType {
|
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){
|
AccountType(final String accountValue) {
|
||||||
this.accountValue=accountValue;
|
this.accountValue = accountValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return accountValue;
|
return this.accountValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final AccountType accountType;
|
private final AccountType accountType;
|
||||||
private final Integer accountID;
|
private final Integer accountID;
|
||||||
|
|
||||||
|
public Account(final Integer accountID, final AccountType accountType) {
|
||||||
public Account(Integer accountID, AccountType accountType) {
|
|
||||||
this.accountID = accountID;
|
this.accountID = accountID;
|
||||||
this.accountType = accountType;
|
this.accountType = accountType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AccountType getAccountType(){
|
public AccountType getAccountType() {
|
||||||
return this.accountType;
|
return this.accountType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getAccountID(){
|
public Integer getAccountID() {
|
||||||
return this.accountID;
|
return this.accountID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-19
@@ -1,41 +1,41 @@
|
|||||||
package org.mifosplatform.integrationtests.common.accounting;
|
package org.mifosplatform.integrationtests.common.accounting;
|
||||||
|
|
||||||
|
import org.mifosplatform.integrationtests.common.Utils;
|
||||||
|
|
||||||
import com.jayway.restassured.specification.RequestSpecification;
|
import com.jayway.restassured.specification.RequestSpecification;
|
||||||
import com.jayway.restassured.specification.ResponseSpecification;
|
import com.jayway.restassured.specification.ResponseSpecification;
|
||||||
import org.mifosplatform.integrationtests.common.Utils;
|
|
||||||
|
|
||||||
public class AccountHelper {
|
public class AccountHelper {
|
||||||
|
|
||||||
private final String CREATE_GL_ACCOUNT_URL = "/mifosng-provider/api/v1/glaccounts?tenantIdentifier=default";
|
private final String CREATE_GL_ACCOUNT_URL = "/mifosng-provider/api/v1/glaccounts?tenantIdentifier=default";
|
||||||
private final String GL_ACCOUNT_ID_RESPONSE = "resourceId";
|
private final String GL_ACCOUNT_ID_RESPONSE = "resourceId";
|
||||||
|
|
||||||
private RequestSpecification requestSpec;
|
private final RequestSpecification requestSpec;
|
||||||
private ResponseSpecification responseSpec;
|
private final ResponseSpecification responseSpec;
|
||||||
|
|
||||||
public AccountHelper(RequestSpecification requestSpec, ResponseSpecification responseSpec) {
|
public AccountHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||||
this.requestSpec = requestSpec;
|
this.requestSpec = requestSpec;
|
||||||
this.responseSpec = responseSpec;
|
this.responseSpec = responseSpec;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Account createAssetAccount(){
|
public Account createAssetAccount() {
|
||||||
String assetAccountJSON= new GLAccountBuilder()
|
final String assetAccountJSON = new GLAccountBuilder().withAccountTypeAsAsset().build();
|
||||||
.withAccountTypeAsAsset()
|
final Integer accountID = Utils.performServerPost(this.requestSpec, this.responseSpec, this.CREATE_GL_ACCOUNT_URL,
|
||||||
.build();
|
assetAccountJSON, this.GL_ACCOUNT_ID_RESPONSE);
|
||||||
Integer accountID = Utils.performServerPost(requestSpec, responseSpec, CREATE_GL_ACCOUNT_URL, assetAccountJSON, GL_ACCOUNT_ID_RESPONSE);
|
|
||||||
return new Account(accountID, Account.AccountType.ASSET);
|
return new Account(accountID, Account.AccountType.ASSET);
|
||||||
}
|
}
|
||||||
public Account createIncomeAccount(){
|
|
||||||
String assetAccountJSON= new GLAccountBuilder()
|
public Account createIncomeAccount() {
|
||||||
.withAccountTypeAsIncome()
|
final String assetAccountJSON = new GLAccountBuilder().withAccountTypeAsIncome().build();
|
||||||
.build();
|
final Integer accountID = Utils.performServerPost(this.requestSpec, this.responseSpec, this.CREATE_GL_ACCOUNT_URL,
|
||||||
Integer accountID = Utils.performServerPost(requestSpec, responseSpec, CREATE_GL_ACCOUNT_URL, assetAccountJSON, GL_ACCOUNT_ID_RESPONSE);
|
assetAccountJSON, this.GL_ACCOUNT_ID_RESPONSE);
|
||||||
return new Account(accountID, Account.AccountType.INCOME);
|
return new Account(accountID, Account.AccountType.INCOME);
|
||||||
}
|
}
|
||||||
public Account createExpenseAccount(){
|
|
||||||
String assetAccountJSON= new GLAccountBuilder()
|
public Account createExpenseAccount() {
|
||||||
.withAccountTypeAsExpense()
|
final String assetAccountJSON = new GLAccountBuilder().withAccountTypeAsExpense().build();
|
||||||
.build();
|
final Integer accountID = Utils.performServerPost(this.requestSpec, this.responseSpec, this.CREATE_GL_ACCOUNT_URL,
|
||||||
Integer accountID = Utils.performServerPost(requestSpec, responseSpec, CREATE_GL_ACCOUNT_URL, assetAccountJSON, GL_ACCOUNT_ID_RESPONSE);
|
assetAccountJSON, this.GL_ACCOUNT_ID_RESPONSE);
|
||||||
return new Account(accountID, Account.AccountType.EXPENSE);
|
return new Account(accountID, Account.AccountType.EXPENSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-7
@@ -29,7 +29,7 @@ public class GLAccountBuilder {
|
|||||||
private static String description = "DEFAULT_DESCRIPTION";
|
private static String description = "DEFAULT_DESCRIPTION";
|
||||||
|
|
||||||
public String build() {
|
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("name", GLAccountBuilder.name);
|
||||||
map.put("glCode", GLAccountBuilder.GLCode);
|
map.put("glCode", GLAccountBuilder.GLCode);
|
||||||
map.put("manualEntriesAllowed", GLAccountBuilder.manualEntriesAllowed);
|
map.put("manualEntriesAllowed", GLAccountBuilder.manualEntriesAllowed);
|
||||||
@@ -43,12 +43,12 @@ public class GLAccountBuilder {
|
|||||||
GLAccountBuilder.accountType = ASSET_ACCOUNT;
|
GLAccountBuilder.accountType = ASSET_ACCOUNT;
|
||||||
GLAccountBuilder.GLCode = Utils.randomStringGenerator("ASSET_", 2);
|
GLAccountBuilder.GLCode = Utils.randomStringGenerator("ASSET_", 2);
|
||||||
GLAccountBuilder.GLCode += Calendar.getInstance().getTimeInMillis() + ""; // Added
|
GLAccountBuilder.GLCode += Calendar.getInstance().getTimeInMillis() + ""; // Added
|
||||||
// unique
|
// unique
|
||||||
// timestamp
|
// timestamp
|
||||||
// for
|
// for
|
||||||
// avoiding
|
// avoiding
|
||||||
// random
|
// random
|
||||||
// collisions
|
// collisions
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-8
@@ -1,11 +1,9 @@
|
|||||||
package org.mifosplatform.integrationtests.common.accounting;
|
package org.mifosplatform.integrationtests.common.accounting;
|
||||||
|
|
||||||
|
|
||||||
public class JournalEntry {
|
public class JournalEntry {
|
||||||
|
|
||||||
public enum TransactionType {
|
public enum TransactionType {
|
||||||
CREDIT("CREDIT"),
|
CREDIT("CREDIT"), DEBIT("DEBIT");
|
||||||
DEBIT("DEBIT");
|
|
||||||
|
|
||||||
private TransactionType(final String type) {
|
private TransactionType(final String type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
@@ -15,22 +13,23 @@ public class JournalEntry {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return type;
|
return this.type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Float transactionAmount;
|
private final Float transactionAmount;
|
||||||
private final TransactionType transactionType;
|
private final TransactionType transactionType;
|
||||||
|
|
||||||
public JournalEntry(float transactionAmount, TransactionType type){
|
public JournalEntry(final float transactionAmount, final TransactionType type) {
|
||||||
this.transactionAmount=transactionAmount;
|
this.transactionAmount = transactionAmount;
|
||||||
this.transactionType = type;
|
this.transactionType = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Float getTransactionAmount(){
|
public Float getTransactionAmount() {
|
||||||
return this.transactionAmount;
|
return this.transactionAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTransactionType(){
|
public String getTransactionType() {
|
||||||
return this.transactionType.toString();
|
return this.transactionType.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -35,7 +35,7 @@ public class JournalEntryHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getEntryValueFromJournalEntry(final ArrayList<HashMap> entryResponse, final int entryNumber) {
|
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");
|
return (String) map.get("value");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,8 +44,8 @@ public class JournalEntryHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void checkJournalEntry(final Account account, final String date, final JournalEntry... accountEntries) {
|
private void checkJournalEntry(final Account account, final String date, final JournalEntry... accountEntries) {
|
||||||
String url = createURLForGettingAccountEntries(account, date);
|
final String url = createURLForGettingAccountEntries(account, date);
|
||||||
ArrayList<HashMap> response = Utils.performServerGet(requestSpec, responseSpec, url, "pageItems");
|
final ArrayList<HashMap> response = Utils.performServerGet(this.requestSpec, this.responseSpec, url, "pageItems");
|
||||||
for (int i = 0; i < accountEntries.length; i++) {
|
for (int i = 0; i < accountEntries.length; i++) {
|
||||||
assertThat(getEntryValueFromJournalEntry(response, i), equalTo(accountEntries[i].getTransactionType()));
|
assertThat(getEntryValueFromJournalEntry(response, i), equalTo(accountEntries[i].getTransactionType()));
|
||||||
assertThat(getTransactionAmountFromJournalEntry(response, i), equalTo(accountEntries[i].getTransactionAmount()));
|
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) {
|
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("dateFormat", "dd MMMM yyyy");
|
||||||
map.put("locale", "en_GB");
|
map.put("locale", "en_GB");
|
||||||
if (loanType == "group")
|
if (this.loanType == "group") {
|
||||||
map.put("groupId", ID);
|
map.put("groupId", ID);
|
||||||
else
|
} else {
|
||||||
map.put("clientId", ID);
|
map.put("clientId", ID);
|
||||||
|
}
|
||||||
map.put("productId", loanProductId);
|
map.put("productId", loanProductId);
|
||||||
map.put("principal", principal);
|
map.put("principal", this.principal);
|
||||||
map.put("loanTermFrequency", loanTermFrequency);
|
map.put("loanTermFrequency", this.loanTermFrequency);
|
||||||
map.put("loanTermFrequencyType", loanTermFrequencyType);
|
map.put("loanTermFrequencyType", this.loanTermFrequencyType);
|
||||||
map.put("numberOfRepayments", numberOfRepayment);
|
map.put("numberOfRepayments", this.numberOfRepayment);
|
||||||
map.put("repaymentEvery", repaymentPeriod);
|
map.put("repaymentEvery", this.repaymentPeriod);
|
||||||
map.put("repaymentFrequencyType", repaymentFrequencyType);
|
map.put("repaymentFrequencyType", this.repaymentFrequencyType);
|
||||||
map.put("interestRatePerPeriod", interestRate);
|
map.put("interestRatePerPeriod", this.interestRate);
|
||||||
map.put("amortizationType", amortizationType);
|
map.put("amortizationType", this.amortizationType);
|
||||||
map.put("interestType", interestType);
|
map.put("interestType", this.interestType);
|
||||||
map.put("interestCalculationPeriodType", interestCalculationPeriodType);
|
map.put("interestCalculationPeriodType", this.interestCalculationPeriodType);
|
||||||
map.put("transactionProcessingStrategyId", transactionProcessingID);
|
map.put("transactionProcessingStrategyId", this.transactionProcessingID);
|
||||||
map.put("expectedDisbursementDate", expectedDisbursmentDate);
|
map.put("expectedDisbursementDate", this.expectedDisbursmentDate);
|
||||||
map.put("submittedOnDate", submittedOnDate);
|
map.put("submittedOnDate", this.submittedOnDate);
|
||||||
map.put("loanType", loanType);
|
map.put("loanType", this.loanType);
|
||||||
return new Gson().toJson(map);
|
return new Gson().toJson(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,7 +161,7 @@ public class LoanApplicationTestBuilder {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoanApplicationTestBuilder withLoanType(final String loanType){
|
public LoanApplicationTestBuilder withLoanType(final String loanType) {
|
||||||
this.loanType = loanType;
|
this.loanType = loanType;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
+111
-112
@@ -3,11 +3,13 @@ package org.mifosplatform.integrationtests.common.loans;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import org.mifosplatform.integrationtests.common.ClientHelper;
|
import org.mifosplatform.integrationtests.common.ClientHelper;
|
||||||
import org.mifosplatform.integrationtests.common.accounting.Account;
|
import org.mifosplatform.integrationtests.common.accounting.Account;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
public class LoanProductTestBuilder {
|
public class LoanProductTestBuilder {
|
||||||
|
|
||||||
private static final String LOCALE = "en_GB";
|
private static final String LOCALE = "en_GB";
|
||||||
private static final String DIGITS_AFTER_DECIMAL = "2";
|
private static final String DIGITS_AFTER_DECIMAL = "2";
|
||||||
private static final String INR = "INR";
|
private static final String INR = "INR";
|
||||||
@@ -15,227 +17,224 @@ public class LoanProductTestBuilder {
|
|||||||
private static final String WEEK = "1";
|
private static final String WEEK = "1";
|
||||||
private static final String MONTHS = "2";
|
private static final String MONTHS = "2";
|
||||||
private static final String YEARS = "3";
|
private static final String YEARS = "3";
|
||||||
private static final String CALCULATION_PERIOD_SAME_AS_REPAYMENT_PERIOD="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_PRINCIPAL_PAYMENTS = "0";
|
||||||
private static final String EQUAL_INSTALLMENTS="1";
|
private static final String EQUAL_INSTALLMENTS = "1";
|
||||||
private static final String DECLINING_BALANCE="0";
|
private static final String DECLINING_BALANCE = "0";
|
||||||
private static final String FLAT_BALANCE="1";
|
private static final String FLAT_BALANCE = "1";
|
||||||
private static final String MIFOS_STANDARD_STRATEGY ="1";
|
private static final String MIFOS_STANDARD_STRATEGY = "1";
|
||||||
// private static final String HEAVENS_FAMILY_STRATEGY ="2";
|
// private static final String HEAVENS_FAMILY_STRATEGY ="2";
|
||||||
// private static final String CREO_CORE_STRATEGY ="3";
|
// private static final String CREO_CORE_STRATEGY ="3";
|
||||||
// private static final String RBI_INDIA_STRATEGY ="4";
|
// private static final String RBI_INDIA_STRATEGY ="4";
|
||||||
private static final String NONE ="1";
|
private static final String NONE = "1";
|
||||||
private static final String CASH_BASED ="2";
|
private static final String CASH_BASED = "2";
|
||||||
private static final String ACCRUAL_BASED ="3";
|
private static final String ACCRUAL_BASED = "3";
|
||||||
|
|
||||||
|
|
||||||
private String nameOfLoanProduct = ClientHelper.randomNameGenerator("LOAN_PRODUCT_", 6);
|
private String nameOfLoanProduct = ClientHelper.randomNameGenerator("LOAN_PRODUCT_", 6);
|
||||||
private String principal = "10000.00";
|
private String principal = "10000.00";
|
||||||
private String numberOfRepayments = "5";
|
private String numberOfRepayments = "5";
|
||||||
private String repaymentFrequency = MONTHS;
|
private String repaymentFrequency = MONTHS;
|
||||||
private String repaymentPeriod = "1";
|
private String repaymentPeriod = "1";
|
||||||
private String interestRatePerPeriod= "2";
|
private String interestRatePerPeriod = "2";
|
||||||
private String interestRateFrequencyType = MONTHS;
|
private String interestRateFrequencyType = MONTHS;
|
||||||
private String interestType = FLAT_BALANCE;
|
private String interestType = FLAT_BALANCE;
|
||||||
private String interestCalculationPeriodType=CALCULATION_PERIOD_SAME_AS_REPAYMENT_PERIOD;
|
private String interestCalculationPeriodType = CALCULATION_PERIOD_SAME_AS_REPAYMENT_PERIOD;
|
||||||
private String inArrearsTolerance="0";
|
private String inArrearsTolerance = "0";
|
||||||
private final String transactionProcessingStrategy=MIFOS_STANDARD_STRATEGY;
|
private final String transactionProcessingStrategy = MIFOS_STANDARD_STRATEGY;
|
||||||
private String accountingRule =NONE;
|
private String accountingRule = NONE;
|
||||||
private final String currencyCode = INR;
|
private final String currencyCode = INR;
|
||||||
private String amortizationType= EQUAL_INSTALLMENTS;
|
private String amortizationType = EQUAL_INSTALLMENTS;
|
||||||
private String minPrincipal = "1000.00";
|
private String minPrincipal = "1000.00";
|
||||||
private String maxPrincipal = "100000.00";
|
private String maxPrincipal = "100000.00";
|
||||||
private Account[] accountList = null;
|
private Account[] accountList = null;
|
||||||
|
|
||||||
public String build() {
|
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("name", this.nameOfLoanProduct);
|
||||||
map.put("currencyCode", currencyCode);
|
map.put("currencyCode", this.currencyCode);
|
||||||
map.put("locale", LOCALE);
|
map.put("locale", LOCALE);
|
||||||
map.put("digitsAfterDecimal",DIGITS_AFTER_DECIMAL);
|
map.put("digitsAfterDecimal", DIGITS_AFTER_DECIMAL);
|
||||||
map.put("principal", principal);
|
map.put("principal", this.principal);
|
||||||
map.put("numberOfRepayments", numberOfRepayments);
|
map.put("numberOfRepayments", this.numberOfRepayments);
|
||||||
map.put("repaymentEvery",repaymentPeriod );
|
map.put("repaymentEvery", this.repaymentPeriod);
|
||||||
map.put("repaymentFrequencyType", repaymentFrequency);
|
map.put("repaymentFrequencyType", this.repaymentFrequency);
|
||||||
map.put("interestRatePerPeriod", interestRatePerPeriod);
|
map.put("interestRatePerPeriod", this.interestRatePerPeriod);
|
||||||
map.put("interestRateFrequencyType", interestRateFrequencyType);
|
map.put("interestRateFrequencyType", this.interestRateFrequencyType);
|
||||||
map.put("amortizationType",amortizationType);
|
map.put("amortizationType", this.amortizationType);
|
||||||
map.put("interestType", interestType);
|
map.put("interestType", this.interestType);
|
||||||
map.put("interestCalculationPeriodType", interestCalculationPeriodType);
|
map.put("interestCalculationPeriodType", this.interestCalculationPeriodType);
|
||||||
map.put("inArrearsTolerance", inArrearsTolerance);
|
map.put("inArrearsTolerance", this.inArrearsTolerance);
|
||||||
map.put("transactionProcessingStrategyId", transactionProcessingStrategy);
|
map.put("transactionProcessingStrategyId", this.transactionProcessingStrategy);
|
||||||
map.put("accountingRule", accountingRule);
|
map.put("accountingRule", this.accountingRule);
|
||||||
map.put("minPrincipal",minPrincipal);
|
map.put("minPrincipal", this.minPrincipal);
|
||||||
map.put("maxPrincipal",maxPrincipal);
|
map.put("maxPrincipal", this.maxPrincipal);
|
||||||
|
|
||||||
if(accountingRule.equals(ACCRUAL_BASED)){
|
if (this.accountingRule.equals(ACCRUAL_BASED)) {
|
||||||
map.putAll(getAccountMappingForAccrualBased());
|
map.putAll(getAccountMappingForAccrualBased());
|
||||||
}else if(accountingRule.equals(CASH_BASED)){
|
} else if (this.accountingRule.equals(CASH_BASED)) {
|
||||||
map.putAll(getAccountMappingForCashBased());
|
map.putAll(getAccountMappingForCashBased());
|
||||||
}
|
}
|
||||||
return new Gson().toJson(map);
|
return new Gson().toJson(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LoanProductTestBuilder withMinPrincipal(final String minPrincipal) {
|
||||||
public LoanProductTestBuilder withMinPrincipal(final String minPrincipal){
|
this.minPrincipal = minPrincipal;
|
||||||
this.minPrincipal=minPrincipal;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
public LoanProductTestBuilder withMaxPrincipal(final String maxPrincipal){
|
|
||||||
this.maxPrincipal=maxPrincipal;
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoanProductTestBuilder withLoanName(final String loanName){
|
public LoanProductTestBuilder withMaxPrincipal(final String maxPrincipal) {
|
||||||
this.nameOfLoanProduct=loanName;
|
this.maxPrincipal = maxPrincipal;
|
||||||
return this;
|
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;
|
this.principal = principal;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoanProductTestBuilder withNumberOfRepayments(final String numberOfRepayment){
|
public LoanProductTestBuilder withNumberOfRepayments(final String numberOfRepayment) {
|
||||||
this.numberOfRepayments = numberOfRepayment;
|
this.numberOfRepayments = numberOfRepayment;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LoanProductTestBuilder withRepaymentTypeAsMonth() {
|
||||||
public LoanProductTestBuilder withRepaymentTypeAsMonth(){
|
|
||||||
this.repaymentFrequency = MONTHS;
|
this.repaymentFrequency = MONTHS;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoanProductTestBuilder withRepaymentTypeAsWeek(){
|
public LoanProductTestBuilder withRepaymentTypeAsWeek() {
|
||||||
this.repaymentFrequency = WEEK;
|
this.repaymentFrequency = WEEK;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoanProductTestBuilder withRepaymentTypeAsDays(){
|
public LoanProductTestBuilder withRepaymentTypeAsDays() {
|
||||||
this.repaymentFrequency = DAYS;
|
this.repaymentFrequency = DAYS;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoanProductTestBuilder withRepaymentAfterEvery(final String repaymentAfterEvery){
|
public LoanProductTestBuilder withRepaymentAfterEvery(final String repaymentAfterEvery) {
|
||||||
this.repaymentPeriod=repaymentAfterEvery;
|
this.repaymentPeriod = repaymentAfterEvery;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoanProductTestBuilder withInterestRateFrequencyTypeAsMonths(){
|
public LoanProductTestBuilder withInterestRateFrequencyTypeAsMonths() {
|
||||||
this.interestRateFrequencyType=MONTHS;
|
this.interestRateFrequencyType = MONTHS;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoanProductTestBuilder withInterestRateFrequencyTypeAsYear(){
|
public LoanProductTestBuilder withInterestRateFrequencyTypeAsYear() {
|
||||||
this.interestRateFrequencyType=YEARS;
|
this.interestRateFrequencyType = YEARS;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoanProductTestBuilder withinterestRatePerPeriod(final String interestRatePerPeriod) {
|
public LoanProductTestBuilder withinterestRatePerPeriod(final String interestRatePerPeriod) {
|
||||||
this.interestRatePerPeriod=interestRatePerPeriod;
|
this.interestRatePerPeriod = interestRatePerPeriod;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoanProductTestBuilder withAmortizationTypeAsEqualPrincipalPayment(){
|
public LoanProductTestBuilder withAmortizationTypeAsEqualPrincipalPayment() {
|
||||||
this.amortizationType = EQUAL_PRINCIPAL_PAYMENTS;
|
this.amortizationType = EQUAL_PRINCIPAL_PAYMENTS;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoanProductTestBuilder withAmortizationTypeAsEqualInstallments(){
|
public LoanProductTestBuilder withAmortizationTypeAsEqualInstallments() {
|
||||||
this.amortizationType = EQUAL_INSTALLMENTS;
|
this.amortizationType = EQUAL_INSTALLMENTS;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoanProductTestBuilder withInterestTypeAsFlat(){
|
public LoanProductTestBuilder withInterestTypeAsFlat() {
|
||||||
this.interestType=FLAT_BALANCE;
|
this.interestType = FLAT_BALANCE;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoanProductTestBuilder withInterestTypeAsDecliningBalance (){
|
public LoanProductTestBuilder withInterestTypeAsDecliningBalance() {
|
||||||
this.interestType=DECLINING_BALANCE;
|
this.interestType = DECLINING_BALANCE;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoanProductTestBuilder withInterestCalculationPeriodTypeAsDays (){
|
public LoanProductTestBuilder withInterestCalculationPeriodTypeAsDays() {
|
||||||
this.interestCalculationPeriodType=DAYS;
|
this.interestCalculationPeriodType = DAYS;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoanProductTestBuilder withInterestCalculationPeriodTypeAsRepaymentPeriod (){
|
public LoanProductTestBuilder withInterestCalculationPeriodTypeAsRepaymentPeriod() {
|
||||||
this.interestCalculationPeriodType=CALCULATION_PERIOD_SAME_AS_REPAYMENT_PERIOD;
|
this.interestCalculationPeriodType = CALCULATION_PERIOD_SAME_AS_REPAYMENT_PERIOD;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoanProductTestBuilder withInArrearsTolerance (final String amountCanBeWaved){
|
public LoanProductTestBuilder withInArrearsTolerance(final String amountCanBeWaved) {
|
||||||
this.inArrearsTolerance = amountCanBeWaved;
|
this.inArrearsTolerance = amountCanBeWaved;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoanProductTestBuilder withAccountingRuleAsNone (){
|
public LoanProductTestBuilder withAccountingRuleAsNone() {
|
||||||
this.accountingRule= NONE;
|
this.accountingRule = NONE;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoanProductTestBuilder withAccountingRuleAsCashBased (Account [] account_list){
|
public LoanProductTestBuilder withAccountingRuleAsCashBased(final Account[] account_list) {
|
||||||
this.accountingRule= CASH_BASED;
|
this.accountingRule = CASH_BASED;
|
||||||
this.accountList = account_list;
|
this.accountList = account_list;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoanProductTestBuilder withAccountingRuleAsAccrualBased (Account[] account_list){
|
public LoanProductTestBuilder withAccountingRuleAsAccrualBased(final Account[] account_list) {
|
||||||
this.accountingRule= ACCRUAL_BASED;
|
this.accountingRule = ACCRUAL_BASED;
|
||||||
this.accountList = account_list;
|
this.accountList = account_list;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String,String> getAccountMappingForCashBased() {
|
private Map<String, String> getAccountMappingForCashBased() {
|
||||||
Map<String,String> map = new HashMap<String, String>();
|
final Map<String, String> map = new HashMap<String, String>();
|
||||||
for (int i=0;i<this.accountList.length;i++)
|
for (int i = 0; i < this.accountList.length; i++) {
|
||||||
{
|
if (this.accountList[i].getAccountType().equals(Account.AccountType.ASSET)) {
|
||||||
if(accountList[i].getAccountType().equals(Account.AccountType.ASSET)){
|
final String ID = this.accountList[i].getAccountID().toString();
|
||||||
String ID = accountList[i].getAccountID().toString();
|
map.put("fundSourceAccountId", ID);
|
||||||
map.put("fundSourceAccountId",ID);
|
map.put("loanPortfolioAccountId", ID);
|
||||||
map.put("loanPortfolioAccountId",ID);
|
map.put("transfersInSuspenseAccountId", ID);
|
||||||
map.put("transfersInSuspenseAccountId",ID);
|
|
||||||
}
|
}
|
||||||
if(accountList[i].getAccountType().equals(Account.AccountType.INCOME)){
|
if (this.accountList[i].getAccountType().equals(Account.AccountType.INCOME)) {
|
||||||
String ID = accountList[i].getAccountID().toString();
|
final String ID = this.accountList[i].getAccountID().toString();
|
||||||
map.put("interestOnLoanAccountId",ID);
|
map.put("interestOnLoanAccountId", ID);
|
||||||
map.put("incomeFromFeeAccountId",ID);
|
map.put("incomeFromFeeAccountId", ID);
|
||||||
map.put("incomeFromPenaltyAccountId",ID);
|
map.put("incomeFromPenaltyAccountId", ID);
|
||||||
}
|
}
|
||||||
if(accountList[i].getAccountType().equals(Account.AccountType.EXPENSE)){
|
if (this.accountList[i].getAccountType().equals(Account.AccountType.EXPENSE)) {
|
||||||
String ID = accountList[i].getAccountID().toString();
|
final String ID = this.accountList[i].getAccountID().toString();
|
||||||
map.put("writeOffAccountId",ID);
|
map.put("writeOffAccountId", ID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, String> getAccountMappingForAccrualBased() {
|
private Map<String, String> getAccountMappingForAccrualBased() {
|
||||||
Map<String,String> map = new HashMap<String, String>();
|
final Map<String, String> map = new HashMap<String, String>();
|
||||||
for (int i=0;i<this.accountList.length;i++)
|
for (int i = 0; i < this.accountList.length; i++) {
|
||||||
{
|
if (this.accountList[i].getAccountType().equals(Account.AccountType.ASSET)) {
|
||||||
if(accountList[i].getAccountType().equals(Account.AccountType.ASSET)){
|
final String ID = this.accountList[i].getAccountID().toString();
|
||||||
String ID = accountList[i].getAccountID().toString();
|
map.put("fundSourceAccountId", ID);
|
||||||
map.put("fundSourceAccountId",ID);
|
map.put("loanPortfolioAccountId", ID);
|
||||||
map.put("loanPortfolioAccountId",ID);
|
map.put("transfersInSuspenseAccountId", ID);
|
||||||
map.put("transfersInSuspenseAccountId",ID);
|
map.put("receivableInterestAccountId", ID);
|
||||||
map.put("receivableInterestAccountId",ID);
|
map.put("receivableFeeAccountId", ID);
|
||||||
map.put("receivableFeeAccountId",ID);
|
map.put("receivablePenaltyAccountId", ID);
|
||||||
map.put("receivablePenaltyAccountId",ID);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if(accountList[i].getAccountType().equals(Account.AccountType.INCOME)){
|
if (this.accountList[i].getAccountType().equals(Account.AccountType.INCOME)) {
|
||||||
String ID = accountList[i].getAccountID().toString();
|
final String ID = this.accountList[i].getAccountID().toString();
|
||||||
map.put("interestOnLoanAccountId",ID);
|
map.put("interestOnLoanAccountId", ID);
|
||||||
map.put("incomeFromFeeAccountId",ID);
|
map.put("incomeFromFeeAccountId", ID);
|
||||||
map.put("incomeFromPenaltyAccountId",ID);
|
map.put("incomeFromPenaltyAccountId", ID);
|
||||||
}
|
}
|
||||||
if(accountList[i].getAccountType().equals(Account.AccountType.EXPENSE)){
|
if (this.accountList[i].getAccountType().equals(Account.AccountType.EXPENSE)) {
|
||||||
String ID = accountList[i].getAccountID().toString();
|
final String ID = this.accountList[i].getAccountID().toString();
|
||||||
map.put("writeOffAccountId",ID);
|
map.put("writeOffAccountId", ID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-3
@@ -5,9 +5,10 @@ import static org.junit.Assert.assertTrue;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import org.mifosplatform.integrationtests.common.Utils;
|
||||||
|
|
||||||
import com.jayway.restassured.specification.RequestSpecification;
|
import com.jayway.restassured.specification.RequestSpecification;
|
||||||
import com.jayway.restassured.specification.ResponseSpecification;
|
import com.jayway.restassured.specification.ResponseSpecification;
|
||||||
import org.mifosplatform.integrationtests.common.Utils;
|
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public class LoanStatusChecker {
|
public class LoanStatusChecker {
|
||||||
@@ -32,13 +33,13 @@ public class LoanStatusChecker {
|
|||||||
assertTrue(getStatus(loanStatusHashMap, "closed"));
|
assertTrue(getStatus(loanStatusHashMap, "closed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void verifyLoanAccountIsNotActive(final HashMap loanStatusHashMap) {
|
public static void verifyLoanAccountIsNotActive(final HashMap loanStatusHashMap) {
|
||||||
assertFalse(getStatus(loanStatusHashMap, "active"));
|
assertFalse(getStatus(loanStatusHashMap, "active"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HashMap getStatusOfLoan(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
public static HashMap getStatusOfLoan(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||||
final Integer loanID) {
|
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");
|
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 MAKE_REPAYMENT_COMMAND = "repayment";
|
||||||
private static final String WITHDRAW_LOAN_APPLICATION_COMMAND = "withdrawnByApplicant";
|
private static final String WITHDRAW_LOAN_APPLICATION_COMMAND = "withdrawnByApplicant";
|
||||||
|
|
||||||
|
public LoanTransactionHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||||
public LoanTransactionHelper(final RequestSpecification requestSpec,final ResponseSpecification responseSpec){
|
this.requestSpec = requestSpec;
|
||||||
this.requestSpec = requestSpec;
|
|
||||||
this.responseSpec = responseSpec;
|
this.responseSpec = responseSpec;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getLoanProductId(final String loanProductJSON) {
|
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) {
|
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,
|
public ArrayList getLoanRepaymentSchedule(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||||
final Integer loanID) {
|
final Integer loanID) {
|
||||||
String URL = "/mifosng-provider/api/v1/loans/" + loanID + "?associations=repaymentSchedule&tenantIdentifier=default";
|
final String URL = "/mifosng-provider/api/v1/loans/" + loanID + "?associations=repaymentSchedule&tenantIdentifier=default";
|
||||||
HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "repaymentSchedule");
|
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "repaymentSchedule");
|
||||||
return (ArrayList) response.get("periods");
|
return (ArrayList) response.get("periods");
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap approveLoan(final String approvalDate, final Integer loanID) {
|
public HashMap approveLoan(final String approvalDate, final Integer loanID) {
|
||||||
return performLoanTransaction(createLoanOperationURL(APPROVE_LOAN_COMMAND, loanID),
|
return performLoanTransaction(createLoanOperationURL(APPROVE_LOAN_COMMAND, loanID), getApproveLoanAsJSON(approvalDate));
|
||||||
getApproveLoanAsJSON(approvalDate));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap undoApproval(final Integer loanID) {
|
public HashMap undoApproval(final Integer loanID) {
|
||||||
String undoBodyJson = "{'note':'UNDO APPROVAL'}";
|
final String undoBodyJson = "{'note':'UNDO APPROVAL'}";
|
||||||
return performLoanTransaction(createLoanOperationURL(UNDO_APPROVAL_LOAN_COMMAND, loanID), undoBodyJson);
|
return performLoanTransaction(createLoanOperationURL(UNDO_APPROVAL_LOAN_COMMAND, loanID), undoBodyJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap disburseLoan(final String date,
|
public HashMap disburseLoan(final String date, final Integer loanID) {
|
||||||
final Integer loanID) {
|
return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID), getDisburseLoanAsJSON(date));
|
||||||
return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID),
|
|
||||||
getDisburseLoanAsJSON(date));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap undoDisbursal(final Integer loanID){
|
public HashMap undoDisbursal(final Integer loanID) {
|
||||||
String undoDisburseJson = "{'note' : 'UNDO DISBURSAL'}";
|
final String undoDisburseJson = "{'note' : 'UNDO DISBURSAL'}";
|
||||||
System.out.println("IN DISBURSE LOAN");
|
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);
|
System.out.println("IN DISBURSE LOAN URL " + url);
|
||||||
return performLoanTransaction(createLoanOperationURL(UNDO_DISBURSE_LOAN_COMMAND, loanID), undoDisburseJson);
|
return performLoanTransaction(createLoanOperationURL(UNDO_DISBURSE_LOAN_COMMAND, loanID), undoDisburseJson);
|
||||||
}
|
}
|
||||||
public HashMap writeOffLoan(final String date,
|
|
||||||
final Integer loanID) {
|
public HashMap writeOffLoan(final String date, final Integer loanID) {
|
||||||
return performLoanTransaction(createLoanTransactionURL(WRITE_OFF_LOAN_COMMAND, loanID),
|
return performLoanTransaction(createLoanTransactionURL(WRITE_OFF_LOAN_COMMAND, loanID), getWriteOffBodyAsJSON(date));
|
||||||
getWriteOffBodyAsJSON(date));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap waiveInterest(final String date, final String amountToBeWaived, final Integer loanID) {
|
public HashMap waiveInterest(final String date, final String amountToBeWaived, final Integer loanID) {
|
||||||
return performLoanTransaction(createLoanTransactionURL(WAIVE_INTEREST_COMMAND, loanID),
|
return performLoanTransaction(createLoanTransactionURL(WAIVE_INTEREST_COMMAND, loanID), getWaiveBodyAsJSON(date, amountToBeWaived));
|
||||||
getWaiveBodyAsJSON(date, amountToBeWaived));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap makeRepayment(final String date, final Float amountToBePaid, final Integer loanID) {
|
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) {
|
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));
|
getWithdrawLoanApplicationBodyAsJSON(date));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getDisburseLoanAsJSON(final String actualDisbursementDate) {
|
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("locale", "en");
|
||||||
map.put("dateFormat", "dd MMMM yyyy");
|
map.put("dateFormat", "dd MMMM yyyy");
|
||||||
map.put("actualDisbursementDate", actualDisbursementDate);
|
map.put("actualDisbursementDate", actualDisbursementDate);
|
||||||
@@ -102,7 +97,7 @@ public class LoanTransactionHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getApproveLoanAsJSON(final String approvalDate) {
|
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("locale", "en");
|
||||||
map.put("dateFormat", "dd MMMM yyyy");
|
map.put("dateFormat", "dd MMMM yyyy");
|
||||||
map.put("approvedOnDate", approvalDate);
|
map.put("approvedOnDate", approvalDate);
|
||||||
@@ -111,7 +106,7 @@ public class LoanTransactionHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getRepaymentBodyAsJSON(final String transactionDate, final Float transactionAmount) {
|
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("locale", "en");
|
||||||
map.put("dateFormat", "dd MMMM yyyy");
|
map.put("dateFormat", "dd MMMM yyyy");
|
||||||
map.put("transactionDate", transactionDate);
|
map.put("transactionDate", transactionDate);
|
||||||
@@ -121,7 +116,7 @@ public class LoanTransactionHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getWriteOffBodyAsJSON(final String transactionDate) {
|
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("dateFormat", "dd MMMM yyyy");
|
||||||
map.put("locale", "en");
|
map.put("locale", "en");
|
||||||
map.put("note", " LOAN WRITE OFF!!!");
|
map.put("note", " LOAN WRITE OFF!!!");
|
||||||
@@ -130,7 +125,7 @@ public class LoanTransactionHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getWaiveBodyAsJSON(final String transactionDate, final String amountToBeWaived) {
|
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("locale", "en");
|
||||||
map.put("dateFormat", "dd MMMM yyyy");
|
map.put("dateFormat", "dd MMMM yyyy");
|
||||||
map.put("transactionDate", transactionDate);
|
map.put("transactionDate", transactionDate);
|
||||||
@@ -139,8 +134,8 @@ public class LoanTransactionHelper {
|
|||||||
return new Gson().toJson(map);
|
return new Gson().toJson(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getWithdrawLoanApplicationBodyAsJSON(final String withdrawDate){
|
private String getWithdrawLoanApplicationBodyAsJSON(final String withdrawDate) {
|
||||||
HashMap<String, String> map = new HashMap<String, String>();
|
final HashMap<String, String> map = new HashMap<String, String>();
|
||||||
map.put("locale", "en");
|
map.put("locale", "en");
|
||||||
map.put("dateFormat", "dd MMMM yyyy");
|
map.put("dateFormat", "dd MMMM yyyy");
|
||||||
map.put("withdrawnOnDate", withdrawDate);
|
map.put("withdrawnOnDate", withdrawDate);
|
||||||
@@ -148,8 +143,9 @@ public class LoanTransactionHelper {
|
|||||||
return new Gson().toJson(map);
|
return new Gson().toJson(map);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLoanCalculationBodyAsJSON(final String productID) {
|
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("dateFormat", "dd MMMM yyyy");
|
||||||
map.put("locale", "en_GB");
|
map.put("locale", "en_GB");
|
||||||
map.put("productId", productID);
|
map.put("productId", productID);
|
||||||
@@ -169,24 +165,26 @@ public class LoanTransactionHelper {
|
|||||||
return new Gson().toJson(map);
|
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";
|
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";
|
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");
|
return (HashMap) response.get("status");
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void verifyRepaymentScheduleEntryFor(final int repaymentNumber, final float expectedPrincipalOutstanding, final Integer loanID) {
|
public void verifyRepaymentScheduleEntryFor(final int repaymentNumber, final float expectedPrincipalOutstanding, final Integer loanID) {
|
||||||
System.out.println("---------------------------GETTING LOAN REPAYMENT SCHEDULE--------------------------------");
|
System.out.println("---------------------------GETTING LOAN REPAYMENT SCHEDULE--------------------------------");
|
||||||
ArrayList<HashMap> repaymentPeriods = getLoanRepaymentSchedule(requestSpec, responseSpec, loanID);
|
final ArrayList<HashMap> repaymentPeriods = getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID);
|
||||||
assertEquals("Mismatch in Principal Loan Balance Outstanding ", expectedPrincipalOutstanding, repaymentPeriods.get(repaymentNumber).get("principalLoanBalanceOutstanding"));
|
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 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";
|
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.requestSpec = requestSpec;
|
||||||
this.responseSpec = responseSpec;
|
this.responseSpec = responseSpec;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList getTaxonomyList() {
|
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;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap getTaxonomyMapping() {
|
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;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-6
@@ -50,20 +50,21 @@ public class AccountingDropdownReadPlatformServiceImpl implements AccountingDrop
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, List<GLAccountData>> retrieveAccountMappingOptionsForLoanProducts() {
|
public Map<String, List<GLAccountData>> retrieveAccountMappingOptionsForLoanProducts() {
|
||||||
Map<String, List<GLAccountData>> accountOptions = new HashMap<String, List<GLAccountData>>();
|
final Map<String, List<GLAccountData>> accountOptions = new HashMap<String, List<GLAccountData>>();
|
||||||
List<GLAccountData> assetAccountOptions = accountReadPlatformService.retrieveAllEnabledDetailGLAccounts(GLAccountType.ASSET);
|
List<GLAccountData> assetAccountOptions = this.accountReadPlatformService.retrieveAllEnabledDetailGLAccounts(GLAccountType.ASSET);
|
||||||
if (assetAccountOptions.isEmpty()) {
|
if (assetAccountOptions.isEmpty()) {
|
||||||
assetAccountOptions = null;
|
assetAccountOptions = null;
|
||||||
}
|
}
|
||||||
accountOptions.put("assetAccountOptions", assetAccountOptions);
|
accountOptions.put("assetAccountOptions", assetAccountOptions);
|
||||||
|
|
||||||
List<GLAccountData> incomeAccountOptions = accountReadPlatformService.retrieveAllEnabledDetailGLAccounts(GLAccountType.INCOME);
|
List<GLAccountData> incomeAccountOptions = this.accountReadPlatformService.retrieveAllEnabledDetailGLAccounts(GLAccountType.INCOME);
|
||||||
if (incomeAccountOptions.isEmpty()) {
|
if (incomeAccountOptions.isEmpty()) {
|
||||||
incomeAccountOptions = null;
|
incomeAccountOptions = null;
|
||||||
}
|
}
|
||||||
accountOptions.put("incomeAccountOptions", incomeAccountOptions);
|
accountOptions.put("incomeAccountOptions", incomeAccountOptions);
|
||||||
|
|
||||||
List<GLAccountData> expenseAccountOptions = accountReadPlatformService.retrieveAllEnabledDetailGLAccounts(GLAccountType.EXPENSE);
|
List<GLAccountData> expenseAccountOptions = this.accountReadPlatformService
|
||||||
|
.retrieveAllEnabledDetailGLAccounts(GLAccountType.EXPENSE);
|
||||||
if (expenseAccountOptions.isEmpty()) {
|
if (expenseAccountOptions.isEmpty()) {
|
||||||
expenseAccountOptions = null;
|
expenseAccountOptions = null;
|
||||||
}
|
}
|
||||||
@@ -73,8 +74,8 @@ public class AccountingDropdownReadPlatformServiceImpl implements AccountingDrop
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, List<GLAccountData>> retrieveAccountMappingOptionsForSavingsProducts() {
|
public Map<String, List<GLAccountData>> retrieveAccountMappingOptionsForSavingsProducts() {
|
||||||
Map<String, List<GLAccountData>> accountOptions = retrieveAccountMappingOptionsForLoanProducts();
|
final Map<String, List<GLAccountData>> accountOptions = retrieveAccountMappingOptionsForLoanProducts();
|
||||||
List<GLAccountData> liabilityAccountOptions = accountReadPlatformService
|
List<GLAccountData> liabilityAccountOptions = this.accountReadPlatformService
|
||||||
.retrieveAllEnabledDetailGLAccounts(GLAccountType.LIABILITY);
|
.retrieveAllEnabledDetailGLAccounts(GLAccountType.LIABILITY);
|
||||||
if (liabilityAccountOptions.isEmpty()) {
|
if (liabilityAccountOptions.isEmpty()) {
|
||||||
liabilityAccountOptions = null;
|
liabilityAccountOptions = null;
|
||||||
|
|||||||
+1
-1
@@ -85,7 +85,7 @@ public class AccountingEnumerations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static EnumOptionData accountingRuleType(final AccountingRuleType type) {
|
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;
|
return optionData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -19,13 +19,13 @@ public enum AccountingRuleType {
|
|||||||
|
|
||||||
private static final Map<Integer, AccountingRuleType> intToEnumMap = new HashMap<Integer, AccountingRuleType>();
|
private static final Map<Integer, AccountingRuleType> intToEnumMap = new HashMap<Integer, AccountingRuleType>();
|
||||||
static {
|
static {
|
||||||
for (AccountingRuleType type : AccountingRuleType.values()) {
|
for (final AccountingRuleType type : AccountingRuleType.values()) {
|
||||||
intToEnumMap.put(type.value, type);
|
intToEnumMap.put(type.value, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AccountingRuleType fromInt(final Integer ruleTypeValue) {
|
public static AccountingRuleType fromInt(final Integer ruleTypeValue) {
|
||||||
AccountingRuleType type = intToEnumMap.get(ruleTypeValue);
|
final AccountingRuleType type = intToEnumMap.get(ruleTypeValue);
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -72,7 +72,8 @@ public class GLAccountCommand {
|
|||||||
baseDataValidator.reset().parameter(GLAccountJsonInputParams.MANUAL_ENTRIES_ALLOWED.getValue()).value(this.manualEntriesAllowed)
|
baseDataValidator.reset().parameter(GLAccountJsonInputParams.MANUAL_ENTRIES_ALLOWED.getValue()).value(this.manualEntriesAllowed)
|
||||||
.notBlank();
|
.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",
|
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist",
|
||||||
"Validation errors exist.", dataValidationErrors); }
|
"Validation errors exist.", dataValidationErrors); }
|
||||||
@@ -106,7 +107,8 @@ public class GLAccountCommand {
|
|||||||
|
|
||||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist",
|
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist",
|
||||||
"Validation errors exist.", dataValidationErrors); }
|
"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() {
|
public boolean isHeaderAccount() {
|
||||||
|
|||||||
+6
-6
@@ -83,7 +83,7 @@ public class GLAccount extends AbstractPersistable<Long> {
|
|||||||
this.tagId = tagId;
|
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 name = command.stringValueOfParameterNamed(GLAccountJsonInputParams.NAME.getValue());
|
||||||
final String glCode = command.stringValueOfParameterNamed(GLAccountJsonInputParams.GL_CODE.getValue());
|
final String glCode = command.stringValueOfParameterNamed(GLAccountJsonInputParams.GL_CODE.getValue());
|
||||||
final boolean disabled = command.booleanPrimitiveValueOfParameterNamed(GLAccountJsonInputParams.DISABLED.getValue());
|
final boolean disabled = command.booleanPrimitiveValueOfParameterNamed(GLAccountJsonInputParams.DISABLED.getValue());
|
||||||
@@ -211,8 +211,8 @@ public class GLAccount extends AbstractPersistable<Long> {
|
|||||||
|
|
||||||
public void generateHierarchy() {
|
public void generateHierarchy() {
|
||||||
|
|
||||||
if (parent != null) {
|
if (this.parent != null) {
|
||||||
this.hierarchy = this.parent.hierarchyOf(this.getId());
|
this.hierarchy = this.parent.hierarchyOf(getId());
|
||||||
} else {
|
} else {
|
||||||
this.hierarchy = ".";
|
this.hierarchy = ".";
|
||||||
}
|
}
|
||||||
@@ -226,12 +226,12 @@ public class GLAccount extends AbstractPersistable<Long> {
|
|||||||
return GLAccountUsage.DETAIL.getValue().equals(this.usage);
|
return GLAccountUsage.DETAIL.getValue().equals(this.usage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateTagId(CodeValue tagID) {
|
public void updateTagId(final CodeValue tagID) {
|
||||||
this.tagId = tagID;
|
this.tagId = tagID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateParentAccount(GLAccount parentAccount) {
|
public void updateParentAccount(final GLAccount parentAccount) {
|
||||||
this.parent = parentAccount;
|
this.parent = parentAccount;
|
||||||
this.generateHierarchy();
|
generateHierarchy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+3
-3
@@ -75,7 +75,7 @@ public class GLAccountWritePlatformServiceJpaRepositoryImpl implements GLAccount
|
|||||||
CodeValue glAccountTagType = null;
|
CodeValue glAccountTagType = null;
|
||||||
final Long tagId = command.longValueOfParameterNamed(GLAccountJsonInputParams.TAGID.getValue());
|
final Long tagId = command.longValueOfParameterNamed(GLAccountJsonInputParams.TAGID.getValue());
|
||||||
final Long type = command.longValueOfParameterNamed(GLAccountJsonInputParams.TYPE.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) {
|
if (tagId != null) {
|
||||||
glAccountTagType = retrieveTagId(tagId, accountType);
|
glAccountTagType = retrieveTagId(tagId, accountType);
|
||||||
@@ -113,7 +113,7 @@ public class GLAccountWritePlatformServiceJpaRepositoryImpl implements GLAccount
|
|||||||
|
|
||||||
// is the new parent valid
|
// is the new parent valid
|
||||||
if (changesOnly.containsKey(GLAccountJsonInputParams.PARENT_ID.getValue())) {
|
if (changesOnly.containsKey(GLAccountJsonInputParams.PARENT_ID.getValue())) {
|
||||||
GLAccount parentAccount = validateParentGLAccount(parentId);
|
final GLAccount parentAccount = validateParentGLAccount(parentId);
|
||||||
glAccount.updateParentAccount(parentAccount);
|
glAccount.updateParentAccount(parentAccount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,7 +203,7 @@ public class GLAccountWritePlatformServiceJpaRepositoryImpl implements GLAccount
|
|||||||
"Unknown data integrity issue with resource GL Account: " + realCause.getMessage());
|
"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;
|
CodeValue glAccountTagType = null;
|
||||||
if (accountType.isAssetType()) {
|
if (accountType.isAssetType()) {
|
||||||
glAccountTagType = this.codeValueRepositoryWrapper.findOneByCodeNameAndIdWithNotFoundDetection(
|
glAccountTagType = this.codeValueRepositoryWrapper.findOneByCodeNameAndIdWithNotFoundDetection(
|
||||||
|
|||||||
+3
-3
@@ -26,9 +26,9 @@ public class DateParam {
|
|||||||
this.dateAsString = dateStr;
|
this.dateAsString = dateStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getDate(String parameterName,String dateFormat, String localeAsString) {
|
public Date getDate(final String parameterName, final String dateFormat, final String localeAsString) {
|
||||||
Locale locale = JsonParserHelper.localeFromString(localeAsString);
|
final Locale locale = JsonParserHelper.localeFromString(localeAsString);
|
||||||
LocalDate localDate = JsonParserHelper.convertFrom(dateAsString, parameterName, dateFormat, locale);
|
final LocalDate localDate = JsonParserHelper.convertFrom(this.dateAsString, parameterName, dateFormat, locale);
|
||||||
return localDate.toDate();
|
return localDate.toDate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -94,9 +94,9 @@ public class JournalEntriesApiResource {
|
|||||||
|
|
||||||
final SearchParameters searchParameters = SearchParameters.forJournalEntries(officeId, offset, limit, orderBy, sortOrder);
|
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);
|
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);
|
return this.apiJsonSerializerService.serialize(settings, glJournalEntries, RESPONSE_DATA_PARAMETERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@ public class ChargePaymentDTO {
|
|||||||
private final BigDecimal amount;
|
private final BigDecimal amount;
|
||||||
private final Long loanChargeId;
|
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.chargeId = chargeId;
|
||||||
this.amount = amount;
|
this.amount = amount;
|
||||||
this.loanChargeId = loanChargeId;
|
this.loanChargeId = loanChargeId;
|
||||||
|
|||||||
+2
-1
@@ -63,7 +63,8 @@ public class JournalEntryData {
|
|||||||
final Long glAccountId, final String glAccountCode, final EnumOptionData glAccountClassification,
|
final Long glAccountId, final String glAccountCode, final EnumOptionData glAccountClassification,
|
||||||
final LocalDate transactionDate, final EnumOptionData entryType, final BigDecimal amount, final String transactionId,
|
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 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.id = id;
|
||||||
this.officeId = officeId;
|
this.officeId = officeId;
|
||||||
this.officeName = officeName;
|
this.officeName = officeName;
|
||||||
|
|||||||
+1
-1
@@ -82,7 +82,7 @@ public class LoanDTO {
|
|||||||
return this.currencyCode;
|
return this.currencyCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCurrencyCode(String currencyCode) {
|
public void setCurrencyCode(final String currencyCode) {
|
||||||
this.currencyCode = currencyCode;
|
this.currencyCode = currencyCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-7
@@ -33,7 +33,7 @@ public class SavingsDTO {
|
|||||||
return this.savingsId;
|
return this.savingsId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSavingsId(Long savingsId) {
|
public void setSavingsId(final Long savingsId) {
|
||||||
this.savingsId = savingsId;
|
this.savingsId = savingsId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ public class SavingsDTO {
|
|||||||
return this.savingsProductId;
|
return this.savingsProductId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSavingsProductId(Long savingsProductId) {
|
public void setSavingsProductId(final Long savingsProductId) {
|
||||||
this.savingsProductId = savingsProductId;
|
this.savingsProductId = savingsProductId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ public class SavingsDTO {
|
|||||||
return this.officeId;
|
return this.officeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOfficeId(Long officeId) {
|
public void setOfficeId(final Long officeId) {
|
||||||
this.officeId = officeId;
|
this.officeId = officeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ public class SavingsDTO {
|
|||||||
return this.cashBasedAccountingEnabled;
|
return this.cashBasedAccountingEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCashBasedAccountingEnabled(boolean cashBasedAccountingEnabled) {
|
public void setCashBasedAccountingEnabled(final boolean cashBasedAccountingEnabled) {
|
||||||
this.cashBasedAccountingEnabled = cashBasedAccountingEnabled;
|
this.cashBasedAccountingEnabled = cashBasedAccountingEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ public class SavingsDTO {
|
|||||||
return this.accrualBasedAccountingEnabled;
|
return this.accrualBasedAccountingEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAccrualBasedAccountingEnabled(boolean accrualBasedAccountingEnabled) {
|
public void setAccrualBasedAccountingEnabled(final boolean accrualBasedAccountingEnabled) {
|
||||||
this.accrualBasedAccountingEnabled = accrualBasedAccountingEnabled;
|
this.accrualBasedAccountingEnabled = accrualBasedAccountingEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ public class SavingsDTO {
|
|||||||
return this.newSavingsTransactions;
|
return this.newSavingsTransactions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNewSavingsTransactions(List<SavingsTransactionDTO> newSavingsTransactions) {
|
public void setNewSavingsTransactions(final List<SavingsTransactionDTO> newSavingsTransactions) {
|
||||||
this.newSavingsTransactions = newSavingsTransactions;
|
this.newSavingsTransactions = newSavingsTransactions;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,7 +81,7 @@ public class SavingsDTO {
|
|||||||
return this.currencyCode;
|
return this.currencyCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCurrencyCode(String currencyCode) {
|
public void setCurrencyCode(final String currencyCode) {
|
||||||
this.currencyCode = currencyCode;
|
this.currencyCode = currencyCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -16,8 +16,7 @@ public class JournalEntryInvalidException extends AbstractPlatformDomainRuleExce
|
|||||||
|
|
||||||
/*** enum of reasons for invalid Journal Entry **/
|
/*** enum of reasons for invalid Journal Entry **/
|
||||||
public static enum GL_JOURNAL_ENTRY_INVALID_REASON {
|
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,
|
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;
|
||||||
INVALID_DEBIT_OR_CREDIT_ACCOUNTS;
|
|
||||||
|
|
||||||
public String errorMessage() {
|
public String errorMessage() {
|
||||||
if (name().toString().equalsIgnoreCase("FUTURE_DATE")) {
|
if (name().toString().equalsIgnoreCase("FUTURE_DATE")) {
|
||||||
|
|||||||
+5
-5
@@ -13,10 +13,10 @@ import org.springframework.stereotype.Component;
|
|||||||
@Component
|
@Component
|
||||||
public class AccountingProcessorForLoanFactory {
|
public class AccountingProcessorForLoanFactory {
|
||||||
|
|
||||||
private ApplicationContext applicationContext;
|
private final ApplicationContext applicationContext;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public AccountingProcessorForLoanFactory(ApplicationContext applicationContext) {
|
public AccountingProcessorForLoanFactory(final ApplicationContext applicationContext) {
|
||||||
this.applicationContext = applicationContext;
|
this.applicationContext = applicationContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,12 +25,12 @@ public class AccountingProcessorForLoanFactory {
|
|||||||
AccountingProcessorForLoan accountingProcessorForLoan = null;
|
AccountingProcessorForLoan accountingProcessorForLoan = null;
|
||||||
|
|
||||||
if (loanDTO.isCashBasedAccountingEnabled()) {
|
if (loanDTO.isCashBasedAccountingEnabled()) {
|
||||||
accountingProcessorForLoan = applicationContext
|
accountingProcessorForLoan = this.applicationContext.getBean("cashBasedAccountingProcessorForLoan",
|
||||||
.getBean("cashBasedAccountingProcessorForLoan", AccountingProcessorForLoan.class);
|
AccountingProcessorForLoan.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (loanDTO.isAccrualBasedAccountingEnabled()) {
|
else if (loanDTO.isAccrualBasedAccountingEnabled()) {
|
||||||
accountingProcessorForLoan = applicationContext.getBean("accrualBasedAccountingProcessorForLoan",
|
accountingProcessorForLoan = this.applicationContext.getBean("accrualBasedAccountingProcessorForLoan",
|
||||||
AccountingProcessorForLoan.class);
|
AccountingProcessorForLoan.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -13,10 +13,10 @@ import org.springframework.stereotype.Component;
|
|||||||
@Component
|
@Component
|
||||||
public class AccountingProcessorForSavingsFactory {
|
public class AccountingProcessorForSavingsFactory {
|
||||||
|
|
||||||
private ApplicationContext applicationContext;
|
private final ApplicationContext applicationContext;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public AccountingProcessorForSavingsFactory(ApplicationContext applicationContext) {
|
public AccountingProcessorForSavingsFactory(final ApplicationContext applicationContext) {
|
||||||
this.applicationContext = applicationContext;
|
this.applicationContext = applicationContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ public class AccountingProcessorForSavingsFactory {
|
|||||||
AccountingProcessorForSavings accountingProcessorForSavings = null;
|
AccountingProcessorForSavings accountingProcessorForSavings = null;
|
||||||
|
|
||||||
if (savingsDTO.isCashBasedAccountingEnabled()) {
|
if (savingsDTO.isCashBasedAccountingEnabled()) {
|
||||||
accountingProcessorForSavings = applicationContext.getBean("cashBasedAccountingProcessorForSavings",
|
accountingProcessorForSavings = this.applicationContext.getBean("cashBasedAccountingProcessorForSavings",
|
||||||
AccountingProcessorForSavings.class);
|
AccountingProcessorForSavings.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+26
-26
@@ -84,8 +84,8 @@ public class AccountingProcessorHelper {
|
|||||||
final boolean reversed = (Boolean) map.get("reversed");
|
final boolean reversed = (Boolean) map.get("reversed");
|
||||||
final Long paymentTypeId = (Long) map.get("paymentTypeId");
|
final Long paymentTypeId = (Long) map.get("paymentTypeId");
|
||||||
|
|
||||||
List<ChargePaymentDTO> feePayments = new ArrayList<ChargePaymentDTO>();
|
final List<ChargePaymentDTO> feePayments = new ArrayList<ChargePaymentDTO>();
|
||||||
List<ChargePaymentDTO> penaltyPayments = new ArrayList<ChargePaymentDTO>();
|
final List<ChargePaymentDTO> penaltyPayments = new ArrayList<ChargePaymentDTO>();
|
||||||
// extract charge payment details (if exists)
|
// extract charge payment details (if exists)
|
||||||
if (map.containsKey("loanChargesPaid")) {
|
if (map.containsKey("loanChargesPaid")) {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@@ -95,7 +95,7 @@ public class AccountingProcessorHelper {
|
|||||||
final Long loanChargeId = (Long) loanChargePaid.get("chargeId");
|
final Long loanChargeId = (Long) loanChargePaid.get("chargeId");
|
||||||
final boolean isPenalty = (Boolean) loanChargePaid.get("isPenalty");
|
final boolean isPenalty = (Boolean) loanChargePaid.get("isPenalty");
|
||||||
final BigDecimal chargeAmountPaid = (BigDecimal) loanChargePaid.get("amount");
|
final BigDecimal chargeAmountPaid = (BigDecimal) loanChargePaid.get("amount");
|
||||||
ChargePaymentDTO chargePaymentDTO = new ChargePaymentDTO(chargeId, loanChargeId, chargeAmountPaid);
|
final ChargePaymentDTO chargePaymentDTO = new ChargePaymentDTO(chargeId, loanChargeId, chargeAmountPaid);
|
||||||
if (isPenalty) {
|
if (isPenalty) {
|
||||||
penaltyPayments.add(chargePaymentDTO);
|
penaltyPayments.add(chargePaymentDTO);
|
||||||
} else {
|
} else {
|
||||||
@@ -254,7 +254,7 @@ public class AccountingProcessorHelper {
|
|||||||
public void createCreditJournalEntryOrReversalForLoan(final Office office, final String currencyCode,
|
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 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) {
|
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,
|
createCreditJournalEntryOrReversalForLoan(office, currencyCode, accountMappingTypeId, loanProductId, paymentTypeId, loanId,
|
||||||
transactionId, transactionDate, amount, isReversal);
|
transactionId, transactionDate, amount, isReversal);
|
||||||
}
|
}
|
||||||
@@ -262,7 +262,7 @@ public class AccountingProcessorHelper {
|
|||||||
public void createCreditJournalEntryOrReversalForLoan(final Office office, final String currencyCode,
|
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 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) {
|
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,
|
createCreditJournalEntryOrReversalForLoan(office, currencyCode, accountMappingTypeId, loanProductId, paymentTypeId, loanId,
|
||||||
transactionId, transactionDate, amount, isReversal);
|
transactionId, transactionDate, amount, isReversal);
|
||||||
}
|
}
|
||||||
@@ -270,7 +270,7 @@ public class AccountingProcessorHelper {
|
|||||||
public void createDebitJournalEntryOrReversalForLoan(final Office office, final String currencyCode,
|
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 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) {
|
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,
|
createDebitJournalEntryOrReversalForLoan(office, currencyCode, accountMappingTypeId, loanProductId, paymentTypeId, loanId,
|
||||||
transactionId, transactionDate, amount, isReversal);
|
transactionId, transactionDate, amount, isReversal);
|
||||||
}
|
}
|
||||||
@@ -278,7 +278,7 @@ public class AccountingProcessorHelper {
|
|||||||
public void createDebitJournalEntryOrReversalForLoan(final Office office, final String currencyCode,
|
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 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) {
|
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,
|
createDebitJournalEntryOrReversalForLoan(office, currencyCode, accountMappingTypeId, loanProductId, paymentTypeId, loanId,
|
||||||
transactionId, transactionDate, amount, isReversal);
|
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);
|
return this.closureRepository.getLatestGLClosureByBranch(officeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Office getOfficeById(long officeId) {
|
public Office getOfficeById(final long officeId) {
|
||||||
return this.officeRepository.findOne(officeId);
|
return this.officeRepository.findOne(officeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createJournalEntriesForLoan(final Office office, final String currencyCode, final int accountTypeToDebitId,
|
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 int accountTypeToCreditId, final Long loanProductId, final Long paymentTypeId, final Long loanId,
|
||||||
final String transactionId, final Date transactionDate, final BigDecimal amount) {
|
final String transactionId, final Date transactionDate, final BigDecimal amount) {
|
||||||
GLAccount debitAccount = getLinkedGLAccountForLoanProduct(loanProductId, accountTypeToDebitId, paymentTypeId);
|
final GLAccount debitAccount = getLinkedGLAccountForLoanProduct(loanProductId, accountTypeToDebitId, paymentTypeId);
|
||||||
GLAccount creditAccount = getLinkedGLAccountForLoanProduct(loanProductId, accountTypeToCreditId, paymentTypeId);
|
final GLAccount creditAccount = getLinkedGLAccountForLoanProduct(loanProductId, accountTypeToCreditId, paymentTypeId);
|
||||||
createDebitJournalEntryForLoan(office, currencyCode, debitAccount, loanId, transactionId, transactionDate, amount);
|
createDebitJournalEntryForLoan(office, currencyCode, debitAccount, loanId, transactionId, transactionDate, amount);
|
||||||
createCreditJournalEntryForLoan(office, currencyCode, creditAccount, 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,
|
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 int accountTypeToCreditId, final Long savingsProductId, final Long paymentTypeId, final Long savingsId,
|
||||||
final String transactionId, final Date transactionDate, final BigDecimal amount) {
|
final String transactionId, final Date transactionDate, final BigDecimal amount) {
|
||||||
GLAccount debitAccount = getLinkedGLAccountForSavingsProduct(savingsProductId, accountTypeToDebitId, paymentTypeId);
|
final GLAccount debitAccount = getLinkedGLAccountForSavingsProduct(savingsProductId, accountTypeToDebitId, paymentTypeId);
|
||||||
GLAccount creditAccount = getLinkedGLAccountForSavingsProduct(savingsProductId, accountTypeToCreditId, paymentTypeId);
|
final GLAccount creditAccount = getLinkedGLAccountForSavingsProduct(savingsProductId, accountTypeToCreditId, paymentTypeId);
|
||||||
createDebitJournalEntryForSavings(office, currencyCode, debitAccount, savingsId, transactionId, transactionDate, amount);
|
createDebitJournalEntryForSavings(office, currencyCode, debitAccount, savingsId, transactionId, transactionDate, amount);
|
||||||
createCreditJournalEntryForSavings(office, currencyCode, creditAccount, 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,
|
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 Long loanProductId, final Long paymentTypeId, final Long loanId, final String transactionId, final Date transactionDate,
|
||||||
final BigDecimal amount, final Boolean isReversal) {
|
final BigDecimal amount, final Boolean isReversal) {
|
||||||
GLAccount account = getLinkedGLAccountForLoanProduct(loanProductId, accountMappingTypeId, paymentTypeId);
|
final GLAccount account = getLinkedGLAccountForLoanProduct(loanProductId, accountMappingTypeId, paymentTypeId);
|
||||||
if (isReversal) {
|
if (isReversal) {
|
||||||
createCreditJournalEntryForLoan(office, currencyCode, account, loanId, transactionId, transactionDate, amount);
|
createCreditJournalEntryForLoan(office, currencyCode, account, loanId, transactionId, transactionDate, amount);
|
||||||
} else {
|
} else {
|
||||||
@@ -343,25 +343,25 @@ public class AccountingProcessorHelper {
|
|||||||
* Map to track each account and the net credit to be made for a
|
* Map to track each account and the net credit to be made for a
|
||||||
* particular account
|
* particular account
|
||||||
***/
|
***/
|
||||||
Map<GLAccount, BigDecimal> creditDetailsMap = new LinkedHashMap<GLAccount, BigDecimal>();
|
final Map<GLAccount, BigDecimal> creditDetailsMap = new LinkedHashMap<GLAccount, BigDecimal>();
|
||||||
for (ChargePaymentDTO chargePaymentDTO : chargePaymentDTOs) {
|
for (final ChargePaymentDTO chargePaymentDTO : chargePaymentDTOs) {
|
||||||
Long chargeId = chargePaymentDTO.getChargeId();
|
final Long chargeId = chargePaymentDTO.getChargeId();
|
||||||
GLAccount chargeSpecificAccount = getLinkedGLAccountForLoanCharges(loanProductId, accountMappingTypeId, chargeId);
|
final GLAccount chargeSpecificAccount = getLinkedGLAccountForLoanCharges(loanProductId, accountMappingTypeId, chargeId);
|
||||||
BigDecimal chargeSpecificAmount = chargePaymentDTO.getAmount();
|
BigDecimal chargeSpecificAmount = chargePaymentDTO.getAmount();
|
||||||
|
|
||||||
// adjust net credit amount if the account is already present in the
|
// adjust net credit amount if the account is already present in the
|
||||||
// map
|
// map
|
||||||
if (creditDetailsMap.containsKey(chargeSpecificAccount)) {
|
if (creditDetailsMap.containsKey(chargeSpecificAccount)) {
|
||||||
BigDecimal existingAmount = creditDetailsMap.get(chargeSpecificAccount);
|
final BigDecimal existingAmount = creditDetailsMap.get(chargeSpecificAccount);
|
||||||
chargeSpecificAmount = chargeSpecificAmount.add(existingAmount);
|
chargeSpecificAmount = chargeSpecificAmount.add(existingAmount);
|
||||||
}
|
}
|
||||||
creditDetailsMap.put(chargeSpecificAccount, chargeSpecificAmount);
|
creditDetailsMap.put(chargeSpecificAccount, chargeSpecificAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
BigDecimal totalCreditedAmount = BigDecimal.ZERO;
|
BigDecimal totalCreditedAmount = BigDecimal.ZERO;
|
||||||
for (Map.Entry<GLAccount, BigDecimal> entry : creditDetailsMap.entrySet()) {
|
for (final Map.Entry<GLAccount, BigDecimal> entry : creditDetailsMap.entrySet()) {
|
||||||
GLAccount account = entry.getKey();
|
final GLAccount account = entry.getKey();
|
||||||
BigDecimal amount = entry.getValue();
|
final BigDecimal amount = entry.getValue();
|
||||||
totalCreditedAmount = totalCreditedAmount.add(amount);
|
totalCreditedAmount = totalCreditedAmount.add(amount);
|
||||||
if (isReversal) {
|
if (isReversal) {
|
||||||
createDebitJournalEntryForLoan(office, currencyCode, account, loanId, transactionId, transactionDate, amount);
|
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,
|
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 Long loanProductId, final Long paymentTypeId, final Long loanId, final String transactionId, final Date transactionDate,
|
||||||
final BigDecimal amount, final Boolean isReversal) {
|
final BigDecimal amount, final Boolean isReversal) {
|
||||||
GLAccount account = getLinkedGLAccountForLoanProduct(loanProductId, accountMappingTypeId, paymentTypeId);
|
final GLAccount account = getLinkedGLAccountForLoanProduct(loanProductId, accountMappingTypeId, paymentTypeId);
|
||||||
if (isReversal) {
|
if (isReversal) {
|
||||||
createDebitJournalEntryForLoan(office, currencyCode, account, loanId, transactionId, transactionDate, amount);
|
createDebitJournalEntryForLoan(office, currencyCode, account, loanId, transactionId, transactionDate, amount);
|
||||||
} else {
|
} else {
|
||||||
@@ -430,7 +430,7 @@ public class AccountingProcessorHelper {
|
|||||||
* both cash and accrual accounts
|
* both cash and accrual accounts
|
||||||
***/
|
***/
|
||||||
if (accountMappingTypeId == CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue()) {
|
if (accountMappingTypeId == CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue()) {
|
||||||
ProductToGLAccountMapping paymentChannelSpecificAccountMapping = this.accountMappingRepository
|
final ProductToGLAccountMapping paymentChannelSpecificAccountMapping = this.accountMappingRepository
|
||||||
.findByProductIdAndProductTypeAndFinancialAccountTypeAndPaymentTypeId(loanProductId,
|
.findByProductIdAndProductTypeAndFinancialAccountTypeAndPaymentTypeId(loanProductId,
|
||||||
PortfolioProductType.LOAN.getValue(), accountMappingTypeId, paymentTypeId);
|
PortfolioProductType.LOAN.getValue(), accountMappingTypeId, paymentTypeId);
|
||||||
if (paymentChannelSpecificAccountMapping != null) {
|
if (paymentChannelSpecificAccountMapping != null) {
|
||||||
@@ -454,7 +454,7 @@ public class AccountingProcessorHelper {
|
|||||||
// Vishwas TODO: remove this condition as it should always be true
|
// Vishwas TODO: remove this condition as it should always be true
|
||||||
if (accountMappingTypeId == CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_FEES.getValue()
|
if (accountMappingTypeId == CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_FEES.getValue()
|
||||||
|| accountMappingTypeId == CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_PENALTIES.getValue()) {
|
|| accountMappingTypeId == CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_PENALTIES.getValue()) {
|
||||||
ProductToGLAccountMapping chargeSpecificIncomeAccountMapping = this.accountMappingRepository
|
final ProductToGLAccountMapping chargeSpecificIncomeAccountMapping = this.accountMappingRepository
|
||||||
.findByProductIdAndProductTypeAndFinancialAccountTypeAndChargeId(loanProductId, PortfolioProductType.LOAN.getValue(),
|
.findByProductIdAndProductTypeAndFinancialAccountTypeAndChargeId(loanProductId, PortfolioProductType.LOAN.getValue(),
|
||||||
accountMappingTypeId, chargeId);
|
accountMappingTypeId, chargeId);
|
||||||
if (chargeSpecificIncomeAccountMapping != null) {
|
if (chargeSpecificIncomeAccountMapping != null) {
|
||||||
@@ -474,7 +474,7 @@ public class AccountingProcessorHelper {
|
|||||||
* both cash and accrual accounts
|
* both cash and accrual accounts
|
||||||
***/
|
***/
|
||||||
if (accountMappingTypeId == CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue()) {
|
if (accountMappingTypeId == CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue()) {
|
||||||
ProductToGLAccountMapping paymentChannelSpecificAccountMapping = this.accountMappingRepository
|
final ProductToGLAccountMapping paymentChannelSpecificAccountMapping = this.accountMappingRepository
|
||||||
.findByProductIdAndProductTypeAndFinancialAccountTypeAndPaymentTypeId(savingsProductId,
|
.findByProductIdAndProductTypeAndFinancialAccountTypeAndPaymentTypeId(savingsProductId,
|
||||||
PortfolioProductType.SAVING.getValue(), accountMappingTypeId, paymentTypeId);
|
PortfolioProductType.SAVING.getValue(), accountMappingTypeId, paymentTypeId);
|
||||||
if (paymentChannelSpecificAccountMapping != null) {
|
if (paymentChannelSpecificAccountMapping != null) {
|
||||||
|
|||||||
+19
-18
@@ -32,7 +32,7 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
|||||||
final Office office = this.helper.getOfficeById(loanDTO.getOfficeId());
|
final Office office = this.helper.getOfficeById(loanDTO.getOfficeId());
|
||||||
for (final LoanTransactionDTO loanTransactionDTO : loanDTO.getNewLoanTransactions()) {
|
for (final LoanTransactionDTO loanTransactionDTO : loanDTO.getNewLoanTransactions()) {
|
||||||
final Date transactionDate = loanTransactionDTO.getTransactionDate();
|
final Date transactionDate = loanTransactionDTO.getTransactionDate();
|
||||||
helper.checkForBranchClosures(latestGLClosure, transactionDate);
|
this.helper.checkForBranchClosures(latestGLClosure, transactionDate);
|
||||||
|
|
||||||
/** Handle Disbursements **/
|
/** Handle Disbursements **/
|
||||||
if (loanTransactionDTO.getTransactionType().isDisbursement()) {
|
if (loanTransactionDTO.getTransactionType().isDisbursement()) {
|
||||||
@@ -54,7 +54,8 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
|||||||
* Repayments and Repayments at disbursement
|
* Repayments and Repayments at disbursement
|
||||||
***/
|
***/
|
||||||
else if (loanTransactionDTO.getTransactionType().isRepayment()
|
else if (loanTransactionDTO.getTransactionType().isRepayment()
|
||||||
|| loanTransactionDTO.getTransactionType().isRepaymentAtDisbursement() || loanTransactionDTO.getTransactionType().isChargePayment()) {
|
|| loanTransactionDTO.getTransactionType().isRepaymentAtDisbursement()
|
||||||
|
|| loanTransactionDTO.getTransactionType().isChargePayment()) {
|
||||||
createJournalEntriesForRepaymentsAndWriteOffs(loanDTO, loanTransactionDTO, office, false, loanTransactionDTO
|
createJournalEntriesForRepaymentsAndWriteOffs(loanDTO, loanTransactionDTO, office, false, loanTransactionDTO
|
||||||
.getTransactionType().isRepaymentAtDisbursement() || loanTransactionDTO.getTransactionType().isChargePayment());
|
.getTransactionType().isRepaymentAtDisbursement() || loanTransactionDTO.getTransactionType().isChargePayment());
|
||||||
}
|
}
|
||||||
@@ -91,7 +92,7 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
|||||||
|
|
||||||
// create journal entries for the disbursement (or disbursement
|
// create journal entries for the disbursement (or disbursement
|
||||||
// reversal)
|
// 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,
|
ACCRUAL_ACCOUNTS_FOR_LOAN.FUND_SOURCE, loanProductId, paymentTypeId, loanId, transactionId, transactionDate,
|
||||||
disbursalAmount, isReversed);
|
disbursalAmount, isReversed);
|
||||||
|
|
||||||
@@ -122,9 +123,9 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
|||||||
|
|
||||||
// create journal entries for recognising interest (or reversal)
|
// create journal entries for recognising interest (or reversal)
|
||||||
if (amount != null && !(amount.compareTo(BigDecimal.ZERO) == 0)) {
|
if (amount != null && !(amount.compareTo(BigDecimal.ZERO) == 0)) {
|
||||||
helper.createAccrualBasedJournalEntriesAndReversalsForLoan(office, currencyCode, ACCRUAL_ACCOUNTS_FOR_LOAN.INTEREST_RECEIVABLE,
|
this.helper.createAccrualBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
|
||||||
ACCRUAL_ACCOUNTS_FOR_LOAN.INTEREST_ON_LOANS, loanProductId, paymentTypeId, loanId, transactionId, transactionDate,
|
ACCRUAL_ACCOUNTS_FOR_LOAN.INTEREST_RECEIVABLE, ACCRUAL_ACCOUNTS_FOR_LOAN.INTEREST_ON_LOANS, loanProductId,
|
||||||
amount, isReversed);
|
paymentTypeId, loanId, transactionId, transactionDate, amount, isReversed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,14 +192,14 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
|||||||
// handle principal payment or writeOff (and reversals)
|
// handle principal payment or writeOff (and reversals)
|
||||||
if (principalAmount != null && !(principalAmount.compareTo(BigDecimal.ZERO) == 0)) {
|
if (principalAmount != null && !(principalAmount.compareTo(BigDecimal.ZERO) == 0)) {
|
||||||
totalDebitAmount = totalDebitAmount.add(principalAmount);
|
totalDebitAmount = totalDebitAmount.add(principalAmount);
|
||||||
helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, ACCRUAL_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO, loanProductId,
|
this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, ACCRUAL_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO,
|
||||||
paymentTypeId, loanId, transactionId, transactionDate, principalAmount, isReversal);
|
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, principalAmount, isReversal);
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle interest payment of writeOff (and reversals)
|
// handle interest payment of writeOff (and reversals)
|
||||||
if (interestAmount != null && !(interestAmount.compareTo(BigDecimal.ZERO) == 0)) {
|
if (interestAmount != null && !(interestAmount.compareTo(BigDecimal.ZERO) == 0)) {
|
||||||
totalDebitAmount = totalDebitAmount.add(interestAmount);
|
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);
|
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, interestAmount, isReversal);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,14 +213,14 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
|||||||
feeAccountToCredit = ACCRUAL_ACCOUNTS_FOR_LOAN.INCOME_FROM_FEES;
|
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);
|
loanId, transactionId, transactionDate, feesAmount, isReversal);
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle penalties payment of writeOff (and reversals)
|
// handle penalties payment of writeOff (and reversals)
|
||||||
if (penaltiesAmount != null && !(penaltiesAmount.compareTo(BigDecimal.ZERO) == 0)) {
|
if (penaltiesAmount != null && !(penaltiesAmount.compareTo(BigDecimal.ZERO) == 0)) {
|
||||||
totalDebitAmount = totalDebitAmount.add(penaltiesAmount);
|
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);
|
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, penaltiesAmount, isReversal);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,11 +229,11 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
|||||||
* reversals)
|
* reversals)
|
||||||
***/
|
***/
|
||||||
if (writeOff) {
|
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);
|
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, totalDebitAmount, isReversal);
|
||||||
} else {
|
} else {
|
||||||
helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, ACCRUAL_ACCOUNTS_FOR_LOAN.FUND_SOURCE, loanProductId,
|
this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, ACCRUAL_ACCOUNTS_FOR_LOAN.FUND_SOURCE,
|
||||||
paymentTypeId, loanId, transactionId, transactionDate, totalDebitAmount, isReversal);
|
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)
|
// create journal entries for the fees application (or reversal)
|
||||||
if (feesAmount != null && !(feesAmount.compareTo(BigDecimal.ZERO) == 0)) {
|
if (feesAmount != null && !(feesAmount.compareTo(BigDecimal.ZERO) == 0)) {
|
||||||
helper.createAccrualBasedJournalEntriesAndReversalsForLoan(office, currencyCode, ACCRUAL_ACCOUNTS_FOR_LOAN.FEES_RECEIVABLE,
|
this.helper.createAccrualBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
|
||||||
ACCRUAL_ACCOUNTS_FOR_LOAN.INCOME_FROM_FEES, loanProductId, paymentTypeId, loanId, transactionId, transactionDate,
|
ACCRUAL_ACCOUNTS_FOR_LOAN.FEES_RECEIVABLE, ACCRUAL_ACCOUNTS_FOR_LOAN.INCOME_FROM_FEES, loanProductId, paymentTypeId,
|
||||||
feesAmount, isReversed);
|
loanId, transactionId, transactionDate, feesAmount, isReversed);
|
||||||
}
|
}
|
||||||
// create journal entries for the penalties application (or reversal)
|
// create journal entries for the penalties application (or reversal)
|
||||||
else if (penaltiesAmount != null && !(penaltiesAmount.compareTo(BigDecimal.ZERO) == 0)) {
|
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,
|
ACCRUAL_ACCOUNTS_FOR_LOAN.PENALTIES_RECEIVABLE, ACCRUAL_ACCOUNTS_FOR_LOAN.INCOME_FROM_PENALTIES, loanProductId,
|
||||||
paymentTypeId, loanId, transactionId, transactionDate, penaltiesAmount, isReversed);
|
paymentTypeId, loanId, transactionId, transactionDate, penaltiesAmount, isReversed);
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-15
@@ -27,7 +27,7 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createJournalEntriesForLoan(LoanDTO loanDTO) {
|
public void createJournalEntriesForLoan(final LoanDTO loanDTO) {
|
||||||
final GLClosure latestGLClosure = this.helper.getLatestClosureByBranch(loanDTO.getOfficeId());
|
final GLClosure latestGLClosure = this.helper.getLatestClosureByBranch(loanDTO.getOfficeId());
|
||||||
// final Office office =
|
// final Office office =
|
||||||
// this.helper.getOfficeById(loanDTO.getOfficeId());
|
// this.helper.getOfficeById(loanDTO.getOfficeId());
|
||||||
@@ -40,7 +40,7 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
|
|||||||
final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId();
|
final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId();
|
||||||
final Long loanId = loanDTO.getLoanId();
|
final Long loanId = loanDTO.getLoanId();
|
||||||
|
|
||||||
helper.checkForBranchClosures(latestGLClosure, transactionDate);
|
this.helper.checkForBranchClosures(latestGLClosure, transactionDate);
|
||||||
|
|
||||||
/** Handle Disbursements and reversals of disbursements **/
|
/** Handle Disbursements and reversals of disbursements **/
|
||||||
if (loanTransactionDTO.getTransactionType().isDisbursement()) {
|
if (loanTransactionDTO.getTransactionType().isDisbursement()) {
|
||||||
@@ -62,9 +62,9 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
|
|||||||
**/
|
**/
|
||||||
else if (loanTransactionDTO.getTransactionType().isWriteOff() && !loanTransactionDTO.isReversed()) {
|
else if (loanTransactionDTO.getTransactionType().isWriteOff() && !loanTransactionDTO.isReversed()) {
|
||||||
final BigDecimal principalAmount = loanTransactionDTO.getPrincipal();
|
final BigDecimal principalAmount = loanTransactionDTO.getPrincipal();
|
||||||
helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.LOSSES_WRITTEN_OFF,
|
this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
|
||||||
CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO, loanProductId, paymentTypeId, loanId, transactionId, transactionDate,
|
CASH_ACCOUNTS_FOR_LOAN.LOSSES_WRITTEN_OFF, CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO, loanProductId, paymentTypeId,
|
||||||
principalAmount, false);
|
loanId, transactionId, transactionDate, principalAmount, false);
|
||||||
} else if (loanTransactionDTO.getTransactionType().isInitiateTransfer()
|
} else if (loanTransactionDTO.getTransactionType().isInitiateTransfer()
|
||||||
|| loanTransactionDTO.getTransactionType().isApproveTransfer()
|
|| loanTransactionDTO.getTransactionType().isApproveTransfer()
|
||||||
|| loanTransactionDTO.getTransactionType().isWithdrawTransfer()) {
|
|| loanTransactionDTO.getTransactionType().isWithdrawTransfer()) {
|
||||||
@@ -98,7 +98,7 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
|
|||||||
final boolean isReversal = loanTransactionDTO.isReversed();
|
final boolean isReversal = loanTransactionDTO.isReversed();
|
||||||
final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId();
|
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,
|
CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE, loanProductId, paymentTypeId, loanId, transactionId, transactionDate, disbursalAmount,
|
||||||
isReversal);
|
isReversal);
|
||||||
}
|
}
|
||||||
@@ -132,32 +132,32 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
|
|||||||
|
|
||||||
if (principalAmount != null && !(principalAmount.compareTo(BigDecimal.ZERO) == 0)) {
|
if (principalAmount != null && !(principalAmount.compareTo(BigDecimal.ZERO) == 0)) {
|
||||||
totalDebitAmount = totalDebitAmount.add(principalAmount);
|
totalDebitAmount = totalDebitAmount.add(principalAmount);
|
||||||
helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO, loanProductId,
|
this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO,
|
||||||
paymentTypeId, loanId, transactionId, transactionDate, principalAmount, isReversal);
|
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, principalAmount, isReversal);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (interestAmount != null && !(interestAmount.compareTo(BigDecimal.ZERO) == 0)) {
|
if (interestAmount != null && !(interestAmount.compareTo(BigDecimal.ZERO) == 0)) {
|
||||||
totalDebitAmount = totalDebitAmount.add(interestAmount);
|
totalDebitAmount = totalDebitAmount.add(interestAmount);
|
||||||
helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.INTEREST_ON_LOANS, loanProductId,
|
this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.INTEREST_ON_LOANS,
|
||||||
paymentTypeId, loanId, transactionId, transactionDate, interestAmount, isReversal);
|
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, interestAmount, isReversal);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (feesAmount != null && !(feesAmount.compareTo(BigDecimal.ZERO) == 0)) {
|
if (feesAmount != null && !(feesAmount.compareTo(BigDecimal.ZERO) == 0)) {
|
||||||
totalDebitAmount = totalDebitAmount.add(feesAmount);
|
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,
|
CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_FEES.getValue(), loanProductId, loanId, transactionId, transactionDate, feesAmount,
|
||||||
isReversal, loanTransactionDTO.getFeePayments());
|
isReversal, loanTransactionDTO.getFeePayments());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (penaltiesAmount != null && !(penaltiesAmount.compareTo(BigDecimal.ZERO) == 0)) {
|
if (penaltiesAmount != null && !(penaltiesAmount.compareTo(BigDecimal.ZERO) == 0)) {
|
||||||
totalDebitAmount = totalDebitAmount.add(penaltiesAmount);
|
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,
|
CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_PENALTIES.getValue(), loanProductId, loanId, transactionId, transactionDate,
|
||||||
penaltiesAmount, isReversal, loanTransactionDTO.getPenaltyPayments());
|
penaltiesAmount, isReversal, loanTransactionDTO.getPenaltyPayments());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** create a single debit entry (or reversal) for the entire amount **/
|
/*** 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);
|
paymentTypeId, loanId, transactionId, transactionDate, totalDebitAmount, isReversal);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,12 +188,12 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
|
|||||||
// final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId();
|
// final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId();
|
||||||
|
|
||||||
if (loanTransactionDTO.getTransactionType().isInitiateTransfer()) {
|
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,
|
CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO, loanProductId, null, loanId, transactionId, transactionDate, principalAmount,
|
||||||
isReversal);
|
isReversal);
|
||||||
} else if (loanTransactionDTO.getTransactionType().isApproveTransfer()
|
} else if (loanTransactionDTO.getTransactionType().isApproveTransfer()
|
||||||
|| loanTransactionDTO.getTransactionType().isWithdrawTransfer()) {
|
|| 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,
|
CASH_ACCOUNTS_FOR_LOAN.TRANSFERS_SUSPENSE, loanProductId, null, loanId, transactionId, transactionDate,
|
||||||
principalAmount, isReversal);
|
principalAmount, isReversal);
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-14
@@ -27,7 +27,7 @@ public class CashBasedAccountingProcessorForSavings implements AccountingProcess
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createJournalEntriesForSavings(SavingsDTO savingsDTO) {
|
public void createJournalEntriesForSavings(final SavingsDTO savingsDTO) {
|
||||||
final GLClosure latestGLClosure = this.helper.getLatestClosureByBranch(savingsDTO.getOfficeId());
|
final GLClosure latestGLClosure = this.helper.getLatestClosureByBranch(savingsDTO.getOfficeId());
|
||||||
final Long savingsProductId = savingsDTO.getSavingsProductId();
|
final Long savingsProductId = savingsDTO.getSavingsProductId();
|
||||||
final Long savingsId = savingsDTO.getSavingsId();
|
final Long savingsId = savingsDTO.getSavingsId();
|
||||||
@@ -40,20 +40,20 @@ public class CashBasedAccountingProcessorForSavings implements AccountingProcess
|
|||||||
final boolean isReversal = savingsTransactionDTO.isReversed();
|
final boolean isReversal = savingsTransactionDTO.isReversed();
|
||||||
final BigDecimal amount = savingsTransactionDTO.getAmount();
|
final BigDecimal amount = savingsTransactionDTO.getAmount();
|
||||||
|
|
||||||
helper.checkForBranchClosures(latestGLClosure, transactionDate);
|
this.helper.checkForBranchClosures(latestGLClosure, transactionDate);
|
||||||
|
|
||||||
/** Handle Deposits and reversals of deposits **/
|
/** Handle Deposits and reversals of deposits **/
|
||||||
if (savingsTransactionDTO.getTransactionType().isDeposit()) {
|
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,
|
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_REFERENCE, CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL, savingsProductId,
|
||||||
paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Handle withdrawals and reversals of withdrawals **/
|
/** Handle withdrawals and reversals of withdrawals **/
|
||||||
else if (savingsTransactionDTO.getTransactionType().isWithdrawal()) {
|
else if (savingsTransactionDTO.getTransactionType().isWithdrawal()) {
|
||||||
helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL,
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_REFERENCE, savingsProductId, paymentTypeId, savingsId, transactionId,
|
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL, CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_REFERENCE, savingsProductId,
|
||||||
transactionDate, amount, isReversal);
|
paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,29 +61,29 @@ public class CashBasedAccountingProcessorForSavings implements AccountingProcess
|
|||||||
* Applications
|
* Applications
|
||||||
**/
|
**/
|
||||||
else if (savingsTransactionDTO.getTransactionType().isInterestPosting()) {
|
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,
|
CASH_ACCOUNTS_FOR_SAVINGS.INTEREST_ON_SAVINGS, CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL, savingsProductId,
|
||||||
paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Handle Fees Deductions and reversals of Fees Deductions **/
|
/** Handle Fees Deductions and reversals of Fees Deductions **/
|
||||||
else if (savingsTransactionDTO.getTransactionType().isFeeDeduction()) {
|
else if (savingsTransactionDTO.getTransactionType().isFeeDeduction()) {
|
||||||
helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL,
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
CASH_ACCOUNTS_FOR_SAVINGS.INCOME_FROM_FEES, savingsProductId, paymentTypeId, savingsId, transactionId,
|
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL, CASH_ACCOUNTS_FOR_SAVINGS.INCOME_FROM_FEES, savingsProductId,
|
||||||
transactionDate, amount, isReversal);
|
paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Handle Transfers proposal **/
|
/** Handle Transfers proposal **/
|
||||||
else if (savingsTransactionDTO.getTransactionType().isInitiateTransfer()) {
|
else if (savingsTransactionDTO.getTransactionType().isInitiateTransfer()) {
|
||||||
helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL,
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
CASH_ACCOUNTS_FOR_SAVINGS.TRANSFERS_SUSPENSE, savingsProductId, paymentTypeId, savingsId, transactionId,
|
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL, CASH_ACCOUNTS_FOR_SAVINGS.TRANSFERS_SUSPENSE, savingsProductId,
|
||||||
transactionDate, amount, isReversal);
|
paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Handle Transfer Withdrawal or Acceptance **/
|
/** Handle Transfer Withdrawal or Acceptance **/
|
||||||
else if (savingsTransactionDTO.getTransactionType().isWithdrawTransfer()
|
else if (savingsTransactionDTO.getTransactionType().isWithdrawTransfer()
|
||||||
|| savingsTransactionDTO.getTransactionType().isApproveTransfer()) {
|
|| 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,
|
CASH_ACCOUNTS_FOR_SAVINGS.TRANSFERS_SUSPENSE, CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL, savingsProductId,
|
||||||
paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
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,
|
public Page<JournalEntryData> retrieveAll(final SearchParameters searchParameters, final Long glAccountId,
|
||||||
final Boolean onlyManualEntries, final Date fromDate, final Date toDate, final String transactionId) {
|
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("select SQL_CALC_FOUND_ROWS ");
|
||||||
sqlBuilder.append(journalEntryMapper.schema());
|
sqlBuilder.append(this.journalEntryMapper.schema());
|
||||||
|
|
||||||
final Object[] objectArray = new Object[5];
|
final Object[] objectArray = new Object[5];
|
||||||
int arrayPos = 0;
|
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
|
* 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
|
* should have only one entry and it must be same as existing account
|
||||||
*/
|
*/
|
||||||
if (creditOrDebits.length != 1) { throw new JournalEntryInvalidException(
|
if (creditOrDebits.length != 1) { throw new JournalEntryInvalidException(
|
||||||
GL_JOURNAL_ENTRY_INVALID_REASON.INVALID_DEBIT_OR_CREDIT_ACCOUNTS, null, null, null); }
|
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(
|
if (!glaccount.getId().equals(creditOrDebit.getGlAccountId())) { throw new JournalEntryInvalidException(
|
||||||
GL_JOURNAL_ENTRY_INVALID_REASON.INVALID_DEBIT_OR_CREDIT_ACCOUNTS, null, null, null); }
|
GL_JOURNAL_ENTRY_INVALID_REASON.INVALID_DEBIT_OR_CREDIT_ACCOUNTS, null, null, null); }
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@ public class ChargeToGLAccountMapper {
|
|||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private final long incomeAccountId;
|
private final long incomeAccountId;
|
||||||
|
|
||||||
public ChargeToGLAccountMapper(long chargeId, long incomeAccountId) {
|
public ChargeToGLAccountMapper(final long chargeId, final long incomeAccountId) {
|
||||||
this.chargeId = chargeId;
|
this.chargeId = chargeId;
|
||||||
this.incomeAccountId = incomeAccountId;
|
this.incomeAccountId = incomeAccountId;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@ public class PaymentTypeToGLAccountMapper {
|
|||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private final long fundSourceAccountId;
|
private final long fundSourceAccountId;
|
||||||
|
|
||||||
public PaymentTypeToGLAccountMapper(long paymentTypeId, long fundSourceAccountId) {
|
public PaymentTypeToGLAccountMapper(final long paymentTypeId, final long fundSourceAccountId) {
|
||||||
this.paymentTypeId = paymentTypeId;
|
this.paymentTypeId = paymentTypeId;
|
||||||
this.fundSourceAccountId = fundSourceAccountId;
|
this.fundSourceAccountId = fundSourceAccountId;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -113,7 +113,7 @@ public class ProductToGLAccountMapping extends AbstractPersistable<Long> {
|
|||||||
return this.paymentType;
|
return this.paymentType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPaymentType(CodeValue paymentType) {
|
public void setPaymentType(final CodeValue paymentType) {
|
||||||
this.paymentType = paymentType;
|
this.paymentType = paymentType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,7 +121,7 @@ public class ProductToGLAccountMapping extends AbstractPersistable<Long> {
|
|||||||
return this.charge;
|
return this.charge;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCharge(Charge charge) {
|
public void setCharge(final Charge charge) {
|
||||||
this.charge = charge;
|
this.charge = charge;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-6
@@ -151,28 +151,28 @@ public final class ProductToGLAccountMappingFromApiJsonDeserializer {
|
|||||||
|
|
||||||
if (isCashBasedAccounting(accountingRuleType)) {
|
if (isCashBasedAccounting(accountingRuleType)) {
|
||||||
|
|
||||||
final Long savingsControlAccountId = fromApiJsonHelper.extractLongNamed(
|
final Long savingsControlAccountId = this.fromApiJsonHelper.extractLongNamed(
|
||||||
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_CONTROL.getValue(), element);
|
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_CONTROL.getValue(), element);
|
||||||
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_CONTROL.getValue())
|
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_CONTROL.getValue())
|
||||||
.value(savingsControlAccountId).notNull().integerGreaterThanZero();
|
.value(savingsControlAccountId).notNull().integerGreaterThanZero();
|
||||||
|
|
||||||
final Long savingsReferenceAccountId = fromApiJsonHelper.extractLongNamed(
|
final Long savingsReferenceAccountId = this.fromApiJsonHelper.extractLongNamed(
|
||||||
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_REFERENCE.getValue(), element);
|
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_REFERENCE.getValue(), element);
|
||||||
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_REFERENCE.getValue())
|
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_REFERENCE.getValue())
|
||||||
.value(savingsReferenceAccountId).notNull().integerGreaterThanZero();
|
.value(savingsReferenceAccountId).notNull().integerGreaterThanZero();
|
||||||
|
|
||||||
final Long transfersInSuspenseAccountId = fromApiJsonHelper.extractLongNamed(
|
final Long transfersInSuspenseAccountId = this.fromApiJsonHelper.extractLongNamed(
|
||||||
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(), element);
|
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(), element);
|
||||||
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue())
|
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue())
|
||||||
.value(transfersInSuspenseAccountId).notNull().integerGreaterThanZero();
|
.value(transfersInSuspenseAccountId).notNull().integerGreaterThanZero();
|
||||||
|
|
||||||
final Long interestOnSavingsAccountId = fromApiJsonHelper.extractLongNamed(
|
final Long interestOnSavingsAccountId = this.fromApiJsonHelper.extractLongNamed(
|
||||||
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_SAVINGS.getValue(), element);
|
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_SAVINGS.getValue(), element);
|
||||||
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_SAVINGS.getValue())
|
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_SAVINGS.getValue())
|
||||||
.value(interestOnSavingsAccountId).notNull().integerGreaterThanZero();
|
.value(interestOnSavingsAccountId).notNull().integerGreaterThanZero();
|
||||||
|
|
||||||
final Long incomeFromFeeId = fromApiJsonHelper.extractLongNamed(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(),
|
final Long incomeFromFeeId = this.fromApiJsonHelper.extractLongNamed(
|
||||||
element);
|
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), element);
|
||||||
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue()).value(incomeFromFeeId)
|
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue()).value(incomeFromFeeId)
|
||||||
.notNull().integerGreaterThanZero();
|
.notNull().integerGreaterThanZero();
|
||||||
|
|
||||||
|
|||||||
+35
-35
@@ -97,8 +97,8 @@ public class ProductToGLAccountMappingHelper {
|
|||||||
* @param changes
|
* @param changes
|
||||||
*/
|
*/
|
||||||
public void savePaymentChannelToFundSourceMappings(final JsonCommand command, final JsonElement element, final Long productId,
|
public void savePaymentChannelToFundSourceMappings(final JsonCommand command, final JsonElement element, final Long productId,
|
||||||
Map<String, Object> changes, final PortfolioProductType portfolioProductType) {
|
final Map<String, Object> changes, final PortfolioProductType portfolioProductType) {
|
||||||
JsonArray paymentChannelMappingArray = fromApiJsonHelper.extractJsonArrayNamed(
|
final JsonArray paymentChannelMappingArray = this.fromApiJsonHelper.extractJsonArrayNamed(
|
||||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(), element);
|
LOAN_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(), element);
|
||||||
if (paymentChannelMappingArray != null) {
|
if (paymentChannelMappingArray != null) {
|
||||||
if (changes != null) {
|
if (changes != null) {
|
||||||
@@ -124,7 +124,7 @@ public class ProductToGLAccountMappingHelper {
|
|||||||
* @param changes
|
* @param changes
|
||||||
*/
|
*/
|
||||||
public void saveChargesToIncomeAccountMappings(final JsonCommand command, final JsonElement element, final Long productId,
|
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;
|
String arrayName;
|
||||||
if (isPenalty) {
|
if (isPenalty) {
|
||||||
arrayName = LOAN_PRODUCT_ACCOUNTING_PARAMS.PENALTY_INCOME_ACCOUNT_MAPPING.getValue();
|
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();
|
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 (chargeToIncomeAccountMappingArray != null) {
|
||||||
if (changes != null) {
|
if (changes != null) {
|
||||||
changes.put(LOAN_PRODUCT_ACCOUNTING_PARAMS.FEE_INCOME_ACCOUNT_MAPPING.getValue(),
|
changes.put(LOAN_PRODUCT_ACCOUNTING_PARAMS.FEE_INCOME_ACCOUNT_MAPPING.getValue(),
|
||||||
@@ -154,33 +154,33 @@ public class ProductToGLAccountMappingHelper {
|
|||||||
* @param changes
|
* @param changes
|
||||||
*/
|
*/
|
||||||
public void updateChargeToIncomeAccountMappings(final JsonCommand command, final JsonElement element, final Long productId,
|
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
|
// find all existing payment Channel to Fund source Mappings
|
||||||
List<ProductToGLAccountMapping> existingChargeToIncomeAccountMappings;
|
List<ProductToGLAccountMapping> existingChargeToIncomeAccountMappings;
|
||||||
String arrayFragmentName;
|
String arrayFragmentName;
|
||||||
|
|
||||||
if (isPenalty) {
|
if (isPenalty) {
|
||||||
existingChargeToIncomeAccountMappings = accountMappingRepository.findAllPenaltyToIncomeAccountMappings(productId,
|
existingChargeToIncomeAccountMappings = this.accountMappingRepository.findAllPenaltyToIncomeAccountMappings(productId,
|
||||||
portfolioProductType.getValue());
|
portfolioProductType.getValue());
|
||||||
arrayFragmentName = LOAN_PRODUCT_ACCOUNTING_PARAMS.PENALTY_INCOME_ACCOUNT_MAPPING.getValue();
|
arrayFragmentName = LOAN_PRODUCT_ACCOUNTING_PARAMS.PENALTY_INCOME_ACCOUNT_MAPPING.getValue();
|
||||||
} else {
|
} else {
|
||||||
existingChargeToIncomeAccountMappings = accountMappingRepository.findAllFeeToIncomeAccountMappings(productId,
|
existingChargeToIncomeAccountMappings = this.accountMappingRepository.findAllFeeToIncomeAccountMappings(productId,
|
||||||
portfolioProductType.getValue());
|
portfolioProductType.getValue());
|
||||||
arrayFragmentName = LOAN_PRODUCT_ACCOUNTING_PARAMS.FEE_INCOME_ACCOUNT_MAPPING.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
|
* Variable stores a map representation of charges (key) and their
|
||||||
* associated income Id's (value) extracted from the passed in
|
* associated income Id's (value) extracted from the passed in
|
||||||
* Jsoncommand
|
* 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
|
* Variable stores all charges which have already been mapped to Income
|
||||||
* Accounts in the system
|
* Accounts in the system
|
||||||
**/
|
**/
|
||||||
Set<Long> existingCharges = new HashSet<Long>();
|
final Set<Long> existingCharges = new HashSet<Long>();
|
||||||
if (chargeToIncomeAccountMappingArray != null) {
|
if (chargeToIncomeAccountMappingArray != null) {
|
||||||
if (changes != null) {
|
if (changes != null) {
|
||||||
changes.put(arrayFragmentName, command.jsonFragment(arrayFragmentName));
|
changes.put(arrayFragmentName, command.jsonFragment(arrayFragmentName));
|
||||||
@@ -195,7 +195,7 @@ public class ProductToGLAccountMappingHelper {
|
|||||||
|
|
||||||
// If input map is empty, delete all existing mappings
|
// If input map is empty, delete all existing mappings
|
||||||
if (inputChargeToIncomeAccountMap.size() == 0) {
|
if (inputChargeToIncomeAccountMap.size() == 0) {
|
||||||
accountMappingRepository.deleteInBatch(existingChargeToIncomeAccountMappings);
|
this.accountMappingRepository.deleteInBatch(existingChargeToIncomeAccountMappings);
|
||||||
}/**
|
}/**
|
||||||
* Else, <br/>
|
* Else, <br/>
|
||||||
* update existing mappings OR <br/>
|
* update existing mappings OR <br/>
|
||||||
@@ -206,30 +206,30 @@ public class ProductToGLAccountMappingHelper {
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
else {
|
else {
|
||||||
for (ProductToGLAccountMapping chargeToIncomeAccountMapping : existingChargeToIncomeAccountMappings) {
|
for (final ProductToGLAccountMapping chargeToIncomeAccountMapping : existingChargeToIncomeAccountMappings) {
|
||||||
Long currentCharge = chargeToIncomeAccountMapping.getCharge().getId();
|
final Long currentCharge = chargeToIncomeAccountMapping.getCharge().getId();
|
||||||
existingCharges.add(currentCharge);
|
existingCharges.add(currentCharge);
|
||||||
// update existing mappings (if required)
|
// update existing mappings (if required)
|
||||||
if (inputChargeToIncomeAccountMap.containsKey(currentCharge)) {
|
if (inputChargeToIncomeAccountMap.containsKey(currentCharge)) {
|
||||||
Long newGLAccountId = inputChargeToIncomeAccountMap.get(currentCharge);
|
final Long newGLAccountId = inputChargeToIncomeAccountMap.get(currentCharge);
|
||||||
if (newGLAccountId != chargeToIncomeAccountMapping.getGlAccount().getId()) {
|
if (newGLAccountId != chargeToIncomeAccountMapping.getGlAccount().getId()) {
|
||||||
final GLAccount glAccount = getAccountByIdAndType(LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_ACCOUNT_ID.getValue(),
|
final GLAccount glAccount = getAccountByIdAndType(LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_ACCOUNT_ID.getValue(),
|
||||||
GLAccountType.INCOME, newGLAccountId);
|
GLAccountType.INCOME, newGLAccountId);
|
||||||
chargeToIncomeAccountMapping.setGlAccount(glAccount);
|
chargeToIncomeAccountMapping.setGlAccount(glAccount);
|
||||||
accountMappingRepository.save(chargeToIncomeAccountMapping);
|
this.accountMappingRepository.save(chargeToIncomeAccountMapping);
|
||||||
}
|
}
|
||||||
}// deleted payment type
|
}// deleted payment type
|
||||||
else {
|
else {
|
||||||
accountMappingRepository.delete(chargeToIncomeAccountMapping);
|
this.accountMappingRepository.delete(chargeToIncomeAccountMapping);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// create new mappings
|
// create new mappings
|
||||||
Set<Long> incomingCharges = inputChargeToIncomeAccountMap.keySet();
|
final Set<Long> incomingCharges = inputChargeToIncomeAccountMap.keySet();
|
||||||
incomingCharges.removeAll(existingCharges);
|
incomingCharges.removeAll(existingCharges);
|
||||||
// incomingPaymentTypes now only contains the newly added
|
// incomingPaymentTypes now only contains the newly added
|
||||||
// payment Type mappings
|
// payment Type mappings
|
||||||
for (Long newCharge : incomingCharges) {
|
for (final Long newCharge : incomingCharges) {
|
||||||
Long newGLAccountId = inputChargeToIncomeAccountMap.get(newCharge);
|
final Long newGLAccountId = inputChargeToIncomeAccountMap.get(newCharge);
|
||||||
saveChargeToFundSourceMapping(productId, newCharge, newGLAccountId, portfolioProductType, isPenalty);
|
saveChargeToFundSourceMapping(productId, newCharge, newGLAccountId, portfolioProductType, isPenalty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -243,22 +243,22 @@ public class ProductToGLAccountMappingHelper {
|
|||||||
* @param changes
|
* @param changes
|
||||||
*/
|
*/
|
||||||
public void updatePaymentChannelToFundSourceMappings(final JsonCommand command, final JsonElement element, final Long productId,
|
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
|
// find all existing payment Channel to Fund source Mappings
|
||||||
List<ProductToGLAccountMapping> existingPaymentChannelToFundSourceMappings = accountMappingRepository
|
final List<ProductToGLAccountMapping> existingPaymentChannelToFundSourceMappings = this.accountMappingRepository
|
||||||
.findAllPaymentTypeToFundSourceMappings(productId, portfolioProductType.getValue());
|
.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);
|
LOAN_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(), element);
|
||||||
/**
|
/**
|
||||||
* Variable stores a map representation of Payment channels (key) and
|
* Variable stores a map representation of Payment channels (key) and
|
||||||
* their fund sources (value) extracted from the passed in Jsoncommand
|
* 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
|
* Variable stores all payment types which have already been mapped to
|
||||||
* Fund Sources in the system
|
* Fund Sources in the system
|
||||||
**/
|
**/
|
||||||
Set<Long> existingPaymentTypes = new HashSet<Long>();
|
final Set<Long> existingPaymentTypes = new HashSet<Long>();
|
||||||
if (paymentChannelMappingArray != null) {
|
if (paymentChannelMappingArray != null) {
|
||||||
if (changes != null) {
|
if (changes != null) {
|
||||||
changes.put(LOAN_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(),
|
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 input map is empty, delete all existing mappings
|
||||||
if (inputPaymentChannelFundSourceMap.size() == 0) {
|
if (inputPaymentChannelFundSourceMap.size() == 0) {
|
||||||
accountMappingRepository.deleteInBatch(existingPaymentChannelToFundSourceMappings);
|
this.accountMappingRepository.deleteInBatch(existingPaymentChannelToFundSourceMappings);
|
||||||
}/**
|
}/**
|
||||||
* Else, <br/>
|
* Else, <br/>
|
||||||
* update existing mappings OR <br/>
|
* update existing mappings OR <br/>
|
||||||
@@ -285,30 +285,30 @@ public class ProductToGLAccountMappingHelper {
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
else {
|
else {
|
||||||
for (ProductToGLAccountMapping existingPaymentChannelToFundSourceMapping : existingPaymentChannelToFundSourceMappings) {
|
for (final ProductToGLAccountMapping existingPaymentChannelToFundSourceMapping : existingPaymentChannelToFundSourceMappings) {
|
||||||
Long currentPaymentChannelId = existingPaymentChannelToFundSourceMapping.getPaymentType().getId();
|
final Long currentPaymentChannelId = existingPaymentChannelToFundSourceMapping.getPaymentType().getId();
|
||||||
existingPaymentTypes.add(currentPaymentChannelId);
|
existingPaymentTypes.add(currentPaymentChannelId);
|
||||||
// update existing mappings (if required)
|
// update existing mappings (if required)
|
||||||
if (inputPaymentChannelFundSourceMap.containsKey(currentPaymentChannelId)) {
|
if (inputPaymentChannelFundSourceMap.containsKey(currentPaymentChannelId)) {
|
||||||
Long newGLAccountId = inputPaymentChannelFundSourceMap.get(currentPaymentChannelId);
|
final Long newGLAccountId = inputPaymentChannelFundSourceMap.get(currentPaymentChannelId);
|
||||||
if (newGLAccountId != existingPaymentChannelToFundSourceMapping.getGlAccount().getId()) {
|
if (newGLAccountId != existingPaymentChannelToFundSourceMapping.getGlAccount().getId()) {
|
||||||
final GLAccount glAccount = getAccountByIdAndType(LOAN_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue(),
|
final GLAccount glAccount = getAccountByIdAndType(LOAN_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue(),
|
||||||
GLAccountType.ASSET, newGLAccountId);
|
GLAccountType.ASSET, newGLAccountId);
|
||||||
existingPaymentChannelToFundSourceMapping.setGlAccount(glAccount);
|
existingPaymentChannelToFundSourceMapping.setGlAccount(glAccount);
|
||||||
accountMappingRepository.save(existingPaymentChannelToFundSourceMapping);
|
this.accountMappingRepository.save(existingPaymentChannelToFundSourceMapping);
|
||||||
}
|
}
|
||||||
}// deleted payment type
|
}// deleted payment type
|
||||||
else {
|
else {
|
||||||
accountMappingRepository.delete(existingPaymentChannelToFundSourceMapping);
|
this.accountMappingRepository.delete(existingPaymentChannelToFundSourceMapping);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// create new mappings
|
// create new mappings
|
||||||
Set<Long> incomingPaymentTypes = inputPaymentChannelFundSourceMap.keySet();
|
final Set<Long> incomingPaymentTypes = inputPaymentChannelFundSourceMap.keySet();
|
||||||
incomingPaymentTypes.removeAll(existingPaymentTypes);
|
incomingPaymentTypes.removeAll(existingPaymentTypes);
|
||||||
// incomingPaymentTypes now only contains the newly added
|
// incomingPaymentTypes now only contains the newly added
|
||||||
// payment Type mappings
|
// payment Type mappings
|
||||||
for (Long newPaymentType : incomingPaymentTypes) {
|
for (final Long newPaymentType : incomingPaymentTypes) {
|
||||||
Long newGLAccountId = inputPaymentChannelFundSourceMap.get(newPaymentType);
|
final Long newGLAccountId = inputPaymentChannelFundSourceMap.get(newPaymentType);
|
||||||
savePaymentChannelToFundSourceMapping(productId, newPaymentType, newGLAccountId, portfolioProductType);
|
savePaymentChannelToFundSourceMapping(productId, newPaymentType, newGLAccountId, portfolioProductType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -321,7 +321,7 @@ public class ProductToGLAccountMappingHelper {
|
|||||||
*/
|
*/
|
||||||
private void savePaymentChannelToFundSourceMapping(final Long productId, final Long paymentTypeId,
|
private void savePaymentChannelToFundSourceMapping(final Long productId, final Long paymentTypeId,
|
||||||
final Long paymentTypeSpecificFundAccountId, final PortfolioProductType portfolioProductType) {
|
final Long paymentTypeSpecificFundAccountId, final PortfolioProductType portfolioProductType) {
|
||||||
CodeValue paymentType = codeValueRepositoryWrapper.findOneByCodeNameAndIdWithNotFoundDetection(
|
final CodeValue paymentType = this.codeValueRepositoryWrapper.findOneByCodeNameAndIdWithNotFoundDetection(
|
||||||
PaymentDetailConstants.paymentTypeCodeName, paymentTypeId);
|
PaymentDetailConstants.paymentTypeCodeName, paymentTypeId);
|
||||||
final GLAccount glAccount = getAccountByIdAndType(LOAN_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue(), GLAccountType.ASSET,
|
final GLAccount glAccount = getAccountByIdAndType(LOAN_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue(), GLAccountType.ASSET,
|
||||||
paymentTypeSpecificFundAccountId);
|
paymentTypeSpecificFundAccountId);
|
||||||
@@ -336,7 +336,7 @@ public class ProductToGLAccountMappingHelper {
|
|||||||
*/
|
*/
|
||||||
private void saveChargeToFundSourceMapping(final Long productId, final Long chargeId, final Long incomeAccountId,
|
private void saveChargeToFundSourceMapping(final Long productId, final Long chargeId, final Long incomeAccountId,
|
||||||
final PortfolioProductType portfolioProductType, final boolean isPenalty) {
|
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
|
// TODO Vishwas: Need to validate if given charge is fee or Penalty
|
||||||
// based on input condition
|
// based on input condition
|
||||||
|
|||||||
+11
-11
@@ -145,7 +145,7 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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 Map<String, Object> accountMappingDetails = new LinkedHashMap<String, Object>(8);
|
||||||
|
|
||||||
final ProductToGLAccountMappingMapper rm = new ProductToGLAccountMappingMapper();
|
final ProductToGLAccountMappingMapper rm = new ProductToGLAccountMappingMapper();
|
||||||
@@ -180,12 +180,12 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<PaymentTypeToGLAccountMapper> fetchPaymentTypeToFundSourceMappingsForLoanProduct(Long loanProductId) {
|
public List<PaymentTypeToGLAccountMapper> fetchPaymentTypeToFundSourceMappingsForLoanProduct(final Long loanProductId) {
|
||||||
return fetchPaymentTypeToFundSourceMappings(PortfolioProductType.LOAN, loanProductId);
|
return fetchPaymentTypeToFundSourceMappings(PortfolioProductType.LOAN, loanProductId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<PaymentTypeToGLAccountMapper> fetchPaymentTypeToFundSourceMappingsForSavingsProduct(Long savingsProductId) {
|
public List<PaymentTypeToGLAccountMapper> fetchPaymentTypeToFundSourceMappingsForSavingsProduct(final Long savingsProductId) {
|
||||||
return fetchPaymentTypeToFundSourceMappings(PortfolioProductType.SAVING, savingsProductId);
|
return fetchPaymentTypeToFundSourceMappings(PortfolioProductType.SAVING, savingsProductId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,8 +194,8 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
|
|||||||
* @param paymentTypeToGLAccountMappers
|
* @param paymentTypeToGLAccountMappers
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private List<PaymentTypeToGLAccountMapper> fetchPaymentTypeToFundSourceMappings(PortfolioProductType portfolioProductType,
|
private List<PaymentTypeToGLAccountMapper> fetchPaymentTypeToFundSourceMappings(final PortfolioProductType portfolioProductType,
|
||||||
Long loanProductId) {
|
final Long loanProductId) {
|
||||||
final ProductToGLAccountMappingMapper rm = new ProductToGLAccountMappingMapper();
|
final ProductToGLAccountMappingMapper rm = new ProductToGLAccountMappingMapper();
|
||||||
final String sql = "select " + rm.schema() + " and product_id = ? and payment_type is not null";
|
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 glAccountId = (Long) productToGLAccountMap.get("glAccountId");
|
||||||
final Long paymentTypeId = (Long) productToGLAccountMap.get("paymentTypeId");
|
final Long paymentTypeId = (Long) productToGLAccountMap.get("paymentTypeId");
|
||||||
PaymentTypeToGLAccountMapper paymentTypeToGLAccountMapper = new PaymentTypeToGLAccountMapper(paymentTypeId, glAccountId);
|
final PaymentTypeToGLAccountMapper paymentTypeToGLAccountMapper = new PaymentTypeToGLAccountMapper(paymentTypeId, glAccountId);
|
||||||
paymentTypeToGLAccountMappers.add(paymentTypeToGLAccountMapper);
|
paymentTypeToGLAccountMappers.add(paymentTypeToGLAccountMapper);
|
||||||
}
|
}
|
||||||
return paymentTypeToGLAccountMappers;
|
return paymentTypeToGLAccountMappers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ChargeToGLAccountMapper> fetchFeeToIncomeAccountMappingsForLoanProduct(Long loanProductId) {
|
public List<ChargeToGLAccountMapper> fetchFeeToIncomeAccountMappingsForLoanProduct(final Long loanProductId) {
|
||||||
return fetchChargeToIncomeAccountMappings(PortfolioProductType.LOAN, loanProductId, false);
|
return fetchChargeToIncomeAccountMappings(PortfolioProductType.LOAN, loanProductId, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ChargeToGLAccountMapper> fetchPenaltyToIncomeAccountMappingsForLoanProduct(Long loanProductId) {
|
public List<ChargeToGLAccountMapper> fetchPenaltyToIncomeAccountMappingsForLoanProduct(final Long loanProductId) {
|
||||||
return fetchChargeToIncomeAccountMappings(PortfolioProductType.LOAN, loanProductId, true);
|
return fetchChargeToIncomeAccountMappings(PortfolioProductType.LOAN, loanProductId, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ChargeToGLAccountMapper> fetchChargeToIncomeAccountMappings(PortfolioProductType portfolioProductType, Long loanProductId,
|
private List<ChargeToGLAccountMapper> fetchChargeToIncomeAccountMappings(final PortfolioProductType portfolioProductType,
|
||||||
boolean penalty) {
|
final Long loanProductId, final boolean penalty) {
|
||||||
final ProductToGLAccountMappingMapper rm = new ProductToGLAccountMappingMapper();
|
final ProductToGLAccountMappingMapper rm = new ProductToGLAccountMappingMapper();
|
||||||
String sql = "select " + rm.schema() + " and product_id = ? and mapping.charge_id is not null and charge.is_penalty=";
|
String sql = "select " + rm.schema() + " and product_id = ? and mapping.charge_id is not null and charge.is_penalty=";
|
||||||
if (penalty) {
|
if (penalty) {
|
||||||
@@ -244,7 +244,7 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
|
|||||||
}
|
}
|
||||||
final Long glAccountId = (Long) chargeToIncomeAccountMap.get("glAccountId");
|
final Long glAccountId = (Long) chargeToIncomeAccountMap.get("glAccountId");
|
||||||
final Long chargeId = (Long) chargeToIncomeAccountMap.get("chargeId");
|
final Long chargeId = (Long) chargeToIncomeAccountMap.get("chargeId");
|
||||||
ChargeToGLAccountMapper chargeToGLAccountMapper = new ChargeToGLAccountMapper(chargeId, glAccountId);
|
final ChargeToGLAccountMapper chargeToGLAccountMapper = new ChargeToGLAccountMapper(chargeId, glAccountId);
|
||||||
chargeToGLAccountMappers.add(chargeToGLAccountMapper);
|
chargeToGLAccountMappers.add(chargeToGLAccountMapper);
|
||||||
}
|
}
|
||||||
return chargeToGLAccountMappers;
|
return chargeToGLAccountMappers;
|
||||||
|
|||||||
+43
-42
@@ -37,8 +37,8 @@ public class ProductToGLAccountMappingWritePlatformServiceImpl implements Produc
|
|||||||
@Autowired
|
@Autowired
|
||||||
public ProductToGLAccountMappingWritePlatformServiceImpl(final FromJsonHelper fromApiJsonHelper,
|
public ProductToGLAccountMappingWritePlatformServiceImpl(final FromJsonHelper fromApiJsonHelper,
|
||||||
final ProductToGLAccountMappingFromApiJsonDeserializer deserializer,
|
final ProductToGLAccountMappingFromApiJsonDeserializer deserializer,
|
||||||
LoanProductToGLAccountMappingHelper loanProductToGLAccountMappingHelper,
|
final LoanProductToGLAccountMappingHelper loanProductToGLAccountMappingHelper,
|
||||||
SavingsProductToGLAccountMappingHelper savingsProductToGLAccountMappingHelper) {
|
final SavingsProductToGLAccountMappingHelper savingsProductToGLAccountMappingHelper) {
|
||||||
this.fromApiJsonHelper = fromApiJsonHelper;
|
this.fromApiJsonHelper = fromApiJsonHelper;
|
||||||
this.deserializer = deserializer;
|
this.deserializer = deserializer;
|
||||||
this.loanProductToGLAccountMappingHelper = loanProductToGLAccountMappingHelper;
|
this.loanProductToGLAccountMappingHelper = loanProductToGLAccountMappingHelper;
|
||||||
@@ -57,84 +57,84 @@ public class ProductToGLAccountMappingWritePlatformServiceImpl implements Produc
|
|||||||
break;
|
break;
|
||||||
case CASH_BASED:
|
case CASH_BASED:
|
||||||
// asset
|
// asset
|
||||||
loanProductToGLAccountMappingHelper
|
this.loanProductToGLAccountMappingHelper
|
||||||
.saveLoanToAssetAccountMapping(element, LOAN_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue(), loanProductId,
|
.saveLoanToAssetAccountMapping(element, LOAN_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue(), loanProductId,
|
||||||
CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue());
|
CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue());
|
||||||
loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.LOAN_PORTFOLIO.getValue(), loanProductId,
|
LOAN_PRODUCT_ACCOUNTING_PARAMS.LOAN_PORTFOLIO.getValue(), loanProductId,
|
||||||
CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO.getValue());
|
CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO.getValue());
|
||||||
loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(), loanProductId,
|
LOAN_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(), loanProductId,
|
||||||
CASH_ACCOUNTS_FOR_LOAN.TRANSFERS_SUSPENSE.getValue());
|
CASH_ACCOUNTS_FOR_LOAN.TRANSFERS_SUSPENSE.getValue());
|
||||||
|
|
||||||
// income
|
// income
|
||||||
loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
||||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_LOANS.getValue(), loanProductId,
|
LOAN_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_LOANS.getValue(), loanProductId,
|
||||||
CASH_ACCOUNTS_FOR_LOAN.INTEREST_ON_LOANS.getValue());
|
CASH_ACCOUNTS_FOR_LOAN.INTEREST_ON_LOANS.getValue());
|
||||||
loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
||||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), loanProductId,
|
LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), loanProductId,
|
||||||
CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_FEES.getValue());
|
CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_FEES.getValue());
|
||||||
loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
||||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue(), loanProductId,
|
LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue(), loanProductId,
|
||||||
CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_PENALTIES.getValue());
|
CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_PENALTIES.getValue());
|
||||||
|
|
||||||
// expenses
|
// expenses
|
||||||
loanProductToGLAccountMappingHelper.saveLoanToExpenseAccountMapping(element,
|
this.loanProductToGLAccountMappingHelper.saveLoanToExpenseAccountMapping(element,
|
||||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue(), loanProductId,
|
LOAN_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue(), loanProductId,
|
||||||
CASH_ACCOUNTS_FOR_LOAN.LOSSES_WRITTEN_OFF.getValue());
|
CASH_ACCOUNTS_FOR_LOAN.LOSSES_WRITTEN_OFF.getValue());
|
||||||
|
|
||||||
// advanced accounting mappings
|
// advanced accounting mappings
|
||||||
loanProductToGLAccountMappingHelper.savePaymentChannelToFundSourceMappings(command, element, loanProductId, null);
|
this.loanProductToGLAccountMappingHelper.savePaymentChannelToFundSourceMappings(command, element, loanProductId, null);
|
||||||
loanProductToGLAccountMappingHelper.saveChargesToIncomeAccountMappings(command, element, loanProductId, null);
|
this.loanProductToGLAccountMappingHelper.saveChargesToIncomeAccountMappings(command, element, loanProductId, null);
|
||||||
break;
|
break;
|
||||||
case ACCRUAL_BASED:
|
case ACCRUAL_BASED:
|
||||||
|
|
||||||
// assets (including receivables)
|
// assets (including receivables)
|
||||||
loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue(), loanProductId,
|
LOAN_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue(), loanProductId,
|
||||||
ACCRUAL_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue());
|
ACCRUAL_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue());
|
||||||
loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.LOAN_PORTFOLIO.getValue(), loanProductId,
|
LOAN_PRODUCT_ACCOUNTING_PARAMS.LOAN_PORTFOLIO.getValue(), loanProductId,
|
||||||
ACCRUAL_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO.getValue());
|
ACCRUAL_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO.getValue());
|
||||||
loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(), loanProductId,
|
LOAN_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(), loanProductId,
|
||||||
ACCRUAL_ACCOUNTS_FOR_LOAN.TRANSFERS_SUSPENSE.getValue());
|
ACCRUAL_ACCOUNTS_FOR_LOAN.TRANSFERS_SUSPENSE.getValue());
|
||||||
loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.INTEREST_RECEIVABLE.getValue(), loanProductId,
|
LOAN_PRODUCT_ACCOUNTING_PARAMS.INTEREST_RECEIVABLE.getValue(), loanProductId,
|
||||||
ACCRUAL_ACCOUNTS_FOR_LOAN.INTEREST_RECEIVABLE.getValue());
|
ACCRUAL_ACCOUNTS_FOR_LOAN.INTEREST_RECEIVABLE.getValue());
|
||||||
loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.FEES_RECEIVABLE.getValue(), loanProductId,
|
LOAN_PRODUCT_ACCOUNTING_PARAMS.FEES_RECEIVABLE.getValue(), loanProductId,
|
||||||
ACCRUAL_ACCOUNTS_FOR_LOAN.FEES_RECEIVABLE.getValue());
|
ACCRUAL_ACCOUNTS_FOR_LOAN.FEES_RECEIVABLE.getValue());
|
||||||
loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
|
||||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.PENALTIES_RECEIVABLE.getValue(), loanProductId,
|
LOAN_PRODUCT_ACCOUNTING_PARAMS.PENALTIES_RECEIVABLE.getValue(), loanProductId,
|
||||||
ACCRUAL_ACCOUNTS_FOR_LOAN.PENALTIES_RECEIVABLE.getValue());
|
ACCRUAL_ACCOUNTS_FOR_LOAN.PENALTIES_RECEIVABLE.getValue());
|
||||||
|
|
||||||
// income
|
// income
|
||||||
loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
||||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_LOANS.getValue(), loanProductId,
|
LOAN_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_LOANS.getValue(), loanProductId,
|
||||||
ACCRUAL_ACCOUNTS_FOR_LOAN.INTEREST_ON_LOANS.getValue());
|
ACCRUAL_ACCOUNTS_FOR_LOAN.INTEREST_ON_LOANS.getValue());
|
||||||
loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
||||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), loanProductId,
|
LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), loanProductId,
|
||||||
ACCRUAL_ACCOUNTS_FOR_LOAN.INCOME_FROM_FEES.getValue());
|
ACCRUAL_ACCOUNTS_FOR_LOAN.INCOME_FROM_FEES.getValue());
|
||||||
loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
|
||||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue(), loanProductId,
|
LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue(), loanProductId,
|
||||||
ACCRUAL_ACCOUNTS_FOR_LOAN.INCOME_FROM_PENALTIES.getValue());
|
ACCRUAL_ACCOUNTS_FOR_LOAN.INCOME_FROM_PENALTIES.getValue());
|
||||||
|
|
||||||
// expenses
|
// expenses
|
||||||
loanProductToGLAccountMappingHelper.saveLoanToExpenseAccountMapping(element,
|
this.loanProductToGLAccountMappingHelper.saveLoanToExpenseAccountMapping(element,
|
||||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue(), loanProductId,
|
LOAN_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue(), loanProductId,
|
||||||
ACCRUAL_ACCOUNTS_FOR_LOAN.LOSSES_WRITTEN_OFF.getValue());
|
ACCRUAL_ACCOUNTS_FOR_LOAN.LOSSES_WRITTEN_OFF.getValue());
|
||||||
|
|
||||||
// advanced accounting mappings
|
// advanced accounting mappings
|
||||||
loanProductToGLAccountMappingHelper.savePaymentChannelToFundSourceMappings(command, element, loanProductId, null);
|
this.loanProductToGLAccountMappingHelper.savePaymentChannelToFundSourceMappings(command, element, loanProductId, null);
|
||||||
loanProductToGLAccountMappingHelper.saveChargesToIncomeAccountMappings(command, element, loanProductId, null);
|
this.loanProductToGLAccountMappingHelper.saveChargesToIncomeAccountMappings(command, element, loanProductId, null);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@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 JsonElement element = this.fromApiJsonHelper.parse(command.json());
|
||||||
final Integer accountingRuleTypeId = this.fromApiJsonHelper.extractIntegerNamed(accountingRuleParamName, element,
|
final Integer accountingRuleTypeId = this.fromApiJsonHelper.extractIntegerNamed(accountingRuleParamName, element,
|
||||||
Locale.getDefault());
|
Locale.getDefault());
|
||||||
@@ -145,30 +145,30 @@ public class ProductToGLAccountMappingWritePlatformServiceImpl implements Produc
|
|||||||
break;
|
break;
|
||||||
case CASH_BASED:
|
case CASH_BASED:
|
||||||
// asset
|
// asset
|
||||||
savingsProductToGLAccountMappingHelper.saveSavingsToAssetAccountMapping(element,
|
this.savingsProductToGLAccountMappingHelper.saveSavingsToAssetAccountMapping(element,
|
||||||
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_REFERENCE.getValue(), savingProductId,
|
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_REFERENCE.getValue(), savingProductId,
|
||||||
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_REFERENCE.getValue());
|
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_REFERENCE.getValue());
|
||||||
|
|
||||||
// income
|
// income
|
||||||
savingsProductToGLAccountMappingHelper.saveSavingsToIncomeAccountMapping(element,
|
this.savingsProductToGLAccountMappingHelper.saveSavingsToIncomeAccountMapping(element,
|
||||||
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), savingProductId,
|
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), savingProductId,
|
||||||
CASH_ACCOUNTS_FOR_SAVINGS.INCOME_FROM_FEES.getValue());
|
CASH_ACCOUNTS_FOR_SAVINGS.INCOME_FROM_FEES.getValue());
|
||||||
|
|
||||||
// expenses
|
// expenses
|
||||||
savingsProductToGLAccountMappingHelper.saveSavingsToExpenseAccountMapping(element,
|
this.savingsProductToGLAccountMappingHelper.saveSavingsToExpenseAccountMapping(element,
|
||||||
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_SAVINGS.getValue(), savingProductId,
|
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_SAVINGS.getValue(), savingProductId,
|
||||||
CASH_ACCOUNTS_FOR_SAVINGS.INTEREST_ON_SAVINGS.getValue());
|
CASH_ACCOUNTS_FOR_SAVINGS.INTEREST_ON_SAVINGS.getValue());
|
||||||
|
|
||||||
// liability
|
// liability
|
||||||
savingsProductToGLAccountMappingHelper.saveSavingsToLiabilityAccountMapping(element,
|
this.savingsProductToGLAccountMappingHelper.saveSavingsToLiabilityAccountMapping(element,
|
||||||
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_CONTROL.getValue(), savingProductId,
|
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_CONTROL.getValue(), savingProductId,
|
||||||
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL.getValue());
|
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL.getValue());
|
||||||
savingsProductToGLAccountMappingHelper.saveSavingsToLiabilityAccountMapping(element,
|
this.savingsProductToGLAccountMappingHelper.saveSavingsToLiabilityAccountMapping(element,
|
||||||
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(), savingProductId,
|
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(), savingProductId,
|
||||||
CASH_ACCOUNTS_FOR_SAVINGS.TRANSFERS_SUSPENSE.getValue());
|
CASH_ACCOUNTS_FOR_SAVINGS.TRANSFERS_SUSPENSE.getValue());
|
||||||
|
|
||||||
// advanced accounting mappings
|
// advanced accounting mappings
|
||||||
savingsProductToGLAccountMappingHelper.savePaymentChannelToFundSourceMappings(command, element, savingProductId, null);
|
this.savingsProductToGLAccountMappingHelper.savePaymentChannelToFundSourceMappings(command, element, savingProductId, null);
|
||||||
break;
|
break;
|
||||||
/*** Do not have accrual based accounting for now ***/
|
/*** Do not have accrual based accounting for now ***/
|
||||||
case ACCRUAL_BASED:
|
case ACCRUAL_BASED:
|
||||||
@@ -195,23 +195,23 @@ public class ProductToGLAccountMappingWritePlatformServiceImpl implements Produc
|
|||||||
***/
|
***/
|
||||||
if (accountingRuleChanged) {
|
if (accountingRuleChanged) {
|
||||||
this.deserializer.validateForLoanProductCreate(command.json());
|
this.deserializer.validateForLoanProductCreate(command.json());
|
||||||
loanProductToGLAccountMappingHelper.deleteLoanProductToGLAccountMapping(loanProductId);
|
this.loanProductToGLAccountMappingHelper.deleteLoanProductToGLAccountMapping(loanProductId);
|
||||||
createLoanProductToGLAccountMapping(loanProductId, command);
|
createLoanProductToGLAccountMapping(loanProductId, command);
|
||||||
changes = loanProductToGLAccountMappingHelper.populateChangesForNewLoanProductToGLAccountMappingCreation(element,
|
changes = this.loanProductToGLAccountMappingHelper.populateChangesForNewLoanProductToGLAccountMappingCreation(element,
|
||||||
accountingRuleType);
|
accountingRuleType);
|
||||||
}/*** else examine and update individual changes ***/
|
}/*** else examine and update individual changes ***/
|
||||||
else {
|
else {
|
||||||
loanProductToGLAccountMappingHelper.handleChangesToLoanProductToGLAccountMappings(loanProductId, changes, element,
|
this.loanProductToGLAccountMappingHelper.handleChangesToLoanProductToGLAccountMappings(loanProductId, changes, element,
|
||||||
accountingRuleType);
|
accountingRuleType);
|
||||||
loanProductToGLAccountMappingHelper.updatePaymentChannelToFundSourceMappings(command, element, loanProductId, changes);
|
this.loanProductToGLAccountMappingHelper.updatePaymentChannelToFundSourceMappings(command, element, loanProductId, changes);
|
||||||
loanProductToGLAccountMappingHelper.updateChargesToIncomeAccountMappings(command, element, loanProductId, changes);
|
this.loanProductToGLAccountMappingHelper.updateChargesToIncomeAccountMappings(command, element, loanProductId, changes);
|
||||||
}
|
}
|
||||||
return changes;
|
return changes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> updateSavingsProductToGLAccountMapping(Long savingsProductId, JsonCommand command,
|
public Map<String, Object> updateSavingsProductToGLAccountMapping(final Long savingsProductId, final JsonCommand command,
|
||||||
boolean accountingRuleChanged, int accountingRuleTypeId) {
|
final boolean accountingRuleChanged, final int accountingRuleTypeId) {
|
||||||
/***
|
/***
|
||||||
* Variable tracks all accounting mapping properties that have been
|
* Variable tracks all accounting mapping properties that have been
|
||||||
* updated
|
* updated
|
||||||
@@ -226,15 +226,16 @@ public class ProductToGLAccountMappingWritePlatformServiceImpl implements Produc
|
|||||||
***/
|
***/
|
||||||
if (accountingRuleChanged) {
|
if (accountingRuleChanged) {
|
||||||
this.deserializer.validateForSavingsProductCreate(command.json());
|
this.deserializer.validateForSavingsProductCreate(command.json());
|
||||||
savingsProductToGLAccountMappingHelper.deleteSavingsProductToGLAccountMapping(savingsProductId);
|
this.savingsProductToGLAccountMappingHelper.deleteSavingsProductToGLAccountMapping(savingsProductId);
|
||||||
createSavingProductToGLAccountMapping(savingsProductId, command);
|
createSavingProductToGLAccountMapping(savingsProductId, command);
|
||||||
changes = savingsProductToGLAccountMappingHelper.populateChangesForNewSavingsProductToGLAccountMappingCreation(element,
|
changes = this.savingsProductToGLAccountMappingHelper.populateChangesForNewSavingsProductToGLAccountMappingCreation(element,
|
||||||
accountingRuleType);
|
accountingRuleType);
|
||||||
}/*** else examine and update individual changes ***/
|
}/*** else examine and update individual changes ***/
|
||||||
else {
|
else {
|
||||||
savingsProductToGLAccountMappingHelper.handleChangesToSavingsProductToGLAccountMappings(savingsProductId, changes, element,
|
this.savingsProductToGLAccountMappingHelper.handleChangesToSavingsProductToGLAccountMappings(savingsProductId, changes,
|
||||||
accountingRuleType);
|
element, accountingRuleType);
|
||||||
savingsProductToGLAccountMappingHelper.updatePaymentChannelToFundSourceMappings(command, element, savingsProductId, changes);
|
this.savingsProductToGLAccountMappingHelper.updatePaymentChannelToFundSourceMappings(command, element, savingsProductId,
|
||||||
|
changes);
|
||||||
}
|
}
|
||||||
return changes;
|
return changes;
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-5
@@ -28,9 +28,9 @@ import com.google.gson.JsonElement;
|
|||||||
public class SavingsProductToGLAccountMappingHelper extends ProductToGLAccountMappingHelper {
|
public class SavingsProductToGLAccountMappingHelper extends ProductToGLAccountMappingHelper {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public SavingsProductToGLAccountMappingHelper(GLAccountRepository glAccountRepository,
|
public SavingsProductToGLAccountMappingHelper(final GLAccountRepository glAccountRepository,
|
||||||
ProductToGLAccountMappingRepository glAccountMappingRepository, FromJsonHelper fromApiJsonHelper,
|
final ProductToGLAccountMappingRepository glAccountMappingRepository, final FromJsonHelper fromApiJsonHelper,
|
||||||
CodeValueRepositoryWrapper codeValueRepositoryWrapper, ChargeRepositoryWrapper chargeRepositoryWrapper) {
|
final CodeValueRepositoryWrapper codeValueRepositoryWrapper, final ChargeRepositoryWrapper chargeRepositoryWrapper) {
|
||||||
super(glAccountRepository, glAccountMappingRepository, fromApiJsonHelper, codeValueRepositoryWrapper, chargeRepositoryWrapper);
|
super(glAccountRepository, glAccountMappingRepository, fromApiJsonHelper, codeValueRepositoryWrapper, chargeRepositoryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,12 +85,12 @@ public class SavingsProductToGLAccountMappingHelper extends ProductToGLAccountMa
|
|||||||
/*** Abstractions for payments channel related to savings products ***/
|
/*** Abstractions for payments channel related to savings products ***/
|
||||||
|
|
||||||
public void savePaymentChannelToFundSourceMappings(final JsonCommand command, final JsonElement element, final Long productId,
|
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);
|
savePaymentChannelToFundSourceMappings(command, element, productId, changes, PortfolioProductType.SAVING);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updatePaymentChannelToFundSourceMappings(final JsonCommand command, final JsonElement element, final Long productId,
|
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);
|
updatePaymentChannelToFundSourceMappings(command, element, productId, changes, PortfolioProductType.SAVING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+14
-8
@@ -108,7 +108,7 @@ public class AccountingRuleApiResource {
|
|||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public String retrieveAllAccountingRules(@Context final UriInfo uriInfo) {
|
public String retrieveAllAccountingRules(@Context final UriInfo uriInfo) {
|
||||||
|
|
||||||
final AppUser currentUser = context.authenticatedUser();
|
final AppUser currentUser = this.context.authenticatedUser();
|
||||||
currentUser.validateHasReadPermission(this.resourceNameForPermission);
|
currentUser.validateHasReadPermission(this.resourceNameForPermission);
|
||||||
|
|
||||||
final String hierarchy = currentUser.getOffice().getHierarchy();
|
final String hierarchy = currentUser.getOffice().getHierarchy();
|
||||||
@@ -118,11 +118,13 @@ public class AccountingRuleApiResource {
|
|||||||
boolean isAssociationParametersExists = false;
|
boolean isAssociationParametersExists = false;
|
||||||
if (!associationParameters.isEmpty()) {
|
if (!associationParameters.isEmpty()) {
|
||||||
if (associationParameters.contains("all")) {
|
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,
|
final List<AccountingRuleData> accountingRuleDatas = this.accountingRuleReadPlatformService.retrieveAllAccountingRules(
|
||||||
isAssociationParametersExists);
|
hierarchySearchString, isAssociationParametersExists);
|
||||||
|
|
||||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||||
return this.apiJsonSerializerService.serialize(settings, accountingRuleDatas, RESPONSE_DATA_PARAMETERS);
|
return this.apiJsonSerializerService.serialize(settings, accountingRuleDatas, RESPONSE_DATA_PARAMETERS);
|
||||||
@@ -189,10 +191,14 @@ public class AccountingRuleApiResource {
|
|||||||
final Collection<CodeValueData> allowedTagOptions = this.codeValueReadPlatformService
|
final Collection<CodeValueData> allowedTagOptions = this.codeValueReadPlatformService
|
||||||
.retrieveCodeValuesByCode(AccountingConstants.ASSESTS_TAG_OPTION_CODE_NAME);
|
.retrieveCodeValuesByCode(AccountingConstants.ASSESTS_TAG_OPTION_CODE_NAME);
|
||||||
|
|
||||||
allowedTagOptions.addAll(this.codeValueReadPlatformService.retrieveCodeValuesByCode(AccountingConstants.LIABILITIES_TAG_OPTION_CODE_NAME));
|
allowedTagOptions.addAll(this.codeValueReadPlatformService
|
||||||
allowedTagOptions.addAll(this.codeValueReadPlatformService.retrieveCodeValuesByCode(AccountingConstants.EQUITY_TAG_OPTION_CODE_NAME));
|
.retrieveCodeValuesByCode(AccountingConstants.LIABILITIES_TAG_OPTION_CODE_NAME));
|
||||||
allowedTagOptions.addAll(this.codeValueReadPlatformService.retrieveCodeValuesByCode(AccountingConstants.INCOME_TAG_OPTION_CODE_NAME));
|
allowedTagOptions.addAll(this.codeValueReadPlatformService
|
||||||
allowedTagOptions.addAll(this.codeValueReadPlatformService.retrieveCodeValuesByCode(AccountingConstants.EXPENSES_TAG_OPTION_CODE_NAME));
|
.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) {
|
if (accountingRuleData == null) {
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ public class AccountingTagRuleData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CodeValueData getTag() {
|
public CodeValueData getTag() {
|
||||||
return tag;
|
return this.tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@ import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRul
|
|||||||
*/
|
*/
|
||||||
public class AccountingRuleDuplicateException extends AbstractPlatformDomainRuleException {
|
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);
|
super("error.msg.accounting.rule.duplicate", "An accounting rule with the name " + name + " already exists" + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -141,7 +141,8 @@ public class AccountingRuleReadPlatformServiceImpl implements AccountingRuleRead
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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,
|
final AccountingRuleDataExtractor resultSetExtractor = new AccountingRuleDataExtractor(this.jdbcTemplate,
|
||||||
this.glAccountReadPlatformService, isAssociationParametersExists);
|
this.glAccountReadPlatformService, isAssociationParametersExists);
|
||||||
Object[] arguments = new Object[] {};
|
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
|
// get the GL Accounts or tags to Debit and Credit
|
||||||
final String[] debitTags = command.arrayValueOfParameterNamed(AccountingRuleJsonInputParams.DEBIT_ACCOUNT_TAGS.getValue());
|
final String[] debitTags = command.arrayValueOfParameterNamed(AccountingRuleJsonInputParams.DEBIT_ACCOUNT_TAGS.getValue());
|
||||||
final String[] creditTags = command.arrayValueOfParameterNamed(AccountingRuleJsonInputParams.CREDIT_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 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 accountToDebitId = command.longValueOfParameterNamed(AccountingRuleJsonInputParams.ACCOUNT_TO_DEBIT.getValue());
|
||||||
final Long accountToCreditId = command.longValueOfParameterNamed(AccountingRuleJsonInputParams.ACCOUNT_TO_CREDIT.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("groupId") final Integer groupId, @QueryParam("clientId") final Integer clientId,
|
||||||
@QueryParam("loanid") final Integer loanId, @QueryParam("savingsAccountId") final Integer savingsAccountId) {
|
@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,
|
final String extraCriteria = getExtraCriteria(actionName, entityName, resourceId, makerId, makerDateTimeFrom, makerDateTimeTo,
|
||||||
checkerId, checkerDateTimeFrom, checkerDateTimeTo, processingResult, officeId, groupId, clientId, loanId, savingsAccountId);
|
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,
|
final Collection<AuditData> auditEntries = this.auditReadPlatformService.retrieveAuditEntries(extraCriteria,
|
||||||
settings.isIncludeJson());
|
settings.isIncludeJson());
|
||||||
|
|
||||||
return this.toApiJsonSerializer.serialize(settings, auditEntries, RESPONSE_DATA_PARAMETERS);
|
return this.toApiJsonSerializer.serialize(settings, auditEntries, this.RESPONSE_DATA_PARAMETERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@@ -93,12 +93,12 @@ public class AuditsApiResource {
|
|||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public String retrieveAuditEntry(@PathParam("auditId") final Long auditId, @Context final UriInfo uriInfo) {
|
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 AuditData auditEntry = this.auditReadPlatformService.retrieveAuditEntry(auditId);
|
||||||
|
|
||||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||||
return this.toApiJsonSerializer.serialize(settings, auditEntry, RESPONSE_DATA_PARAMETERS);
|
return this.toApiJsonSerializer.serialize(settings, auditEntry, this.RESPONSE_DATA_PARAMETERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@@ -107,9 +107,9 @@ public class AuditsApiResource {
|
|||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public String retrieveAuditSearchTemplate(@Context final UriInfo uriInfo) {
|
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");
|
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,
|
final String extraCriteria = getExtraCriteria(actionName, entityName, resourceId, makerId, makerDateTimeFrom, makerDateTimeTo,
|
||||||
officeId, groupId, clientId, loanId, savingsAccountId);
|
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,
|
final Collection<AuditData> entries = this.readPlatformService.retrieveAllEntriesToBeChecked(extraCriteria,
|
||||||
settings.isIncludeJson());
|
settings.isIncludeJson());
|
||||||
|
|
||||||
return this.toApiJsonSerializerAudit.serialize(settings, entries, RESPONSE_DATA_PARAMETERS);
|
return this.toApiJsonSerializerAudit.serialize(settings, entries, this.RESPONSE_DATA_PARAMETERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@@ -91,7 +91,7 @@ public class MakercheckersApiResource {
|
|||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public String retrieveAuditSearchTemplate(@Context final UriInfo uriInfo) {
|
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");
|
final AuditSearchData auditSearchData = this.readPlatformService.retrieveSearchTemplate("makerchecker");
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -21,11 +21,11 @@ public enum CommandProcessingResultType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Integer getValue() {
|
public Integer getValue() {
|
||||||
return value;
|
return this.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCode() {
|
public String getCode() {
|
||||||
return code;
|
return this.code;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CommandProcessingResultType fromInt(final Integer typeValue) {
|
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")
|
@Table(name = "m_portfolio_command_source")
|
||||||
public class CommandSource extends AbstractPersistable<Long> {
|
public class CommandSource extends AbstractPersistable<Long> {
|
||||||
|
|
||||||
@Column(name = "action_name", nullable = true, length = 100)
|
@Column(name = "action_name", nullable = true, length = 100)
|
||||||
private String actionName;
|
private String actionName;
|
||||||
|
|
||||||
@Column(name = "entity_name", nullable = true, length = 100)
|
@Column(name = "entity_name", nullable = true, length = 100)
|
||||||
private String entityName;
|
private String entityName;
|
||||||
|
|
||||||
@Column(name = "office_id")
|
@Column(name = "office_id")
|
||||||
private Long officeId;
|
private Long officeId;
|
||||||
|
|
||||||
@Column(name = "group_id")
|
@Column(name = "group_id")
|
||||||
private Long groupId;
|
private Long groupId;
|
||||||
|
|
||||||
@Column(name = "client_id")
|
@Column(name = "client_id")
|
||||||
private Long clientId;
|
private Long clientId;
|
||||||
|
|
||||||
@Column(name = "loan_id")
|
@Column(name = "loan_id")
|
||||||
private Long loanId;
|
private Long loanId;
|
||||||
|
|
||||||
@Column(name = "savings_account_id")
|
@Column(name = "savings_account_id")
|
||||||
private Long savingsId;
|
private Long savingsId;
|
||||||
|
|
||||||
@Column(name = "api_get_url", length = 100)
|
@Column(name = "api_get_url", length = 100)
|
||||||
private String resourceGetUrl;
|
private String resourceGetUrl;
|
||||||
|
|
||||||
@Column(name = "resource_id")
|
@Column(name = "resource_id")
|
||||||
private Long resourceId;
|
private Long resourceId;
|
||||||
|
|
||||||
@Column(name = "subresource_id")
|
@Column(name = "subresource_id")
|
||||||
private Long subresourceId;
|
private Long subresourceId;
|
||||||
|
|
||||||
@Column(name = "command_as_json", length = 1000)
|
@Column(name = "command_as_json", length = 1000)
|
||||||
private String commandAsJson;
|
private String commandAsJson;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "maker_id", nullable = false)
|
@JoinColumn(name = "maker_id", nullable = false)
|
||||||
private AppUser maker;
|
private AppUser maker;
|
||||||
|
|
||||||
@Column(name = "made_on_date", nullable = false)
|
@Column(name = "made_on_date", nullable = false)
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
private Date madeOnDate;
|
private Date madeOnDate;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "checker_id", nullable = true)
|
@JoinColumn(name = "checker_id", nullable = true)
|
||||||
private AppUser checker;
|
private AppUser checker;
|
||||||
|
|
||||||
@Column(name = "checked_on_date", nullable = true)
|
@Column(name = "checked_on_date", nullable = true)
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
private Date checkedOnDate;
|
private Date checkedOnDate;
|
||||||
|
|
||||||
@Column(name = "processing_result_enum", nullable = false)
|
@Column(name = "processing_result_enum", nullable = false)
|
||||||
private Integer processingResult;
|
private Integer processingResult;
|
||||||
|
|
||||||
@Column(name = "product_id")
|
@Column(name = "product_id")
|
||||||
private Long productId;
|
private Long productId;
|
||||||
|
|
||||||
public static CommandSource fullEntryFrom(final CommandWrapper wrapper,
|
public static CommandSource fullEntryFrom(final CommandWrapper wrapper, final JsonCommand command, final AppUser maker) {
|
||||||
final JsonCommand command, final AppUser maker) {
|
return new CommandSource(wrapper.actionName(), wrapper.entityName(), wrapper.getHref(), command.entityId(), command.subentityId(),
|
||||||
return new CommandSource(wrapper.actionName(), wrapper.entityName(),
|
command.json(), maker, DateTime.now());
|
||||||
wrapper.getHref(), command.entityId(), command.subentityId(),
|
}
|
||||||
command.json(), maker, DateTime.now());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected CommandSource() {
|
protected CommandSource() {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
private CommandSource(final String actionName, final String entityName,
|
private CommandSource(final String actionName, final String entityName, final String href, final Long resourceId,
|
||||||
final String href, final Long resourceId, final Long subresourceId,
|
final Long subresourceId, final String commandSerializedAsJson, final AppUser maker, final DateTime madeOnDateTime) {
|
||||||
final String commandSerializedAsJson, final AppUser maker,
|
this.actionName = actionName;
|
||||||
final DateTime madeOnDateTime) {
|
this.entityName = entityName;
|
||||||
this.actionName = actionName;
|
this.resourceGetUrl = href;
|
||||||
this.entityName = entityName;
|
this.resourceId = resourceId;
|
||||||
this.resourceGetUrl = href;
|
this.subresourceId = subresourceId;
|
||||||
this.resourceId = resourceId;
|
this.commandAsJson = commandSerializedAsJson;
|
||||||
this.subresourceId = subresourceId;
|
this.maker = maker;
|
||||||
this.commandAsJson = commandSerializedAsJson;
|
this.madeOnDate = madeOnDateTime.toDate();
|
||||||
this.maker = maker;
|
this.processingResult = CommandProcessingResultType.PROCESSED.getValue();
|
||||||
this.madeOnDate = madeOnDateTime.toDate();
|
}
|
||||||
this.processingResult = CommandProcessingResultType.PROCESSED
|
|
||||||
.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void markAsChecked(final AppUser checker,
|
public void markAsChecked(final AppUser checker, final DateTime checkedOnDate) {
|
||||||
final DateTime checkedOnDate) {
|
this.checker = checker;
|
||||||
this.checker = checker;
|
this.checkedOnDate = checkedOnDate.toDate();
|
||||||
this.checkedOnDate = checkedOnDate.toDate();
|
this.processingResult = CommandProcessingResultType.PROCESSED.getValue();
|
||||||
this.processingResult = CommandProcessingResultType.PROCESSED
|
}
|
||||||
.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateResourceId(final Long resourceId) {
|
public void updateResourceId(final Long resourceId) {
|
||||||
this.resourceId = resourceId;
|
this.resourceId = resourceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateSubresourceId(final Long subresourceId) {
|
public void updateSubresourceId(final Long subresourceId) {
|
||||||
this.subresourceId = subresourceId;
|
this.subresourceId = subresourceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateJsonTo(final String json) {
|
public void updateJsonTo(final String json) {
|
||||||
this.commandAsJson = json;
|
this.commandAsJson = json;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long resourceId() {
|
public Long resourceId() {
|
||||||
return this.resourceId;
|
return this.resourceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long subresourceId() {
|
public Long subresourceId() {
|
||||||
return this.subresourceId;
|
return this.subresourceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasJson() {
|
public boolean hasJson() {
|
||||||
return StringUtils.isNotBlank(this.commandAsJson);
|
return StringUtils.isNotBlank(this.commandAsJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String json() {
|
public String json() {
|
||||||
return this.commandAsJson;
|
return this.commandAsJson;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getActionName() {
|
public String getActionName() {
|
||||||
return this.actionName;
|
return this.actionName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEntityName() {
|
public String getEntityName() {
|
||||||
return this.entityName;
|
return this.entityName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPermissionCode() {
|
public String getPermissionCode() {
|
||||||
return this.actionName + "_" + this.entityName;
|
return this.actionName + "_" + this.entityName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getResourceId() {
|
public Long getResourceId() {
|
||||||
return this.resourceId;
|
return this.resourceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getSubresourceId() {
|
public Long getSubresourceId() {
|
||||||
return this.subresourceId;
|
return this.subresourceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void markAsAwaitingApproval() {
|
public void markAsAwaitingApproval() {
|
||||||
this.processingResult = CommandProcessingResultType.AWAITING_APPROVAL
|
this.processingResult = CommandProcessingResultType.AWAITING_APPROVAL.getValue();
|
||||||
.getValue();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isMarkedAsAwaitingApproval() {
|
public boolean isMarkedAsAwaitingApproval() {
|
||||||
if (this.processingResult
|
if (this.processingResult.equals(CommandProcessingResultType.AWAITING_APPROVAL.getValue())) { return true; }
|
||||||
.equals(CommandProcessingResultType.AWAITING_APPROVAL
|
|
||||||
.getValue())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateForAudit(final Long officeId, final Long groupId,
|
public void updateForAudit(final Long officeId, final Long groupId, final Long clientId, final Long loanId, final Long savingsId,
|
||||||
final Long clientId, final Long loanId, final Long savingsId,
|
final Long productId) {
|
||||||
final Long productId) {
|
this.officeId = officeId;
|
||||||
this.officeId = officeId;
|
this.groupId = groupId;
|
||||||
this.groupId = groupId;
|
this.clientId = clientId;
|
||||||
this.clientId = clientId;
|
this.loanId = loanId;
|
||||||
this.loanId = loanId;
|
this.savingsId = savingsId;
|
||||||
this.savingsId = savingsId;
|
this.productId = productId;
|
||||||
this.productId = productId;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getResourceGetUrl() {
|
public String getResourceGetUrl() {
|
||||||
return this.resourceGetUrl;
|
return this.resourceGetUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getProductId() {
|
public Long getProductId() {
|
||||||
return this.productId;
|
return this.productId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -185,8 +185,8 @@ public class CommandWrapper {
|
|||||||
|
|
||||||
public boolean isUpdate() {
|
public boolean isUpdate() {
|
||||||
// permissions resource has special update which involves no resource.
|
// permissions resource has special update which involves no resource.
|
||||||
return isPermissionResource() && isUpdateOperation() || isCurrencyResource() && isUpdateOperation() || isCacheResource() && isUpdateOperation()
|
return isPermissionResource() && isUpdateOperation() || isCurrencyResource() && isUpdateOperation() || isCacheResource()
|
||||||
|| isUpdateOperation() && this.entityId != null;
|
&& isUpdateOperation() || isUpdateOperation() && this.entityId != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUpdateOperation() {
|
public boolean isUpdateOperation() {
|
||||||
|
|||||||
+1
-1
@@ -18,6 +18,6 @@ public class UnsupportedCommandException extends RuntimeException {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getUnsupportedCommandName() {
|
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) {
|
public String schema(final boolean includeJson, final String hierarchy) {
|
||||||
|
|
||||||
String commandAsJsonString = "";
|
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,"
|
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,"
|
+ " 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
|
// commandAsJson might not be on the select list of columns
|
||||||
try {
|
try {
|
||||||
commandAsJson = rs.getString("commandAsJson");
|
commandAsJson = rs.getString("commandAsJson");
|
||||||
} catch (SQLException e) {
|
} catch (final SQLException e) {
|
||||||
commandAsJson = null;
|
commandAsJson = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String officeName = rs.getString("officeName");
|
final String officeName = rs.getString("officeName");
|
||||||
String groupLevelName = rs.getString("groupLevelName");
|
final String groupLevelName = rs.getString("groupLevelName");
|
||||||
String groupName = rs.getString("groupName");
|
final String groupName = rs.getString("groupName");
|
||||||
String clientName = rs.getString("clientName");
|
final String clientName = rs.getString("clientName");
|
||||||
String loanAccountNo = rs.getString("loanAccountNo");
|
final String loanAccountNo = rs.getString("loanAccountNo");
|
||||||
String savingsAccountNo = rs.getString("savingsAccountNo");
|
final String savingsAccountNo = rs.getString("savingsAccountNo");
|
||||||
|
|
||||||
return new AuditData(id, actionName, entityName, resourceId, subresourceId, maker, madeOnDate, checker, checkedOnDate,
|
return new AuditData(id, actionName, entityName, resourceId, subresourceId, maker, madeOnDate, checker, checkedOnDate,
|
||||||
processingResult, commandAsJson, officeName, groupLevelName, groupName, clientName, loanAccountNo, savingsAccountNo);
|
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) {
|
public Collection<AuditData> retrieveAuditEntries(final String extraCriteria, final boolean includeJson) {
|
||||||
|
|
||||||
String updatedExtraCriteria = "";
|
String updatedExtraCriteria = "";
|
||||||
if (StringUtils.isNotBlank(extraCriteria)) updatedExtraCriteria = " where (" + extraCriteria + ")";
|
if (StringUtils.isNotBlank(extraCriteria)) {
|
||||||
|
updatedExtraCriteria = " where (" + extraCriteria + ")";
|
||||||
|
}
|
||||||
|
|
||||||
updatedExtraCriteria += " order by aud.id DESC";
|
updatedExtraCriteria += " order by aud.id DESC";
|
||||||
return retrieveEntries("audit", updatedExtraCriteria, includeJson);
|
return retrieveEntries("audit", updatedExtraCriteria, includeJson);
|
||||||
@@ -150,10 +154,11 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
|||||||
public Collection<AuditData> retrieveAllEntriesToBeChecked(final String extraCriteria, final boolean includeJson) {
|
public Collection<AuditData> retrieveAllEntriesToBeChecked(final String extraCriteria, final boolean includeJson) {
|
||||||
|
|
||||||
String updatedExtraCriteria = "";
|
String updatedExtraCriteria = "";
|
||||||
if (StringUtils.isNotBlank(extraCriteria))
|
if (StringUtils.isNotBlank(extraCriteria)) {
|
||||||
updatedExtraCriteria = " where (" + extraCriteria + ")" + " and aud.processing_result_enum = 2";
|
updatedExtraCriteria = " where (" + extraCriteria + ")" + " and aud.processing_result_enum = 2";
|
||||||
else
|
} else {
|
||||||
updatedExtraCriteria = " where aud.processing_result_enum = 2";
|
updatedExtraCriteria = " where aud.processing_result_enum = 2";
|
||||||
|
}
|
||||||
|
|
||||||
updatedExtraCriteria += " order by aud.id";
|
updatedExtraCriteria += " order by aud.id";
|
||||||
|
|
||||||
@@ -165,8 +170,8 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
|||||||
if (!(useType.equals("audit") || useType.equals("makerchecker"))) { throw new PlatformDataIntegrityException(
|
if (!(useType.equals("audit") || useType.equals("makerchecker"))) { throw new PlatformDataIntegrityException(
|
||||||
"error.msg.invalid.auditSearchTemplate.useType", "Invalid Audit Search Template UseType: " + useType); }
|
"error.msg.invalid.auditSearchTemplate.useType", "Invalid Audit Search Template UseType: " + useType); }
|
||||||
|
|
||||||
AppUser currentUser = context.authenticatedUser();
|
final AppUser currentUser = this.context.authenticatedUser();
|
||||||
String hierarchy = currentUser.getOffice().getHierarchy();
|
final String hierarchy = currentUser.getOffice().getHierarchy();
|
||||||
|
|
||||||
final AuditMapper rm = new AuditMapper();
|
final AuditMapper rm = new AuditMapper();
|
||||||
String sql = "select " + rm.schema(includeJson, hierarchy);
|
String sql = "select " + rm.schema(includeJson, hierarchy);
|
||||||
@@ -194,7 +199,7 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
|||||||
@Override
|
@Override
|
||||||
public AuditData retrieveAuditEntry(final Long auditId) {
|
public AuditData retrieveAuditEntry(final Long auditId) {
|
||||||
|
|
||||||
final AppUser currentUser = context.authenticatedUser();
|
final AppUser currentUser = this.context.authenticatedUser();
|
||||||
final String hierarchy = currentUser.getOffice().getHierarchy();
|
final String hierarchy = currentUser.getOffice().getHierarchy();
|
||||||
|
|
||||||
final AuditMapper rm = new AuditMapper();
|
final AuditMapper rm = new AuditMapper();
|
||||||
@@ -220,10 +225,10 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
|||||||
commandAsJsonMap.remove("officeId");
|
commandAsJsonMap.remove("officeId");
|
||||||
|
|
||||||
Long officeId = null;
|
Long officeId = null;
|
||||||
String officeIdStr = auditObject.get("officeId").getAsString();
|
final String officeIdStr = auditObject.get("officeId").getAsString();
|
||||||
if (StringUtils.isNotBlank(officeIdStr)) {
|
if (StringUtils.isNotBlank(officeIdStr)) {
|
||||||
officeId = Long.valueOf(officeIdStr);
|
officeId = Long.valueOf(officeIdStr);
|
||||||
OfficeData office = this.officeReadPlatformService.retrieveOffice(officeId);
|
final OfficeData office = this.officeReadPlatformService.retrieveOffice(officeId);
|
||||||
commandAsJsonMap.put("officeName", office.name());
|
commandAsJsonMap.put("officeName", office.name());
|
||||||
} else {
|
} else {
|
||||||
commandAsJsonMap.put("officeName", "");
|
commandAsJsonMap.put("officeName", "");
|
||||||
@@ -234,10 +239,10 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
|||||||
commandAsJsonMap.remove("clientId");
|
commandAsJsonMap.remove("clientId");
|
||||||
|
|
||||||
Long clientId = null;
|
Long clientId = null;
|
||||||
String clientIdStr = auditObject.get("clientId").getAsString();
|
final String clientIdStr = auditObject.get("clientId").getAsString();
|
||||||
if (StringUtils.isNotBlank(clientIdStr)) {
|
if (StringUtils.isNotBlank(clientIdStr)) {
|
||||||
clientId = Long.valueOf(clientIdStr);
|
clientId = Long.valueOf(clientIdStr);
|
||||||
ClientData client = this.clientReadPlatformService.retrieveOne(clientId);
|
final ClientData client = this.clientReadPlatformService.retrieveOne(clientId);
|
||||||
commandAsJsonMap.put("clientName", client.displayName());
|
commandAsJsonMap.put("clientName", client.displayName());
|
||||||
} else {
|
} else {
|
||||||
commandAsJsonMap.put("clientName", "");
|
commandAsJsonMap.put("clientName", "");
|
||||||
@@ -248,10 +253,10 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
|||||||
commandAsJsonMap.remove("productId");
|
commandAsJsonMap.remove("productId");
|
||||||
|
|
||||||
Long productId = null;
|
Long productId = null;
|
||||||
String productIdStr = auditObject.get("productId").getAsString();
|
final String productIdStr = auditObject.get("productId").getAsString();
|
||||||
if (StringUtils.isNotBlank(productIdStr)) {
|
if (StringUtils.isNotBlank(productIdStr)) {
|
||||||
productId = Long.valueOf(productIdStr);
|
productId = Long.valueOf(productIdStr);
|
||||||
LoanProductData loanProduct = this.loanProductReadPlatformService.retrieveLoanProduct(productId);
|
final LoanProductData loanProduct = this.loanProductReadPlatformService.retrieveLoanProduct(productId);
|
||||||
commandAsJsonMap.put("productName", loanProduct.getName());
|
commandAsJsonMap.put("productName", loanProduct.getName());
|
||||||
} else {
|
} else {
|
||||||
commandAsJsonMap.put("productName", "");
|
commandAsJsonMap.put("productName", "");
|
||||||
@@ -262,10 +267,10 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
|||||||
commandAsJsonMap.remove("loanOfficerId");
|
commandAsJsonMap.remove("loanOfficerId");
|
||||||
|
|
||||||
Long loanOfficerId = null;
|
Long loanOfficerId = null;
|
||||||
String loanOfficerIdStr = auditObject.get("loanOfficerId").getAsString();
|
final String loanOfficerIdStr = auditObject.get("loanOfficerId").getAsString();
|
||||||
if (StringUtils.isNotBlank(loanOfficerIdStr)) {
|
if (StringUtils.isNotBlank(loanOfficerIdStr)) {
|
||||||
loanOfficerId = Long.valueOf(loanOfficerIdStr);
|
loanOfficerId = Long.valueOf(loanOfficerIdStr);
|
||||||
StaffData officer = this.staffReadPlatformService.retrieveStaff(loanOfficerId);
|
final StaffData officer = this.staffReadPlatformService.retrieveStaff(loanOfficerId);
|
||||||
commandAsJsonMap.put("loanOfficerName", officer.getDisplayName());
|
commandAsJsonMap.put("loanOfficerName", officer.getDisplayName());
|
||||||
} else {
|
} else {
|
||||||
commandAsJsonMap.put("loanOfficerName", "");
|
commandAsJsonMap.put("loanOfficerName", "");
|
||||||
@@ -275,7 +280,7 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
|||||||
final String[] enumTypes = { "loanTermFrequencyType", "repaymentFrequencyType", "amortizationType", "interestType",
|
final String[] enumTypes = { "loanTermFrequencyType", "repaymentFrequencyType", "amortizationType", "interestType",
|
||||||
"interestCalculationPeriodType", "interestRateFrequencyType" };
|
"interestCalculationPeriodType", "interestRateFrequencyType" };
|
||||||
|
|
||||||
for (String typeName : enumTypes) {
|
for (final String typeName : enumTypes) {
|
||||||
if (commandAsJsonMap.containsKey(typeName)) {
|
if (commandAsJsonMap.containsKey(typeName)) {
|
||||||
commandAsJsonMap.remove(typeName);
|
commandAsJsonMap.remove(typeName);
|
||||||
|
|
||||||
@@ -301,25 +306,25 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
|||||||
if (!(useType.equals("audit") || useType.equals("makerchecker"))) { throw new PlatformDataIntegrityException(
|
if (!(useType.equals("audit") || useType.equals("makerchecker"))) { throw new PlatformDataIntegrityException(
|
||||||
"error.msg.invalid.auditSearchTemplate.useType", "Invalid Audit Search Template UseType: " + useType); }
|
"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 ";
|
String sql = " SELECT distinct(action_name) as actionName FROM m_permission p ";
|
||||||
sql += makercheckerCapabilityOnly(useType, currentUser);
|
sql += makercheckerCapabilityOnly(useType, currentUser);
|
||||||
sql += " order by if(action_name in ('CREATE', 'DELETE', 'UPDATE'), action_name, 'ZZZ'), action_name";
|
sql += " order by if(action_name in ('CREATE', 'DELETE', 'UPDATE'), action_name, 'ZZZ'), action_name";
|
||||||
ActionNamesMapper mapper = new ActionNamesMapper();
|
final ActionNamesMapper mapper = new ActionNamesMapper();
|
||||||
List<String> actionNames = this.jdbcTemplate.query(sql, mapper, new Object[] {});
|
final List<String> actionNames = this.jdbcTemplate.query(sql, mapper, new Object[] {});
|
||||||
|
|
||||||
sql = " select distinct(entity_name) as entityName from m_permission p ";
|
sql = " select distinct(entity_name) as entityName from m_permission p ";
|
||||||
sql += makercheckerCapabilityOnly(useType, currentUser);
|
sql += makercheckerCapabilityOnly(useType, currentUser);
|
||||||
sql += " order by if(grouping = 'datatable', 'ZZZ', entity_name), entity_name";
|
sql += " order by if(grouping = 'datatable', 'ZZZ', entity_name), entity_name";
|
||||||
EntityNamesMapper mapper2 = new EntityNamesMapper();
|
final EntityNamesMapper mapper2 = new EntityNamesMapper();
|
||||||
List<String> entityNames = this.jdbcTemplate.query(sql, mapper2, new Object[] {});
|
final List<String> entityNames = this.jdbcTemplate.query(sql, mapper2, new Object[] {});
|
||||||
|
|
||||||
Collection<ProcessingResultLookup> processingResults = null;
|
Collection<ProcessingResultLookup> processingResults = null;
|
||||||
if (useType.equals("audit")) {
|
if (useType.equals("audit")) {
|
||||||
ProcessingResultsMapper mapper3 = new ProcessingResultsMapper();
|
final ProcessingResultsMapper mapper3 = new ProcessingResultsMapper();
|
||||||
processingResults = this.jdbcTemplate.query(mapper3.schema(), mapper3, new Object[] {});
|
processingResults = this.jdbcTemplate.query(mapper3.schema(), mapper3, new Object[] {});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -370,8 +375,8 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ProcessingResultLookup mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
public ProcessingResultLookup mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
||||||
Long id = JdbcSupport.getLong(rs, "id");
|
final Long id = JdbcSupport.getLong(rs, "id");
|
||||||
String processingResult = rs.getString("processingResult");
|
final String processingResult = rs.getString("processingResult");
|
||||||
|
|
||||||
return new ProcessingResultLookup(id, processingResult);
|
return new ProcessingResultLookup(id, processingResult);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-3
@@ -496,9 +496,9 @@ public class CommandWrapperBuilder {
|
|||||||
this.entityName = "LOANCHARGE";
|
this.entityName = "LOANCHARGE";
|
||||||
this.entityId = loanChargeId;
|
this.entityId = loanChargeId;
|
||||||
this.loanId = loanId;
|
this.loanId = loanId;
|
||||||
if(loanChargeId == null){
|
if (loanChargeId == null) {
|
||||||
this.href = "/loans/" + loanId;
|
this.href = "/loans/" + loanId;
|
||||||
}else{
|
} else {
|
||||||
this.href = "/loans/" + loanId + "/charges/" + loanChargeId;
|
this.href = "/loans/" + loanId + "/charges/" + loanChargeId;
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
@@ -866,7 +866,6 @@ public class CommandWrapperBuilder {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public CommandWrapperBuilder createAccountTransfer() {
|
public CommandWrapperBuilder createAccountTransfer() {
|
||||||
this.actionName = "CREATE";
|
this.actionName = "CREATE";
|
||||||
this.entityName = "ACCOUNTTRANSFER";
|
this.entityName = "ACCOUNTTRANSFER";
|
||||||
|
|||||||
+6
-6
@@ -47,7 +47,7 @@ public class PortfolioCommandSourceWritePlatformServiceImpl implements Portfolio
|
|||||||
|
|
||||||
boolean isApprovedByChecker = false;
|
boolean isApprovedByChecker = false;
|
||||||
// check if is update of own account details
|
// 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.
|
// then allow this operation to proceed.
|
||||||
// maker checker doesnt mean anything here.
|
// maker checker doesnt mean anything here.
|
||||||
isApprovedByChecker = true; // set to true in case permissions have
|
isApprovedByChecker = true; // set to true in case permissions have
|
||||||
@@ -56,7 +56,7 @@ public class PortfolioCommandSourceWritePlatformServiceImpl implements Portfolio
|
|||||||
} else {
|
} else {
|
||||||
// if not user changing their own details - check user has
|
// if not user changing their own details - check user has
|
||||||
// permission to perform specific task.
|
// permission to perform specific task.
|
||||||
context.authenticatedUser().validateHasPermissionTo(wrapper.getTaskPermissionName());
|
this.context.authenticatedUser().validateHasPermissionTo(wrapper.getTaskPermissionName());
|
||||||
}
|
}
|
||||||
validateIsUpdateAllowed();
|
validateIsUpdateAllowed();
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ public class PortfolioCommandSourceWritePlatformServiceImpl implements Portfolio
|
|||||||
wrapper.getTransactionId(), wrapper.getHref(), wrapper.getProductId());
|
wrapper.getTransactionId(), wrapper.getHref(), wrapper.getProductId());
|
||||||
|
|
||||||
result = this.processAndLogCommandService.processAndLogCommand(wrapper, command, isApprovedByChecker);
|
result = this.processAndLogCommandService.processAndLogCommand(wrapper, command, isApprovedByChecker);
|
||||||
} catch (RollbackTransactionAsCommandIsNotApprovedByCheckerException e) {
|
} catch (final RollbackTransactionAsCommandIsNotApprovedByCheckerException e) {
|
||||||
|
|
||||||
result = this.processAndLogCommandService.logCommand(e.getCommandSourceResult());
|
result = this.processAndLogCommandService.logCommand(e.getCommandSourceResult());
|
||||||
}
|
}
|
||||||
@@ -81,7 +81,7 @@ public class PortfolioCommandSourceWritePlatformServiceImpl implements Portfolio
|
|||||||
@Override
|
@Override
|
||||||
public CommandProcessingResult approveEntry(final Long makerCheckerId) {
|
public CommandProcessingResult approveEntry(final Long makerCheckerId) {
|
||||||
|
|
||||||
CommandSource commandSourceInput = validateMakerCheckerTransaction(makerCheckerId);
|
final CommandSource commandSourceInput = validateMakerCheckerTransaction(makerCheckerId);
|
||||||
validateIsUpdateAllowed();
|
validateIsUpdateAllowed();
|
||||||
|
|
||||||
final CommandWrapper wrapper = CommandWrapper.fromExistingCommand(makerCheckerId, commandSourceInput.getActionName(),
|
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 == null) { throw new CommandNotFoundException(makerCheckerId); }
|
||||||
if (!(commandSourceInput.isMarkedAsAwaitingApproval())) { throw new CommandNotAwaitingApprovalException(makerCheckerId); }
|
if (!(commandSourceInput.isMarkedAsAwaitingApproval())) { throw new CommandNotAwaitingApprovalException(makerCheckerId); }
|
||||||
|
|
||||||
context.authenticatedUser().validateHasCheckerPermissionTo(commandSourceInput.getPermissionCode());
|
this.context.authenticatedUser().validateHasCheckerPermissionTo(commandSourceInput.getPermissionCode());
|
||||||
|
|
||||||
return commandSourceInput;
|
return commandSourceInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean validateIsUpdateAllowed() {
|
private boolean validateIsUpdateAllowed() {
|
||||||
return schedulerJobRunnerReadService.isUpdatesAllowed();
|
return this.schedulerJobRunnerReadService.isUpdatesAllowed();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+5
-6
@@ -111,8 +111,7 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
|
|||||||
} else {
|
} else {
|
||||||
throw new UnsupportedCommandException(wrapper.commandName());
|
throw new UnsupportedCommandException(wrapper.commandName());
|
||||||
}
|
}
|
||||||
}
|
} else if (wrapper.isConfigurationResource()) {
|
||||||
else if (wrapper.isConfigurationResource()) {
|
|
||||||
handler = this.applicationContext.getBean("updateGlobalConfigurationCommandHandler", NewCommandSourceHandler.class);
|
handler = this.applicationContext.getBean("updateGlobalConfigurationCommandHandler", NewCommandSourceHandler.class);
|
||||||
} else if (wrapper.isDatatableResource()) {
|
} else if (wrapper.isDatatableResource()) {
|
||||||
if (wrapper.isCreateDatatable()) {
|
if (wrapper.isCreateDatatable()) {
|
||||||
@@ -476,7 +475,7 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
|
|||||||
handler = this.applicationContext.getBean("unassignRoleCommandHandler", NewCommandSourceHandler.class);
|
handler = this.applicationContext.getBean("unassignRoleCommandHandler", NewCommandSourceHandler.class);
|
||||||
} else if (wrapper.isUpdateGroupRole()) {
|
} else if (wrapper.isUpdateGroupRole()) {
|
||||||
handler = this.applicationContext.getBean("updateGroupRoleCommandHandler", NewCommandSourceHandler.class);
|
handler = this.applicationContext.getBean("updateGroupRoleCommandHandler", NewCommandSourceHandler.class);
|
||||||
} else if (wrapper.isAssignStaff()) {
|
} else if (wrapper.isAssignStaff()) {
|
||||||
handler = this.applicationContext.getBean("assignGroupStaffCommandHandler", NewCommandSourceHandler.class);
|
handler = this.applicationContext.getBean("assignGroupStaffCommandHandler", NewCommandSourceHandler.class);
|
||||||
} else if (wrapper.isTransferClientsBetweenGroups()) {
|
} else if (wrapper.isTransferClientsBetweenGroups()) {
|
||||||
handler = this.applicationContext.getBean("transferClientsBetweenGroupsCommandHandler", NewCommandSourceHandler.class);
|
handler = this.applicationContext.getBean("transferClientsBetweenGroupsCommandHandler", NewCommandSourceHandler.class);
|
||||||
@@ -534,9 +533,9 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else if (wrapper.isXBRLMappingResource()) {
|
} else if (wrapper.isXBRLMappingResource()) {
|
||||||
if (wrapper.isUpdate()) {
|
if (wrapper.isUpdate()) {
|
||||||
handler = this.applicationContext.getBean("updateTaxonomyMappingCommandHandler", NewCommandSourceHandler.class);
|
handler = this.applicationContext.getBean("updateTaxonomyMappingCommandHandler", NewCommandSourceHandler.class);
|
||||||
} else {
|
} else {
|
||||||
throw new UnsupportedCommandException(wrapper.commandName());
|
throw new UnsupportedCommandException(wrapper.commandName());
|
||||||
}
|
}
|
||||||
} else if (wrapper.isHolidayResource()) {
|
} else if (wrapper.isHolidayResource()) {
|
||||||
|
|||||||
Vendored
+3
-3
@@ -15,8 +15,7 @@ public class CacheEnumerations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static EnumOptionData cacheType(final CacheType cacheType) {
|
public static EnumOptionData cacheType(final CacheType cacheType) {
|
||||||
EnumOptionData optionData = new EnumOptionData(CacheType.INVALID.getValue().longValue(), CacheType.INVALID.getCode(),
|
EnumOptionData optionData = new EnumOptionData(CacheType.INVALID.getValue().longValue(), CacheType.INVALID.getCode(), "Invalid");
|
||||||
"Invalid");
|
|
||||||
switch (cacheType) {
|
switch (cacheType) {
|
||||||
case INVALID:
|
case INVALID:
|
||||||
optionData = new EnumOptionData(CacheType.INVALID.getValue().longValue(), CacheType.INVALID.getCode(), "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");
|
optionData = new EnumOptionData(CacheType.NO_CACHE.getValue().longValue(), CacheType.NO_CACHE.getCode(), "No cache");
|
||||||
break;
|
break;
|
||||||
case SINGLE_NODE:
|
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;
|
break;
|
||||||
case MULTI_NODE:
|
case MULTI_NODE:
|
||||||
optionData = new EnumOptionData(CacheType.MULTI_NODE.getValue().longValue(), CacheType.MULTI_NODE.getCode(), "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);
|
final Map<String, Object> changes = this.cacheService.switchToCache(ehCacheEnabled, toCacheType);
|
||||||
|
|
||||||
if (!changes.isEmpty()) {
|
if (!changes.isEmpty()) {
|
||||||
this.configurationDomainService.updateCache(toCacheType);
|
this.configurationDomainService.updateCache(toCacheType);
|
||||||
}
|
}
|
||||||
|
|
||||||
return changes;
|
return changes;
|
||||||
|
|||||||
+3
-2
@@ -11,7 +11,8 @@ import java.util.Set;
|
|||||||
public class CodeConstants {
|
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 {
|
public static enum CODEVALUE_JSON_INPUT_PARAMS {
|
||||||
CODEVALUE_ID("id"), NAME("name"), POSITION("position");
|
CODEVALUE_ID("id"), NAME("name"), POSITION("position");
|
||||||
@@ -24,7 +25,7 @@ public class CodeConstants {
|
|||||||
|
|
||||||
private static final Set<String> values = new HashSet<String>();
|
private static final Set<String> values = new HashSet<String>();
|
||||||
static {
|
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);
|
values.add(type.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -112,7 +112,8 @@ public class CodeValuesApiResource {
|
|||||||
public String updateCodeValue(@PathParam("codeId") final Long codeId, @PathParam("codeValueId") final Long codeValueId,
|
public String updateCodeValue(@PathParam("codeId") final Long codeId, @PathParam("codeValueId") final Long codeValueId,
|
||||||
final String apiRequestBodyAsJson) {
|
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);
|
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -69,12 +69,12 @@ public class CodesApiResource {
|
|||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public String retrieveCodes(@Context final UriInfo uriInfo) {
|
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 Collection<CodeData> codes = this.readPlatformService.retrieveAllCodes();
|
||||||
|
|
||||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||||
return this.toApiJsonSerializer.serialize(settings, codes, RESPONSE_DATA_PARAMETERS);
|
return this.toApiJsonSerializer.serialize(settings, codes, this.RESPONSE_DATA_PARAMETERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@@ -97,8 +97,8 @@ public class CodesApiResource {
|
|||||||
|
|
||||||
final CodeData code = this.readPlatformService.retrieveCode(codeId);
|
final CodeData code = this.readPlatformService.retrieveCode(codeId);
|
||||||
|
|
||||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||||
return this.toApiJsonSerializer.serialize(settings, code, RESPONSE_DATA_PARAMETERS);
|
return this.toApiJsonSerializer.serialize(settings, code, this.RESPONSE_DATA_PARAMETERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
|
|||||||
+1
-1
@@ -28,7 +28,7 @@ public class CodeData implements Serializable {
|
|||||||
this.systemDefined = systemDefined;
|
this.systemDefined = systemDefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getCodeId(){
|
public Long getCodeId() {
|
||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -10,7 +10,7 @@ import java.io.Serializable;
|
|||||||
/**
|
/**
|
||||||
* Immutable data object represent code-value data in system.
|
* Immutable data object represent code-value data in system.
|
||||||
*/
|
*/
|
||||||
public class CodeValueData implements Serializable{
|
public class CodeValueData implements Serializable {
|
||||||
|
|
||||||
private final Long id;
|
private final Long id;
|
||||||
|
|
||||||
@@ -35,6 +35,6 @@ public class CodeValueData implements Serializable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Long getId() {
|
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) {
|
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);
|
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;
|
import org.springframework.data.jpa.domain.AbstractPersistable;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "m_code_value", uniqueConstraints = { @UniqueConstraint(columnNames = {
|
@Table(name = "m_code_value", uniqueConstraints = { @UniqueConstraint(columnNames = { "code_id", "code_value" }, name = "code_value_duplicate") })
|
||||||
"code_id", "code_value" }, name = "code_value_duplicate") })
|
|
||||||
public class CodeValue extends AbstractPersistable<Long> {
|
public class CodeValue extends AbstractPersistable<Long> {
|
||||||
|
|
||||||
@Column(name = "code_value", length = 100)
|
@Column(name = "code_value", length = 100)
|
||||||
private String label;
|
private String label;
|
||||||
|
|
||||||
@Column(name = "order_position")
|
@Column(name = "order_position")
|
||||||
private int position;
|
private int position;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "code_id", nullable = false)
|
@JoinColumn(name = "code_id", nullable = false)
|
||||||
private Code code;
|
private Code code;
|
||||||
|
|
||||||
public static CodeValue createNew(final Code code, final String label,
|
public static CodeValue createNew(final Code code, final String label, final int position) {
|
||||||
final int position) {
|
return new CodeValue(code, label, position);
|
||||||
return new CodeValue(code, label, position);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected CodeValue() {
|
protected CodeValue() {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
private CodeValue(final Code code, final String label, final int position) {
|
private CodeValue(final Code code, final String label, final int position) {
|
||||||
this.code = code;
|
this.code = code;
|
||||||
this.label = StringUtils.defaultIfEmpty(label, null);
|
this.label = StringUtils.defaultIfEmpty(label, null);
|
||||||
this.position = position;
|
this.position = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String label() {
|
public String label() {
|
||||||
return this.label;
|
return this.label;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int position() {
|
public int position() {
|
||||||
return this.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
|
final String label = command.stringValueOfParameterNamed(CODEVALUE_JSON_INPUT_PARAMS.NAME.getValue());
|
||||||
.stringValueOfParameterNamed(CODEVALUE_JSON_INPUT_PARAMS.NAME
|
Integer position = command.integerValueSansLocaleOfParameterNamed(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue());
|
||||||
.getValue());
|
if (position == null) {
|
||||||
Integer position = command
|
position = new Integer(0);
|
||||||
.integerValueSansLocaleOfParameterNamed(CODEVALUE_JSON_INPUT_PARAMS.POSITION
|
}
|
||||||
.getValue());
|
return new CodeValue(code, label, position.intValue());
|
||||||
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>(
|
final Map<String, Object> actualChanges = new LinkedHashMap<String, Object>(2);
|
||||||
2);
|
|
||||||
|
|
||||||
final String labelParamName = CODEVALUE_JSON_INPUT_PARAMS.NAME
|
final String labelParamName = CODEVALUE_JSON_INPUT_PARAMS.NAME.getValue();
|
||||||
.getValue();
|
if (command.isChangeInStringParameterNamed(labelParamName, this.label)) {
|
||||||
if (command.isChangeInStringParameterNamed(labelParamName, this.label)) {
|
final String newValue = command.stringValueOfParameterNamed(labelParamName);
|
||||||
final String newValue = command
|
actualChanges.put(labelParamName, newValue);
|
||||||
.stringValueOfParameterNamed(labelParamName);
|
this.label = StringUtils.defaultIfEmpty(newValue, null);
|
||||||
actualChanges.put(labelParamName, newValue);
|
}
|
||||||
this.label = StringUtils.defaultIfEmpty(newValue, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
final String positionParamName = CODEVALUE_JSON_INPUT_PARAMS.POSITION
|
final String positionParamName = CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue();
|
||||||
.getValue();
|
if (command.isChangeInIntegerSansLocaleParameterNamed(positionParamName, this.position)) {
|
||||||
if (command.isChangeInIntegerSansLocaleParameterNamed(
|
final Integer newValue = command.integerValueSansLocaleOfParameterNamed(positionParamName);
|
||||||
positionParamName, this.position)) {
|
actualChanges.put(positionParamName, newValue);
|
||||||
final Integer newValue = command
|
this.position = newValue.intValue();
|
||||||
.integerValueSansLocaleOfParameterNamed(positionParamName);
|
}
|
||||||
actualChanges.put(positionParamName, newValue);
|
|
||||||
this.position = newValue.intValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
return actualChanges;
|
return actualChanges;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CodeValueData toData() {
|
public CodeValueData toData() {
|
||||||
return CodeValueData.instance(getId(), this.label, this.position);
|
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;
|
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 {
|
public class SystemDefinedCodeCannotBeChangedException extends AbstractPlatformDomainRuleException {
|
||||||
|
|
||||||
|
|||||||
+7
-7
@@ -46,14 +46,14 @@ public final class CodeCommandFromApiJsonDeserializer {
|
|||||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||||
|
|
||||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
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 List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("code");
|
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);
|
baseDataValidator.reset().parameter("name").value(name).notBlank().notExceedingLengthOf(100);
|
||||||
|
|
||||||
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
||||||
@@ -63,14 +63,14 @@ public final class CodeCommandFromApiJsonDeserializer {
|
|||||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||||
|
|
||||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
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 List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("code");
|
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("code");
|
||||||
|
|
||||||
final JsonElement element = fromApiJsonHelper.parse(json);
|
final JsonElement element = this.fromApiJsonHelper.parse(json);
|
||||||
if (fromApiJsonHelper.parameterExists("name", element)) {
|
if (this.fromApiJsonHelper.parameterExists("name", element)) {
|
||||||
final String name = fromApiJsonHelper.extractStringNamed("name", element);
|
final String name = this.fromApiJsonHelper.extractStringNamed("name", element);
|
||||||
baseDataValidator.reset().parameter("name").value(name).notBlank().notExceedingLengthOf(100);
|
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);
|
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)) {
|
if (this.fromApiJsonHelper.parameterExists(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue(), element)) {
|
||||||
//Validate input value is a valid Integer
|
// Validate input value is a valid Integer
|
||||||
this.fromApiJsonHelper.extractIntegerSansLocaleNamed(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue(),
|
this.fromApiJsonHelper.extractIntegerSansLocaleNamed(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue(), element);
|
||||||
element);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
||||||
@@ -82,9 +81,8 @@ public final class CodeValueCommandFromApiJsonDeserializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.fromApiJsonHelper.parameterExists(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue(), element)) {
|
if (this.fromApiJsonHelper.parameterExists(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue(), element)) {
|
||||||
//Validate input value is a valid Integer
|
// Validate input value is a valid Integer
|
||||||
this.fromApiJsonHelper.extractIntegerSansLocaleNamed(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue(),
|
this.fromApiJsonHelper.extractIntegerSansLocaleNamed(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue(), element);
|
||||||
element);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
||||||
|
|||||||
+6
-6
@@ -52,7 +52,7 @@ public class CodeReadPlatformServiceImpl implements CodeReadPlatformService {
|
|||||||
@Override
|
@Override
|
||||||
@Cacheable(value = "codes", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat('CD')")
|
@Cacheable(value = "codes", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat('CD')")
|
||||||
public Collection<CodeData> retrieveAllCodes() {
|
public Collection<CodeData> retrieveAllCodes() {
|
||||||
context.authenticatedUser();
|
this.context.authenticatedUser();
|
||||||
|
|
||||||
final CodeMapper rm = new CodeMapper();
|
final CodeMapper rm = new CodeMapper();
|
||||||
final String sql = "select " + rm.schema() + " order by c.code_name";
|
final String sql = "select " + rm.schema() + " order by c.code_name";
|
||||||
@@ -63,27 +63,27 @@ public class CodeReadPlatformServiceImpl implements CodeReadPlatformService {
|
|||||||
@Override
|
@Override
|
||||||
public CodeData retrieveCode(final Long codeId) {
|
public CodeData retrieveCode(final Long codeId) {
|
||||||
try {
|
try {
|
||||||
context.authenticatedUser();
|
this.context.authenticatedUser();
|
||||||
|
|
||||||
final CodeMapper rm = new CodeMapper();
|
final CodeMapper rm = new CodeMapper();
|
||||||
final String sql = "select " + rm.schema() + " where c.id = ?";
|
final String sql = "select " + rm.schema() + " where c.id = ?";
|
||||||
|
|
||||||
return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { codeId });
|
return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { codeId });
|
||||||
} catch (EmptyResultDataAccessException e) {
|
} catch (final EmptyResultDataAccessException e) {
|
||||||
throw new CodeNotFoundException(codeId);
|
throw new CodeNotFoundException(codeId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CodeData retriveCode(String codeName) {
|
public CodeData retriveCode(final String codeName) {
|
||||||
try {
|
try {
|
||||||
context.authenticatedUser();
|
this.context.authenticatedUser();
|
||||||
|
|
||||||
final CodeMapper rm = new CodeMapper();
|
final CodeMapper rm = new CodeMapper();
|
||||||
final String sql = "select " + rm.schema() + " where c.code_name = ?";
|
final String sql = "select " + rm.schema() + " where c.code_name = ?";
|
||||||
|
|
||||||
return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { codeName });
|
return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { codeName });
|
||||||
} catch (EmptyResultDataAccessException e) {
|
} catch (final EmptyResultDataAccessException e) {
|
||||||
throw new CodeNotFoundException(codeName);
|
throw new CodeNotFoundException(codeName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-5
@@ -51,7 +51,7 @@ public class CodeValueReadPlatformServiceImpl implements CodeValueReadPlatformSe
|
|||||||
@Override
|
@Override
|
||||||
public Collection<CodeValueData> retrieveCodeValuesByCode(final String code) {
|
public Collection<CodeValueData> retrieveCodeValuesByCode(final String code) {
|
||||||
|
|
||||||
context.authenticatedUser();
|
this.context.authenticatedUser();
|
||||||
|
|
||||||
final CodeValueDataMapper rm = new CodeValueDataMapper();
|
final CodeValueDataMapper rm = new CodeValueDataMapper();
|
||||||
final String sql = "select " + rm.schema() + "where c.code_name like ? order by position";
|
final String sql = "select " + rm.schema() + "where c.code_name like ? order by position";
|
||||||
@@ -61,9 +61,9 @@ public class CodeValueReadPlatformServiceImpl implements CodeValueReadPlatformSe
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Cacheable(value = "code_values", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat(#codeId+'cv')")
|
@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 CodeValueDataMapper rm = new CodeValueDataMapper();
|
||||||
final String sql = "select " + rm.schema() + "where cv.code_id = ? order by position";
|
final String sql = "select " + rm.schema() + "where cv.code_id = ? order by position";
|
||||||
@@ -72,9 +72,9 @@ public class CodeValueReadPlatformServiceImpl implements CodeValueReadPlatformSe
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CodeValueData retrieveCodeValue(Long codeValueId) {
|
public CodeValueData retrieveCodeValue(final Long codeValueId) {
|
||||||
|
|
||||||
context.authenticatedUser();
|
this.context.authenticatedUser();
|
||||||
|
|
||||||
final CodeValueDataMapper rm = new CodeValueDataMapper();
|
final CodeValueDataMapper rm = new CodeValueDataMapper();
|
||||||
final String sql = "select " + rm.schema() + "where cv.id = ? order by position";
|
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()) //
|
.withCommandId(command.commandId()) //
|
||||||
.withEntityId(codeValue.getId()) //
|
.withEntityId(codeValue.getId()) //
|
||||||
.build();
|
.build();
|
||||||
} catch (DataIntegrityViolationException dve) {
|
} catch (final DataIntegrityViolationException dve) {
|
||||||
handleCodeValueDataIntegrityIssues(command, dve);
|
handleCodeValueDataIntegrityIssues(command, dve);
|
||||||
return new CommandProcessingResultBuilder() //
|
return new CommandProcessingResultBuilder() //
|
||||||
.withCommandId(command.commandId()) //
|
.withCommandId(command.commandId()) //
|
||||||
@@ -115,7 +115,7 @@ public class CodeValueWritePlatformServiceJpaRepositoryImpl implements CodeValue
|
|||||||
.withEntityId(codeValueId) //
|
.withEntityId(codeValueId) //
|
||||||
.with(changes) //
|
.with(changes) //
|
||||||
.build();
|
.build();
|
||||||
} catch (DataIntegrityViolationException dve) {
|
} catch (final DataIntegrityViolationException dve) {
|
||||||
handleCodeValueDataIntegrityIssues(command, dve);
|
handleCodeValueDataIntegrityIssues(command, dve);
|
||||||
return new CommandProcessingResultBuilder() //
|
return new CommandProcessingResultBuilder() //
|
||||||
.withCommandId(command.commandId()) //
|
.withCommandId(command.commandId()) //
|
||||||
@@ -137,7 +137,7 @@ public class CodeValueWritePlatformServiceJpaRepositoryImpl implements CodeValue
|
|||||||
|
|
||||||
final CodeValue codeValueToDelete = this.codeValueRepositoryWrapper.findOneWithNotFoundDetection(codeValueId);
|
final CodeValue codeValueToDelete = this.codeValueRepositoryWrapper.findOneWithNotFoundDetection(codeValueId);
|
||||||
|
|
||||||
boolean removed = code.remove(codeValueToDelete);
|
final boolean removed = code.remove(codeValueToDelete);
|
||||||
if (removed) {
|
if (removed) {
|
||||||
this.codeRepository.saveAndFlush(code);
|
this.codeRepository.saveAndFlush(code);
|
||||||
}
|
}
|
||||||
@@ -145,7 +145,7 @@ public class CodeValueWritePlatformServiceJpaRepositoryImpl implements CodeValue
|
|||||||
return new CommandProcessingResultBuilder() //
|
return new CommandProcessingResultBuilder() //
|
||||||
.withEntityId(codeValueId) //
|
.withEntityId(codeValueId) //
|
||||||
.build();
|
.build();
|
||||||
} catch (DataIntegrityViolationException dve) {
|
} catch (final DataIntegrityViolationException dve) {
|
||||||
logger.error(dve.getMessage(), dve);
|
logger.error(dve.getMessage(), dve);
|
||||||
throw new PlatformDataIntegrityException("error.msg.code.value.unknown.data.integrity.issue",
|
throw new PlatformDataIntegrityException("error.msg.code.value.unknown.data.integrity.issue",
|
||||||
"Unknown data integrity issue with resource: " + dve.getMostSpecificCause().getMessage());
|
"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) {
|
public CommandProcessingResult createCode(final JsonCommand command) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
context.authenticatedUser();
|
this.context.authenticatedUser();
|
||||||
|
|
||||||
this.fromApiJsonDeserializer.validateForCreate(command.json());
|
this.fromApiJsonDeserializer.validateForCreate(command.json());
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ public class CodeWritePlatformServiceJpaRepositoryImpl implements CodeWritePlatf
|
|||||||
this.codeRepository.save(code);
|
this.codeRepository.save(code);
|
||||||
|
|
||||||
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(code.getId()).build();
|
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(code.getId()).build();
|
||||||
} catch (DataIntegrityViolationException dve) {
|
} catch (final DataIntegrityViolationException dve) {
|
||||||
handleCodeDataIntegrityIssues(command, dve);
|
handleCodeDataIntegrityIssues(command, dve);
|
||||||
return CommandProcessingResult.empty();
|
return CommandProcessingResult.empty();
|
||||||
}
|
}
|
||||||
@@ -68,7 +68,7 @@ public class CodeWritePlatformServiceJpaRepositoryImpl implements CodeWritePlatf
|
|||||||
public CommandProcessingResult updateCode(final Long codeId, final JsonCommand command) {
|
public CommandProcessingResult updateCode(final Long codeId, final JsonCommand command) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
context.authenticatedUser();
|
this.context.authenticatedUser();
|
||||||
|
|
||||||
this.fromApiJsonDeserializer.validateForUpdate(command.json());
|
this.fromApiJsonDeserializer.validateForUpdate(command.json());
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ public class CodeWritePlatformServiceJpaRepositoryImpl implements CodeWritePlatf
|
|||||||
.withEntityId(codeId) //
|
.withEntityId(codeId) //
|
||||||
.with(changes) //
|
.with(changes) //
|
||||||
.build();
|
.build();
|
||||||
} catch (DataIntegrityViolationException dve) {
|
} catch (final DataIntegrityViolationException dve) {
|
||||||
handleCodeDataIntegrityIssues(command, dve);
|
handleCodeDataIntegrityIssues(command, dve);
|
||||||
return null;
|
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')")
|
@CacheEvict(value = "codes", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat('cv')")
|
||||||
public CommandProcessingResult deleteCode(final Long codeId) {
|
public CommandProcessingResult deleteCode(final Long codeId) {
|
||||||
|
|
||||||
context.authenticatedUser();
|
this.context.authenticatedUser();
|
||||||
|
|
||||||
final Code code = retrieveCodeBy(codeId);
|
final Code code = retrieveCodeBy(codeId);
|
||||||
if (code.isSystemDefined()) { throw new SystemDefinedCodeCannotBeChangedException(); }
|
if (code.isSystemDefined()) { throw new SystemDefinedCodeCannotBeChangedException(); }
|
||||||
@@ -103,7 +103,7 @@ public class CodeWritePlatformServiceJpaRepositoryImpl implements CodeWritePlatf
|
|||||||
try {
|
try {
|
||||||
this.codeRepository.delete(code);
|
this.codeRepository.delete(code);
|
||||||
this.codeRepository.flush();
|
this.codeRepository.flush();
|
||||||
} catch (DataIntegrityViolationException e) {
|
} catch (final DataIntegrityViolationException e) {
|
||||||
throw new PlatformDataIntegrityException("error.msg.cund.unknown.data.integrity.issue",
|
throw new PlatformDataIntegrityException("error.msg.cund.unknown.data.integrity.issue",
|
||||||
"Unknown data integrity issue with resource: " + e.getMostSpecificCause());
|
"Unknown data integrity issue with resource: " + e.getMostSpecificCause());
|
||||||
}
|
}
|
||||||
@@ -121,7 +121,7 @@ public class CodeWritePlatformServiceJpaRepositoryImpl implements CodeWritePlatf
|
|||||||
* is.
|
* is.
|
||||||
*/
|
*/
|
||||||
private void handleCodeDataIntegrityIssues(final JsonCommand command, final DataIntegrityViolationException dve) {
|
private void handleCodeDataIntegrityIssues(final JsonCommand command, final DataIntegrityViolationException dve) {
|
||||||
Throwable realCause = dve.getMostSpecificCause();
|
final Throwable realCause = dve.getMostSpecificCause();
|
||||||
if (realCause.getMessage().contains("code_name")) {
|
if (realCause.getMessage().contains("code_name")) {
|
||||||
final String name = command.stringValueOfParameterNamed("name");
|
final String name = command.stringValueOfParameterNamed("name");
|
||||||
throw new PlatformDataIntegrityException("error.msg.code.duplicate.name", "A code with name '" + name + "' already exists",
|
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 })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public String retrieveConfiguration(@Context final UriInfo uriInfo) {
|
public String retrieveConfiguration(@Context final UriInfo uriInfo) {
|
||||||
|
|
||||||
context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions);
|
this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions);
|
||||||
|
|
||||||
final GlobalConfigurationData configurationData = this.readPlatformService.retrieveGlobalConfiguration();
|
final GlobalConfigurationData configurationData = this.readPlatformService.retrieveGlobalConfiguration();
|
||||||
|
|
||||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||||
return this.toApiJsonSerializer.serialize(settings, configurationData, RESPONSE_DATA_PARAMETERS);
|
return this.toApiJsonSerializer.serialize(settings, configurationData, this.RESPONSE_DATA_PARAMETERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@@ -81,9 +81,9 @@ public class GlobalConfigurationApiResource {
|
|||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public String updateConfiguration(@Context final UriInfo uriInfo) {
|
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);
|
globalConfiguration.put("globalConfiguration", configurationParameters);
|
||||||
|
|
||||||
final String apiRequestJson = this.toApiJsonSerializer.serialize(globalConfiguration);
|
final String apiRequestJson = this.toApiJsonSerializer.serialize(globalConfiguration);
|
||||||
|
|||||||
+2
-2
@@ -11,9 +11,9 @@ package org.mifosplatform.infrastructure.configuration.data;
|
|||||||
public class GlobalConfigurationPropertyData {
|
public class GlobalConfigurationPropertyData {
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private String name;
|
private final String name;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private boolean enabled;
|
private final boolean enabled;
|
||||||
|
|
||||||
public GlobalConfigurationPropertyData(final String name, final boolean enabled) {
|
public GlobalConfigurationPropertyData(final String name, final boolean enabled) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ public class S3CredentialsData {
|
|||||||
private final String accessKey;
|
private final String accessKey;
|
||||||
private final String secretKey;
|
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.bucketName = bucketName;
|
||||||
this.accessKey = accessKey;
|
this.accessKey = accessKey;
|
||||||
this.secretKey = secretKey;
|
this.secretKey = secretKey;
|
||||||
|
|||||||
+8
@@ -10,12 +10,20 @@ import org.mifosplatform.infrastructure.cache.domain.CacheType;
|
|||||||
public interface ConfigurationDomainService {
|
public interface ConfigurationDomainService {
|
||||||
|
|
||||||
boolean isMakerCheckerEnabledForTask(String taskPermissionCode);
|
boolean isMakerCheckerEnabledForTask(String taskPermissionCode);
|
||||||
|
|
||||||
boolean isAmazonS3Enabled();
|
boolean isAmazonS3Enabled();
|
||||||
|
|
||||||
boolean isRescheduleFutureRepaymentsEnabled();
|
boolean isRescheduleFutureRepaymentsEnabled();
|
||||||
|
|
||||||
boolean isRescheduleRepaymentsOnHolidaysEnabled();
|
boolean isRescheduleRepaymentsOnHolidaysEnabled();
|
||||||
|
|
||||||
boolean allowTransactionsOnHolidayEnabled();
|
boolean allowTransactionsOnHolidayEnabled();
|
||||||
|
|
||||||
boolean allowTransactionsOnNonWorkingDayEnabled();
|
boolean allowTransactionsOnNonWorkingDayEnabled();
|
||||||
|
|
||||||
boolean isConstraintApproachEnabledForDatatables();
|
boolean isConstraintApproachEnabledForDatatables();
|
||||||
|
|
||||||
boolean isEhcacheEnabled();
|
boolean isEhcacheEnabled();
|
||||||
|
|
||||||
void updateCache(CacheType cacheType);
|
void updateCache(CacheType cacheType);
|
||||||
}
|
}
|
||||||
+12
-8
@@ -7,8 +7,8 @@ package org.mifosplatform.infrastructure.configuration.domain;
|
|||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.mifosplatform.infrastructure.cache.domain.CacheType;
|
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.PlatformCache;
|
||||||
|
import org.mifosplatform.infrastructure.cache.domain.PlatformCacheRepository;
|
||||||
import org.mifosplatform.infrastructure.configuration.exception.GlobalConfigurationPropertyNotFoundException;
|
import org.mifosplatform.infrastructure.configuration.exception.GlobalConfigurationPropertyNotFoundException;
|
||||||
import org.mifosplatform.useradministration.domain.Permission;
|
import org.mifosplatform.useradministration.domain.Permission;
|
||||||
import org.mifosplatform.useradministration.domain.PermissionRepository;
|
import org.mifosplatform.useradministration.domain.PermissionRepository;
|
||||||
@@ -26,8 +26,7 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public ConfigurationDomainServiceJpa(final PermissionRepository permissionRepository,
|
public ConfigurationDomainServiceJpa(final PermissionRepository permissionRepository,
|
||||||
final GlobalConfigurationRepository globalConfigurationRepository,
|
final GlobalConfigurationRepository globalConfigurationRepository, final PlatformCacheRepository cacheTypeRepository) {
|
||||||
final PlatformCacheRepository cacheTypeRepository) {
|
|
||||||
this.permissionRepository = permissionRepository;
|
this.permissionRepository = permissionRepository;
|
||||||
this.globalConfigurationRepository = globalConfigurationRepository;
|
this.globalConfigurationRepository = globalConfigurationRepository;
|
||||||
this.cacheTypeRepository = cacheTypeRepository;
|
this.cacheTypeRepository = cacheTypeRepository;
|
||||||
@@ -48,20 +47,24 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAmazonS3Enabled(){
|
public boolean isAmazonS3Enabled() {
|
||||||
return this.globalConfigurationRepository.findOneByName("amazon-S3").isEnabled();
|
return this.globalConfigurationRepository.findOneByName("amazon-S3").isEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRescheduleFutureRepaymentsEnabled() {
|
public boolean isRescheduleFutureRepaymentsEnabled() {
|
||||||
final String rescheduleRepaymentsConfigurationProperty = "reschedule-future-repayments";
|
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); }
|
if (property == null) { throw new GlobalConfigurationPropertyNotFoundException(rescheduleRepaymentsConfigurationProperty); }
|
||||||
return property.isEnabled();
|
return property.isEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
* @see org.mifosplatform.infrastructure.configuration.domain.ConfigurationDomainService#isHolidaysEnabled()
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.mifosplatform.infrastructure.configuration.domain.
|
||||||
|
* ConfigurationDomainService#isHolidaysEnabled()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isRescheduleRepaymentsOnHolidaysEnabled() {
|
public boolean isRescheduleRepaymentsOnHolidaysEnabled() {
|
||||||
@@ -82,7 +85,8 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService
|
|||||||
@Override
|
@Override
|
||||||
public boolean allowTransactionsOnNonWorkingDayEnabled() {
|
public boolean allowTransactionsOnNonWorkingDayEnabled() {
|
||||||
final String allowTransactionsOnNonWorkingDayProperty = "allow-transactions-on-non_workingday";
|
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); }
|
if (property == null) { throw new GlobalConfigurationPropertyNotFoundException(allowTransactionsOnNonWorkingDayProperty); }
|
||||||
return property.isEnabled();
|
return property.isEnabled();
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -47,8 +47,8 @@ public final class GlobalConfigurationCommandFromApiJsonDeserializer extends
|
|||||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||||
|
|
||||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
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.context = context;
|
||||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||||
|
|
||||||
rm = new GlobalConfigurationRowMapper();
|
this.rm = new GlobalConfigurationRowMapper();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GlobalConfigurationData retrieveGlobalConfiguration() {
|
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 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);
|
return new GlobalConfigurationData(globalConfiguration);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -24,7 +24,7 @@ public class ExternalServicesReadPlatformServiceImpl implements ExternalServices
|
|||||||
private static final class S3CredentialsDataExtractor implements ResultSetExtractor<S3CredentialsData> {
|
private static final class S3CredentialsDataExtractor implements ResultSetExtractor<S3CredentialsData> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public S3CredentialsData extractData(ResultSet rs) throws SQLException, DataAccessException {
|
public S3CredentialsData extractData(final ResultSet rs) throws SQLException, DataAccessException {
|
||||||
String accessKey = null;
|
String accessKey = null;
|
||||||
String bucketName = null;
|
String bucketName = null;
|
||||||
String secretKey = null;
|
String secretKey = null;
|
||||||
|
|||||||
+6
-5
@@ -30,7 +30,8 @@ public class GlobalConfigurationWritePlatformServiceJpaRepositoryImpl implements
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public GlobalConfigurationWritePlatformServiceJpaRepositoryImpl(final PlatformSecurityContext context,
|
public GlobalConfigurationWritePlatformServiceJpaRepositoryImpl(final PlatformSecurityContext context,
|
||||||
final GlobalConfigurationRepository codeRepository, final GlobalConfigurationCommandFromApiJsonDeserializer fromApiJsonDeserializer) {
|
final GlobalConfigurationRepository codeRepository,
|
||||||
|
final GlobalConfigurationCommandFromApiJsonDeserializer fromApiJsonDeserializer) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.repository = codeRepository;
|
this.repository = codeRepository;
|
||||||
this.fromApiJsonDeserializer = fromApiJsonDeserializer;
|
this.fromApiJsonDeserializer = fromApiJsonDeserializer;
|
||||||
@@ -40,7 +41,7 @@ public class GlobalConfigurationWritePlatformServiceJpaRepositoryImpl implements
|
|||||||
@Override
|
@Override
|
||||||
public CommandProcessingResult update(final JsonCommand command) {
|
public CommandProcessingResult update(final JsonCommand command) {
|
||||||
|
|
||||||
context.authenticatedUser();
|
this.context.authenticatedUser();
|
||||||
|
|
||||||
final UpdateGlobalConfigurationCommand configurationCommand = this.fromApiJsonDeserializer.commandFromApiJson(command.json());
|
final UpdateGlobalConfigurationCommand configurationCommand = this.fromApiJsonDeserializer.commandFromApiJson(command.json());
|
||||||
|
|
||||||
@@ -48,11 +49,11 @@ public class GlobalConfigurationWritePlatformServiceJpaRepositoryImpl implements
|
|||||||
|
|
||||||
final Map<String, Object> changes = new LinkedHashMap<String, Object>(params.size());
|
final Map<String, Object> changes = new LinkedHashMap<String, Object>(params.size());
|
||||||
final Map<String, Boolean> propertiesMap = new LinkedHashMap<String, Boolean>(1);
|
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);
|
final GlobalConfigurationProperty property = retrieveBy(propertyName);
|
||||||
|
|
||||||
Boolean value = params.get(propertyName);
|
final Boolean value = params.get(propertyName);
|
||||||
boolean updated = property.updateTo(value);
|
final boolean updated = property.updateTo(value);
|
||||||
|
|
||||||
if (updated) {
|
if (updated) {
|
||||||
propertiesMap.put(propertyName, value);
|
propertiesMap.put(propertyName, value);
|
||||||
|
|||||||
+16
-16
@@ -58,7 +58,7 @@ public class ApiParameterHelper {
|
|||||||
public static boolean prettyPrint(final MultivaluedMap<String, String> queryParams) {
|
public static boolean prettyPrint(final MultivaluedMap<String, String> queryParams) {
|
||||||
boolean prettyPrint = false;
|
boolean prettyPrint = false;
|
||||||
if (queryParams.getFirst("pretty") != null) {
|
if (queryParams.getFirst("pretty") != null) {
|
||||||
String prettyPrintValue = queryParams.getFirst("pretty");
|
final String prettyPrintValue = queryParams.getFirst("pretty");
|
||||||
prettyPrint = "true".equalsIgnoreCase(prettyPrintValue);
|
prettyPrint = "true".equalsIgnoreCase(prettyPrintValue);
|
||||||
}
|
}
|
||||||
return prettyPrint;
|
return prettyPrint;
|
||||||
@@ -67,7 +67,7 @@ public class ApiParameterHelper {
|
|||||||
public static Locale extractLocale(final MultivaluedMap<String, String> queryParams) {
|
public static Locale extractLocale(final MultivaluedMap<String, String> queryParams) {
|
||||||
Locale locale = null;
|
Locale locale = null;
|
||||||
if (queryParams.getFirst("locale") != null) {
|
if (queryParams.getFirst("locale") != null) {
|
||||||
String localeAsString = queryParams.getFirst("locale");
|
final String localeAsString = queryParams.getFirst("locale");
|
||||||
locale = JsonParserHelper.localeFromString(localeAsString);
|
locale = JsonParserHelper.localeFromString(localeAsString);
|
||||||
}
|
}
|
||||||
return locale;
|
return locale;
|
||||||
@@ -76,7 +76,7 @@ public class ApiParameterHelper {
|
|||||||
public static boolean exportCsv(final MultivaluedMap<String, String> queryParams) {
|
public static boolean exportCsv(final MultivaluedMap<String, String> queryParams) {
|
||||||
boolean exportCsv = false;
|
boolean exportCsv = false;
|
||||||
if (queryParams.getFirst("exportCSV") != null) {
|
if (queryParams.getFirst("exportCSV") != null) {
|
||||||
String exportCsvValue = queryParams.getFirst("exportCSV");
|
final String exportCsvValue = queryParams.getFirst("exportCSV");
|
||||||
exportCsv = "true".equalsIgnoreCase(exportCsvValue);
|
exportCsv = "true".equalsIgnoreCase(exportCsvValue);
|
||||||
}
|
}
|
||||||
return exportCsv;
|
return exportCsv;
|
||||||
@@ -85,7 +85,7 @@ public class ApiParameterHelper {
|
|||||||
public static boolean exportPdf(final MultivaluedMap<String, String> queryParams) {
|
public static boolean exportPdf(final MultivaluedMap<String, String> queryParams) {
|
||||||
boolean exportPDF = false;
|
boolean exportPDF = false;
|
||||||
if (queryParams.getFirst("exportPDF") != null) {
|
if (queryParams.getFirst("exportPDF") != null) {
|
||||||
String exportPdfValue = queryParams.getFirst("exportPDF");
|
final String exportPdfValue = queryParams.getFirst("exportPDF");
|
||||||
exportPDF = "true".equalsIgnoreCase(exportPdfValue);
|
exportPDF = "true".equalsIgnoreCase(exportPdfValue);
|
||||||
}
|
}
|
||||||
return exportPDF;
|
return exportPDF;
|
||||||
@@ -94,7 +94,7 @@ public class ApiParameterHelper {
|
|||||||
public static boolean parameterType(final MultivaluedMap<String, String> queryParams) {
|
public static boolean parameterType(final MultivaluedMap<String, String> queryParams) {
|
||||||
boolean parameterType = false;
|
boolean parameterType = false;
|
||||||
if (queryParams.getFirst("parameterType") != null) {
|
if (queryParams.getFirst("parameterType") != null) {
|
||||||
String parameterTypeValue = queryParams.getFirst("parameterType");
|
final String parameterTypeValue = queryParams.getFirst("parameterType");
|
||||||
parameterType = "true".equalsIgnoreCase(parameterTypeValue);
|
parameterType = "true".equalsIgnoreCase(parameterTypeValue);
|
||||||
}
|
}
|
||||||
return parameterType;
|
return parameterType;
|
||||||
@@ -103,7 +103,7 @@ public class ApiParameterHelper {
|
|||||||
public static boolean template(final MultivaluedMap<String, String> queryParams) {
|
public static boolean template(final MultivaluedMap<String, String> queryParams) {
|
||||||
boolean template = false;
|
boolean template = false;
|
||||||
if (queryParams.getFirst("template") != null) {
|
if (queryParams.getFirst("template") != null) {
|
||||||
String prettyPrintValue = queryParams.getFirst("template");
|
final String prettyPrintValue = queryParams.getFirst("template");
|
||||||
template = "true".equalsIgnoreCase(prettyPrintValue);
|
template = "true".equalsIgnoreCase(prettyPrintValue);
|
||||||
}
|
}
|
||||||
return template;
|
return template;
|
||||||
@@ -112,7 +112,7 @@ public class ApiParameterHelper {
|
|||||||
public static boolean makerCheckerable(final MultivaluedMap<String, String> queryParams) {
|
public static boolean makerCheckerable(final MultivaluedMap<String, String> queryParams) {
|
||||||
boolean makerCheckerable = false;
|
boolean makerCheckerable = false;
|
||||||
if (queryParams.getFirst("makerCheckerable") != null) {
|
if (queryParams.getFirst("makerCheckerable") != null) {
|
||||||
String prettyPrintValue = queryParams.getFirst("makerCheckerable");
|
final String prettyPrintValue = queryParams.getFirst("makerCheckerable");
|
||||||
makerCheckerable = "true".equalsIgnoreCase(prettyPrintValue);
|
makerCheckerable = "true".equalsIgnoreCase(prettyPrintValue);
|
||||||
}
|
}
|
||||||
return makerCheckerable;
|
return makerCheckerable;
|
||||||
@@ -121,7 +121,7 @@ public class ApiParameterHelper {
|
|||||||
public static boolean includeJson(final MultivaluedMap<String, String> queryParams) {
|
public static boolean includeJson(final MultivaluedMap<String, String> queryParams) {
|
||||||
boolean includeJson = false;
|
boolean includeJson = false;
|
||||||
if (queryParams.getFirst("includeJson") != null) {
|
if (queryParams.getFirst("includeJson") != null) {
|
||||||
String includeJsonValue = queryParams.getFirst("includeJson");
|
final String includeJsonValue = queryParams.getFirst("includeJson");
|
||||||
includeJson = "true".equalsIgnoreCase(includeJsonValue);
|
includeJson = "true".equalsIgnoreCase(includeJsonValue);
|
||||||
}
|
}
|
||||||
return includeJson;
|
return includeJson;
|
||||||
@@ -130,28 +130,28 @@ public class ApiParameterHelper {
|
|||||||
public static boolean genericResultSet(final MultivaluedMap<String, String> queryParams) {
|
public static boolean genericResultSet(final MultivaluedMap<String, String> queryParams) {
|
||||||
boolean genericResultSet = false;
|
boolean genericResultSet = false;
|
||||||
if (queryParams.getFirst("genericResultSet") != null) {
|
if (queryParams.getFirst("genericResultSet") != null) {
|
||||||
String genericResultSetValue = queryParams.getFirst("genericResultSet");
|
final String genericResultSetValue = queryParams.getFirst("genericResultSet");
|
||||||
genericResultSet = "true".equalsIgnoreCase(genericResultSetValue);
|
genericResultSet = "true".equalsIgnoreCase(genericResultSetValue);
|
||||||
}
|
}
|
||||||
return genericResultSet;
|
return genericResultSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean genericResultSetPassed(MultivaluedMap<String, String> queryParams) {
|
public static boolean genericResultSetPassed(final MultivaluedMap<String, String> queryParams) {
|
||||||
return queryParams.getFirst("genericResultSet") != null;
|
return queryParams.getFirst("genericResultSet") != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String sqlEncodeString(String str) {
|
public static String sqlEncodeString(final String str) {
|
||||||
String singleQuote = "'";
|
final String singleQuote = "'";
|
||||||
String twoSingleQuotes = "''";
|
final String twoSingleQuotes = "''";
|
||||||
return singleQuote + StringUtils.replace(str, singleQuote, twoSingleQuotes, -1) + singleQuote;
|
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());
|
final Map<String, String> map = new HashMap<String, String>(queryParameters.size());
|
||||||
|
|
||||||
for (String parameterName : queryParameters.keySet()) {
|
for (final String parameterName : queryParameters.keySet()) {
|
||||||
List<String> values = queryParameters.get(parameterName);
|
final List<String> values = queryParameters.get(parameterName);
|
||||||
map.put(parameterName, values.get(0));
|
map.put(parameterName, values.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -29,7 +29,7 @@ public class ApiRequestParameterHelper {
|
|||||||
public ApiRequestJsonSerializationSettings process(final MultivaluedMap<String, String> queryParameters,
|
public ApiRequestJsonSerializationSettings process(final MultivaluedMap<String, String> queryParameters,
|
||||||
final Set<String> mandatoryResponseParameters) {
|
final Set<String> mandatoryResponseParameters) {
|
||||||
|
|
||||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(queryParameters);
|
final Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(queryParameters);
|
||||||
if (!responseParameters.isEmpty()) {
|
if (!responseParameters.isEmpty()) {
|
||||||
responseParameters.addAll(mandatoryResponseParameters);
|
responseParameters.addAll(mandatoryResponseParameters);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -68,7 +68,8 @@ public final class JsonCommand {
|
|||||||
public JsonCommand(final Long commandId, final String jsonCommand, final JsonElement parsedCommand,
|
public JsonCommand(final Long commandId, final String jsonCommand, final JsonElement parsedCommand,
|
||||||
final FromJsonHelper fromApiJsonHelper, final String entityName, final Long resourceId, final Long subresourceId,
|
final FromJsonHelper fromApiJsonHelper, final String entityName, final Long resourceId, final Long subresourceId,
|
||||||
final Long groupId, final Long clientId, final Long loanId, final Long savingsId, final Long codeId,
|
final Long groupId, final Long clientId, final Long loanId, final Long savingsId, final Long codeId,
|
||||||
final String supportedEntityType, final Long supportedEntityId, final String transactionId, final String url, final Long productId) {
|
final String supportedEntityType, final Long supportedEntityId, final String transactionId, final String url,
|
||||||
|
final Long productId) {
|
||||||
this.commandId = commandId;
|
this.commandId = commandId;
|
||||||
this.jsonCommand = jsonCommand;
|
this.jsonCommand = jsonCommand;
|
||||||
this.parsedCommand = parsedCommand;
|
this.parsedCommand = parsedCommand;
|
||||||
|
|||||||
+12
-12
@@ -118,7 +118,7 @@ public final class JsonQuery {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean parameterExists(final String parameterName) {
|
private boolean parameterExists(final String parameterName) {
|
||||||
return this.fromApiJsonHelper.parameterExists(parameterName, parsedQuery);
|
return this.fromApiJsonHelper.parameterExists(parameterName, this.parsedQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasParameter(final String parameterName) {
|
public boolean hasParameter(final String parameterName) {
|
||||||
@@ -136,11 +136,11 @@ public final class JsonQuery {
|
|||||||
public Map<String, Boolean> mapValueOfParameterNamed(final String parameterName) {
|
public Map<String, Boolean> mapValueOfParameterNamed(final String parameterName) {
|
||||||
final Type typeOfMap = new TypeToken<Map<String, Boolean>>() {}.getType();
|
final Type typeOfMap = new TypeToken<Map<String, Boolean>>() {}.getType();
|
||||||
|
|
||||||
if (parsedQuery.getAsJsonObject().has(parameterName)) {
|
if (this.parsedQuery.getAsJsonObject().has(parameterName)) {
|
||||||
parsedQuery.getAsJsonObject().get(parameterName);
|
this.parsedQuery.getAsJsonObject().get(parameterName);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.fromApiJsonHelper.extractMap(typeOfMap, jsonQuery);
|
return this.fromApiJsonHelper.extractMap(typeOfMap, this.jsonQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isChangeInLongParameterNamed(final String parameterName, final Long existingValue) {
|
public boolean isChangeInLongParameterNamed(final String parameterName, final Long existingValue) {
|
||||||
@@ -153,7 +153,7 @@ public final class JsonQuery {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Long longValueOfParameterNamed(final String parameterName) {
|
public Long longValueOfParameterNamed(final String parameterName) {
|
||||||
return this.fromApiJsonHelper.extractLongNamed(parameterName, parsedQuery);
|
return this.fromApiJsonHelper.extractLongNamed(parameterName, this.parsedQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isChangeInLocalDateParameterNamed(final String parameterName, final LocalDate existingValue) {
|
public boolean isChangeInLocalDateParameterNamed(final String parameterName, final LocalDate existingValue) {
|
||||||
@@ -166,7 +166,7 @@ public final class JsonQuery {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public LocalDate localDateValueOfParameterNamed(final String parameterName) {
|
public LocalDate localDateValueOfParameterNamed(final String parameterName) {
|
||||||
return this.fromApiJsonHelper.extractLocalDateNamed(parameterName, parsedQuery);
|
return this.fromApiJsonHelper.extractLocalDateNamed(parameterName, this.parsedQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isChangeInStringParameterNamed(final String parameterName, final String existingValue) {
|
public boolean isChangeInStringParameterNamed(final String parameterName, final String existingValue) {
|
||||||
@@ -179,7 +179,7 @@ public final class JsonQuery {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String stringValueOfParameterNamed(final String parameterName) {
|
public String stringValueOfParameterNamed(final String parameterName) {
|
||||||
final String value = this.fromApiJsonHelper.extractStringNamed(parameterName, parsedQuery);
|
final String value = this.fromApiJsonHelper.extractStringNamed(parameterName, this.parsedQuery);
|
||||||
return StringUtils.defaultIfEmpty(value, "");
|
return StringUtils.defaultIfEmpty(value, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,7 +193,7 @@ public final class JsonQuery {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal bigDecimalValueOfParameterNamed(final String parameterName) {
|
public BigDecimal bigDecimalValueOfParameterNamed(final String parameterName) {
|
||||||
return this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(parameterName, parsedQuery);
|
return this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(parameterName, this.parsedQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isChangeInIntegerParameterNamed(final String parameterName, final Integer existingValue) {
|
public boolean isChangeInIntegerParameterNamed(final String parameterName, final Integer existingValue) {
|
||||||
@@ -206,7 +206,7 @@ public final class JsonQuery {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Integer integerValueOfParameterNamed(final String parameterName) {
|
public Integer integerValueOfParameterNamed(final String parameterName) {
|
||||||
return this.fromApiJsonHelper.extractIntegerWithLocaleNamed(parameterName, parsedQuery);
|
return this.fromApiJsonHelper.extractIntegerWithLocaleNamed(parameterName, this.parsedQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isChangeInBooleanParameterNamed(final String parameterName, final Boolean existingValue) {
|
public boolean isChangeInBooleanParameterNamed(final String parameterName, final Boolean existingValue) {
|
||||||
@@ -222,14 +222,14 @@ public final class JsonQuery {
|
|||||||
* Returns {@link Boolean} that could possibly be null.
|
* Returns {@link Boolean} that could possibly be null.
|
||||||
*/
|
*/
|
||||||
public Boolean booleanObjectValueOfParameterNamed(final String parameterName) {
|
public Boolean booleanObjectValueOfParameterNamed(final String parameterName) {
|
||||||
return this.fromApiJsonHelper.extractBooleanNamed(parameterName, parsedQuery);
|
return this.fromApiJsonHelper.extractBooleanNamed(parameterName, this.parsedQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* always returns true or false
|
* always returns true or false
|
||||||
*/
|
*/
|
||||||
public boolean booleanPrimitiveValueOfParameterNamed(final String parameterName) {
|
public boolean booleanPrimitiveValueOfParameterNamed(final String parameterName) {
|
||||||
final Boolean value = this.fromApiJsonHelper.extractBooleanNamed(parameterName, parsedQuery);
|
final Boolean value = this.fromApiJsonHelper.extractBooleanNamed(parameterName, this.parsedQuery);
|
||||||
return (Boolean) ObjectUtils.defaultIfNull(value, Boolean.FALSE);
|
return (Boolean) ObjectUtils.defaultIfNull(value, Boolean.FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,7 +243,7 @@ public final class JsonQuery {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String[] arrayValueOfParameterNamed(final String parameterName) {
|
public String[] arrayValueOfParameterNamed(final String parameterName) {
|
||||||
return this.fromApiJsonHelper.extractArrayNamed(parameterName, parsedQuery);
|
return this.fromApiJsonHelper.extractArrayNamed(parameterName, this.parsedQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isChangeInPasswordParameterNamed(final String parameterName, final String existingValue,
|
public boolean isChangeInPasswordParameterNamed(final String parameterName, final String existingValue,
|
||||||
|
|||||||
+3
-3
@@ -23,13 +23,13 @@ public class ParameterListExclusionStrategy implements ExclusionStrategy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldSkipField(FieldAttributes f) {
|
public boolean shouldSkipField(final FieldAttributes f) {
|
||||||
return parameterNamesToSkip.contains(f.getName());
|
return this.parameterNamesToSkip.contains(f.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldSkipClass(Class<?> clazz) {
|
public boolean shouldSkipClass(final Class<?> clazz) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+19
-20
@@ -5,31 +5,30 @@
|
|||||||
*/
|
*/
|
||||||
package org.mifosplatform.infrastructure.core.data;
|
package org.mifosplatform.infrastructure.core.data;
|
||||||
|
|
||||||
|
|
||||||
public class ApiErrorMessageArg {
|
public class ApiErrorMessageArg {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The actual value of the parameter (if any) as passed to API.
|
* The actual value of the parameter (if any) as passed to API.
|
||||||
*/
|
*/
|
||||||
private Object value;
|
private Object value;
|
||||||
|
|
||||||
public static ApiErrorMessageArg from(Object object) {
|
public static ApiErrorMessageArg from(final Object object) {
|
||||||
return new ApiErrorMessageArg(object);
|
return new ApiErrorMessageArg(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ApiErrorMessageArg() {
|
protected ApiErrorMessageArg() {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApiErrorMessageArg(Object object) {
|
public ApiErrorMessageArg(final Object object) {
|
||||||
this.value = object;
|
this.value = object;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getValue() {
|
public Object getValue() {
|
||||||
return value;
|
return this.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setValue(Object value) {
|
public void setValue(final Object value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+20
-20
@@ -48,7 +48,7 @@ public class ApiGlobalErrorResponse {
|
|||||||
|
|
||||||
public static ApiGlobalErrorResponse unAuthenticated() {
|
public static ApiGlobalErrorResponse unAuthenticated() {
|
||||||
|
|
||||||
ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
|
final ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
|
||||||
globalErrorResponse.setHttpStatusCode("401");
|
globalErrorResponse.setHttpStatusCode("401");
|
||||||
globalErrorResponse.setDeveloperMessage("Invalid authentication details were passed in api request.");
|
globalErrorResponse.setDeveloperMessage("Invalid authentication details were passed in api request.");
|
||||||
globalErrorResponse.setUserMessageGlobalisationCode("error.msg.not.authenticated");
|
globalErrorResponse.setUserMessageGlobalisationCode("error.msg.not.authenticated");
|
||||||
@@ -59,7 +59,7 @@ public class ApiGlobalErrorResponse {
|
|||||||
|
|
||||||
public static ApiGlobalErrorResponse invalidTenantIdentifier() {
|
public static ApiGlobalErrorResponse invalidTenantIdentifier() {
|
||||||
|
|
||||||
ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
|
final ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
|
||||||
globalErrorResponse.setHttpStatusCode("401");
|
globalErrorResponse.setHttpStatusCode("401");
|
||||||
globalErrorResponse.setDeveloperMessage("Invalid tenant details were passed in api request.");
|
globalErrorResponse.setDeveloperMessage("Invalid tenant details were passed in api request.");
|
||||||
globalErrorResponse.setUserMessageGlobalisationCode("error.msg.invalid.tenant.identifier");
|
globalErrorResponse.setUserMessageGlobalisationCode("error.msg.invalid.tenant.identifier");
|
||||||
@@ -69,14 +69,14 @@ public class ApiGlobalErrorResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ApiGlobalErrorResponse unAuthorized(final String defaultUserMessage) {
|
public static ApiGlobalErrorResponse unAuthorized(final String defaultUserMessage) {
|
||||||
ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
|
final ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
|
||||||
globalErrorResponse.setHttpStatusCode("403");
|
globalErrorResponse.setHttpStatusCode("403");
|
||||||
globalErrorResponse
|
globalErrorResponse
|
||||||
.setDeveloperMessage("The user associated with credentials passed on this request does not have sufficient privileges to perform this action.");
|
.setDeveloperMessage("The user associated with credentials passed on this request does not have sufficient privileges to perform this action.");
|
||||||
globalErrorResponse.setUserMessageGlobalisationCode("error.msg.not.authorized");
|
globalErrorResponse.setUserMessageGlobalisationCode("error.msg.not.authorized");
|
||||||
globalErrorResponse.setDefaultUserMessage("Insufficient privileges to perform this action.");
|
globalErrorResponse.setDefaultUserMessage("Insufficient privileges to perform this action.");
|
||||||
|
|
||||||
List<ApiParameterError> errors = new ArrayList<ApiParameterError>();
|
final List<ApiParameterError> errors = new ArrayList<ApiParameterError>();
|
||||||
errors.add(ApiParameterError.generalError("error.msg.not.authorized", defaultUserMessage));
|
errors.add(ApiParameterError.generalError("error.msg.not.authorized", defaultUserMessage));
|
||||||
globalErrorResponse.setErrors(errors);
|
globalErrorResponse.setErrors(errors);
|
||||||
|
|
||||||
@@ -85,13 +85,13 @@ public class ApiGlobalErrorResponse {
|
|||||||
|
|
||||||
public static ApiGlobalErrorResponse domainRuleViolation(final String globalisationMessageCode, final String defaultUserMessage,
|
public static ApiGlobalErrorResponse domainRuleViolation(final String globalisationMessageCode, final String defaultUserMessage,
|
||||||
final Object... defaultUserMessageArgs) {
|
final Object... defaultUserMessageArgs) {
|
||||||
ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
|
final ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
|
||||||
globalErrorResponse.setHttpStatusCode("403");
|
globalErrorResponse.setHttpStatusCode("403");
|
||||||
globalErrorResponse.setDeveloperMessage("Request was understood but caused a domain rule violation.");
|
globalErrorResponse.setDeveloperMessage("Request was understood but caused a domain rule violation.");
|
||||||
globalErrorResponse.setUserMessageGlobalisationCode("validation.msg.domain.rule.violation");
|
globalErrorResponse.setUserMessageGlobalisationCode("validation.msg.domain.rule.violation");
|
||||||
globalErrorResponse.setDefaultUserMessage("Errors contain reason for domain rule violation.");
|
globalErrorResponse.setDefaultUserMessage("Errors contain reason for domain rule violation.");
|
||||||
|
|
||||||
List<ApiParameterError> errors = new ArrayList<ApiParameterError>();
|
final List<ApiParameterError> errors = new ArrayList<ApiParameterError>();
|
||||||
errors.add(ApiParameterError.generalError(globalisationMessageCode, defaultUserMessage, defaultUserMessageArgs));
|
errors.add(ApiParameterError.generalError(globalisationMessageCode, defaultUserMessage, defaultUserMessageArgs));
|
||||||
globalErrorResponse.setErrors(errors);
|
globalErrorResponse.setErrors(errors);
|
||||||
|
|
||||||
@@ -101,13 +101,13 @@ public class ApiGlobalErrorResponse {
|
|||||||
public static ApiGlobalErrorResponse notFound(final String globalisationMessageCode, final String defaultUserMessage,
|
public static ApiGlobalErrorResponse notFound(final String globalisationMessageCode, final String defaultUserMessage,
|
||||||
final Object... defaultUserMessageArgs) {
|
final Object... defaultUserMessageArgs) {
|
||||||
|
|
||||||
ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
|
final ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
|
||||||
globalErrorResponse.setHttpStatusCode("404");
|
globalErrorResponse.setHttpStatusCode("404");
|
||||||
globalErrorResponse.setDeveloperMessage("The requested resource is not available.");
|
globalErrorResponse.setDeveloperMessage("The requested resource is not available.");
|
||||||
globalErrorResponse.setUserMessageGlobalisationCode("error.msg.resource.not.found");
|
globalErrorResponse.setUserMessageGlobalisationCode("error.msg.resource.not.found");
|
||||||
globalErrorResponse.setDefaultUserMessage("The requested resource is not available.");
|
globalErrorResponse.setDefaultUserMessage("The requested resource is not available.");
|
||||||
|
|
||||||
List<ApiParameterError> errors = new ArrayList<ApiParameterError>();
|
final List<ApiParameterError> errors = new ArrayList<ApiParameterError>();
|
||||||
errors.add(ApiParameterError.resourceIdentifierNotFound(globalisationMessageCode, defaultUserMessage, defaultUserMessageArgs));
|
errors.add(ApiParameterError.resourceIdentifierNotFound(globalisationMessageCode, defaultUserMessage, defaultUserMessageArgs));
|
||||||
globalErrorResponse.setErrors(errors);
|
globalErrorResponse.setErrors(errors);
|
||||||
|
|
||||||
@@ -117,13 +117,13 @@ public class ApiGlobalErrorResponse {
|
|||||||
public static ApiGlobalErrorResponse dataIntegrityError(final String globalisationMessageCode, final String defaultUserMessage,
|
public static ApiGlobalErrorResponse dataIntegrityError(final String globalisationMessageCode, final String defaultUserMessage,
|
||||||
final String parameterName, final Object... defaultUserMessageArgs) {
|
final String parameterName, final Object... defaultUserMessageArgs) {
|
||||||
|
|
||||||
ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
|
final ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
|
||||||
globalErrorResponse.setHttpStatusCode("403");
|
globalErrorResponse.setHttpStatusCode("403");
|
||||||
globalErrorResponse.setDeveloperMessage("The request caused a data integrity issue to be fired by the database.");
|
globalErrorResponse.setDeveloperMessage("The request caused a data integrity issue to be fired by the database.");
|
||||||
globalErrorResponse.setUserMessageGlobalisationCode(globalisationMessageCode);
|
globalErrorResponse.setUserMessageGlobalisationCode(globalisationMessageCode);
|
||||||
globalErrorResponse.setDefaultUserMessage(defaultUserMessage);
|
globalErrorResponse.setDefaultUserMessage(defaultUserMessage);
|
||||||
|
|
||||||
List<ApiParameterError> errors = new ArrayList<ApiParameterError>();
|
final List<ApiParameterError> errors = new ArrayList<ApiParameterError>();
|
||||||
errors.add(ApiParameterError.parameterError(globalisationMessageCode, defaultUserMessage, parameterName, defaultUserMessageArgs));
|
errors.add(ApiParameterError.parameterError(globalisationMessageCode, defaultUserMessage, parameterName, defaultUserMessageArgs));
|
||||||
globalErrorResponse.setErrors(errors);
|
globalErrorResponse.setErrors(errors);
|
||||||
|
|
||||||
@@ -133,7 +133,7 @@ public class ApiGlobalErrorResponse {
|
|||||||
public static ApiGlobalErrorResponse badClientRequest(final String globalisationMessageCode, final String defaultUserMessage,
|
public static ApiGlobalErrorResponse badClientRequest(final String globalisationMessageCode, final String defaultUserMessage,
|
||||||
final List<ApiParameterError> errors) {
|
final List<ApiParameterError> errors) {
|
||||||
|
|
||||||
ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
|
final ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
|
||||||
globalErrorResponse.setHttpStatusCode("400");
|
globalErrorResponse.setHttpStatusCode("400");
|
||||||
globalErrorResponse
|
globalErrorResponse
|
||||||
.setDeveloperMessage("The request was invalid. This typically will happen due to validation errors which are provided.");
|
.setDeveloperMessage("The request was invalid. This typically will happen due to validation errors which are provided.");
|
||||||
@@ -148,13 +148,13 @@ public class ApiGlobalErrorResponse {
|
|||||||
public static ApiGlobalErrorResponse serverSideError(final String globalisationMessageCode, final String defaultUserMessage,
|
public static ApiGlobalErrorResponse serverSideError(final String globalisationMessageCode, final String defaultUserMessage,
|
||||||
final Object... defaultUserMessageArgs) {
|
final Object... defaultUserMessageArgs) {
|
||||||
|
|
||||||
ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
|
final ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
|
||||||
globalErrorResponse.setHttpStatusCode("500");
|
globalErrorResponse.setHttpStatusCode("500");
|
||||||
globalErrorResponse.setDeveloperMessage("An unexpected error occured on the platform server.");
|
globalErrorResponse.setDeveloperMessage("An unexpected error occured on the platform server.");
|
||||||
globalErrorResponse.setUserMessageGlobalisationCode("error.msg.platform.server.side.error");
|
globalErrorResponse.setUserMessageGlobalisationCode("error.msg.platform.server.side.error");
|
||||||
globalErrorResponse.setDefaultUserMessage("An unexpected error occured on the platform server.");
|
globalErrorResponse.setDefaultUserMessage("An unexpected error occured on the platform server.");
|
||||||
|
|
||||||
List<ApiParameterError> errors = new ArrayList<ApiParameterError>();
|
final List<ApiParameterError> errors = new ArrayList<ApiParameterError>();
|
||||||
errors.add(ApiParameterError.generalError(globalisationMessageCode, defaultUserMessage, defaultUserMessageArgs));
|
errors.add(ApiParameterError.generalError(globalisationMessageCode, defaultUserMessage, defaultUserMessageArgs));
|
||||||
globalErrorResponse.setErrors(errors);
|
globalErrorResponse.setErrors(errors);
|
||||||
|
|
||||||
@@ -164,13 +164,13 @@ public class ApiGlobalErrorResponse {
|
|||||||
public static ApiGlobalErrorResponse serviceUnavailable(final String globalisationMessageCode, final String defaultUserMessage,
|
public static ApiGlobalErrorResponse serviceUnavailable(final String globalisationMessageCode, final String defaultUserMessage,
|
||||||
final Object... defaultUserMessageArgs) {
|
final Object... defaultUserMessageArgs) {
|
||||||
|
|
||||||
ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
|
final ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
|
||||||
globalErrorResponse.setHttpStatusCode("503");
|
globalErrorResponse.setHttpStatusCode("503");
|
||||||
globalErrorResponse.setDeveloperMessage("The server is currently unable to handle the request , please try after some time.");
|
globalErrorResponse.setDeveloperMessage("The server is currently unable to handle the request , please try after some time.");
|
||||||
globalErrorResponse.setUserMessageGlobalisationCode("error.msg.platform.service.unavailable");
|
globalErrorResponse.setUserMessageGlobalisationCode("error.msg.platform.service.unavailable");
|
||||||
globalErrorResponse.setDefaultUserMessage("The server is currently unable to handle the request , please try after some time.");
|
globalErrorResponse.setDefaultUserMessage("The server is currently unable to handle the request , please try after some time.");
|
||||||
|
|
||||||
List<ApiParameterError> errors = new ArrayList<ApiParameterError>();
|
final List<ApiParameterError> errors = new ArrayList<ApiParameterError>();
|
||||||
errors.add(ApiParameterError.generalError(globalisationMessageCode, defaultUserMessage, defaultUserMessageArgs));
|
errors.add(ApiParameterError.generalError(globalisationMessageCode, defaultUserMessage, defaultUserMessageArgs));
|
||||||
globalErrorResponse.setErrors(errors);
|
globalErrorResponse.setErrors(errors);
|
||||||
|
|
||||||
@@ -188,7 +188,7 @@ public class ApiGlobalErrorResponse {
|
|||||||
@XmlElementWrapper(name = "errors")
|
@XmlElementWrapper(name = "errors")
|
||||||
@XmlElement(name = "errorResponse")
|
@XmlElement(name = "errorResponse")
|
||||||
public List<ApiParameterError> getErrors() {
|
public List<ApiParameterError> getErrors() {
|
||||||
return errors;
|
return this.errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setErrors(final List<ApiParameterError> errors) {
|
public void setErrors(final List<ApiParameterError> errors) {
|
||||||
@@ -196,7 +196,7 @@ public class ApiGlobalErrorResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getDeveloperMessage() {
|
public String getDeveloperMessage() {
|
||||||
return developerMessage;
|
return this.developerMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDeveloperMessage(final String developerMessage) {
|
public void setDeveloperMessage(final String developerMessage) {
|
||||||
@@ -204,7 +204,7 @@ public class ApiGlobalErrorResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getHttpStatusCode() {
|
public String getHttpStatusCode() {
|
||||||
return httpStatusCode;
|
return this.httpStatusCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHttpStatusCode(final String httpStatusCode) {
|
public void setHttpStatusCode(final String httpStatusCode) {
|
||||||
@@ -212,7 +212,7 @@ public class ApiGlobalErrorResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getDefaultUserMessage() {
|
public String getDefaultUserMessage() {
|
||||||
return defaultUserMessage;
|
return this.defaultUserMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDefaultUserMessage(final String defaultUserMessage) {
|
public void setDefaultUserMessage(final String defaultUserMessage) {
|
||||||
@@ -220,7 +220,7 @@ public class ApiGlobalErrorResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getUserMessageGlobalisationCode() {
|
public String getUserMessageGlobalisationCode() {
|
||||||
return userMessageGlobalisationCode;
|
return this.userMessageGlobalisationCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUserMessageGlobalisationCode(final String userMessageGlobalisationCode) {
|
public void setUserMessageGlobalisationCode(final String userMessageGlobalisationCode) {
|
||||||
|
|||||||
+19
-19
@@ -44,19 +44,19 @@ public class ApiParameterError {
|
|||||||
*/
|
*/
|
||||||
private List<ApiErrorMessageArg> args = new ArrayList<ApiErrorMessageArg>();
|
private List<ApiErrorMessageArg> args = new ArrayList<ApiErrorMessageArg>();
|
||||||
|
|
||||||
public static ApiParameterError generalError(String globalisationMessageCode, String defaultUserMessage,
|
public static ApiParameterError generalError(final String globalisationMessageCode, final String defaultUserMessage,
|
||||||
Object... defaultUserMessageArgs) {
|
final Object... defaultUserMessageArgs) {
|
||||||
return new ApiParameterError(globalisationMessageCode, defaultUserMessage, defaultUserMessageArgs);
|
return new ApiParameterError(globalisationMessageCode, defaultUserMessage, defaultUserMessageArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ApiParameterError resourceIdentifierNotFound(String globalisationMessageCode, String defaultUserMessage,
|
public static ApiParameterError resourceIdentifierNotFound(final String globalisationMessageCode, final String defaultUserMessage,
|
||||||
Object... defaultUserMessageArgs) {
|
final Object... defaultUserMessageArgs) {
|
||||||
return new ApiParameterError(globalisationMessageCode, defaultUserMessage, defaultUserMessageArgs);
|
return new ApiParameterError(globalisationMessageCode, defaultUserMessage, defaultUserMessageArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ApiParameterError parameterError(final String globalisationMessageCode, final String defaultUserMessage,
|
public static ApiParameterError parameterError(final String globalisationMessageCode, final String defaultUserMessage,
|
||||||
final String parameterName, final Object... defaultUserMessageArgs) {
|
final String parameterName, final Object... defaultUserMessageArgs) {
|
||||||
ApiParameterError error = new ApiParameterError(globalisationMessageCode, defaultUserMessage, defaultUserMessageArgs);
|
final ApiParameterError error = new ApiParameterError(globalisationMessageCode, defaultUserMessage, defaultUserMessageArgs);
|
||||||
error.setParameterName(parameterName);
|
error.setParameterName(parameterName);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
@@ -70,9 +70,9 @@ public class ApiParameterError {
|
|||||||
this.developerMessage = defaultUserMessage;
|
this.developerMessage = defaultUserMessage;
|
||||||
this.defaultUserMessage = defaultUserMessage;
|
this.defaultUserMessage = defaultUserMessage;
|
||||||
|
|
||||||
List<ApiErrorMessageArg> messageArgs = new ArrayList<ApiErrorMessageArg>();
|
final List<ApiErrorMessageArg> messageArgs = new ArrayList<ApiErrorMessageArg>();
|
||||||
if (defaultUserMessageArgs != null) {
|
if (defaultUserMessageArgs != null) {
|
||||||
for (Object object : defaultUserMessageArgs) {
|
for (final Object object : defaultUserMessageArgs) {
|
||||||
messageArgs.add(ApiErrorMessageArg.from(object));
|
messageArgs.add(ApiErrorMessageArg.from(object));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -82,50 +82,50 @@ public class ApiParameterError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getDeveloperMessage() {
|
public String getDeveloperMessage() {
|
||||||
return developerMessage;
|
return this.developerMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDeveloperMessage(String developerMessage) {
|
public void setDeveloperMessage(final String developerMessage) {
|
||||||
this.developerMessage = developerMessage;
|
this.developerMessage = developerMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDefaultUserMessage() {
|
public String getDefaultUserMessage() {
|
||||||
return defaultUserMessage;
|
return this.defaultUserMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDefaultUserMessage(String defaultUserMessage) {
|
public void setDefaultUserMessage(final String defaultUserMessage) {
|
||||||
this.defaultUserMessage = defaultUserMessage;
|
this.defaultUserMessage = defaultUserMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUserMessageGlobalisationCode() {
|
public String getUserMessageGlobalisationCode() {
|
||||||
return userMessageGlobalisationCode;
|
return this.userMessageGlobalisationCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUserMessageGlobalisationCode(String userMessageGlobalisationCode) {
|
public void setUserMessageGlobalisationCode(final String userMessageGlobalisationCode) {
|
||||||
this.userMessageGlobalisationCode = userMessageGlobalisationCode;
|
this.userMessageGlobalisationCode = userMessageGlobalisationCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getParameterName() {
|
public String getParameterName() {
|
||||||
return parameterName;
|
return this.parameterName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParameterName(String parameterName) {
|
public void setParameterName(final String parameterName) {
|
||||||
this.parameterName = parameterName;
|
this.parameterName = parameterName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getValue() {
|
public Object getValue() {
|
||||||
return value;
|
return this.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setValue(Object value) {
|
public void setValue(final Object value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ApiErrorMessageArg> getArgs() {
|
public List<ApiErrorMessageArg> getArgs() {
|
||||||
return args;
|
return this.args;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setArgs(List<ApiErrorMessageArg> args) {
|
public void setArgs(final List<ApiErrorMessageArg> args) {
|
||||||
this.args = args;
|
this.args = args;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -26,8 +26,8 @@ public class CommandProcessingResultBuilder {
|
|||||||
private Long productId;
|
private Long productId;
|
||||||
|
|
||||||
public CommandProcessingResult build() {
|
public CommandProcessingResult build() {
|
||||||
return CommandProcessingResult.fromDetails(commandId, officeId, groupId, clientId, loanId, savingsId, resourceIdentifier, entityId,
|
return CommandProcessingResult.fromDetails(this.commandId, this.officeId, this.groupId, this.clientId, this.loanId, this.savingsId,
|
||||||
transactionId, changes, productId);
|
this.resourceIdentifier, this.entityId, this.transactionId, this.changes, this.productId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandProcessingResultBuilder withCommandId(final Long withCommandId) {
|
public CommandProcessingResultBuilder withCommandId(final Long withCommandId) {
|
||||||
|
|||||||
+304
-294
@@ -37,7 +37,7 @@ public class DataValidatorBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DataValidatorBuilder reset() {
|
public DataValidatorBuilder reset() {
|
||||||
return new DataValidatorBuilder(dataValidationErrors).resource(resource);
|
return new DataValidatorBuilder(this.dataValidationErrors).resource(this.resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataValidatorBuilder resource(final String resource) {
|
public DataValidatorBuilder resource(final String resource) {
|
||||||
@@ -67,211 +67,215 @@ public class DataValidatorBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DataValidatorBuilder andNotBlank(final String linkedParameterName, final String linkedValue) {
|
public DataValidatorBuilder andNotBlank(final String linkedParameterName, final String linkedValue) {
|
||||||
if (value == null && linkedValue == null && ignoreNullValue) { return this; }
|
if (this.value == null && linkedValue == null && this.ignoreNullValue) { return this; }
|
||||||
|
|
||||||
if (StringUtils.isBlank(linkedValue)) {
|
if (StringUtils.isBlank(linkedValue)) {
|
||||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".")
|
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||||
.append(linkedParameterName).append(".cannot.be.empty.when.").append(parameter).append(".is.populated");
|
.append(linkedParameterName).append(".cannot.be.empty.when.").append(this.parameter).append(".is.populated");
|
||||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(linkedParameterName)
|
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(linkedParameterName)
|
||||||
.append(" cannot be empty when ").append(parameter).append(" is populated.");
|
.append(" cannot be empty when ").append(this.parameter).append(" is populated.");
|
||||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||||
linkedParameterName, linkedValue, value);
|
defaultEnglishMessage.toString(), linkedParameterName, linkedValue, this.value);
|
||||||
dataValidationErrors.add(error);
|
this.dataValidationErrors.add(error);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void failWithCode(final String errorCode) {
|
public void failWithCode(final String errorCode) {
|
||||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(this.parameter)
|
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||||
.append(".").append(errorCode);
|
.append(this.parameter).append(".").append(errorCode);
|
||||||
StringBuilder defaultEnglishMessage = new StringBuilder("Failed data validation due to: ").append(errorCode).append(".");
|
final StringBuilder defaultEnglishMessage = new StringBuilder("Failed data validation due to: ").append(errorCode).append(".");
|
||||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
||||||
this.parameter, this.value);
|
this.parameter, this.value);
|
||||||
dataValidationErrors.add(error);
|
this.dataValidationErrors.add(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void failWithCodeNoParameterAddedToErrorCode(final String errorCode) {
|
public void failWithCodeNoParameterAddedToErrorCode(final String errorCode) {
|
||||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(errorCode);
|
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".").append(errorCode);
|
||||||
StringBuilder defaultEnglishMessage = new StringBuilder("Failed data validation due to: ").append(errorCode).append(".");
|
final StringBuilder defaultEnglishMessage = new StringBuilder("Failed data validation due to: ").append(errorCode).append(".");
|
||||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
||||||
this.parameter, this.value);
|
this.parameter, this.value);
|
||||||
dataValidationErrors.add(error);
|
this.dataValidationErrors.add(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataValidatorBuilder equalToParameter(final String linkedParameterName, final Object linkedValue) {
|
public DataValidatorBuilder equalToParameter(final String linkedParameterName, final Object linkedValue) {
|
||||||
if (value == null && linkedValue == null && ignoreNullValue) { return this; }
|
if (this.value == null && linkedValue == null && this.ignoreNullValue) { return this; }
|
||||||
|
|
||||||
if (value != null && !value.equals(linkedValue)) {
|
if (this.value != null && !this.value.equals(linkedValue)) {
|
||||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".")
|
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||||
.append(linkedParameterName).append(".not.equal.to.").append(parameter);
|
.append(linkedParameterName).append(".not.equal.to.").append(this.parameter);
|
||||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(linkedParameterName)
|
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(linkedParameterName)
|
||||||
.append(" is not equal to ").append(parameter).append(".");
|
.append(" is not equal to ").append(this.parameter).append(".");
|
||||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||||
linkedParameterName, linkedValue, value);
|
defaultEnglishMessage.toString(), linkedParameterName, linkedValue, this.value);
|
||||||
dataValidationErrors.add(error);
|
this.dataValidationErrors.add(error);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataValidatorBuilder notSameAsParameter(final String linkedParameterName, final Object linkedValue) {
|
public DataValidatorBuilder notSameAsParameter(final String linkedParameterName, final Object linkedValue) {
|
||||||
if (value == null && linkedValue == null && ignoreNullValue) { return this; }
|
if (this.value == null && linkedValue == null && this.ignoreNullValue) { return this; }
|
||||||
|
|
||||||
if (value != null && value.equals(linkedValue)) {
|
if (this.value != null && this.value.equals(linkedValue)) {
|
||||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".")
|
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||||
.append(linkedParameterName).append(".same.as.").append(parameter);
|
.append(linkedParameterName).append(".same.as.").append(this.parameter);
|
||||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(linkedParameterName).append(" is same as ")
|
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(linkedParameterName)
|
||||||
.append(parameter).append(".");
|
.append(" is same as ").append(this.parameter).append(".");
|
||||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||||
linkedParameterName, linkedValue, value);
|
defaultEnglishMessage.toString(), linkedParameterName, linkedValue, this.value);
|
||||||
dataValidationErrors.add(error);
|
this.dataValidationErrors.add(error);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***FIXME: Vishwas, why does this method have a parameter? Seems wrong***/
|
/*** FIXME: Vishwas, why does this method have a parameter? Seems wrong ***/
|
||||||
public DataValidatorBuilder trueOrFalseRequired(final boolean trueOfFalseFieldProvided) {
|
public DataValidatorBuilder trueOrFalseRequired(final boolean trueOfFalseFieldProvided) {
|
||||||
if (!trueOfFalseFieldProvided && !ignoreNullValue) {
|
if (!trueOfFalseFieldProvided && !this.ignoreNullValue) {
|
||||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||||
.append(".must.be.true.or.false");
|
.append(this.parameter).append(".must.be.true.or.false");
|
||||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(
|
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter).append(
|
||||||
" must be set as true or false.");
|
" must be set as true or false.");
|
||||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||||
parameter);
|
defaultEnglishMessage.toString(), this.parameter);
|
||||||
dataValidationErrors.add(error);
|
this.dataValidationErrors.add(error);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataValidatorBuilder notNull() {
|
public DataValidatorBuilder notNull() {
|
||||||
if (value == null && !ignoreNullValue) {
|
if (this.value == null && !this.ignoreNullValue) {
|
||||||
|
|
||||||
String realParameterName = this.parameter;
|
String realParameterName = this.parameter;
|
||||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter);
|
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||||
if (this.arrayIndex != null && StringUtils.isNotBlank(arrayPart)) {
|
.append(this.parameter);
|
||||||
|
if (this.arrayIndex != null && StringUtils.isNotBlank(this.arrayPart)) {
|
||||||
validationErrorCode.append(".").append(this.arrayPart);
|
validationErrorCode.append(".").append(this.arrayPart);
|
||||||
realParameterName = new StringBuilder(parameter).append('[').append(this.arrayIndex).append("][").append(arrayPart)
|
realParameterName = new StringBuilder(this.parameter).append('[').append(this.arrayIndex).append("][")
|
||||||
.append(']').toString();
|
.append(this.arrayPart).append(']').toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
validationErrorCode.append(".cannot.be.blank");
|
validationErrorCode.append(".cannot.be.blank");
|
||||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(realParameterName).append(" is mandatory.");
|
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(realParameterName).append(
|
||||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
" is mandatory.");
|
||||||
realParameterName, arrayIndex);
|
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||||
dataValidationErrors.add(error);
|
defaultEnglishMessage.toString(), realParameterName, this.arrayIndex);
|
||||||
|
this.dataValidationErrors.add(error);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataValidatorBuilder notBlank() {
|
public DataValidatorBuilder notBlank() {
|
||||||
if (value == null && ignoreNullValue) { return this; }
|
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||||
|
|
||||||
if (value == null || StringUtils.isBlank(value.toString())) {
|
if (this.value == null || StringUtils.isBlank(this.value.toString())) {
|
||||||
String realParameterName = this.parameter;
|
String realParameterName = this.parameter;
|
||||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter);
|
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||||
if (this.arrayIndex != null && StringUtils.isNotBlank(arrayPart)) {
|
.append(this.parameter);
|
||||||
|
if (this.arrayIndex != null && StringUtils.isNotBlank(this.arrayPart)) {
|
||||||
validationErrorCode.append(".").append(this.arrayPart);
|
validationErrorCode.append(".").append(this.arrayPart);
|
||||||
realParameterName = new StringBuilder(parameter).append('[').append(this.arrayIndex).append("][").append(arrayPart)
|
realParameterName = new StringBuilder(this.parameter).append('[').append(this.arrayIndex).append("][")
|
||||||
.append(']').toString();
|
.append(this.arrayPart).append(']').toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
validationErrorCode.append(".cannot.be.blank");
|
validationErrorCode.append(".cannot.be.blank");
|
||||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(realParameterName).append(" is mandatory.");
|
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(realParameterName).append(
|
||||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
" is mandatory.");
|
||||||
realParameterName, arrayIndex);
|
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||||
dataValidationErrors.add(error);
|
defaultEnglishMessage.toString(), realParameterName, this.arrayIndex);
|
||||||
|
this.dataValidationErrors.add(error);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataValidatorBuilder notExceedingLengthOf(final Integer maxLength) {
|
public DataValidatorBuilder notExceedingLengthOf(final Integer maxLength) {
|
||||||
if (value == null && ignoreNullValue) { return this; }
|
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||||
|
|
||||||
if (value != null && value.toString().trim().length() > maxLength) {
|
if (this.value != null && this.value.toString().trim().length() > maxLength) {
|
||||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||||
.append(".exceeds.max.length");
|
.append(this.parameter).append(".exceeds.max.length");
|
||||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" exceeds max length of ")
|
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter)
|
||||||
.append(maxLength).append(".");
|
.append(" exceeds max length of ").append(maxLength).append(".");
|
||||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||||
parameter, maxLength, value.toString());
|
defaultEnglishMessage.toString(), this.parameter, maxLength, this.value.toString());
|
||||||
dataValidationErrors.add(error);
|
this.dataValidationErrors.add(error);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataValidatorBuilder inMinMaxRange(final Integer min, final Integer max) {
|
public DataValidatorBuilder inMinMaxRange(final Integer min, final Integer max) {
|
||||||
if (value == null && ignoreNullValue) { return this; }
|
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||||
|
|
||||||
if (value != null) {
|
if (this.value != null) {
|
||||||
Integer number = Integer.valueOf(value.toString());
|
final Integer number = Integer.valueOf(this.value.toString());
|
||||||
if (number < min || number > max) {
|
if (number < min || number > max) {
|
||||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||||
.append(".is.not.within.expected.range");
|
.append(this.parameter).append(".is.not.within.expected.range");
|
||||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" must be between ")
|
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter)
|
||||||
.append(min).append(" and ").append(max).append(".");
|
.append(" must be between ").append(min).append(" and ").append(max).append(".");
|
||||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||||
defaultEnglishMessage.toString(), parameter, number, min, max);
|
defaultEnglishMessage.toString(), this.parameter, number, min, max);
|
||||||
dataValidationErrors.add(error);
|
this.dataValidationErrors.add(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataValidatorBuilder isOneOfTheseValues(final Object... values) {
|
public DataValidatorBuilder isOneOfTheseValues(final Object... values) {
|
||||||
if (value == null && ignoreNullValue) { return this; }
|
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||||
|
|
||||||
List<Object> valuesList = Arrays.asList(values);
|
final List<Object> valuesList = Arrays.asList(values);
|
||||||
String valuesListStr = StringUtils.join(valuesList, ", ");
|
final String valuesListStr = StringUtils.join(valuesList, ", ");
|
||||||
|
|
||||||
if (this.value == null || !valuesList.contains(this.value)) {
|
if (this.value == null || !valuesList.contains(this.value)) {
|
||||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||||
.append(".is.not.one.of.expected.enumerations");
|
.append(this.parameter).append(".is.not.one.of.expected.enumerations");
|
||||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" must be one of [ ")
|
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter)
|
||||||
.append(valuesListStr).append(" ] ").append(".");
|
.append(" must be one of [ ").append(valuesListStr).append(" ] ").append(".");
|
||||||
|
|
||||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||||
parameter, this.value, values);
|
defaultEnglishMessage.toString(), this.parameter, this.value, values);
|
||||||
|
|
||||||
dataValidationErrors.add(error);
|
this.dataValidationErrors.add(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataValidatorBuilder isNotOneOfTheseValues(final Object... values) {
|
public DataValidatorBuilder isNotOneOfTheseValues(final Object... values) {
|
||||||
if (value == null && ignoreNullValue) { return this; }
|
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||||
|
|
||||||
if (value != null) {
|
if (this.value != null) {
|
||||||
List<Object> valuesList = Arrays.asList(values);
|
final List<Object> valuesList = Arrays.asList(values);
|
||||||
String valuesListStr = StringUtils.join(valuesList, ", ");
|
final String valuesListStr = StringUtils.join(valuesList, ", ");
|
||||||
|
|
||||||
if (valuesList.contains(this.value)) {
|
if (valuesList.contains(this.value)) {
|
||||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||||
.append(".is.one.of.unwanted.enumerations");
|
.append(this.parameter).append(".is.one.of.unwanted.enumerations");
|
||||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter)
|
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter)
|
||||||
.append(" must not be any of [ ").append(valuesListStr).append(" ] ").append(".");
|
.append(" must not be any of [ ").append(valuesListStr).append(" ] ").append(".");
|
||||||
|
|
||||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||||
defaultEnglishMessage.toString(), parameter, this.value, values);
|
defaultEnglishMessage.toString(), this.parameter, this.value, values);
|
||||||
|
|
||||||
dataValidationErrors.add(error);
|
this.dataValidationErrors.add(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataValidatorBuilder positiveAmount() {
|
public DataValidatorBuilder positiveAmount() {
|
||||||
if (value == null && ignoreNullValue) { return this; }
|
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||||
|
|
||||||
if (value != null) {
|
if (this.value != null) {
|
||||||
BigDecimal number = BigDecimal.valueOf(Double.valueOf(value.toString()));
|
final BigDecimal number = BigDecimal.valueOf(Double.valueOf(this.value.toString()));
|
||||||
if (number.compareTo(BigDecimal.ZERO) <= 0) {
|
if (number.compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||||
.append(".not.greater.than.zero");
|
.append(this.parameter).append(".not.greater.than.zero");
|
||||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(
|
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter).append(
|
||||||
" must be greater than 0.");
|
" must be greater than 0.");
|
||||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||||
defaultEnglishMessage.toString(), parameter, number, 0);
|
defaultEnglishMessage.toString(), this.parameter, number, 0);
|
||||||
dataValidationErrors.add(error);
|
this.dataValidationErrors.add(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
@@ -281,18 +285,18 @@ public class DataValidatorBuilder {
|
|||||||
* should be used with .notNull() before it
|
* should be used with .notNull() before it
|
||||||
*/
|
*/
|
||||||
public DataValidatorBuilder zeroOrPositiveAmount() {
|
public DataValidatorBuilder zeroOrPositiveAmount() {
|
||||||
if (value == null && ignoreNullValue) { return this; }
|
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||||
|
|
||||||
if (value != null) {
|
if (this.value != null) {
|
||||||
BigDecimal number = BigDecimal.valueOf(Double.valueOf(value.toString()));
|
final BigDecimal number = BigDecimal.valueOf(Double.valueOf(this.value.toString()));
|
||||||
if (number.compareTo(BigDecimal.ZERO) < 0) {
|
if (number.compareTo(BigDecimal.ZERO) < 0) {
|
||||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||||
.append(".not.zero.or.greater");
|
.append(this.parameter).append(".not.zero.or.greater");
|
||||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(
|
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter).append(
|
||||||
" must be greater than or equal to 0.");
|
" must be greater than or equal to 0.");
|
||||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||||
defaultEnglishMessage.toString(), parameter, number, 0);
|
defaultEnglishMessage.toString(), this.parameter, number, 0);
|
||||||
dataValidationErrors.add(error);
|
this.dataValidationErrors.add(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
@@ -302,18 +306,18 @@ public class DataValidatorBuilder {
|
|||||||
* should be used with .notNull() before it
|
* should be used with .notNull() before it
|
||||||
*/
|
*/
|
||||||
public DataValidatorBuilder integerZeroOrGreater() {
|
public DataValidatorBuilder integerZeroOrGreater() {
|
||||||
if (value == null && ignoreNullValue) { return this; }
|
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||||
|
|
||||||
if (value != null) {
|
if (this.value != null) {
|
||||||
Integer number = Integer.valueOf(value.toString());
|
final Integer number = Integer.valueOf(this.value.toString());
|
||||||
if (number < 0) {
|
if (number < 0) {
|
||||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||||
.append(".not.zero.or.greater");
|
.append(this.parameter).append(".not.zero.or.greater");
|
||||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(
|
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter).append(
|
||||||
" must be zero or greater.");
|
" must be zero or greater.");
|
||||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||||
defaultEnglishMessage.toString(), parameter, number, 0);
|
defaultEnglishMessage.toString(), this.parameter, number, 0);
|
||||||
dataValidationErrors.add(error);
|
this.dataValidationErrors.add(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
@@ -323,18 +327,18 @@ public class DataValidatorBuilder {
|
|||||||
* should be used with .notNull() before it
|
* should be used with .notNull() before it
|
||||||
*/
|
*/
|
||||||
public DataValidatorBuilder integerGreaterThanZero() {
|
public DataValidatorBuilder integerGreaterThanZero() {
|
||||||
if (value == null && ignoreNullValue) { return this; }
|
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||||
|
|
||||||
if (value != null) {
|
if (this.value != null) {
|
||||||
Integer number = Integer.valueOf(value.toString());
|
final Integer number = Integer.valueOf(this.value.toString());
|
||||||
if (number < 1) {
|
if (number < 1) {
|
||||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||||
.append(".not.greater.than.zero");
|
.append(this.parameter).append(".not.greater.than.zero");
|
||||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(
|
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter).append(
|
||||||
" must be greater than 0.");
|
" must be greater than 0.");
|
||||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||||
defaultEnglishMessage.toString(), parameter, number, 0);
|
defaultEnglishMessage.toString(), this.parameter, number, 0);
|
||||||
dataValidationErrors.add(error);
|
this.dataValidationErrors.add(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
@@ -344,67 +348,67 @@ public class DataValidatorBuilder {
|
|||||||
* should be used with .notNull() before it
|
* should be used with .notNull() before it
|
||||||
*/
|
*/
|
||||||
public DataValidatorBuilder longGreaterThanZero() {
|
public DataValidatorBuilder longGreaterThanZero() {
|
||||||
if (value == null && ignoreNullValue) { return this; }
|
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||||
|
|
||||||
if (value != null) {
|
if (this.value != null) {
|
||||||
Long number = Long.valueOf(value.toString());
|
final Long number = Long.valueOf(this.value.toString());
|
||||||
if (number < 1) {
|
if (number < 1) {
|
||||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||||
.append(".not.greater.than.zero");
|
.append(this.parameter).append(".not.greater.than.zero");
|
||||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(
|
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter).append(
|
||||||
" must be greater than 0.");
|
" must be greater than 0.");
|
||||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||||
defaultEnglishMessage.toString(), parameter, number, 0);
|
defaultEnglishMessage.toString(), this.parameter, number, 0);
|
||||||
dataValidationErrors.add(error);
|
this.dataValidationErrors.add(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataValidatorBuilder arrayNotEmpty() {
|
public DataValidatorBuilder arrayNotEmpty() {
|
||||||
if (value == null && ignoreNullValue) { return this; }
|
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||||
|
|
||||||
Object[] array = (Object[]) value;
|
final Object[] array = (Object[]) this.value;
|
||||||
if (ObjectUtils.isEmpty(array)) {
|
if (ObjectUtils.isEmpty(array)) {
|
||||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||||
.append(".cannot.be.empty");
|
.append(this.parameter).append(".cannot.be.empty");
|
||||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(
|
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter).append(
|
||||||
" cannot be empty. You must select at least one.");
|
" cannot be empty. You must select at least one.");
|
||||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||||
parameter);
|
defaultEnglishMessage.toString(), this.parameter);
|
||||||
dataValidationErrors.add(error);
|
this.dataValidationErrors.add(error);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataValidatorBuilder jsonArrayNotEmpty() {
|
public DataValidatorBuilder jsonArrayNotEmpty() {
|
||||||
if (value == null && ignoreNullValue) { return this; }
|
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||||
|
|
||||||
JsonArray array = (JsonArray) value;
|
final JsonArray array = (JsonArray) this.value;
|
||||||
if (value != null && !array.iterator().hasNext()) {
|
if (this.value != null && !array.iterator().hasNext()) {
|
||||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||||
.append(".cannot.be.empty");
|
.append(this.parameter).append(".cannot.be.empty");
|
||||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(
|
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter).append(
|
||||||
" cannot be empty. You must select at least one.");
|
" cannot be empty. You must select at least one.");
|
||||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||||
parameter);
|
defaultEnglishMessage.toString(), this.parameter);
|
||||||
dataValidationErrors.add(error);
|
this.dataValidationErrors.add(error);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void expectedArrayButIsNot() {
|
public void expectedArrayButIsNot() {
|
||||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||||
.append(".is.not.an.array");
|
.append(this.parameter).append(".is.not.an.array");
|
||||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" is not an array.");
|
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter).append(" is not an array.");
|
||||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
||||||
parameter);
|
this.parameter);
|
||||||
dataValidationErrors.add(error);
|
this.dataValidationErrors.add(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataValidatorBuilder anyOfNotNull(final Object... object) {
|
public DataValidatorBuilder anyOfNotNull(final Object... object) {
|
||||||
boolean hasData = false;
|
boolean hasData = false;
|
||||||
for (Object obj : object) {
|
for (final Object obj : object) {
|
||||||
if (obj != null) {
|
if (obj != null) {
|
||||||
hasData = true;
|
hasData = true;
|
||||||
break;
|
break;
|
||||||
@@ -412,100 +416,105 @@ public class DataValidatorBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!hasData) {
|
if (!hasData) {
|
||||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".no.parameters.for.update");
|
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(
|
||||||
StringBuilder defaultEnglishMessage = new StringBuilder("No parameters passed for update.");
|
".no.parameters.for.update");
|
||||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
final StringBuilder defaultEnglishMessage = new StringBuilder("No parameters passed for update.");
|
||||||
"id");
|
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||||
dataValidationErrors.add(error);
|
defaultEnglishMessage.toString(), "id");
|
||||||
|
this.dataValidationErrors.add(error);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataValidatorBuilder inValidValue(final String parameterValueCode, final Object invalidValue) {
|
public DataValidatorBuilder inValidValue(final String parameterValueCode, final Object invalidValue) {
|
||||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||||
.append(".invalid.").append(parameterValueCode);
|
.append(this.parameter).append(".invalid.").append(parameterValueCode);
|
||||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" has an invalid value.");
|
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter).append(
|
||||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
" has an invalid value.");
|
||||||
parameter, invalidValue);
|
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
||||||
dataValidationErrors.add(error);
|
this.parameter, invalidValue);
|
||||||
|
this.dataValidationErrors.add(error);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataValidatorBuilder mustBeBlankWhenParameterProvided(final String parameterName, final Object parameterValue) {
|
public DataValidatorBuilder mustBeBlankWhenParameterProvided(final String parameterName, final Object parameterValue) {
|
||||||
if (value == null && ignoreNullValue) { return this; }
|
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||||
|
|
||||||
if (value == null && parameterValue != null) { return this; }
|
if (this.value == null && parameterValue != null) { return this; }
|
||||||
|
|
||||||
if (value != null && StringUtils.isBlank(value.toString()) && parameterValue != null
|
if (this.value != null && StringUtils.isBlank(this.value.toString()) && parameterValue != null
|
||||||
&& StringUtils.isNotBlank(parameterValue.toString())) { return this; }
|
&& StringUtils.isNotBlank(parameterValue.toString())) { return this; }
|
||||||
|
|
||||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||||
.append(".cannot.also.be.provided.when.").append(parameterName).append(".is.populated");
|
.append(this.parameter).append(".cannot.also.be.provided.when.").append(parameterName).append(".is.populated");
|
||||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter)
|
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter)
|
||||||
.append(" cannot also be provided when ").append(parameterName).append(" is populated.");
|
.append(" cannot also be provided when ").append(parameterName).append(" is populated.");
|
||||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
||||||
parameter, value, parameterName, parameterValue);
|
this.parameter, this.value, parameterName, parameterValue);
|
||||||
dataValidationErrors.add(error);
|
this.dataValidationErrors.add(error);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataValidatorBuilder mustBeBlankWhenParameterProvidedIs(final String parameterName, final Object parameterValue) {
|
public DataValidatorBuilder mustBeBlankWhenParameterProvidedIs(final String parameterName, final Object parameterValue) {
|
||||||
if (value == null && ignoreNullValue) { return this; }
|
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||||
|
|
||||||
if (value == null && parameterValue != null) { return this; }
|
if (this.value == null && parameterValue != null) { return this; }
|
||||||
|
|
||||||
if (value != null && StringUtils.isBlank(value.toString()) && parameterValue != null
|
if (this.value != null && StringUtils.isBlank(this.value.toString()) && parameterValue != null
|
||||||
&& StringUtils.isNotBlank(parameterValue.toString())) { return this; }
|
&& StringUtils.isNotBlank(parameterValue.toString())) { return this; }
|
||||||
|
|
||||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||||
.append(".cannot.also.be.provided.when.").append(parameterName).append(".is.").append(parameterValue);
|
.append(this.parameter).append(".cannot.also.be.provided.when.").append(parameterName).append(".is.")
|
||||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter)
|
.append(parameterValue);
|
||||||
|
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter)
|
||||||
.append(" cannot also be provided when ").append(parameterName).append(" is ").append(parameterValue);
|
.append(" cannot also be provided when ").append(parameterName).append(" is ").append(parameterValue);
|
||||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
||||||
parameter, value, parameterName, parameterValue);
|
this.parameter, this.value, parameterName, parameterValue);
|
||||||
dataValidationErrors.add(error);
|
this.dataValidationErrors.add(error);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataValidatorBuilder cantBeBlankWhenParameterProvidedIs(final String parameterName, final Object parameterValue) {
|
public DataValidatorBuilder cantBeBlankWhenParameterProvidedIs(final String parameterName, final Object parameterValue) {
|
||||||
if (value != null && StringUtils.isNotBlank(value.toString())) { return this; }
|
if (this.value != null && StringUtils.isNotBlank(this.value.toString())) { return this; }
|
||||||
|
|
||||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||||
.append(".must.be.provided.when.").append(parameterName).append(".is.").append(parameterValue);
|
.append(this.parameter).append(".must.be.provided.when.").append(parameterName).append(".is.").append(parameterValue);
|
||||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" must be provided when ")
|
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter)
|
||||||
.append(parameterName).append(" is ").append(parameterValue);
|
.append(" must be provided when ").append(parameterName).append(" is ").append(parameterValue);
|
||||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
||||||
parameter, value, parameterName, parameterValue);
|
this.parameter, this.value, parameterName, parameterValue);
|
||||||
dataValidationErrors.add(error);
|
this.dataValidationErrors.add(error);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataValidatorBuilder comapareMinimumAndMaximumAmounts(final BigDecimal minimumBalance, final BigDecimal maximumBalance) {
|
public DataValidatorBuilder comapareMinimumAndMaximumAmounts(final BigDecimal minimumBalance, final BigDecimal maximumBalance) {
|
||||||
if (minimumBalance != null && maximumBalance != null)
|
if (minimumBalance != null && maximumBalance != null) {
|
||||||
if (maximumBalance.compareTo(minimumBalance) == -1) {
|
if (maximumBalance.compareTo(minimumBalance) == -1) {
|
||||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||||
.append(".is.not.within.expected.range");
|
.append(this.parameter).append(".is.not.within.expected.range");
|
||||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(" minimum amount ").append(minimumBalance)
|
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(" minimum amount ")
|
||||||
.append(" should less than maximum amount ").append(maximumBalance).append(".");
|
.append(minimumBalance).append(" should less than maximum amount ").append(maximumBalance).append(".");
|
||||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||||
defaultEnglishMessage.toString(), parameter, minimumBalance, maximumBalance);
|
defaultEnglishMessage.toString(), this.parameter, minimumBalance, maximumBalance);
|
||||||
dataValidationErrors.add(error);
|
this.dataValidationErrors.add(error);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataValidatorBuilder inMinAndMaxAmountRange(final BigDecimal minimumAmount, final BigDecimal maximumAmount) {
|
public DataValidatorBuilder inMinAndMaxAmountRange(final BigDecimal minimumAmount, final BigDecimal maximumAmount) {
|
||||||
if (minimumAmount != null && maximumAmount != null && value != null) {
|
if (minimumAmount != null && maximumAmount != null && this.value != null) {
|
||||||
BigDecimal amount = BigDecimal.valueOf(Double.valueOf(value.toString()));
|
final BigDecimal amount = BigDecimal.valueOf(Double.valueOf(this.value.toString()));
|
||||||
if (amount.compareTo(minimumAmount) == -1 || amount.compareTo(maximumAmount) == 1) {
|
if (amount.compareTo(minimumAmount) == -1 || amount.compareTo(maximumAmount) == 1) {
|
||||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||||
.append(".amount.is.not.within.min.max.range");
|
.append(this.parameter).append(".amount.is.not.within.min.max.range");
|
||||||
StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(parameter).append(" amount ").append(amount)
|
final StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(this.parameter).append(" amount ")
|
||||||
.append(" must be between ").append(minimumAmount).append(" and ").append(maximumAmount).append(" .");
|
.append(amount).append(" must be between ").append(minimumAmount).append(" and ").append(maximumAmount)
|
||||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
.append(" .");
|
||||||
defaultEnglishMessage.toString(), parameter, amount, minimumAmount, maximumAmount);
|
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||||
dataValidationErrors.add(error);
|
defaultEnglishMessage.toString(), this.parameter, amount, minimumAmount, maximumAmount);
|
||||||
|
this.dataValidationErrors.add(error);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -513,16 +522,16 @@ public class DataValidatorBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DataValidatorBuilder notLessThanMin(final BigDecimal min) {
|
public DataValidatorBuilder notLessThanMin(final BigDecimal min) {
|
||||||
if (min != null && value != null) {
|
if (min != null && this.value != null) {
|
||||||
BigDecimal amount = BigDecimal.valueOf(Double.valueOf(value.toString()));
|
final BigDecimal amount = BigDecimal.valueOf(Double.valueOf(this.value.toString()));
|
||||||
if (amount.compareTo(min) == -1) {
|
if (amount.compareTo(min) == -1) {
|
||||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||||
.append(".is.less.than.min");
|
.append(this.parameter).append(".is.less.than.min");
|
||||||
StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(parameter).append(" value ").append(amount)
|
final StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(this.parameter).append(" value ")
|
||||||
.append(" must not be less than minimum value ").append(min);
|
.append(amount).append(" must not be less than minimum value ").append(min);
|
||||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||||
defaultEnglishMessage.toString(), parameter, amount, min);
|
defaultEnglishMessage.toString(), this.parameter, amount, min);
|
||||||
dataValidationErrors.add(error);
|
this.dataValidationErrors.add(error);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -530,16 +539,16 @@ public class DataValidatorBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DataValidatorBuilder notGreaterThanMax(final BigDecimal max) {
|
public DataValidatorBuilder notGreaterThanMax(final BigDecimal max) {
|
||||||
if (max != null && value != null) {
|
if (max != null && this.value != null) {
|
||||||
BigDecimal amount = BigDecimal.valueOf(Double.valueOf(value.toString()));
|
final BigDecimal amount = BigDecimal.valueOf(Double.valueOf(this.value.toString()));
|
||||||
if (amount.compareTo(max) == 1) {
|
if (amount.compareTo(max) == 1) {
|
||||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||||
.append(".is.greater.than.max");
|
.append(this.parameter).append(".is.greater.than.max");
|
||||||
StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(parameter).append(" value ").append(amount)
|
final StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(this.parameter).append(" value ")
|
||||||
.append(" must not be more than maximum value ").append(max);
|
.append(amount).append(" must not be more than maximum value ").append(max);
|
||||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||||
defaultEnglishMessage.toString(), parameter, amount, max);
|
defaultEnglishMessage.toString(), this.parameter, amount, max);
|
||||||
dataValidationErrors.add(error);
|
this.dataValidationErrors.add(error);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -547,34 +556,35 @@ public class DataValidatorBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DataValidatorBuilder comapareMinAndMaxOfTwoBigDecmimalNos(final BigDecimal min, final BigDecimal max) {
|
public DataValidatorBuilder comapareMinAndMaxOfTwoBigDecmimalNos(final BigDecimal min, final BigDecimal max) {
|
||||||
if (min != null && max != null)
|
if (min != null && max != null) {
|
||||||
if (max.compareTo(min) == -1) {
|
if (max.compareTo(min) == -1) {
|
||||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||||
.append(".is.not.within.expected.range");
|
.append(this.parameter).append(".is.not.within.expected.range");
|
||||||
StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(" min number ").append(min)
|
final StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(" min number ").append(min)
|
||||||
.append(" should less than max number ").append(max).append(".");
|
.append(" should less than max number ").append(max).append(".");
|
||||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||||
defaultEnglishMessage.toString(), parameter, min, max);
|
defaultEnglishMessage.toString(), this.parameter, min, max);
|
||||||
dataValidationErrors.add(error);
|
this.dataValidationErrors.add(error);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataValidatorBuilder isValidRecurringRule(final String recurringRule) {
|
public DataValidatorBuilder isValidRecurringRule(final String recurringRule) {
|
||||||
if (StringUtils.isNotBlank(recurringRule)) {
|
if (StringUtils.isNotBlank(recurringRule)) {
|
||||||
try {
|
try {
|
||||||
RRule rRule = new RRule(recurringRule);
|
final RRule rRule = new RRule(recurringRule);
|
||||||
rRule.validate();
|
rRule.validate();
|
||||||
} catch (ValidationException e) {
|
} catch (final ValidationException e) {
|
||||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.invalid.recurring.rule",
|
final ApiParameterError error = ApiParameterError.parameterError("validation.msg.invalid.recurring.rule",
|
||||||
"The Recurring Rule value: " + recurringRule + " is not valid.", parameter, recurringRule);
|
"The Recurring Rule value: " + recurringRule + " is not valid.", this.parameter, recurringRule);
|
||||||
dataValidationErrors.add(error);
|
this.dataValidationErrors.add(error);
|
||||||
return this;
|
return this;
|
||||||
} catch (ParseException e) {
|
} catch (final ParseException e) {
|
||||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.recurring.rule.parsing.error",
|
final ApiParameterError error = ApiParameterError.parameterError("validation.msg.recurring.rule.parsing.error",
|
||||||
"Error in pasring the Recurring Rule value: " + recurringRule + ".", parameter, recurringRule);
|
"Error in pasring the Recurring Rule value: " + recurringRule + ".", this.parameter, recurringRule);
|
||||||
dataValidationErrors.add(error);
|
this.dataValidationErrors.add(error);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -582,54 +592,54 @@ public class DataValidatorBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DataValidatorBuilder notLessThanMin(final Integer min) {
|
public DataValidatorBuilder notLessThanMin(final Integer min) {
|
||||||
if (value == null && ignoreNullValue) { return this; }
|
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||||
|
|
||||||
if (value != null && min != null) {
|
if (this.value != null && min != null) {
|
||||||
Integer number = Integer.valueOf(value.toString());
|
final Integer number = Integer.valueOf(this.value.toString());
|
||||||
if (number < min) {
|
if (number < min) {
|
||||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||||
.append(".is.less.than.min");
|
.append(this.parameter).append(".is.less.than.min");
|
||||||
StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(parameter)
|
final StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(this.parameter)
|
||||||
.append(" must be greater than minimum value ").append(min);
|
.append(" must be greater than minimum value ").append(min);
|
||||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||||
defaultEnglishMessage.toString(), parameter, number, min);
|
defaultEnglishMessage.toString(), this.parameter, number, min);
|
||||||
dataValidationErrors.add(error);
|
this.dataValidationErrors.add(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataValidatorBuilder notGreaterThanMax(final Integer max) {
|
public DataValidatorBuilder notGreaterThanMax(final Integer max) {
|
||||||
if (value == null && ignoreNullValue) { return this; }
|
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||||
|
|
||||||
if (value != null && max != null) {
|
if (this.value != null && max != null) {
|
||||||
Integer number = Integer.valueOf(value.toString());
|
final Integer number = Integer.valueOf(this.value.toString());
|
||||||
if (number > max) {
|
if (number > max) {
|
||||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||||
.append(".is.greater.than.max");
|
.append(this.parameter).append(".is.greater.than.max");
|
||||||
StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(parameter)
|
final StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(this.parameter)
|
||||||
.append(" must be less than maximum value ").append(max);
|
.append(" must be less than maximum value ").append(max);
|
||||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||||
defaultEnglishMessage.toString(), parameter, number, max);
|
defaultEnglishMessage.toString(), this.parameter, number, max);
|
||||||
dataValidationErrors.add(error);
|
this.dataValidationErrors.add(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataValidatorBuilder matchesRegularExpression(final String expression) {
|
public DataValidatorBuilder matchesRegularExpression(final String expression) {
|
||||||
if (value == null && ignoreNullValue) { return this; }
|
if (this.value == null && this.ignoreNullValue) { return this; }
|
||||||
|
|
||||||
if (value != null && !value.toString().matches(expression)) {
|
if (this.value != null && !this.value.toString().matches(expression)) {
|
||||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||||
.append(".does.not.match.regexp");
|
.append(this.parameter).append(".does.not.match.regexp");
|
||||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter)
|
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter)
|
||||||
.append(" must match the provided regular expression [ ").append(expression).append(" ] ").append(".");
|
.append(" must match the provided regular expression [ ").append(expression).append(" ] ").append(".");
|
||||||
|
|
||||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(),
|
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||||
parameter, this.value, expression);
|
defaultEnglishMessage.toString(), this.parameter, this.value, expression);
|
||||||
|
|
||||||
dataValidationErrors.add(error);
|
this.dataValidationErrors.add(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
@@ -669,9 +679,9 @@ public class DataValidatorBuilder {
|
|||||||
* the beginning and can contain whitespaces in between and length
|
* the beginning and can contain whitespaces in between and length
|
||||||
* allowed is 0-25 chars.
|
* allowed is 0-25 chars.
|
||||||
*/
|
*/
|
||||||
String regex = "^\\+?[0-9. ()-]{0,25}$";
|
final String regex = "^\\+?[0-9. ()-]{0,25}$";
|
||||||
Pattern pattern = Pattern.compile(regex);
|
final Pattern pattern = Pattern.compile(regex);
|
||||||
Matcher matcher = pattern.matcher(this.value.toString());
|
final Matcher matcher = pattern.matcher(this.value.toString());
|
||||||
if (matcher.matches()) {
|
if (matcher.matches()) {
|
||||||
validationErr = false;
|
validationErr = false;
|
||||||
}
|
}
|
||||||
@@ -688,14 +698,14 @@ public class DataValidatorBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DataValidatorBuilder validateCronExpression() {
|
public DataValidatorBuilder validateCronExpression() {
|
||||||
if (value != null && !CronExpression.isValidExpression(this.value.toString().trim())) {
|
if (this.value != null && !CronExpression.isValidExpression(this.value.toString().trim())) {
|
||||||
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter)
|
final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource).append(".")
|
||||||
.append(".invalid");
|
.append(this.parameter).append(".invalid");
|
||||||
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(
|
final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter).append(
|
||||||
" value is not a valid cron expression");
|
" value is not a valid cron expression");
|
||||||
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(),
|
||||||
defaultEnglishMessage.toString(), parameter, this.value);
|
defaultEnglishMessage.toString(), this.parameter, this.value);
|
||||||
dataValidationErrors.add(error);
|
this.dataValidationErrors.add(error);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -24,10 +24,10 @@ public class EnumOptionData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCode() {
|
public String getCode() {
|
||||||
return code;
|
return this.code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user