FINERACT-821 Added and Enforced Typename checkstyle

This commit is contained in:
thesmallstar
2020-05-22 15:23:23 +02:00
committed by Michael Vorburger ⛑️
parent 014c6bba40
commit baa1177854
103 changed files with 1735 additions and 1736 deletions
@@ -71,6 +71,10 @@
<property name="format" value="\.printStackTrace?\("/> <property name="format" value="\.printStackTrace?\("/>
<property name="message" value="Line contains printStacktrace()."/> <property name="message" value="Line contains printStacktrace()."/>
<property name="ignoreComments" value="false" /> <property name="ignoreComments" value="false" />
</module>
<module name="TypeName">
<message key="name.invalidPattern"
value="Type name ''{0}'' must match pattern ''{1}''."/>
</module> </module>
<module name="PackageName"> <module name="PackageName">
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9_]*)*$"/> <property name="format" value="^[a-z]+(\.[a-z][a-z0-9_]*)*$"/>
@@ -158,11 +162,6 @@
<property name="tokens" value="COMMA"/> <property name="tokens" value="COMMA"/>
<property name="option" value="EOL"/> <property name="option" value="EOL"/>
</module> </module>
<module name="TypeName">
<message key="name.invalidPattern"
value="Type name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="MemberName"> <module name="MemberName">
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/> <property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
<message key="name.invalidPattern" <message key="name.invalidPattern"
@@ -27,7 +27,7 @@ import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification; import io.restassured.specification.ResponseSpecification;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import org.apache.fineract.accounting.common.AccountingConstants.FINANCIAL_ACTIVITY; import org.apache.fineract.accounting.common.AccountingConstants.FinancialActivity;
import org.apache.fineract.accounting.financialactivityaccount.exception.DuplicateFinancialActivityAccountFoundException; import org.apache.fineract.accounting.financialactivityaccount.exception.DuplicateFinancialActivityAccountFoundException;
import org.apache.fineract.accounting.financialactivityaccount.exception.FinancialActivityAccountInvalidException; import org.apache.fineract.accounting.financialactivityaccount.exception.FinancialActivityAccountInvalidException;
import org.apache.fineract.integrationtests.common.CommonConstants; import org.apache.fineract.integrationtests.common.CommonConstants;
@@ -50,8 +50,8 @@ public class FinancialActivityAccountsTest {
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
private AccountHelper accountHelper; private AccountHelper accountHelper;
private FinancialActivityAccountHelper financialActivityAccountHelper; private FinancialActivityAccountHelper financialActivityAccountHelper;
private final Integer assetTransferFinancialActivityId = FINANCIAL_ACTIVITY.ASSET_TRANSFER.getValue(); private final Integer assetTransferFinancialActivityId = FinancialActivity.ASSET_TRANSFER.getValue();
public static final Integer liabilityTransferFinancialActivityId = FINANCIAL_ACTIVITY.LIABILITY_TRANSFER.getValue(); public static final Integer liabilityTransferFinancialActivityId = FinancialActivity.LIABILITY_TRANSFER.getValue();
@Before @Before
public void setup() { public void setup() {
@@ -37,7 +37,7 @@ import java.util.Calendar;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import org.apache.fineract.accounting.common.AccountingConstants.FINANCIAL_ACTIVITY; import org.apache.fineract.accounting.common.AccountingConstants.FinancialActivity;
import org.apache.fineract.integrationtests.common.ClientHelper; import org.apache.fineract.integrationtests.common.ClientHelper;
import org.apache.fineract.integrationtests.common.CommonConstants; import org.apache.fineract.integrationtests.common.CommonConstants;
import org.apache.fineract.integrationtests.common.SchedulerJobHelper; import org.apache.fineract.integrationtests.common.SchedulerJobHelper;
@@ -2501,7 +2501,7 @@ public class FixedDepositTest {
} }
private Account getMappedLiabilityFinancialAccount() { private Account getMappedLiabilityFinancialAccount() {
final Integer liabilityTransferFinancialActivityId = FINANCIAL_ACTIVITY.LIABILITY_TRANSFER.getValue(); final Integer liabilityTransferFinancialActivityId = FinancialActivity.LIABILITY_TRANSFER.getValue();
List<HashMap> financialActivities = this.financialActivityAccountHelper.getAllFinancialActivityAccounts(this.responseSpec); List<HashMap> financialActivities = this.financialActivityAccountHelper.getAllFinancialActivityAccounts(this.responseSpec);
final Account financialAccount; final Account financialAccount;
/*** /***
@@ -35,7 +35,7 @@ import java.util.Calendar;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import org.apache.fineract.accounting.common.AccountingConstants.FINANCIAL_ACTIVITY; import org.apache.fineract.accounting.common.AccountingConstants.FinancialActivity;
import org.apache.fineract.integrationtests.common.ClientHelper; import org.apache.fineract.integrationtests.common.ClientHelper;
import org.apache.fineract.integrationtests.common.CommonConstants; import org.apache.fineract.integrationtests.common.CommonConstants;
import org.apache.fineract.integrationtests.common.SchedulerJobHelper; import org.apache.fineract.integrationtests.common.SchedulerJobHelper;
@@ -3137,7 +3137,7 @@ public class RecurringDepositTest {
} }
private Account getMappedLiabilityFinancialAccount() { private Account getMappedLiabilityFinancialAccount() {
final Integer liabilityTransferFinancialActivityId = FINANCIAL_ACTIVITY.LIABILITY_TRANSFER.getValue(); final Integer liabilityTransferFinancialActivityId = FinancialActivity.LIABILITY_TRANSFER.getValue();
List<HashMap> financialActivities = this.financialActivityAccountHelper.getAllFinancialActivityAccounts(this.responseSpec); List<HashMap> financialActivities = this.financialActivityAccountHelper.getAllFinancialActivityAccounts(this.responseSpec);
final Account financialAccount; final Account financialAccount;
/*** /***
@@ -27,7 +27,7 @@ import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainR
public class GLClosureInvalidException extends AbstractPlatformDomainRuleException { public class GLClosureInvalidException extends AbstractPlatformDomainRuleException {
/*** enum of reasons for invalid Accounting Closure **/ /*** enum of reasons for invalid Accounting Closure **/
public static enum GL_CLOSURE_INVALID_REASON { public static enum GlClosureInvalidReason {
FUTURE_DATE, ACCOUNTING_CLOSED; FUTURE_DATE, ACCOUNTING_CLOSED;
public String errorMessage() { public String errorMessage() {
@@ -45,7 +45,7 @@ public class GLClosureInvalidException extends AbstractPlatformDomainRuleExcepti
} }
} }
public GLClosureInvalidException(final GL_CLOSURE_INVALID_REASON reason, final Date date) { public GLClosureInvalidException(final GlClosureInvalidReason reason, final Date date) {
super(reason.errorCode(), reason.errorMessage(), date); super(reason.errorCode(), reason.errorMessage(), date);
} }
} }
@@ -27,7 +27,7 @@ import org.apache.fineract.accounting.closure.domain.GLClosureRepository;
import org.apache.fineract.accounting.closure.exception.GLClosureDuplicateException; import org.apache.fineract.accounting.closure.exception.GLClosureDuplicateException;
import org.apache.fineract.accounting.closure.exception.GLClosureInvalidDeleteException; import org.apache.fineract.accounting.closure.exception.GLClosureInvalidDeleteException;
import org.apache.fineract.accounting.closure.exception.GLClosureInvalidException; import org.apache.fineract.accounting.closure.exception.GLClosureInvalidException;
import org.apache.fineract.accounting.closure.exception.GLClosureInvalidException.GL_CLOSURE_INVALID_REASON; import org.apache.fineract.accounting.closure.exception.GLClosureInvalidException.GlClosureInvalidReason;
import org.apache.fineract.accounting.closure.exception.GLClosureNotFoundException; import org.apache.fineract.accounting.closure.exception.GLClosureNotFoundException;
import org.apache.fineract.accounting.closure.serialization.GLClosureCommandFromApiJsonDeserializer; import org.apache.fineract.accounting.closure.serialization.GLClosureCommandFromApiJsonDeserializer;
import org.apache.fineract.infrastructure.core.api.JsonCommand; import org.apache.fineract.infrastructure.core.api.JsonCommand;
@@ -75,12 +75,12 @@ public class GLClosureWritePlatformServiceJpaRepositoryImpl implements GLClosure
// ensure closure date is not in the future // ensure closure date is not in the future
final Date todaysDate = new Date(); final Date todaysDate = new Date();
final Date closureDate = command.DateValueOfParameterNamed(GLClosureJsonInputParams.CLOSING_DATE.getValue()); final Date closureDate = command.DateValueOfParameterNamed(GLClosureJsonInputParams.CLOSING_DATE.getValue());
if (closureDate.after(todaysDate)) { throw new GLClosureInvalidException(GL_CLOSURE_INVALID_REASON.FUTURE_DATE, closureDate); } if (closureDate.after(todaysDate)) { throw new GLClosureInvalidException(GlClosureInvalidReason.FUTURE_DATE, closureDate); }
// shouldn't be before an existing accounting closure // shouldn't be before an existing accounting closure
final GLClosure latestGLClosure = this.glClosureRepository.getLatestGLClosureByBranch(officeId); final GLClosure latestGLClosure = this.glClosureRepository.getLatestGLClosureByBranch(officeId);
if (latestGLClosure != null) { if (latestGLClosure != null) {
if (latestGLClosure.getClosingDate().after(closureDate)) { throw new GLClosureInvalidException( if (latestGLClosure.getClosingDate().after(closureDate)) { throw new GLClosureInvalidException(
GL_CLOSURE_INVALID_REASON.ACCOUNTING_CLOSED, latestGLClosure.getClosingDate()); } GlClosureInvalidReason.ACCOUNTING_CLOSED, latestGLClosure.getClosingDate()); }
} }
final GLClosure glClosure = GLClosure.fromJson(office, command); final GLClosure glClosure = GLClosure.fromJson(office, command);
@@ -28,13 +28,13 @@ import org.apache.fineract.accounting.glaccount.domain.GLAccountType;
public class AccountingConstants { public class AccountingConstants {
/*** Accounting placeholders for cash based accounting for loan products ***/ /*** Accounting placeholders for cash based accounting for loan products ***/
public static enum CASH_ACCOUNTS_FOR_LOAN { public static enum CashAccountsForLoan {
FUND_SOURCE(1), LOAN_PORTFOLIO(2), INTEREST_ON_LOANS(3), INCOME_FROM_FEES(4), INCOME_FROM_PENALTIES(5), LOSSES_WRITTEN_OFF(6), TRANSFERS_SUSPENSE( FUND_SOURCE(1), LOAN_PORTFOLIO(2), INTEREST_ON_LOANS(3), INCOME_FROM_FEES(4), INCOME_FROM_PENALTIES(5), LOSSES_WRITTEN_OFF(6), TRANSFERS_SUSPENSE(
10), OVERPAYMENT(11), INCOME_FROM_RECOVERY(12); 10), OVERPAYMENT(11), INCOME_FROM_RECOVERY(12);
private final Integer value; private final Integer value;
private CASH_ACCOUNTS_FOR_LOAN(final Integer value) { private CashAccountsForLoan(final Integer value) {
this.value = value; this.value = value;
} }
@@ -47,27 +47,27 @@ public class AccountingConstants {
return this.value; return this.value;
} }
private static final Map<Integer, CASH_ACCOUNTS_FOR_LOAN> intToEnumMap = new HashMap<>(); private static final Map<Integer, CashAccountsForLoan> intToEnumMap = new HashMap<>();
static { static {
for (final CASH_ACCOUNTS_FOR_LOAN type : CASH_ACCOUNTS_FOR_LOAN.values()) { for (final CashAccountsForLoan type : CashAccountsForLoan.values()) {
intToEnumMap.put(type.value, type); intToEnumMap.put(type.value, type);
} }
} }
public static CASH_ACCOUNTS_FOR_LOAN fromInt(final int i) { public static CashAccountsForLoan fromInt(final int i) {
final CASH_ACCOUNTS_FOR_LOAN type = intToEnumMap.get(Integer.valueOf(i)); final CashAccountsForLoan type = intToEnumMap.get(Integer.valueOf(i));
return type; return type;
} }
} }
/*** Accounting placeholders for accrual based accounting for loan products ***/ /*** Accounting placeholders for accrual based accounting for loan products ***/
public static enum ACCRUAL_ACCOUNTS_FOR_LOAN { public static enum AccrualAccountsForLoan {
FUND_SOURCE(1), LOAN_PORTFOLIO(2), INTEREST_ON_LOANS(3), INCOME_FROM_FEES(4), INCOME_FROM_PENALTIES(5), LOSSES_WRITTEN_OFF(6), INTEREST_RECEIVABLE( FUND_SOURCE(1), LOAN_PORTFOLIO(2), INTEREST_ON_LOANS(3), INCOME_FROM_FEES(4), INCOME_FROM_PENALTIES(5), LOSSES_WRITTEN_OFF(6), INTEREST_RECEIVABLE(
7), FEES_RECEIVABLE(8), PENALTIES_RECEIVABLE(9), TRANSFERS_SUSPENSE(10), OVERPAYMENT(11), INCOME_FROM_RECOVERY(12); 7), FEES_RECEIVABLE(8), PENALTIES_RECEIVABLE(9), TRANSFERS_SUSPENSE(10), OVERPAYMENT(11), INCOME_FROM_RECOVERY(12);
private final Integer value; private final Integer value;
private ACCRUAL_ACCOUNTS_FOR_LOAN(final Integer value) { private AccrualAccountsForLoan(final Integer value) {
this.value = value; this.value = value;
} }
@@ -80,15 +80,15 @@ public class AccountingConstants {
return this.value; return this.value;
} }
private static final Map<Integer, ACCRUAL_ACCOUNTS_FOR_LOAN> intToEnumMap = new HashMap<>(); private static final Map<Integer, AccrualAccountsForLoan> intToEnumMap = new HashMap<>();
static { static {
for (final ACCRUAL_ACCOUNTS_FOR_LOAN type : ACCRUAL_ACCOUNTS_FOR_LOAN.values()) { for (final AccrualAccountsForLoan type : AccrualAccountsForLoan.values()) {
intToEnumMap.put(type.value, type); intToEnumMap.put(type.value, type);
} }
} }
public static ACCRUAL_ACCOUNTS_FOR_LOAN fromInt(final int i) { public static AccrualAccountsForLoan fromInt(final int i) {
final ACCRUAL_ACCOUNTS_FOR_LOAN type = intToEnumMap.get(Integer.valueOf(i)); final AccrualAccountsForLoan type = intToEnumMap.get(Integer.valueOf(i));
return type; return type;
} }
@@ -98,7 +98,7 @@ public class AccountingConstants {
* Enum of all accounting related input parameter names used while * Enum of all accounting related input parameter names used while
* creating/updating a loan product * creating/updating a loan product
***/ ***/
public static enum LOAN_PRODUCT_ACCOUNTING_PARAMS { public static enum LoanProductAccountingParams {
FUND_SOURCE("fundSourceAccountId"), LOAN_PORTFOLIO("loanPortfolioAccountId"), INTEREST_ON_LOANS("interestOnLoanAccountId"), INCOME_FROM_FEES( FUND_SOURCE("fundSourceAccountId"), LOAN_PORTFOLIO("loanPortfolioAccountId"), INTEREST_ON_LOANS("interestOnLoanAccountId"), INCOME_FROM_FEES(
"incomeFromFeeAccountId"), INCOME_FROM_PENALTIES("incomeFromPenaltyAccountId"), LOSSES_WRITTEN_OFF("writeOffAccountId"), OVERPAYMENT( "incomeFromFeeAccountId"), INCOME_FROM_PENALTIES("incomeFromPenaltyAccountId"), LOSSES_WRITTEN_OFF("writeOffAccountId"), OVERPAYMENT(
"overpaymentLiabilityAccountId"), INTEREST_RECEIVABLE("receivableInterestAccountId"), FEES_RECEIVABLE( "overpaymentLiabilityAccountId"), INTEREST_RECEIVABLE("receivableInterestAccountId"), FEES_RECEIVABLE(
@@ -110,7 +110,7 @@ public class AccountingConstants {
private final String value; private final String value;
private LOAN_PRODUCT_ACCOUNTING_PARAMS(final String value) { private LoanProductAccountingParams(final String value) {
this.value = value; this.value = value;
} }
@@ -124,7 +124,7 @@ public class AccountingConstants {
} }
} }
public static enum LOAN_PRODUCT_ACCOUNTING_DATA_PARAMS { public static enum LoanProductAccountingDataParams {
FUND_SOURCE("fundSourceAccount"), LOAN_PORTFOLIO("loanPortfolioAccount"), INTEREST_ON_LOANS("interestOnLoanAccount"), INCOME_FROM_FEES( FUND_SOURCE("fundSourceAccount"), LOAN_PORTFOLIO("loanPortfolioAccount"), INTEREST_ON_LOANS("interestOnLoanAccount"), INCOME_FROM_FEES(
"incomeFromFeeAccount"), INCOME_FROM_PENALTIES("incomeFromPenaltyAccount"), LOSSES_WRITTEN_OFF("writeOffAccount"), OVERPAYMENT( "incomeFromFeeAccount"), INCOME_FROM_PENALTIES("incomeFromPenaltyAccount"), LOSSES_WRITTEN_OFF("writeOffAccount"), OVERPAYMENT(
"overpaymentLiabilityAccount"), INTEREST_RECEIVABLE("receivableInterestAccount"), FEES_RECEIVABLE("receivableFeeAccount"), PENALTIES_RECEIVABLE( "overpaymentLiabilityAccount"), INTEREST_RECEIVABLE("receivableInterestAccount"), FEES_RECEIVABLE("receivableFeeAccount"), PENALTIES_RECEIVABLE(
@@ -133,7 +133,7 @@ public class AccountingConstants {
private final String value; private final String value;
private LOAN_PRODUCT_ACCOUNTING_DATA_PARAMS(final String value) { private LoanProductAccountingDataParams(final String value) {
this.value = value; this.value = value;
} }
@@ -148,13 +148,13 @@ public class AccountingConstants {
} }
/*** Accounting placeholders for cash based accounting for savings products ***/ /*** Accounting placeholders for cash based accounting for savings products ***/
public static enum CASH_ACCOUNTS_FOR_SAVINGS { public static enum CashAccountsForSavings {
SAVINGS_REFERENCE(1), SAVINGS_CONTROL(2), INTEREST_ON_SAVINGS(3), INCOME_FROM_FEES(4), INCOME_FROM_PENALTIES(5), TRANSFERS_SUSPENSE( SAVINGS_REFERENCE(1), SAVINGS_CONTROL(2), INTEREST_ON_SAVINGS(3), INCOME_FROM_FEES(4), INCOME_FROM_PENALTIES(5), TRANSFERS_SUSPENSE(
10), OVERDRAFT_PORTFOLIO_CONTROL(11), INCOME_FROM_INTEREST(12), LOSSES_WRITTEN_OFF(13), ESCHEAT_LIABILITY(14); 10), OVERDRAFT_PORTFOLIO_CONTROL(11), INCOME_FROM_INTEREST(12), LOSSES_WRITTEN_OFF(13), ESCHEAT_LIABILITY(14);
private final Integer value; private final Integer value;
private CASH_ACCOUNTS_FOR_SAVINGS(final Integer value) { private CashAccountsForSavings(final Integer value) {
this.value = value; this.value = value;
} }
@@ -167,15 +167,15 @@ public class AccountingConstants {
return this.value; return this.value;
} }
private static final Map<Integer, CASH_ACCOUNTS_FOR_SAVINGS> intToEnumMap = new HashMap<>(); private static final Map<Integer, CashAccountsForSavings> intToEnumMap = new HashMap<>();
static { static {
for (final CASH_ACCOUNTS_FOR_SAVINGS type : CASH_ACCOUNTS_FOR_SAVINGS.values()) { for (final CashAccountsForSavings type : CashAccountsForSavings.values()) {
intToEnumMap.put(type.value, type); intToEnumMap.put(type.value, type);
} }
} }
public static CASH_ACCOUNTS_FOR_SAVINGS fromInt(final int i) { public static CashAccountsForSavings fromInt(final int i) {
final CASH_ACCOUNTS_FOR_SAVINGS type = intToEnumMap.get(Integer.valueOf(i)); final CashAccountsForSavings type = intToEnumMap.get(Integer.valueOf(i));
return type; return type;
} }
} }
@@ -184,7 +184,7 @@ public class AccountingConstants {
* Enum of all accounting related input parameter names used while * Enum of all accounting related input parameter names used while
* creating/updating a savings product * creating/updating a savings product
***/ ***/
public static enum SAVINGS_PRODUCT_ACCOUNTING_PARAMS { public static enum SavingProductAccountingParams {
SAVINGS_REFERENCE("savingsReferenceAccountId"), SAVINGS_CONTROL("savingsControlAccountId"), INCOME_FROM_FEES( SAVINGS_REFERENCE("savingsReferenceAccountId"), SAVINGS_CONTROL("savingsControlAccountId"), INCOME_FROM_FEES(
"incomeFromFeeAccountId"), INCOME_FROM_PENALTIES("incomeFromPenaltyAccountId"), INTEREST_ON_SAVINGS( "incomeFromFeeAccountId"), INCOME_FROM_PENALTIES("incomeFromPenaltyAccountId"), INTEREST_ON_SAVINGS(
"interestOnSavingsAccountId"), PAYMENT_CHANNEL_FUND_SOURCE_MAPPING("paymentChannelToFundSourceMappings"), PAYMENT_TYPE( "interestOnSavingsAccountId"), PAYMENT_CHANNEL_FUND_SOURCE_MAPPING("paymentChannelToFundSourceMappings"), PAYMENT_TYPE(
@@ -195,7 +195,7 @@ public class AccountingConstants {
private final String value; private final String value;
private SAVINGS_PRODUCT_ACCOUNTING_PARAMS(final String value) { private SavingProductAccountingParams(final String value) {
this.value = value; this.value = value;
} }
@@ -209,7 +209,7 @@ public class AccountingConstants {
} }
} }
public static enum SAVINGS_PRODUCT_ACCOUNTING_DATA_PARAMS { public static enum SavingProductAccountingDataParams {
SAVINGS_REFERENCE("savingsReferenceAccount"), SAVINGS_CONTROL("savingsControlAccount"), INCOME_FROM_FEES("incomeFromFeeAccount"), INCOME_FROM_PENALTIES( SAVINGS_REFERENCE("savingsReferenceAccount"), SAVINGS_CONTROL("savingsControlAccount"), INCOME_FROM_FEES("incomeFromFeeAccount"), INCOME_FROM_PENALTIES(
"incomeFromPenaltyAccount"), INTEREST_ON_SAVINGS("interestOnSavingsAccount"), PAYMENT_TYPE("paymentType"), FUND_SOURCE( "incomeFromPenaltyAccount"), INTEREST_ON_SAVINGS("interestOnSavingsAccount"), PAYMENT_TYPE("paymentType"), FUND_SOURCE(
"fundSourceAccount"), TRANSFERS_SUSPENSE("transfersInSuspenseAccount"), PENALTY_INCOME_ACCOUNT_MAPPING( "fundSourceAccount"), TRANSFERS_SUSPENSE("transfersInSuspenseAccount"), PENALTY_INCOME_ACCOUNT_MAPPING(
@@ -219,7 +219,7 @@ public class AccountingConstants {
private final String value; private final String value;
private SAVINGS_PRODUCT_ACCOUNTING_DATA_PARAMS(final String value) { private SavingProductAccountingDataParams(final String value) {
this.value = value; this.value = value;
} }
@@ -233,7 +233,7 @@ public class AccountingConstants {
} }
} }
public static enum FINANCIAL_ACTIVITY { public static enum FinancialActivity {
ASSET_TRANSFER(100, "assetTransfer", GLAccountType.ASSET), LIABILITY_TRANSFER(200, "liabilityTransfer", GLAccountType.LIABILITY), CASH_AT_MAINVAULT( ASSET_TRANSFER(100, "assetTransfer", GLAccountType.ASSET), LIABILITY_TRANSFER(200, "liabilityTransfer", GLAccountType.LIABILITY), CASH_AT_MAINVAULT(
101, "cashAtMainVault", GLAccountType.ASSET), CASH_AT_TELLER(102, "cashAtTeller", GLAccountType.ASSET), OPENING_BALANCES_TRANSFER_CONTRA( 101, "cashAtMainVault", GLAccountType.ASSET), CASH_AT_TELLER(102, "cashAtTeller", GLAccountType.ASSET), OPENING_BALANCES_TRANSFER_CONTRA(
300, "openingBalancesTransferContra", GLAccountType.EQUITY), ASSET_FUND_SOURCE(103, "fundSource", GLAccountType.ASSET), PAYABLE_DIVIDENDS( 300, "openingBalancesTransferContra", GLAccountType.EQUITY), ASSET_FUND_SOURCE(103, "fundSource", GLAccountType.ASSET), PAYABLE_DIVIDENDS(
@@ -246,13 +246,13 @@ public class AccountingConstants {
private static List<FinancialActivityData> financialActivities; private static List<FinancialActivityData> financialActivities;
static { static {
financialActivities = new ArrayList<>(); financialActivities = new ArrayList<>();
for (final FINANCIAL_ACTIVITY type : FINANCIAL_ACTIVITY.values()) { for (final FinancialActivity type : FinancialActivity.values()) {
FinancialActivityData financialActivityData = convertToFinancialActivityData(type); FinancialActivityData financialActivityData = convertToFinancialActivityData(type);
financialActivities.add(financialActivityData); financialActivities.add(financialActivityData);
} }
} }
private FINANCIAL_ACTIVITY(final Integer value, final String code, final GLAccountType mappedGLAccountType) { private FinancialActivity(final Integer value, final String code, final GLAccountType mappedGLAccountType) {
this.value = value; this.value = value;
this.code = code; this.code = code;
this.mappedGLAccountType = mappedGLAccountType; this.mappedGLAccountType = mappedGLAccountType;
@@ -279,20 +279,20 @@ public class AccountingConstants {
return this.value.toString(); return this.value.toString();
} }
private static final Map<Integer, FINANCIAL_ACTIVITY> intToEnumMap = new HashMap<>(); private static final Map<Integer, FinancialActivity> intToEnumMap = new HashMap<>();
static { static {
for (final FINANCIAL_ACTIVITY type : FINANCIAL_ACTIVITY.values()) { for (final FinancialActivity type : FinancialActivity.values()) {
intToEnumMap.put(type.value, type); intToEnumMap.put(type.value, type);
} }
} }
public static FINANCIAL_ACTIVITY fromInt(final int financialActivityId) { public static FinancialActivity fromInt(final int financialActivityId) {
final FINANCIAL_ACTIVITY type = intToEnumMap.get(Integer.valueOf(financialActivityId)); final FinancialActivity type = intToEnumMap.get(Integer.valueOf(financialActivityId));
return type; return type;
} }
public static FinancialActivityData toFinancialActivityData(final int financialActivityId) { public static FinancialActivityData toFinancialActivityData(final int financialActivityId) {
final FINANCIAL_ACTIVITY type = fromInt(financialActivityId); final FinancialActivity type = fromInt(financialActivityId);
return convertToFinancialActivityData(type); return convertToFinancialActivityData(type);
} }
@@ -300,19 +300,19 @@ public class AccountingConstants {
return financialActivities; return financialActivities;
} }
private static FinancialActivityData convertToFinancialActivityData(final FINANCIAL_ACTIVITY type) { private static FinancialActivityData convertToFinancialActivityData(final FinancialActivity type) {
FinancialActivityData financialActivityData = new FinancialActivityData(type.value, type.code, type.getMappedGLAccountType()); FinancialActivityData financialActivityData = new FinancialActivityData(type.value, type.code, type.getMappedGLAccountType());
return financialActivityData; return financialActivityData;
} }
} }
/*** Accounting placeholders for cash based accounting for Share products ***/ /*** Accounting placeholders for cash based accounting for Share products ***/
public static enum CASH_ACCOUNTS_FOR_SHARES { public static enum CashAccountsForShares {
SHARES_REFERENCE(1), SHARES_SUSPENSE(2), INCOME_FROM_FEES(3), SHARES_EQUITY(4); SHARES_REFERENCE(1), SHARES_SUSPENSE(2), INCOME_FROM_FEES(3), SHARES_EQUITY(4);
private final Integer value; private final Integer value;
private CASH_ACCOUNTS_FOR_SHARES(final Integer value) { private CashAccountsForShares(final Integer value) {
this.value = value; this.value = value;
} }
@@ -325,15 +325,15 @@ public class AccountingConstants {
return this.value; return this.value;
} }
private static final Map<Integer, CASH_ACCOUNTS_FOR_SHARES> intToEnumMap = new HashMap<>(); private static final Map<Integer, CashAccountsForShares> intToEnumMap = new HashMap<>();
static { static {
for (final CASH_ACCOUNTS_FOR_SHARES type : CASH_ACCOUNTS_FOR_SHARES.values()) { for (final CashAccountsForShares type : CashAccountsForShares.values()) {
intToEnumMap.put(type.value, type); intToEnumMap.put(type.value, type);
} }
} }
public static CASH_ACCOUNTS_FOR_SHARES fromInt(final int i) { public static CashAccountsForShares fromInt(final int i) {
final CASH_ACCOUNTS_FOR_SHARES type = intToEnumMap.get(Integer.valueOf(i)); final CashAccountsForShares type = intToEnumMap.get(Integer.valueOf(i));
return type; return type;
} }
} }
@@ -342,13 +342,13 @@ public class AccountingConstants {
* Enum of all accounting related input parameter names used while * Enum of all accounting related input parameter names used while
* creating/updating a savings product * creating/updating a savings product
***/ ***/
public static enum SHARES_PRODUCT_ACCOUNTING_PARAMS { public static enum SharesProductAccountingParams {
SHARES_REFERENCE("shareReferenceId"), SHARES_SUSPENSE("shareSuspenseId"), INCOME_FROM_FEES("incomeFromFeeAccountId"), SHARES_EQUITY( SHARES_REFERENCE("shareReferenceId"), SHARES_SUSPENSE("shareSuspenseId"), INCOME_FROM_FEES("incomeFromFeeAccountId"), SHARES_EQUITY(
"shareEquityId"); "shareEquityId");
private final String value; private final String value;
private SHARES_PRODUCT_ACCOUNTING_PARAMS(final String value) { private SharesProductAccountingParams(final String value) {
this.value = value; this.value = value;
} }
@@ -18,7 +18,7 @@
*/ */
package org.apache.fineract.accounting.financialactivityaccount.exception; package org.apache.fineract.accounting.financialactivityaccount.exception;
import org.apache.fineract.accounting.common.AccountingConstants.FINANCIAL_ACTIVITY; import org.apache.fineract.accounting.common.AccountingConstants.FinancialActivity;
import org.apache.fineract.accounting.glaccount.domain.GLAccount; import org.apache.fineract.accounting.glaccount.domain.GLAccount;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainRuleException; import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainRuleException;
@@ -30,7 +30,7 @@ public class FinancialActivityAccountInvalidException extends AbstractPlatformDo
private final static String errorCode = "error.msg.financialActivityAccount.invalid"; private final static String errorCode = "error.msg.financialActivityAccount.invalid";
public FinancialActivityAccountInvalidException(final FINANCIAL_ACTIVITY financialActivity, final GLAccount glAccount) { public FinancialActivityAccountInvalidException(final FinancialActivity financialActivity, final GLAccount glAccount) {
super(errorCode, "Financial Activity '" + financialActivity.getCode() + "' with Id :" + financialActivity.getValue() super(errorCode, "Financial Activity '" + financialActivity.getCode() + "' with Id :" + financialActivity.getValue()
+ "' can only be associated with a Ledger Account of Type " + financialActivity.getMappedGLAccountType().getCode() + "' can only be associated with a Ledger Account of Type " + financialActivity.getMappedGLAccountType().getCode()
+ " the provided Ledger Account '" + glAccount.getName() + "(" + glAccount.getGlCode() + " the provided Ledger Account '" + glAccount.getName() + "(" + glAccount.getGlCode()
@@ -26,7 +26,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.accounting.common.AccountingConstants.FINANCIAL_ACTIVITY; import org.apache.fineract.accounting.common.AccountingConstants.FinancialActivity;
import org.apache.fineract.accounting.financialactivityaccount.api.FinancialActivityAccountsJsonInputParams; import org.apache.fineract.accounting.financialactivityaccount.api.FinancialActivityAccountsJsonInputParams;
import org.apache.fineract.infrastructure.core.data.ApiParameterError; import org.apache.fineract.infrastructure.core.data.ApiParameterError;
import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder; import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder;
@@ -64,10 +64,10 @@ public final class FinancialActivityAccountDataValidator {
final Integer financialActivityId = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(paramNameForFinancialActivity, element); final Integer financialActivityId = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(paramNameForFinancialActivity, element);
baseDataValidator.reset().parameter(paramNameForFinancialActivity).value(financialActivityId).notNull().isOneOfTheseValues( baseDataValidator.reset().parameter(paramNameForFinancialActivity).value(financialActivityId).notNull().isOneOfTheseValues(
FINANCIAL_ACTIVITY.ASSET_TRANSFER.getValue(), FINANCIAL_ACTIVITY.LIABILITY_TRANSFER.getValue(), FinancialActivity.ASSET_TRANSFER.getValue(), FinancialActivity.LIABILITY_TRANSFER.getValue(),
FINANCIAL_ACTIVITY.CASH_AT_MAINVAULT.getValue(), FINANCIAL_ACTIVITY.CASH_AT_TELLER.getValue(), FinancialActivity.CASH_AT_MAINVAULT.getValue(), FinancialActivity.CASH_AT_TELLER.getValue(),
FINANCIAL_ACTIVITY.OPENING_BALANCES_TRANSFER_CONTRA.getValue(), FINANCIAL_ACTIVITY.ASSET_FUND_SOURCE.getValue(), FinancialActivity.OPENING_BALANCES_TRANSFER_CONTRA.getValue(), FinancialActivity.ASSET_FUND_SOURCE.getValue(),
FINANCIAL_ACTIVITY.PAYABLE_DIVIDENDS.getValue()); FinancialActivity.PAYABLE_DIVIDENDS.getValue());
final Long glAccountId = this.fromApiJsonHelper.extractLongNamed(paramNameForGLAccount, element); final Long glAccountId = this.fromApiJsonHelper.extractLongNamed(paramNameForGLAccount, element);
baseDataValidator.reset().parameter(paramNameForGLAccount).value(glAccountId).notNull().integerGreaterThanZero(); baseDataValidator.reset().parameter(paramNameForGLAccount).value(glAccountId).notNull().integerGreaterThanZero();
@@ -92,9 +92,9 @@ public final class FinancialActivityAccountDataValidator {
final Integer financialActivityId = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(paramNameForFinancialActivity, final Integer financialActivityId = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(paramNameForFinancialActivity,
element); element);
baseDataValidator.reset().parameter(paramNameForFinancialActivity).value(financialActivityId).ignoreIfNull().isOneOfTheseValues( baseDataValidator.reset().parameter(paramNameForFinancialActivity).value(financialActivityId).ignoreIfNull().isOneOfTheseValues(
FINANCIAL_ACTIVITY.ASSET_TRANSFER.getValue(), FINANCIAL_ACTIVITY.LIABILITY_TRANSFER.getValue(), FinancialActivity.ASSET_TRANSFER.getValue(), FinancialActivity.LIABILITY_TRANSFER.getValue(),
FINANCIAL_ACTIVITY.OPENING_BALANCES_TRANSFER_CONTRA.getValue(), FINANCIAL_ACTIVITY.ASSET_FUND_SOURCE.getValue(), FinancialActivity.OPENING_BALANCES_TRANSFER_CONTRA.getValue(), FinancialActivity.ASSET_FUND_SOURCE.getValue(),
FINANCIAL_ACTIVITY.PAYABLE_DIVIDENDS.getValue()); FinancialActivity.PAYABLE_DIVIDENDS.getValue());
} }
if (this.fromApiJsonHelper.parameterExists(paramNameForGLAccount, element)) { if (this.fromApiJsonHelper.parameterExists(paramNameForGLAccount, element)) {
@@ -22,7 +22,7 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.fineract.accounting.common.AccountingConstants.FINANCIAL_ACTIVITY; import org.apache.fineract.accounting.common.AccountingConstants.FinancialActivity;
import org.apache.fineract.accounting.common.AccountingDropdownReadPlatformService; import org.apache.fineract.accounting.common.AccountingDropdownReadPlatformService;
import org.apache.fineract.accounting.financialactivityaccount.data.FinancialActivityAccountData; import org.apache.fineract.accounting.financialactivityaccount.data.FinancialActivityAccountData;
import org.apache.fineract.accounting.financialactivityaccount.data.FinancialActivityData; import org.apache.fineract.accounting.financialactivityaccount.data.FinancialActivityData;
@@ -75,7 +75,7 @@ public class FinancialActivityAccountReadPlatformServiceImpl implements Financia
public FinancialActivityAccountData addTemplateDetails(FinancialActivityAccountData financialActivityAccountData) { public FinancialActivityAccountData addTemplateDetails(FinancialActivityAccountData financialActivityAccountData) {
final Map<String, List<GLAccountData>> accountOptions = this.accountingDropdownReadPlatformService.retrieveAccountMappingOptions(); final Map<String, List<GLAccountData>> accountOptions = this.accountingDropdownReadPlatformService.retrieveAccountMappingOptions();
financialActivityAccountData.setAccountingMappingOptions(accountOptions); financialActivityAccountData.setAccountingMappingOptions(accountOptions);
financialActivityAccountData.setFinancialActivityOptions(FINANCIAL_ACTIVITY.getAllFinancialActivities()); financialActivityAccountData.setFinancialActivityOptions(FinancialActivity.getAllFinancialActivities());
return financialActivityAccountData; return financialActivityAccountData;
} }
@@ -110,7 +110,7 @@ public class FinancialActivityAccountReadPlatformServiceImpl implements Financia
final String glCode = rs.getString("glCode"); final String glCode = rs.getString("glCode");
final GLAccountData glAccountData = new GLAccountData(glAccountId, glAccountName, glCode); final GLAccountData glAccountData = new GLAccountData(glAccountId, glAccountName, glCode);
final FinancialActivityData financialActivityData = FINANCIAL_ACTIVITY.toFinancialActivityData(financialActivityId); final FinancialActivityData financialActivityData = FinancialActivity.toFinancialActivityData(financialActivityId);
final FinancialActivityAccountData financialActivityAccountData = new FinancialActivityAccountData(id, financialActivityData, final FinancialActivityAccountData financialActivityAccountData = new FinancialActivityAccountData(id, financialActivityData,
glAccountData); glAccountData);
@@ -22,7 +22,7 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import javax.persistence.PersistenceException; import javax.persistence.PersistenceException;
import org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.fineract.accounting.common.AccountingConstants.FINANCIAL_ACTIVITY; import org.apache.fineract.accounting.common.AccountingConstants.FinancialActivity;
import org.apache.fineract.accounting.financialactivityaccount.api.FinancialActivityAccountsJsonInputParams; import org.apache.fineract.accounting.financialactivityaccount.api.FinancialActivityAccountsJsonInputParams;
import org.apache.fineract.accounting.financialactivityaccount.domain.FinancialActivityAccount; import org.apache.fineract.accounting.financialactivityaccount.domain.FinancialActivityAccount;
import org.apache.fineract.accounting.financialactivityaccount.domain.FinancialActivityAccountRepositoryWrapper; import org.apache.fineract.accounting.financialactivityaccount.domain.FinancialActivityAccountRepositoryWrapper;
@@ -91,7 +91,7 @@ public class FinancialActivityAccountWritePlatformServiceImpl implements Financi
* Activity Type * Activity Type
**/ **/
private void validateFinancialActivityAndAccountMapping(FinancialActivityAccount financialActivityAccount) { private void validateFinancialActivityAndAccountMapping(FinancialActivityAccount financialActivityAccount) {
FINANCIAL_ACTIVITY financialActivity = FINANCIAL_ACTIVITY.fromInt(financialActivityAccount.getFinancialActivityType()); FinancialActivity financialActivity = FinancialActivity.fromInt(financialActivityAccount.getFinancialActivityType());
GLAccount glAccount = financialActivityAccount.getGlAccount(); GLAccount glAccount = financialActivityAccount.getGlAccount();
if (!financialActivity.getMappedGLAccountType().getValue().equals(glAccount.getType())) { throw new FinancialActivityAccountInvalidException( if (!financialActivity.getMappedGLAccountType().getValue().equals(glAccount.getType())) { throw new FinancialActivityAccountInvalidException(
financialActivity, glAccount); } financialActivity, glAccount); }
@@ -27,7 +27,7 @@ import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainR
public class GLAccountInvalidDeleteException extends AbstractPlatformDomainRuleException { public class GLAccountInvalidDeleteException extends AbstractPlatformDomainRuleException {
/*** Enum of reasons for invalid delete **/ /*** Enum of reasons for invalid delete **/
public static enum GL_ACCOUNT_INVALID_DELETE_REASON { public static enum GlAccountInvalidDeleteReason {
TRANSANCTIONS_LOGGED, HAS_CHILDREN; TRANSANCTIONS_LOGGED, HAS_CHILDREN;
public String errorMessage() { public String errorMessage() {
@@ -45,7 +45,7 @@ public class GLAccountInvalidDeleteException extends AbstractPlatformDomainRuleE
} }
} }
public GLAccountInvalidDeleteException(final GL_ACCOUNT_INVALID_DELETE_REASON reason, final Long glAccountId) { public GLAccountInvalidDeleteException(final GlAccountInvalidDeleteReason reason, final Long glAccountId) {
super(reason.errorCode(), reason.errorMessage(), glAccountId); super(reason.errorCode(), reason.errorMessage(), glAccountId);
} }
} }
@@ -27,7 +27,7 @@ import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainR
public class GLAccountInvalidUpdateException extends AbstractPlatformDomainRuleException { public class GLAccountInvalidUpdateException extends AbstractPlatformDomainRuleException {
/*** Enum of reasons for invalid delete **/ /*** Enum of reasons for invalid delete **/
public static enum GL_ACCOUNT_INVALID_UPDATE_REASON { public static enum GlAccountInvalidUpdateReason {
TRANSANCTIONS_LOGGED; TRANSANCTIONS_LOGGED;
public String errorMessage() { public String errorMessage() {
@@ -41,7 +41,7 @@ public class GLAccountInvalidUpdateException extends AbstractPlatformDomainRuleE
} }
} }
public GLAccountInvalidUpdateException(final GL_ACCOUNT_INVALID_UPDATE_REASON reason, final Long glAccountId) { public GLAccountInvalidUpdateException(final GlAccountInvalidUpdateReason reason, final Long glAccountId) {
super(reason.errorCode(), reason.errorMessage(), glAccountId); super(reason.errorCode(), reason.errorMessage(), glAccountId);
} }
} }
@@ -29,10 +29,10 @@ import org.apache.fineract.accounting.glaccount.domain.GLAccountType;
import org.apache.fineract.accounting.glaccount.exception.GLAccountDisableException; import org.apache.fineract.accounting.glaccount.exception.GLAccountDisableException;
import org.apache.fineract.accounting.glaccount.exception.GLAccountDuplicateException; import org.apache.fineract.accounting.glaccount.exception.GLAccountDuplicateException;
import org.apache.fineract.accounting.glaccount.exception.GLAccountInvalidDeleteException; import org.apache.fineract.accounting.glaccount.exception.GLAccountInvalidDeleteException;
import org.apache.fineract.accounting.glaccount.exception.GLAccountInvalidDeleteException.GL_ACCOUNT_INVALID_DELETE_REASON; import org.apache.fineract.accounting.glaccount.exception.GLAccountInvalidDeleteException.GlAccountInvalidDeleteReason;
import org.apache.fineract.accounting.glaccount.exception.GLAccountInvalidParentException; import org.apache.fineract.accounting.glaccount.exception.GLAccountInvalidParentException;
import org.apache.fineract.accounting.glaccount.exception.GLAccountInvalidUpdateException; import org.apache.fineract.accounting.glaccount.exception.GLAccountInvalidUpdateException;
import org.apache.fineract.accounting.glaccount.exception.GLAccountInvalidUpdateException.GL_ACCOUNT_INVALID_UPDATE_REASON; import org.apache.fineract.accounting.glaccount.exception.GLAccountInvalidUpdateException.GlAccountInvalidUpdateReason;
import org.apache.fineract.accounting.glaccount.exception.GLAccountNotFoundException; import org.apache.fineract.accounting.glaccount.exception.GLAccountNotFoundException;
import org.apache.fineract.accounting.glaccount.exception.InvalidParentGLAccountHeadException; import org.apache.fineract.accounting.glaccount.exception.InvalidParentGLAccountHeadException;
import org.apache.fineract.accounting.glaccount.serialization.GLAccountCommandFromApiJsonDeserializer; import org.apache.fineract.accounting.glaccount.serialization.GLAccountCommandFromApiJsonDeserializer;
@@ -160,7 +160,7 @@ public class GLAccountWritePlatformServiceJpaRepositoryImpl implements GLAccount
final List<JournalEntry> journalEntriesForAccount = this.glJournalEntryRepository final List<JournalEntry> journalEntriesForAccount = this.glJournalEntryRepository
.findFirstJournalEntryForAccount(glAccountId); .findFirstJournalEntryForAccount(glAccountId);
if (journalEntriesForAccount.size() > 0) { throw new GLAccountInvalidUpdateException( if (journalEntriesForAccount.size() > 0) { throw new GLAccountInvalidUpdateException(
GL_ACCOUNT_INVALID_UPDATE_REASON.TRANSANCTIONS_LOGGED, glAccountId); } GlAccountInvalidUpdateReason.TRANSANCTIONS_LOGGED, glAccountId); }
} }
} }
@@ -195,12 +195,12 @@ public class GLAccountWritePlatformServiceJpaRepositoryImpl implements GLAccount
// validate this isn't a header account that has children // validate this isn't a header account that has children
if (glAccount.isHeaderAccount() && glAccount.getChildren().size() > 0) { throw new GLAccountInvalidDeleteException( if (glAccount.isHeaderAccount() && glAccount.getChildren().size() > 0) { throw new GLAccountInvalidDeleteException(
GL_ACCOUNT_INVALID_DELETE_REASON.HAS_CHILDREN, glAccountId); } GlAccountInvalidDeleteReason.HAS_CHILDREN, glAccountId); }
// does this account have transactions logged against it // does this account have transactions logged against it
final List<JournalEntry> journalEntriesForAccount = this.glJournalEntryRepository.findFirstJournalEntryForAccount(glAccountId); final List<JournalEntry> journalEntriesForAccount = this.glJournalEntryRepository.findFirstJournalEntryForAccount(glAccountId);
if (journalEntriesForAccount.size() > 0) { throw new GLAccountInvalidDeleteException( if (journalEntriesForAccount.size() > 0) { throw new GLAccountInvalidDeleteException(
GL_ACCOUNT_INVALID_DELETE_REASON.TRANSANCTIONS_LOGGED, glAccountId); } GlAccountInvalidDeleteReason.TRANSANCTIONS_LOGGED, glAccountId); }
this.glAccountRepository.delete(glAccount); this.glAccountRepository.delete(glAccount);
return new CommandProcessingResultBuilder().withEntityId(glAccountId).build(); return new CommandProcessingResultBuilder().withEntityId(glAccountId).build();
@@ -27,7 +27,7 @@ import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainR
public class JournalEntryInvalidException extends AbstractPlatformDomainRuleException { public class JournalEntryInvalidException extends AbstractPlatformDomainRuleException {
/*** 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 GlJournalEntryInvalidReason {
FUTURE_DATE, ACCOUNTING_CLOSED, NO_DEBITS_OR_CREDITS, DEBIT_CREDIT_SUM_MISMATCH_WITH_AMOUNT, DEBIT_CREDIT_SUM_MISMATCH, DEBIT_CREDIT_ACCOUNT_OR_AMOUNT_EMPTY, GL_ACCOUNT_DISABLED, GL_ACCOUNT_MANUAL_ENTRIES_NOT_PERMITTED, INVALID_DEBIT_OR_CREDIT_ACCOUNTS; FUTURE_DATE, ACCOUNTING_CLOSED, NO_DEBITS_OR_CREDITS, DEBIT_CREDIT_SUM_MISMATCH_WITH_AMOUNT, DEBIT_CREDIT_SUM_MISMATCH, DEBIT_CREDIT_ACCOUNT_OR_AMOUNT_EMPTY, GL_ACCOUNT_DISABLED, GL_ACCOUNT_MANUAL_ENTRIES_NOT_PERMITTED, INVALID_DEBIT_OR_CREDIT_ACCOUNTS;
public String errorMessage() { public String errorMessage() {
@@ -71,7 +71,7 @@ public class JournalEntryInvalidException extends AbstractPlatformDomainRuleExce
} }
} }
public JournalEntryInvalidException(final GL_JOURNAL_ENTRY_INVALID_REASON reason, final Date date, final String accountName, public JournalEntryInvalidException(final GlJournalEntryInvalidReason reason, final Date date, final String accountName,
final String accountGLCode) { final String accountGLCode) {
super(reason.errorCode(), reason.errorMessage(), date, accountName, accountGLCode); super(reason.errorCode(), reason.errorMessage(), date, accountName, accountGLCode);
} }
@@ -27,11 +27,11 @@ import java.util.Map;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.accounting.closure.domain.GLClosure; import org.apache.fineract.accounting.closure.domain.GLClosure;
import org.apache.fineract.accounting.closure.domain.GLClosureRepository; import org.apache.fineract.accounting.closure.domain.GLClosureRepository;
import org.apache.fineract.accounting.common.AccountingConstants.ACCRUAL_ACCOUNTS_FOR_LOAN; import org.apache.fineract.accounting.common.AccountingConstants.AccrualAccountsForLoan;
import org.apache.fineract.accounting.common.AccountingConstants.CASH_ACCOUNTS_FOR_LOAN; import org.apache.fineract.accounting.common.AccountingConstants.CashAccountsForLoan;
import org.apache.fineract.accounting.common.AccountingConstants.CASH_ACCOUNTS_FOR_SAVINGS; import org.apache.fineract.accounting.common.AccountingConstants.CashAccountsForSavings;
import org.apache.fineract.accounting.common.AccountingConstants.CASH_ACCOUNTS_FOR_SHARES; import org.apache.fineract.accounting.common.AccountingConstants.CashAccountsForShares;
import org.apache.fineract.accounting.common.AccountingConstants.FINANCIAL_ACTIVITY; import org.apache.fineract.accounting.common.AccountingConstants.FinancialActivity;
import org.apache.fineract.accounting.financialactivityaccount.domain.FinancialActivityAccount; import org.apache.fineract.accounting.financialactivityaccount.domain.FinancialActivityAccount;
import org.apache.fineract.accounting.financialactivityaccount.domain.FinancialActivityAccountRepositoryWrapper; import org.apache.fineract.accounting.financialactivityaccount.domain.FinancialActivityAccountRepositoryWrapper;
import org.apache.fineract.accounting.glaccount.domain.GLAccount; import org.apache.fineract.accounting.glaccount.domain.GLAccount;
@@ -50,7 +50,7 @@ import org.apache.fineract.accounting.journalentry.domain.JournalEntry;
import org.apache.fineract.accounting.journalentry.domain.JournalEntryRepository; import org.apache.fineract.accounting.journalentry.domain.JournalEntryRepository;
import org.apache.fineract.accounting.journalentry.domain.JournalEntryType; import org.apache.fineract.accounting.journalentry.domain.JournalEntryType;
import org.apache.fineract.accounting.journalentry.exception.JournalEntryInvalidException; import org.apache.fineract.accounting.journalentry.exception.JournalEntryInvalidException;
import org.apache.fineract.accounting.journalentry.exception.JournalEntryInvalidException.GL_JOURNAL_ENTRY_INVALID_REASON; import org.apache.fineract.accounting.journalentry.exception.JournalEntryInvalidException.GlJournalEntryInvalidReason;
import org.apache.fineract.accounting.producttoaccountmapping.domain.PortfolioProductType; import org.apache.fineract.accounting.producttoaccountmapping.domain.PortfolioProductType;
import org.apache.fineract.accounting.producttoaccountmapping.domain.ProductToGLAccountMapping; import org.apache.fineract.accounting.producttoaccountmapping.domain.ProductToGLAccountMapping;
import org.apache.fineract.accounting.producttoaccountmapping.domain.ProductToGLAccountMappingRepository; import org.apache.fineract.accounting.producttoaccountmapping.domain.ProductToGLAccountMappingRepository;
@@ -502,7 +502,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 CashAccountsForLoan 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) {
final int accountMappingTypeId = accountMappingType.getValue(); final int accountMappingTypeId = accountMappingType.getValue();
createCreditJournalEntryOrReversalForLoan(office, currencyCode, accountMappingTypeId, loanProductId, paymentTypeId, loanId, createCreditJournalEntryOrReversalForLoan(office, currencyCode, accountMappingTypeId, loanProductId, paymentTypeId, loanId,
@@ -510,7 +510,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 AccrualAccountsForLoan 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) {
final int accountMappingTypeId = accountMappingType.getValue(); final int accountMappingTypeId = accountMappingType.getValue();
createCreditJournalEntryOrReversalForLoan(office, currencyCode, accountMappingTypeId, loanProductId, paymentTypeId, loanId, createCreditJournalEntryOrReversalForLoan(office, currencyCode, accountMappingTypeId, loanProductId, paymentTypeId, loanId,
@@ -528,7 +528,7 @@ public class AccountingProcessorHelper {
**/ **/
if (latestGLClosure != null) { if (latestGLClosure != null) {
if (latestGLClosure.getClosingDate().after(transactionDate) || latestGLClosure.getClosingDate().equals(transactionDate)) { throw new JournalEntryInvalidException( if (latestGLClosure.getClosingDate().after(transactionDate) || latestGLClosure.getClosingDate().equals(transactionDate)) { throw new JournalEntryInvalidException(
GL_JOURNAL_ENTRY_INVALID_REASON.ACCOUNTING_CLOSED, latestGLClosure.getClosingDate(), null, null); } GlJournalEntryInvalidReason.ACCOUNTING_CLOSED, latestGLClosure.getClosingDate(), null, null); }
} }
} }
@@ -579,7 +579,7 @@ public class AccountingProcessorHelper {
* @param taxDetails * @param taxDetails
*/ */
public void createCashBasedJournalEntriesAndReversalsForSavingsTax(final Office office, final String currencyCode, public void createCashBasedJournalEntriesAndReversalsForSavingsTax(final Office office, final String currencyCode,
final CASH_ACCOUNTS_FOR_SAVINGS accountTypeToBeDebited, final CASH_ACCOUNTS_FOR_SAVINGS accountTypeToBeCredited, final CashAccountsForSavings accountTypeToBeDebited, final CashAccountsForSavings accountTypeToBeCredited,
final Long savingsProductId, final Long paymentTypeId, final Long savingsId, final String transactionId, final Long savingsProductId, final Long paymentTypeId, final Long savingsId, final String transactionId,
final Date transactionDate, final BigDecimal amount, final Boolean isReversal, final List<TaxPaymentDTO> taxDetails) { final Date transactionDate, final BigDecimal amount, final Boolean isReversal, final List<TaxPaymentDTO> taxDetails) {
@@ -738,7 +738,7 @@ public class AccountingProcessorHelper {
* @param chargePaymentDTOs chargePaymentDTOs * @param chargePaymentDTOs chargePaymentDTOs
*/ */
public void createCashBasedJournalEntriesAndReversalsForSavingsCharges(final Office office, final String currencyCode, public void createCashBasedJournalEntriesAndReversalsForSavingsCharges(final Office office, final String currencyCode,
final CASH_ACCOUNTS_FOR_SAVINGS accountTypeToBeDebited, final CASH_ACCOUNTS_FOR_SAVINGS accountTypeToBeCredited, final CashAccountsForSavings accountTypeToBeDebited, final CashAccountsForSavings accountTypeToBeCredited,
final Long savingsProductId, final Long paymentTypeId, final Long loanId, final String transactionId, final Long savingsProductId, final Long paymentTypeId, final Long loanId, final String transactionId,
final Date transactionDate, final BigDecimal totalAmount, final Boolean isReversal, final Date transactionDate, final BigDecimal totalAmount, final Boolean isReversal,
final List<ChargePaymentDTO> chargePaymentDTOs) { final List<ChargePaymentDTO> chargePaymentDTOs) {
@@ -969,7 +969,7 @@ public class AccountingProcessorHelper {
} }
public void createCashBasedJournalEntriesForSharesCharges(final Office office, final String currencyCode, public void createCashBasedJournalEntriesForSharesCharges(final Office office, final String currencyCode,
final CASH_ACCOUNTS_FOR_SHARES accountTypeToBeDebited, final CASH_ACCOUNTS_FOR_SHARES accountTypeToBeCredited, final CashAccountsForShares accountTypeToBeDebited, final CashAccountsForShares accountTypeToBeCredited,
final Long shareProductId, final Long paymentTypeId, final Long shareAccountId, final String transactionId, final Long shareProductId, final Long paymentTypeId, final Long shareAccountId, final String transactionId,
final Date transactionDate, final BigDecimal totalAmount, final List<ChargePaymentDTO> chargePaymentDTOs) { final Date transactionDate, final BigDecimal totalAmount, final List<ChargePaymentDTO> chargePaymentDTOs) {
@@ -980,7 +980,7 @@ public class AccountingProcessorHelper {
} }
public void createCashBasedJournalEntryForSharesCharges(final Office office, final String currencyCode, public void createCashBasedJournalEntryForSharesCharges(final Office office, final String currencyCode,
final CASH_ACCOUNTS_FOR_SHARES accountTypeToBeCredited, final Long shareProductId, final Long shareAccountId, final CashAccountsForShares accountTypeToBeCredited, final Long shareProductId, final Long shareAccountId,
final String transactionId, final Date transactionDate, final BigDecimal totalAmount, final String transactionId, final Date transactionDate, final BigDecimal totalAmount,
final List<ChargePaymentDTO> chargePaymentDTOs) { final List<ChargePaymentDTO> chargePaymentDTOs) {
final Map<GLAccount, BigDecimal> creditDetailsMap = new LinkedHashMap<>(); final Map<GLAccount, BigDecimal> creditDetailsMap = new LinkedHashMap<>();
@@ -1011,7 +1011,7 @@ public class AccountingProcessorHelper {
} }
public void revertCashBasedJournalEntryForSharesCharges(final Office office, final String currencyCode, public void revertCashBasedJournalEntryForSharesCharges(final Office office, final String currencyCode,
final CASH_ACCOUNTS_FOR_SHARES accountTypeToBeCredited, final Long shareProductId, final Long shareAccountId, final CashAccountsForShares accountTypeToBeCredited, final Long shareProductId, final Long shareAccountId,
final String transactionId, final Date transactionDate, final BigDecimal totalAmount, final String transactionId, final Date transactionDate, final BigDecimal totalAmount,
final List<ChargePaymentDTO> chargePaymentDTOs) { final List<ChargePaymentDTO> chargePaymentDTOs) {
final Map<GLAccount, BigDecimal> creditDetailsMap = new LinkedHashMap<>(); final Map<GLAccount, BigDecimal> creditDetailsMap = new LinkedHashMap<>();
@@ -1094,7 +1094,7 @@ public class AccountingProcessorHelper {
* payment channels). Note that fund source placeholder ID would be * payment channels). Note that fund source placeholder ID would be
* same for both cash and accrual accounts * same for both cash and accrual accounts
***/ ***/
if (accountMappingTypeId == CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue()) { if (accountMappingTypeId == CashAccountsForLoan.FUND_SOURCE.getValue()) {
final ProductToGLAccountMapping paymentChannelSpecificAccountMapping = this.accountMappingRepository final ProductToGLAccountMapping paymentChannelSpecificAccountMapping = this.accountMappingRepository
.findByProductIdAndProductTypeAndFinancialAccountTypeAndPaymentTypeId(loanProductId, .findByProductIdAndProductTypeAndFinancialAccountTypeAndPaymentTypeId(loanProductId,
PortfolioProductType.LOAN.getValue(), accountMappingTypeId, paymentTypeId); PortfolioProductType.LOAN.getValue(), accountMappingTypeId, paymentTypeId);
@@ -1104,7 +1104,7 @@ public class AccountingProcessorHelper {
} }
if (accountMapping == null) { throw new ProductToGLAccountMappingNotFoundException(PortfolioProductType.LOAN, loanProductId, if (accountMapping == null) { throw new ProductToGLAccountMappingNotFoundException(PortfolioProductType.LOAN, loanProductId,
ACCRUAL_ACCOUNTS_FOR_LOAN.OVERPAYMENT.toString()); } AccrualAccountsForLoan.OVERPAYMENT.toString()); }
glAccount = accountMapping.getGlAccount(); glAccount = accountMapping.getGlAccount();
} }
return glAccount; return glAccount;
@@ -1121,8 +1121,8 @@ 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 == CashAccountsForLoan.INCOME_FROM_FEES.getValue()
|| accountMappingTypeId == CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_PENALTIES.getValue()) { || accountMappingTypeId == CashAccountsForLoan.INCOME_FROM_PENALTIES.getValue()) {
final ProductToGLAccountMapping chargeSpecificIncomeAccountMapping = this.accountMappingRepository final ProductToGLAccountMapping chargeSpecificIncomeAccountMapping = this.accountMappingRepository
.findByProductIdAndProductTypeAndFinancialAccountTypeAndChargeId(loanProductId, PortfolioProductType.LOAN.getValue(), .findByProductIdAndProductTypeAndFinancialAccountTypeAndChargeId(loanProductId, PortfolioProductType.LOAN.getValue(),
accountMappingTypeId, chargeId); accountMappingTypeId, chargeId);
@@ -1144,8 +1144,8 @@ 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_SAVINGS.INCOME_FROM_FEES.getValue() if (accountMappingTypeId == CashAccountsForSavings.INCOME_FROM_FEES.getValue()
|| accountMappingTypeId == CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_PENALTIES.getValue()) { || accountMappingTypeId == CashAccountsForLoan.INCOME_FROM_PENALTIES.getValue()) {
final ProductToGLAccountMapping chargeSpecificIncomeAccountMapping = this.accountMappingRepository final ProductToGLAccountMapping chargeSpecificIncomeAccountMapping = this.accountMappingRepository
.findByProductIdAndProductTypeAndFinancialAccountTypeAndChargeId(savingsProductId, .findByProductIdAndProductTypeAndFinancialAccountTypeAndChargeId(savingsProductId,
PortfolioProductType.SAVING.getValue(), accountMappingTypeId, chargeId); PortfolioProductType.SAVING.getValue(), accountMappingTypeId, chargeId);
@@ -1171,7 +1171,7 @@ public class AccountingProcessorHelper {
* payment channels). Note that fund source placeholder ID would be * payment channels). Note that fund source placeholder ID would be
* same for both cash and accrual accounts * same for both cash and accrual accounts
***/ ***/
if (accountMappingTypeId == CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_REFERENCE.getValue()) { if (accountMappingTypeId == CashAccountsForSavings.SAVINGS_REFERENCE.getValue()) {
final ProductToGLAccountMapping paymentChannelSpecificAccountMapping = this.accountMappingRepository final ProductToGLAccountMapping paymentChannelSpecificAccountMapping = this.accountMappingRepository
.findByProductIdAndProductTypeAndFinancialAccountTypeAndPaymentTypeId(savingsProductId, .findByProductIdAndProductTypeAndFinancialAccountTypeAndPaymentTypeId(savingsProductId,
PortfolioProductType.SAVING.getValue(), accountMappingTypeId, paymentTypeId); PortfolioProductType.SAVING.getValue(), accountMappingTypeId, paymentTypeId);
@@ -1194,7 +1194,7 @@ public class AccountingProcessorHelper {
ProductToGLAccountMapping accountMapping = this.accountMappingRepository.findCoreProductToFinAccountMapping(shareProductId, ProductToGLAccountMapping accountMapping = this.accountMappingRepository.findCoreProductToFinAccountMapping(shareProductId,
PortfolioProductType.SHARES.getValue(), accountMappingTypeId); PortfolioProductType.SHARES.getValue(), accountMappingTypeId);
if (accountMappingTypeId == CASH_ACCOUNTS_FOR_SHARES.SHARES_REFERENCE.getValue()) { if (accountMappingTypeId == CashAccountsForShares.SHARES_REFERENCE.getValue()) {
final ProductToGLAccountMapping paymentChannelSpecificAccountMapping = this.accountMappingRepository final ProductToGLAccountMapping paymentChannelSpecificAccountMapping = this.accountMappingRepository
.findByProductIdAndProductTypeAndFinancialAccountTypeAndPaymentTypeId(shareProductId, .findByProductIdAndProductTypeAndFinancialAccountTypeAndPaymentTypeId(shareProductId,
PortfolioProductType.SHARES.getValue(), accountMappingTypeId, paymentTypeId); PortfolioProductType.SHARES.getValue(), accountMappingTypeId, paymentTypeId);
@@ -1228,7 +1228,7 @@ public class AccountingProcessorHelper {
private boolean isOrganizationAccount(final int accountMappingTypeId) { private boolean isOrganizationAccount(final int accountMappingTypeId) {
boolean isOrganizationAccount = false; boolean isOrganizationAccount = false;
if (FINANCIAL_ACTIVITY.fromInt(accountMappingTypeId) != null) { if (FinancialActivity.fromInt(accountMappingTypeId) != null) {
isOrganizationAccount = true; isOrganizationAccount = true;
} }
return isOrganizationAccount; return isOrganizationAccount;
@@ -1274,7 +1274,7 @@ public class AccountingProcessorHelper {
public void createDebitJournalEntryOrReversalForClientChargePayments(final Office office, final String currencyCode, public void createDebitJournalEntryOrReversalForClientChargePayments(final Office office, final String currencyCode,
final Long clientId, final Long transactionId, final Date transactionDate, final BigDecimal amount, final Boolean isReversal) { final Long clientId, final Long transactionId, final Date transactionDate, final BigDecimal amount, final Boolean isReversal) {
final GLAccount account = financialActivityAccountRepository.findByFinancialActivityTypeWithNotFoundDetection( final GLAccount account = financialActivityAccountRepository.findByFinancialActivityTypeWithNotFoundDetection(
FINANCIAL_ACTIVITY.ASSET_FUND_SOURCE.getValue()).getGlAccount(); FinancialActivity.ASSET_FUND_SOURCE.getValue()).getGlAccount();
if (isReversal) { if (isReversal) {
createCreditJournalEntryForClientPayments(office, currencyCode, account, clientId, transactionId, transactionDate, amount); createCreditJournalEntryForClientPayments(office, currencyCode, account, clientId, transactionId, transactionDate, amount);
} else { } else {
@@ -26,9 +26,9 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import org.apache.fineract.accounting.closure.domain.GLClosure; import org.apache.fineract.accounting.closure.domain.GLClosure;
import org.apache.fineract.accounting.common.AccountingConstants.ACCRUAL_ACCOUNTS_FOR_LOAN; import org.apache.fineract.accounting.common.AccountingConstants.AccrualAccountsForLoan;
import org.apache.fineract.accounting.common.AccountingConstants.CASH_ACCOUNTS_FOR_LOAN; import org.apache.fineract.accounting.common.AccountingConstants.CashAccountsForLoan;
import org.apache.fineract.accounting.common.AccountingConstants.FINANCIAL_ACTIVITY; import org.apache.fineract.accounting.common.AccountingConstants.FinancialActivity;
import org.apache.fineract.accounting.glaccount.domain.GLAccount; import org.apache.fineract.accounting.glaccount.domain.GLAccount;
import org.apache.fineract.accounting.journalentry.data.ChargePaymentDTO; import org.apache.fineract.accounting.journalentry.data.ChargePaymentDTO;
import org.apache.fineract.accounting.journalentry.data.LoanDTO; import org.apache.fineract.accounting.journalentry.data.LoanDTO;
@@ -125,15 +125,15 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
// reversal) // reversal)
if(loanTransactionDTO.isLoanToLoanTransfer()){ if(loanTransactionDTO.isLoanToLoanTransfer()){
this.helper.createAccrualBasedJournalEntriesAndReversalsForLoan(office, currencyCode, this.helper.createAccrualBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
ACCRUAL_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO.getValue(), FINANCIAL_ACTIVITY.ASSET_TRANSFER.getValue(), loanProductId, AccrualAccountsForLoan.LOAN_PORTFOLIO.getValue(), FinancialActivity.ASSET_TRANSFER.getValue(), loanProductId,
paymentTypeId, loanId, transactionId, transactionDate, disbursalAmount, isReversed); paymentTypeId, loanId, transactionId, transactionDate, disbursalAmount, isReversed);
} else if (loanTransactionDTO.isAccountTransfer()) { } else if (loanTransactionDTO.isAccountTransfer()) {
this.helper.createAccrualBasedJournalEntriesAndReversalsForLoan(office, currencyCode, this.helper.createAccrualBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
ACCRUAL_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO.getValue(), FINANCIAL_ACTIVITY.LIABILITY_TRANSFER.getValue(), loanProductId, AccrualAccountsForLoan.LOAN_PORTFOLIO.getValue(), FinancialActivity.LIABILITY_TRANSFER.getValue(), loanProductId,
paymentTypeId, loanId, transactionId, transactionDate, disbursalAmount, isReversed); paymentTypeId, loanId, transactionId, transactionDate, disbursalAmount, isReversed);
} else { } else {
this.helper.createAccrualBasedJournalEntriesAndReversalsForLoan(office, currencyCode, this.helper.createAccrualBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
ACCRUAL_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO.getValue(), ACCRUAL_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue(), loanProductId, AccrualAccountsForLoan.LOAN_PORTFOLIO.getValue(), AccrualAccountsForLoan.FUND_SOURCE.getValue(), loanProductId,
paymentTypeId, loanId, transactionId, transactionDate, disbursalAmount, isReversed); paymentTypeId, loanId, transactionId, transactionDate, disbursalAmount, isReversed);
} }
@@ -206,7 +206,7 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
if (principalAmount != null && !(principalAmount.compareTo(BigDecimal.ZERO) == 0)) { if (principalAmount != null && !(principalAmount.compareTo(BigDecimal.ZERO) == 0)) {
totalDebitAmount = totalDebitAmount.add(principalAmount); totalDebitAmount = totalDebitAmount.add(principalAmount);
GLAccount account = this.helper.getLinkedGLAccountForLoanProduct(loanProductId, GLAccount account = this.helper.getLinkedGLAccountForLoanProduct(loanProductId,
ACCRUAL_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO.getValue(), paymentTypeId); AccrualAccountsForLoan.LOAN_PORTFOLIO.getValue(), paymentTypeId);
accountMap.put(account, principalAmount); accountMap.put(account, principalAmount);
} }
@@ -214,7 +214,7 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
if (interestAmount != null && !(interestAmount.compareTo(BigDecimal.ZERO) == 0)) { if (interestAmount != null && !(interestAmount.compareTo(BigDecimal.ZERO) == 0)) {
totalDebitAmount = totalDebitAmount.add(interestAmount); totalDebitAmount = totalDebitAmount.add(interestAmount);
GLAccount account = this.helper.getLinkedGLAccountForLoanProduct(loanProductId, GLAccount account = this.helper.getLinkedGLAccountForLoanProduct(loanProductId,
ACCRUAL_ACCOUNTS_FOR_LOAN.INTEREST_RECEIVABLE.getValue(), paymentTypeId); AccrualAccountsForLoan.INTEREST_RECEIVABLE.getValue(), paymentTypeId);
if (accountMap.containsKey(account)) { if (accountMap.containsKey(account)) {
BigDecimal amount = accountMap.get(account).add(interestAmount); BigDecimal amount = accountMap.get(account).add(interestAmount);
accountMap.put(account, amount); accountMap.put(account, amount);
@@ -229,7 +229,7 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
if (isIncomeFromFee) { if (isIncomeFromFee) {
GLAccount account = this.helper.getLinkedGLAccountForLoanProduct(loanProductId, GLAccount account = this.helper.getLinkedGLAccountForLoanProduct(loanProductId,
ACCRUAL_ACCOUNTS_FOR_LOAN.INCOME_FROM_FEES.getValue(), paymentTypeId); AccrualAccountsForLoan.INCOME_FROM_FEES.getValue(), paymentTypeId);
if (accountMap.containsKey(account)) { if (accountMap.containsKey(account)) {
BigDecimal amount = accountMap.get(account).add(feesAmount); BigDecimal amount = accountMap.get(account).add(feesAmount);
accountMap.put(account, amount); accountMap.put(account, amount);
@@ -238,7 +238,7 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
} }
} else { } else {
GLAccount account = this.helper.getLinkedGLAccountForLoanProduct(loanProductId, GLAccount account = this.helper.getLinkedGLAccountForLoanProduct(loanProductId,
ACCRUAL_ACCOUNTS_FOR_LOAN.FEES_RECEIVABLE.getValue(), paymentTypeId); AccrualAccountsForLoan.FEES_RECEIVABLE.getValue(), paymentTypeId);
if (accountMap.containsKey(account)) { if (accountMap.containsKey(account)) {
BigDecimal amount = accountMap.get(account).add(feesAmount); BigDecimal amount = accountMap.get(account).add(feesAmount);
accountMap.put(account, amount); accountMap.put(account, amount);
@@ -253,7 +253,7 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
totalDebitAmount = totalDebitAmount.add(penaltiesAmount); totalDebitAmount = totalDebitAmount.add(penaltiesAmount);
if (isIncomeFromFee) { if (isIncomeFromFee) {
GLAccount account = this.helper.getLinkedGLAccountForLoanProduct(loanProductId, GLAccount account = this.helper.getLinkedGLAccountForLoanProduct(loanProductId,
ACCRUAL_ACCOUNTS_FOR_LOAN.INCOME_FROM_PENALTIES.getValue(), paymentTypeId); AccrualAccountsForLoan.INCOME_FROM_PENALTIES.getValue(), paymentTypeId);
if (accountMap.containsKey(account)) { if (accountMap.containsKey(account)) {
BigDecimal amount = accountMap.get(account).add(penaltiesAmount); BigDecimal amount = accountMap.get(account).add(penaltiesAmount);
accountMap.put(account, amount); accountMap.put(account, amount);
@@ -262,7 +262,7 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
} }
} else { } else {
GLAccount account = this.helper.getLinkedGLAccountForLoanProduct(loanProductId, GLAccount account = this.helper.getLinkedGLAccountForLoanProduct(loanProductId,
ACCRUAL_ACCOUNTS_FOR_LOAN.PENALTIES_RECEIVABLE.getValue(), paymentTypeId); AccrualAccountsForLoan.PENALTIES_RECEIVABLE.getValue(), paymentTypeId);
if (accountMap.containsKey(account)) { if (accountMap.containsKey(account)) {
BigDecimal amount = accountMap.get(account).add(penaltiesAmount); BigDecimal amount = accountMap.get(account).add(penaltiesAmount);
accountMap.put(account, amount); accountMap.put(account, amount);
@@ -275,7 +275,7 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
if (overPaymentAmount != null && !(overPaymentAmount.compareTo(BigDecimal.ZERO) == 0)) { if (overPaymentAmount != null && !(overPaymentAmount.compareTo(BigDecimal.ZERO) == 0)) {
totalDebitAmount = totalDebitAmount.add(overPaymentAmount); totalDebitAmount = totalDebitAmount.add(overPaymentAmount);
GLAccount account = this.helper.getLinkedGLAccountForLoanProduct(loanProductId, GLAccount account = this.helper.getLinkedGLAccountForLoanProduct(loanProductId,
ACCRUAL_ACCOUNTS_FOR_LOAN.OVERPAYMENT.getValue(), paymentTypeId); AccrualAccountsForLoan.OVERPAYMENT.getValue(), paymentTypeId);
if (accountMap.containsKey(account)) { if (accountMap.containsKey(account)) {
BigDecimal amount = accountMap.get(account).add(overPaymentAmount); BigDecimal amount = accountMap.get(account).add(overPaymentAmount);
accountMap.put(account, amount); accountMap.put(account, amount);
@@ -296,20 +296,20 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
if (!(totalDebitAmount.compareTo(BigDecimal.ZERO) == 0)) { if (!(totalDebitAmount.compareTo(BigDecimal.ZERO) == 0)) {
if (writeOff) { if (writeOff) {
this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode,
ACCRUAL_ACCOUNTS_FOR_LOAN.LOSSES_WRITTEN_OFF.getValue(), loanProductId, paymentTypeId, loanId, transactionId, AccrualAccountsForLoan.LOSSES_WRITTEN_OFF.getValue(), loanProductId, paymentTypeId, loanId, transactionId,
transactionDate, totalDebitAmount, isReversal); transactionDate, totalDebitAmount, isReversal);
} else { } else {
if(loanTransactionDTO.isLoanToLoanTransfer()){ if(loanTransactionDTO.isLoanToLoanTransfer()){
this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode,
FINANCIAL_ACTIVITY.ASSET_TRANSFER.getValue(), loanProductId, paymentTypeId, loanId, transactionId, FinancialActivity.ASSET_TRANSFER.getValue(), loanProductId, paymentTypeId, loanId, transactionId,
transactionDate, totalDebitAmount, isReversal); transactionDate, totalDebitAmount, isReversal);
} else if (loanTransactionDTO.isAccountTransfer()) { } else if (loanTransactionDTO.isAccountTransfer()) {
this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode,
FINANCIAL_ACTIVITY.LIABILITY_TRANSFER.getValue(), loanProductId, paymentTypeId, loanId, transactionId, FinancialActivity.LIABILITY_TRANSFER.getValue(), loanProductId, paymentTypeId, loanId, transactionId,
transactionDate, totalDebitAmount, isReversal); transactionDate, totalDebitAmount, isReversal);
} else { } else {
this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode,
ACCRUAL_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue(), loanProductId, paymentTypeId, loanId, transactionId, AccrualAccountsForLoan.FUND_SOURCE.getValue(), loanProductId, paymentTypeId, loanId, transactionId,
transactionDate, totalDebitAmount, isReversal); transactionDate, totalDebitAmount, isReversal);
} }
} }
@@ -338,7 +338,7 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId(); final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId();
this.helper.createAccrualBasedJournalEntriesAndReversalsForLoan(office, currencyCode, this.helper.createAccrualBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
ACCRUAL_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue(), ACCRUAL_ACCOUNTS_FOR_LOAN.INCOME_FROM_RECOVERY.getValue(), loanProductId, AccrualAccountsForLoan.FUND_SOURCE.getValue(), AccrualAccountsForLoan.INCOME_FROM_RECOVERY.getValue(), loanProductId,
paymentTypeId, loanId, transactionId, transactionDate, amount, isReversal); paymentTypeId, loanId, transactionId, transactionDate, amount, isReversal);
} }
@@ -378,20 +378,20 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
// create journal entries for recognizing interest (or reversal) // create journal entries for recognizing interest (or reversal)
if (interestAmount != null && !(interestAmount.compareTo(BigDecimal.ZERO) == 0)) { if (interestAmount != null && !(interestAmount.compareTo(BigDecimal.ZERO) == 0)) {
this.helper.createAccrualBasedJournalEntriesAndReversalsForLoan(office, currencyCode, this.helper.createAccrualBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
ACCRUAL_ACCOUNTS_FOR_LOAN.INTEREST_RECEIVABLE.getValue(), ACCRUAL_ACCOUNTS_FOR_LOAN.INTEREST_ON_LOANS.getValue(), AccrualAccountsForLoan.INTEREST_RECEIVABLE.getValue(), AccrualAccountsForLoan.INTEREST_ON_LOANS.getValue(),
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, interestAmount, isReversed); loanProductId, paymentTypeId, loanId, transactionId, transactionDate, interestAmount, isReversed);
} }
// 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)) {
this.helper.createAccrualBasedJournalEntriesAndReversalsForLoanCharges(office, currencyCode, this.helper.createAccrualBasedJournalEntriesAndReversalsForLoanCharges(office, currencyCode,
ACCRUAL_ACCOUNTS_FOR_LOAN.FEES_RECEIVABLE.getValue(), ACCRUAL_ACCOUNTS_FOR_LOAN.INCOME_FROM_FEES.getValue(), AccrualAccountsForLoan.FEES_RECEIVABLE.getValue(), AccrualAccountsForLoan.INCOME_FROM_FEES.getValue(),
loanProductId, loanId, transactionId, transactionDate, feesAmount, isReversed, loanTransactionDTO.getFeePayments()); loanProductId, loanId, transactionId, transactionDate, feesAmount, isReversed, loanTransactionDTO.getFeePayments());
} }
// create journal entries for the penalties application (or reversal) // create journal entries for the penalties application (or reversal)
if (penaltiesAmount != null && !(penaltiesAmount.compareTo(BigDecimal.ZERO) == 0)) { if (penaltiesAmount != null && !(penaltiesAmount.compareTo(BigDecimal.ZERO) == 0)) {
this.helper.createAccrualBasedJournalEntriesAndReversalsForLoanCharges(office, currencyCode, this.helper.createAccrualBasedJournalEntriesAndReversalsForLoanCharges(office, currencyCode,
ACCRUAL_ACCOUNTS_FOR_LOAN.PENALTIES_RECEIVABLE.getValue(), ACCRUAL_ACCOUNTS_FOR_LOAN.INCOME_FROM_PENALTIES.getValue(), AccrualAccountsForLoan.PENALTIES_RECEIVABLE.getValue(), AccrualAccountsForLoan.INCOME_FROM_PENALTIES.getValue(),
loanProductId, loanId, transactionId, transactionDate, penaltiesAmount, isReversed, loanProductId, loanId, transactionId, transactionDate, penaltiesAmount, isReversed,
loanTransactionDTO.getPenaltyPayments()); loanTransactionDTO.getPenaltyPayments());
} }
@@ -412,11 +412,11 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
if (loanTransactionDTO.isAccountTransfer()) { if (loanTransactionDTO.isAccountTransfer()) {
this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
CASH_ACCOUNTS_FOR_LOAN.OVERPAYMENT.getValue(), FINANCIAL_ACTIVITY.LIABILITY_TRANSFER.getValue(), loanProductId, CashAccountsForLoan.OVERPAYMENT.getValue(), FinancialActivity.LIABILITY_TRANSFER.getValue(), loanProductId,
paymentTypeId, loanId, transactionId, transactionDate, refundAmount, isReversal); paymentTypeId, loanId, transactionId, transactionDate, refundAmount, isReversal);
} else { } else {
this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
CASH_ACCOUNTS_FOR_LOAN.OVERPAYMENT.getValue(), CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue(), loanProductId, CashAccountsForLoan.OVERPAYMENT.getValue(), CashAccountsForLoan.FUND_SOURCE.getValue(), loanProductId,
paymentTypeId, loanId, transactionId, transactionDate, refundAmount, isReversal); paymentTypeId, loanId, transactionId, transactionDate, refundAmount, isReversal);
} }
} }
@@ -443,13 +443,13 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
if (principalAmount != null && !(principalAmount.compareTo(BigDecimal.ZERO) == 0)) { if (principalAmount != null && !(principalAmount.compareTo(BigDecimal.ZERO) == 0)) {
totalDebitAmount = totalDebitAmount.add(principalAmount); totalDebitAmount = totalDebitAmount.add(principalAmount);
this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO, this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, CashAccountsForLoan.LOAN_PORTFOLIO,
loanProductId, 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);
this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.INTEREST_ON_LOANS, this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, CashAccountsForLoan.INTEREST_ON_LOANS,
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, interestAmount, !isReversal); loanProductId, paymentTypeId, loanId, transactionId, transactionDate, interestAmount, !isReversal);
} }
@@ -464,7 +464,7 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
: chargePaymentDTO.getAmount())); : chargePaymentDTO.getAmount()));
} }
this.helper.createCreditJournalEntryOrReversalForLoanCharges(office, currencyCode, this.helper.createCreditJournalEntryOrReversalForLoanCharges(office, currencyCode,
CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_FEES.getValue(), loanProductId, loanId, transactionId, transactionDate, feesAmount, CashAccountsForLoan.INCOME_FROM_FEES.getValue(), loanProductId, loanId, transactionId, transactionDate, feesAmount,
!isReversal, chargePaymentDTOs); !isReversal, chargePaymentDTOs);
} }
@@ -479,18 +479,18 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
} }
this.helper.createCreditJournalEntryOrReversalForLoanCharges(office, currencyCode, this.helper.createCreditJournalEntryOrReversalForLoanCharges(office, currencyCode,
CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_PENALTIES.getValue(), loanProductId, loanId, transactionId, transactionDate, CashAccountsForLoan.INCOME_FROM_PENALTIES.getValue(), loanProductId, loanId, transactionId, transactionDate,
penaltiesAmount, !isReversal, chargePaymentDTOs); penaltiesAmount, !isReversal, chargePaymentDTOs);
} }
if (overPaymentAmount != null && !(overPaymentAmount.compareTo(BigDecimal.ZERO) == 0)) { if (overPaymentAmount != null && !(overPaymentAmount.compareTo(BigDecimal.ZERO) == 0)) {
totalDebitAmount = totalDebitAmount.add(overPaymentAmount); totalDebitAmount = totalDebitAmount.add(overPaymentAmount);
this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.OVERPAYMENT, loanProductId, this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, CashAccountsForLoan.OVERPAYMENT, loanProductId,
paymentTypeId, loanId, transactionId, transactionDate, overPaymentAmount, !isReversal); paymentTypeId, loanId, transactionId, transactionDate, overPaymentAmount, !isReversal);
} }
/*** create a single debit entry (or reversal) for the entire amount **/ /*** create a single debit entry (or reversal) for the entire amount **/
this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue(), this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, CashAccountsForLoan.FUND_SOURCE.getValue(),
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, totalDebitAmount, !isReversal); loanProductId, paymentTypeId, loanId, transactionId, transactionDate, totalDebitAmount, !isReversal);
} }
@@ -23,8 +23,8 @@ import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import org.apache.fineract.accounting.closure.domain.GLClosure; import org.apache.fineract.accounting.closure.domain.GLClosure;
import org.apache.fineract.accounting.common.AccountingConstants.CASH_ACCOUNTS_FOR_LOAN; import org.apache.fineract.accounting.common.AccountingConstants.CashAccountsForLoan;
import org.apache.fineract.accounting.common.AccountingConstants.FINANCIAL_ACTIVITY; import org.apache.fineract.accounting.common.AccountingConstants.FinancialActivity;
import org.apache.fineract.accounting.journalentry.data.ChargePaymentDTO; import org.apache.fineract.accounting.journalentry.data.ChargePaymentDTO;
import org.apache.fineract.accounting.journalentry.data.LoanDTO; import org.apache.fineract.accounting.journalentry.data.LoanDTO;
import org.apache.fineract.accounting.journalentry.data.LoanTransactionDTO; import org.apache.fineract.accounting.journalentry.data.LoanTransactionDTO;
@@ -90,7 +90,7 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
final BigDecimal principalAmount = loanTransactionDTO.getPrincipal(); final BigDecimal principalAmount = loanTransactionDTO.getPrincipal();
if (principalAmount != null && !(principalAmount.compareTo(BigDecimal.ZERO) == 0)) { if (principalAmount != null && !(principalAmount.compareTo(BigDecimal.ZERO) == 0)) {
this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
CASH_ACCOUNTS_FOR_LOAN.LOSSES_WRITTEN_OFF.getValue(), CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO.getValue(), CashAccountsForLoan.LOSSES_WRITTEN_OFF.getValue(), CashAccountsForLoan.LOAN_PORTFOLIO.getValue(),
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, principalAmount, loanProductId, paymentTypeId, loanId, transactionId, transactionDate, principalAmount,
loanTransactionDTO.isReversed()); loanTransactionDTO.isReversed());
@@ -133,15 +133,15 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId(); final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId();
if(loanTransactionDTO.isLoanToLoanTransfer()){ if(loanTransactionDTO.isLoanToLoanTransfer()){
this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO.getValue(), FINANCIAL_ACTIVITY.ASSET_TRANSFER.getValue(), loanProductId, CashAccountsForLoan.LOAN_PORTFOLIO.getValue(), FinancialActivity.ASSET_TRANSFER.getValue(), loanProductId,
paymentTypeId, loanId, transactionId, transactionDate, disbursalAmount, isReversal); paymentTypeId, loanId, transactionId, transactionDate, disbursalAmount, isReversal);
} else if (loanTransactionDTO.isAccountTransfer()) { } else if (loanTransactionDTO.isAccountTransfer()) {
this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO.getValue(), FINANCIAL_ACTIVITY.LIABILITY_TRANSFER.getValue(), loanProductId, CashAccountsForLoan.LOAN_PORTFOLIO.getValue(), FinancialActivity.LIABILITY_TRANSFER.getValue(), loanProductId,
paymentTypeId, loanId, transactionId, transactionDate, disbursalAmount, isReversal); paymentTypeId, loanId, transactionId, transactionDate, disbursalAmount, isReversal);
} else { } else {
this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO.getValue(), CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue(), loanProductId, CashAccountsForLoan.LOAN_PORTFOLIO.getValue(), CashAccountsForLoan.FUND_SOURCE.getValue(), loanProductId,
paymentTypeId, loanId, transactionId, transactionDate, disbursalAmount, isReversal); paymentTypeId, loanId, transactionId, transactionDate, disbursalAmount, isReversal);
} }
@@ -173,11 +173,11 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
if (loanTransactionDTO.isAccountTransfer()) { if (loanTransactionDTO.isAccountTransfer()) {
this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
CASH_ACCOUNTS_FOR_LOAN.OVERPAYMENT.getValue(), FINANCIAL_ACTIVITY.LIABILITY_TRANSFER.getValue(), loanProductId, CashAccountsForLoan.OVERPAYMENT.getValue(), FinancialActivity.LIABILITY_TRANSFER.getValue(), loanProductId,
paymentTypeId, loanId, transactionId, transactionDate, refundAmount, isReversal); paymentTypeId, loanId, transactionId, transactionDate, refundAmount, isReversal);
} else { } else {
this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
CASH_ACCOUNTS_FOR_LOAN.OVERPAYMENT.getValue(), CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue(), loanProductId, CashAccountsForLoan.OVERPAYMENT.getValue(), CashAccountsForLoan.FUND_SOURCE.getValue(), loanProductId,
paymentTypeId, loanId, transactionId, transactionDate, refundAmount, isReversal); paymentTypeId, loanId, transactionId, transactionDate, refundAmount, isReversal);
} }
} }
@@ -212,45 +212,45 @@ 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);
this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO, this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, CashAccountsForLoan.LOAN_PORTFOLIO,
loanProductId, 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);
this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.INTEREST_ON_LOANS, this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, CashAccountsForLoan.INTEREST_ON_LOANS,
loanProductId, 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);
this.helper.createCreditJournalEntryOrReversalForLoanCharges(office, currencyCode, this.helper.createCreditJournalEntryOrReversalForLoanCharges(office, currencyCode,
CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_FEES.getValue(), loanProductId, loanId, transactionId, transactionDate, feesAmount, CashAccountsForLoan.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);
this.helper.createCreditJournalEntryOrReversalForLoanCharges(office, currencyCode, this.helper.createCreditJournalEntryOrReversalForLoanCharges(office, currencyCode,
CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_PENALTIES.getValue(), loanProductId, loanId, transactionId, transactionDate, CashAccountsForLoan.INCOME_FROM_PENALTIES.getValue(), loanProductId, loanId, transactionId, transactionDate,
penaltiesAmount, isReversal, loanTransactionDTO.getPenaltyPayments()); penaltiesAmount, isReversal, loanTransactionDTO.getPenaltyPayments());
} }
if (overPaymentAmount != null && !(overPaymentAmount.compareTo(BigDecimal.ZERO) == 0)) { if (overPaymentAmount != null && !(overPaymentAmount.compareTo(BigDecimal.ZERO) == 0)) {
totalDebitAmount = totalDebitAmount.add(overPaymentAmount); totalDebitAmount = totalDebitAmount.add(overPaymentAmount);
this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.OVERPAYMENT, loanProductId, this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, CashAccountsForLoan.OVERPAYMENT, loanProductId,
paymentTypeId, loanId, transactionId, transactionDate, overPaymentAmount, isReversal); paymentTypeId, loanId, transactionId, transactionDate, overPaymentAmount, isReversal);
} }
/*** create a single debit entry (or reversal) for the entire amount **/ /*** create a single debit entry (or reversal) for the entire amount **/
if(loanTransactionDTO.isLoanToLoanTransfer()){ if(loanTransactionDTO.isLoanToLoanTransfer()){
this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, FINANCIAL_ACTIVITY.ASSET_TRANSFER.getValue(), this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, FinancialActivity.ASSET_TRANSFER.getValue(),
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, totalDebitAmount, isReversal); loanProductId, paymentTypeId, loanId, transactionId, transactionDate, totalDebitAmount, isReversal);
} else if (loanTransactionDTO.isAccountTransfer()) { } else if (loanTransactionDTO.isAccountTransfer()) {
this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, FINANCIAL_ACTIVITY.LIABILITY_TRANSFER.getValue(), this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, FinancialActivity.LIABILITY_TRANSFER.getValue(),
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, totalDebitAmount, isReversal); loanProductId, paymentTypeId, loanId, transactionId, transactionDate, totalDebitAmount, isReversal);
} else { } else {
this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue(), this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, CashAccountsForLoan.FUND_SOURCE.getValue(),
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, totalDebitAmount, isReversal); loanProductId, paymentTypeId, loanId, transactionId, transactionDate, totalDebitAmount, isReversal);
} }
} }
@@ -276,8 +276,8 @@ 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();
this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue(), this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode, CashAccountsForLoan.FUND_SOURCE.getValue(),
CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_RECOVERY.getValue(), loanProductId, paymentTypeId, loanId, transactionId, CashAccountsForLoan.INCOME_FROM_RECOVERY.getValue(), loanProductId, paymentTypeId, loanId, transactionId,
transactionDate, amount, isReversal); transactionDate, amount, isReversal);
} }
@@ -310,12 +310,12 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
if (loanTransactionDTO.getTransactionType().isInitiateTransfer()) { if (loanTransactionDTO.getTransactionType().isInitiateTransfer()) {
this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
CASH_ACCOUNTS_FOR_LOAN.TRANSFERS_SUSPENSE.getValue(), CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO.getValue(), loanProductId, CashAccountsForLoan.TRANSFERS_SUSPENSE.getValue(), CashAccountsForLoan.LOAN_PORTFOLIO.getValue(), loanProductId,
null, loanId, transactionId, transactionDate, principalAmount, isReversal); null, loanId, transactionId, transactionDate, principalAmount, isReversal);
} else if (loanTransactionDTO.getTransactionType().isApproveTransfer() } else if (loanTransactionDTO.getTransactionType().isApproveTransfer()
|| loanTransactionDTO.getTransactionType().isWithdrawTransfer()) { || loanTransactionDTO.getTransactionType().isWithdrawTransfer()) {
this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO.getValue(), CASH_ACCOUNTS_FOR_LOAN.TRANSFERS_SUSPENSE.getValue(), loanProductId, CashAccountsForLoan.LOAN_PORTFOLIO.getValue(), CashAccountsForLoan.TRANSFERS_SUSPENSE.getValue(), loanProductId,
null, loanId, transactionId, transactionDate, principalAmount, isReversal); null, loanId, transactionId, transactionDate, principalAmount, isReversal);
} }
} }
@@ -341,13 +341,13 @@ 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);
this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO, this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, CashAccountsForLoan.LOAN_PORTFOLIO,
loanProductId, 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);
this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.INTEREST_ON_LOANS, this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, CashAccountsForLoan.INTEREST_ON_LOANS,
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, interestAmount, !isReversal); loanProductId, paymentTypeId, loanId, transactionId, transactionDate, interestAmount, !isReversal);
} }
@@ -361,7 +361,7 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
chargePaymentDTO.getAmount().floatValue() < 0 ? chargePaymentDTO.getAmount().multiply(new BigDecimal(-1)):chargePaymentDTO.getAmount() )); chargePaymentDTO.getAmount().floatValue() < 0 ? chargePaymentDTO.getAmount().multiply(new BigDecimal(-1)):chargePaymentDTO.getAmount() ));
} }
this.helper.createCreditJournalEntryOrReversalForLoanCharges(office, currencyCode, this.helper.createCreditJournalEntryOrReversalForLoanCharges(office, currencyCode,
CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_FEES.getValue(), loanProductId, loanId, transactionId, transactionDate, feesAmount, CashAccountsForLoan.INCOME_FROM_FEES.getValue(), loanProductId, loanId, transactionId, transactionDate, feesAmount,
!isReversal, chargePaymentDTOs); !isReversal, chargePaymentDTOs);
} }
@@ -375,18 +375,18 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
} }
this.helper.createCreditJournalEntryOrReversalForLoanCharges(office, currencyCode, this.helper.createCreditJournalEntryOrReversalForLoanCharges(office, currencyCode,
CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_PENALTIES.getValue(), loanProductId, loanId, transactionId, transactionDate, CashAccountsForLoan.INCOME_FROM_PENALTIES.getValue(), loanProductId, loanId, transactionId, transactionDate,
penaltiesAmount, !isReversal, chargePaymentDTOs); penaltiesAmount, !isReversal, chargePaymentDTOs);
} }
if (overPaymentAmount != null && !(overPaymentAmount.compareTo(BigDecimal.ZERO) == 0)) { if (overPaymentAmount != null && !(overPaymentAmount.compareTo(BigDecimal.ZERO) == 0)) {
totalDebitAmount = totalDebitAmount.add(overPaymentAmount); totalDebitAmount = totalDebitAmount.add(overPaymentAmount);
this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.OVERPAYMENT, loanProductId, this.helper.createCreditJournalEntryOrReversalForLoan(office, currencyCode, CashAccountsForLoan.OVERPAYMENT, loanProductId,
paymentTypeId, loanId, transactionId, transactionDate, overPaymentAmount, !isReversal); paymentTypeId, loanId, transactionId, transactionDate, overPaymentAmount, !isReversal);
} }
/*** create a single debit entry (or reversal) for the entire amount **/ /*** create a single debit entry (or reversal) for the entire amount **/
this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue(), loanProductId, this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, CashAccountsForLoan.FUND_SOURCE.getValue(), loanProductId,
paymentTypeId, loanId, transactionId, transactionDate, totalDebitAmount, !isReversal); paymentTypeId, loanId, transactionId, transactionDate, totalDebitAmount, !isReversal);
} }
@@ -22,8 +22,8 @@ import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import org.apache.fineract.accounting.closure.domain.GLClosure; import org.apache.fineract.accounting.closure.domain.GLClosure;
import org.apache.fineract.accounting.common.AccountingConstants.CASH_ACCOUNTS_FOR_SAVINGS; import org.apache.fineract.accounting.common.AccountingConstants.CashAccountsForSavings;
import org.apache.fineract.accounting.common.AccountingConstants.FINANCIAL_ACTIVITY; import org.apache.fineract.accounting.common.AccountingConstants.FinancialActivity;
import org.apache.fineract.accounting.journalentry.data.ChargePaymentDTO; import org.apache.fineract.accounting.journalentry.data.ChargePaymentDTO;
import org.apache.fineract.accounting.journalentry.data.SavingsDTO; import org.apache.fineract.accounting.journalentry.data.SavingsDTO;
import org.apache.fineract.accounting.journalentry.data.SavingsTransactionDTO; import org.apache.fineract.accounting.journalentry.data.SavingsTransactionDTO;
@@ -63,48 +63,48 @@ public class CashBasedAccountingProcessorForSavings implements AccountingProcess
if (savingsTransactionDTO.getTransactionType().isWithdrawal() && savingsTransactionDTO.isOverdraftTransaction()) { if (savingsTransactionDTO.getTransactionType().isWithdrawal() && savingsTransactionDTO.isOverdraftTransaction()) {
if (savingsTransactionDTO.isAccountTransfer()) { if (savingsTransactionDTO.isAccountTransfer()) {
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
CASH_ACCOUNTS_FOR_SAVINGS.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(),
FINANCIAL_ACTIVITY.LIABILITY_TRANSFER.getValue(), savingsProductId, paymentTypeId, savingsId, transactionId, FinancialActivity.LIABILITY_TRANSFER.getValue(), savingsProductId, paymentTypeId, savingsId, transactionId,
transactionDate, overdraftAmount, isReversal); transactionDate, overdraftAmount, isReversal);
if (amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) == 1) { if (amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) == 1) {
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL.getValue(), FINANCIAL_ACTIVITY.LIABILITY_TRANSFER.getValue(), CashAccountsForSavings.SAVINGS_CONTROL.getValue(), FinancialActivity.LIABILITY_TRANSFER.getValue(),
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate,
amount.subtract(overdraftAmount), isReversal); amount.subtract(overdraftAmount), isReversal);
} }
} else { } else {
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
CASH_ACCOUNTS_FOR_SAVINGS.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(),
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_REFERENCE.getValue(), savingsProductId, paymentTypeId, savingsId, CashAccountsForSavings.SAVINGS_REFERENCE.getValue(), savingsProductId, paymentTypeId, savingsId,
transactionId, transactionDate, overdraftAmount, isReversal); transactionId, transactionDate, overdraftAmount, isReversal);
if (amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) == 1) { if (amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) == 1) {
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL.getValue(), CashAccountsForSavings.SAVINGS_CONTROL.getValue(),
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_REFERENCE.getValue(), savingsProductId, paymentTypeId, savingsId, CashAccountsForSavings.SAVINGS_REFERENCE.getValue(), savingsProductId, paymentTypeId, savingsId,
transactionId, transactionDate, amount.subtract(overdraftAmount), isReversal); transactionId, transactionDate, amount.subtract(overdraftAmount), isReversal);
} }
} }
} else if (savingsTransactionDTO.getTransactionType().isDeposit() && savingsTransactionDTO.isOverdraftTransaction()) { } else if (savingsTransactionDTO.getTransactionType().isDeposit() && savingsTransactionDTO.isOverdraftTransaction()) {
if (savingsTransactionDTO.isAccountTransfer()) { if (savingsTransactionDTO.isAccountTransfer()) {
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
FINANCIAL_ACTIVITY.LIABILITY_TRANSFER.getValue(), FinancialActivity.LIABILITY_TRANSFER.getValue(),
CASH_ACCOUNTS_FOR_SAVINGS.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId, CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId,
transactionId, transactionDate, overdraftAmount, isReversal); transactionId, transactionDate, overdraftAmount, isReversal);
if (amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) == 1) { if (amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) == 1) {
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
FINANCIAL_ACTIVITY.LIABILITY_TRANSFER.getValue(), CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL.getValue(), FinancialActivity.LIABILITY_TRANSFER.getValue(), CashAccountsForSavings.SAVINGS_CONTROL.getValue(),
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate,
amount.subtract(overdraftAmount), isReversal); amount.subtract(overdraftAmount), isReversal);
} }
} else { } else {
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_REFERENCE.getValue(), CashAccountsForSavings.SAVINGS_REFERENCE.getValue(),
CASH_ACCOUNTS_FOR_SAVINGS.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId, CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId,
transactionId, transactionDate, overdraftAmount, isReversal); transactionId, transactionDate, overdraftAmount, isReversal);
if (amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) == 1) { if (amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) == 1) {
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_REFERENCE.getValue(), CashAccountsForSavings.SAVINGS_REFERENCE.getValue(),
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId, CashAccountsForSavings.SAVINGS_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId,
transactionId, transactionDate, amount.subtract(overdraftAmount), isReversal); transactionId, transactionDate, amount.subtract(overdraftAmount), isReversal);
} }
} }
@@ -114,11 +114,11 @@ public class CashBasedAccountingProcessorForSavings implements AccountingProcess
else if (savingsTransactionDTO.getTransactionType().isDeposit()) { else if (savingsTransactionDTO.getTransactionType().isDeposit()) {
if (savingsTransactionDTO.isAccountTransfer()) { if (savingsTransactionDTO.isAccountTransfer()) {
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
FINANCIAL_ACTIVITY.LIABILITY_TRANSFER.getValue(), CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL.getValue(), FinancialActivity.LIABILITY_TRANSFER.getValue(), CashAccountsForSavings.SAVINGS_CONTROL.getValue(),
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal); savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
} else { } else {
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_REFERENCE.getValue(), CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL.getValue(), CashAccountsForSavings.SAVINGS_REFERENCE.getValue(), CashAccountsForSavings.SAVINGS_CONTROL.getValue(),
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal); savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
} }
} }
@@ -126,25 +126,25 @@ public class CashBasedAccountingProcessorForSavings implements AccountingProcess
/** Handle Deposits and reversals of Dividend pay outs **/ /** Handle Deposits and reversals of Dividend pay outs **/
else if (savingsTransactionDTO.getTransactionType().isDividendPayout()) { else if (savingsTransactionDTO.getTransactionType().isDividendPayout()) {
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
FINANCIAL_ACTIVITY.PAYABLE_DIVIDENDS.getValue(), CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL.getValue(), FinancialActivity.PAYABLE_DIVIDENDS.getValue(), CashAccountsForSavings.SAVINGS_CONTROL.getValue(),
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal); savingsProductId, 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()) {
if (savingsTransactionDTO.isAccountTransfer()) { if (savingsTransactionDTO.isAccountTransfer()) {
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL.getValue(), FINANCIAL_ACTIVITY.LIABILITY_TRANSFER.getValue(), CashAccountsForSavings.SAVINGS_CONTROL.getValue(), FinancialActivity.LIABILITY_TRANSFER.getValue(),
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal); savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
} else { } else {
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL.getValue(), CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_REFERENCE.getValue(), CashAccountsForSavings.SAVINGS_CONTROL.getValue(), CashAccountsForSavings.SAVINGS_REFERENCE.getValue(),
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal); savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
} }
} }
else if (savingsTransactionDTO.getTransactionType().isEscheat()) { else if (savingsTransactionDTO.getTransactionType().isEscheat()) {
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL.getValue(), CASH_ACCOUNTS_FOR_SAVINGS.ESCHEAT_LIABILITY.getValue(), CashAccountsForSavings.SAVINGS_CONTROL.getValue(), CashAccountsForSavings.ESCHEAT_LIABILITY.getValue(),
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal); savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
} }
/** /**
@@ -156,13 +156,13 @@ public class CashBasedAccountingProcessorForSavings implements AccountingProcess
// zero // zero
if (savingsTransactionDTO.getAmount().compareTo(BigDecimal.ZERO) == 1) { if (savingsTransactionDTO.getAmount().compareTo(BigDecimal.ZERO) == 1) {
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
CASH_ACCOUNTS_FOR_SAVINGS.INTEREST_ON_SAVINGS.getValue(), CashAccountsForSavings.INTEREST_ON_SAVINGS.getValue(),
CASH_ACCOUNTS_FOR_SAVINGS.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId, CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId,
transactionId, transactionDate, overdraftAmount, isReversal); transactionId, transactionDate, overdraftAmount, isReversal);
if (amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) == 1) { if (amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) == 1) {
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
CASH_ACCOUNTS_FOR_SAVINGS.INTEREST_ON_SAVINGS.getValue(), CashAccountsForSavings.INTEREST_ON_SAVINGS.getValue(),
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId, CashAccountsForSavings.SAVINGS_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId,
transactionId, transactionDate, amount.subtract(overdraftAmount), isReversal); transactionId, transactionDate, amount.subtract(overdraftAmount), isReversal);
} }
} }
@@ -173,14 +173,14 @@ public class CashBasedAccountingProcessorForSavings implements AccountingProcess
// zero // zero
if (savingsTransactionDTO.getAmount().compareTo(BigDecimal.ZERO) == 1) { if (savingsTransactionDTO.getAmount().compareTo(BigDecimal.ZERO) == 1) {
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
CASH_ACCOUNTS_FOR_SAVINGS.INTEREST_ON_SAVINGS.getValue(), CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL.getValue(), CashAccountsForSavings.INTEREST_ON_SAVINGS.getValue(), CashAccountsForSavings.SAVINGS_CONTROL.getValue(),
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal); savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
} }
} }
else if (savingsTransactionDTO.getTransactionType().isWithholdTax()) { else if (savingsTransactionDTO.getTransactionType().isWithholdTax()) {
this.helper.createCashBasedJournalEntriesAndReversalsForSavingsTax(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForSavingsTax(office, currencyCode,
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL, CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_REFERENCE, savingsProductId, CashAccountsForSavings.SAVINGS_CONTROL, CashAccountsForSavings.SAVINGS_REFERENCE, savingsProductId,
paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal,
savingsTransactionDTO.getTaxPayments()); savingsTransactionDTO.getTaxPayments());
} }
@@ -190,23 +190,23 @@ public class CashBasedAccountingProcessorForSavings implements AccountingProcess
// Is the Charge a penalty? // Is the Charge a penalty?
if (penaltyPayments.size() > 0) { if (penaltyPayments.size() > 0) {
this.helper.createCashBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode,
CASH_ACCOUNTS_FOR_SAVINGS.OVERDRAFT_PORTFOLIO_CONTROL, CASH_ACCOUNTS_FOR_SAVINGS.INCOME_FROM_PENALTIES, CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL, CashAccountsForSavings.INCOME_FROM_PENALTIES,
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, overdraftAmount, isReversal, savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, overdraftAmount, isReversal,
penaltyPayments); penaltyPayments);
if (amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) == 1) { if (amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) == 1) {
this.helper.createCashBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode,
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL, CASH_ACCOUNTS_FOR_SAVINGS.INCOME_FROM_PENALTIES, CashAccountsForSavings.SAVINGS_CONTROL, CashAccountsForSavings.INCOME_FROM_PENALTIES,
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate,
amount.subtract(overdraftAmount), isReversal, penaltyPayments); amount.subtract(overdraftAmount), isReversal, penaltyPayments);
} }
} else { } else {
this.helper.createCashBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode,
CASH_ACCOUNTS_FOR_SAVINGS.OVERDRAFT_PORTFOLIO_CONTROL, CASH_ACCOUNTS_FOR_SAVINGS.INCOME_FROM_FEES, CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL, CashAccountsForSavings.INCOME_FROM_FEES,
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, overdraftAmount, isReversal, savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, overdraftAmount, isReversal,
feePayments); feePayments);
if (amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) == 1) { if (amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) == 1) {
this.helper.createCashBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode,
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL, CASH_ACCOUNTS_FOR_SAVINGS.INCOME_FROM_FEES, savingsProductId, CashAccountsForSavings.SAVINGS_CONTROL, CashAccountsForSavings.INCOME_FROM_FEES, savingsProductId,
paymentTypeId, savingsId, transactionId, transactionDate, amount.subtract(overdraftAmount), isReversal, paymentTypeId, savingsId, transactionId, transactionDate, amount.subtract(overdraftAmount), isReversal,
feePayments); feePayments);
} }
@@ -217,11 +217,11 @@ public class CashBasedAccountingProcessorForSavings implements AccountingProcess
// Is the Charge a penalty? // Is the Charge a penalty?
if (penaltyPayments.size() > 0) { if (penaltyPayments.size() > 0) {
this.helper.createCashBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode,
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL, CASH_ACCOUNTS_FOR_SAVINGS.INCOME_FROM_PENALTIES, savingsProductId, CashAccountsForSavings.SAVINGS_CONTROL, CashAccountsForSavings.INCOME_FROM_PENALTIES, savingsProductId,
paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal, penaltyPayments); paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal, penaltyPayments);
} else { } else {
this.helper.createCashBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode,
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL, CASH_ACCOUNTS_FOR_SAVINGS.INCOME_FROM_FEES, savingsProductId, CashAccountsForSavings.SAVINGS_CONTROL, CashAccountsForSavings.INCOME_FROM_FEES, savingsProductId,
paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal, feePayments); paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal, feePayments);
} }
} }
@@ -229,7 +229,7 @@ public class CashBasedAccountingProcessorForSavings implements AccountingProcess
/** Handle Transfers proposal **/ /** Handle Transfers proposal **/
else if (savingsTransactionDTO.getTransactionType().isInitiateTransfer()) { else if (savingsTransactionDTO.getTransactionType().isInitiateTransfer()) {
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL.getValue(), CASH_ACCOUNTS_FOR_SAVINGS.TRANSFERS_SUSPENSE.getValue(), CashAccountsForSavings.SAVINGS_CONTROL.getValue(), CashAccountsForSavings.TRANSFERS_SUSPENSE.getValue(),
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal); savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
} }
@@ -237,23 +237,23 @@ public class CashBasedAccountingProcessorForSavings implements AccountingProcess
else if (savingsTransactionDTO.getTransactionType().isWithdrawTransfer() else if (savingsTransactionDTO.getTransactionType().isWithdrawTransfer()
|| savingsTransactionDTO.getTransactionType().isApproveTransfer()) { || savingsTransactionDTO.getTransactionType().isApproveTransfer()) {
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
CASH_ACCOUNTS_FOR_SAVINGS.TRANSFERS_SUSPENSE.getValue(), CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL.getValue(), CashAccountsForSavings.TRANSFERS_SUSPENSE.getValue(), CashAccountsForSavings.SAVINGS_CONTROL.getValue(),
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal); savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
} }
/** overdraft **/ /** overdraft **/
else if (savingsTransactionDTO.getTransactionType().isOverdraftInterest()) { else if (savingsTransactionDTO.getTransactionType().isOverdraftInterest()) {
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_REFERENCE.getValue(), CASH_ACCOUNTS_FOR_SAVINGS.INCOME_FROM_INTEREST.getValue(), CashAccountsForSavings.SAVINGS_REFERENCE.getValue(), CashAccountsForSavings.INCOME_FROM_INTEREST.getValue(),
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal); savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
} else if (savingsTransactionDTO.getTransactionType().isWrittenoff()) { } else if (savingsTransactionDTO.getTransactionType().isWrittenoff()) {
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
CASH_ACCOUNTS_FOR_SAVINGS.LOSSES_WRITTEN_OFF.getValue(), CashAccountsForSavings.LOSSES_WRITTEN_OFF.getValue(),
CASH_ACCOUNTS_FOR_SAVINGS.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId, CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId,
transactionId, transactionDate, amount, isReversal); transactionId, transactionDate, amount, isReversal);
} else if (savingsTransactionDTO.getTransactionType().isOverdraftFee()) { } else if (savingsTransactionDTO.getTransactionType().isOverdraftFee()) {
this.helper.createCashBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode, this.helper.createCashBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode,
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_REFERENCE, CASH_ACCOUNTS_FOR_SAVINGS.INCOME_FROM_FEES, savingsProductId, CashAccountsForSavings.SAVINGS_REFERENCE, CashAccountsForSavings.INCOME_FROM_FEES, savingsProductId,
paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal, feePayments); paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal, feePayments);
} }
} }
@@ -22,7 +22,7 @@ import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import org.apache.fineract.accounting.closure.domain.GLClosure; import org.apache.fineract.accounting.closure.domain.GLClosure;
import org.apache.fineract.accounting.common.AccountingConstants.CASH_ACCOUNTS_FOR_SHARES; import org.apache.fineract.accounting.common.AccountingConstants.CashAccountsForShares;
import org.apache.fineract.accounting.journalentry.data.ChargePaymentDTO; import org.apache.fineract.accounting.journalentry.data.ChargePaymentDTO;
import org.apache.fineract.accounting.journalentry.data.SharesDTO; import org.apache.fineract.accounting.journalentry.data.SharesDTO;
import org.apache.fineract.accounting.journalentry.data.SharesTransactionDTO; import org.apache.fineract.accounting.journalentry.data.SharesTransactionDTO;
@@ -65,8 +65,8 @@ public class CashBasedAccountingProcessorForShares implements AccountingProcesso
paymentTypeId, amount, chargeAmount, feePayments); paymentTypeId, amount, chargeAmount, feePayments);
} else if (transactionDTO.getTransactionType().isChargePayment()) { } else if (transactionDTO.getTransactionType().isChargePayment()) {
this.helper.createCashBasedJournalEntriesForSharesCharges(office, currencyCode, CASH_ACCOUNTS_FOR_SHARES.SHARES_REFERENCE, this.helper.createCashBasedJournalEntriesForSharesCharges(office, currencyCode, CashAccountsForShares.SHARES_REFERENCE,
CASH_ACCOUNTS_FOR_SHARES.INCOME_FROM_FEES, shareProductId, paymentTypeId, shareAccountId, transactionId, CashAccountsForShares.INCOME_FROM_FEES, shareProductId, paymentTypeId, shareAccountId, transactionId,
transactionDate, amount, feePayments); transactionDate, amount, feePayments);
} }
} }
@@ -77,15 +77,15 @@ public class CashBasedAccountingProcessorForShares implements AccountingProcesso
final Date transactionDate, final String transactionId, final Office office, final Long paymentTypeId, final BigDecimal amount, final Date transactionDate, final String transactionId, final Office office, final Long paymentTypeId, final BigDecimal amount,
final BigDecimal chargeAmount, final List<ChargePaymentDTO> feePayments) { final BigDecimal chargeAmount, final List<ChargePaymentDTO> feePayments) {
if (chargeAmount == null || chargeAmount.compareTo(BigDecimal.ZERO) != 1) { if (chargeAmount == null || chargeAmount.compareTo(BigDecimal.ZERO) != 1) {
this.helper.createJournalEntriesForShares(office, currencyCode, CASH_ACCOUNTS_FOR_SHARES.SHARES_EQUITY.getValue(), this.helper.createJournalEntriesForShares(office, currencyCode, CashAccountsForShares.SHARES_EQUITY.getValue(),
CASH_ACCOUNTS_FOR_SHARES.SHARES_REFERENCE.getValue(), shareProductId, paymentTypeId, shareAccountId, transactionId, CashAccountsForShares.SHARES_REFERENCE.getValue(), shareProductId, paymentTypeId, shareAccountId, transactionId,
transactionDate, amount); transactionDate, amount);
} else { } else {
this.helper.createDebitJournalEntryForShares(office, currencyCode, CASH_ACCOUNTS_FOR_SHARES.SHARES_EQUITY.getValue(), this.helper.createDebitJournalEntryForShares(office, currencyCode, CashAccountsForShares.SHARES_EQUITY.getValue(),
shareProductId, paymentTypeId, shareAccountId, transactionId, transactionDate, amount.add(chargeAmount)); shareProductId, paymentTypeId, shareAccountId, transactionId, transactionDate, amount.add(chargeAmount));
this.helper.createCreditJournalEntryForShares(office, currencyCode, CASH_ACCOUNTS_FOR_SHARES.SHARES_REFERENCE.getValue(), this.helper.createCreditJournalEntryForShares(office, currencyCode, CashAccountsForShares.SHARES_REFERENCE.getValue(),
shareProductId, paymentTypeId, shareAccountId, transactionId, transactionDate, amount); shareProductId, paymentTypeId, shareAccountId, transactionId, transactionDate, amount);
this.helper.createCashBasedJournalEntryForSharesCharges(office, currencyCode, CASH_ACCOUNTS_FOR_SHARES.INCOME_FROM_FEES, this.helper.createCashBasedJournalEntryForSharesCharges(office, currencyCode, CashAccountsForShares.INCOME_FROM_FEES,
shareProductId, shareAccountId, transactionId, transactionDate, chargeAmount, feePayments); shareProductId, shareAccountId, transactionId, transactionDate, chargeAmount, feePayments);
} }
} }
@@ -95,15 +95,15 @@ public class CashBasedAccountingProcessorForShares implements AccountingProcesso
final Long paymentTypeId, final BigDecimal amount, final BigDecimal chargeAmount, final List<ChargePaymentDTO> feePayments) { final Long paymentTypeId, final BigDecimal amount, final BigDecimal chargeAmount, final List<ChargePaymentDTO> feePayments) {
if (transactionDTO.getTransactionStatus().isApplied()) { if (transactionDTO.getTransactionStatus().isApplied()) {
if (chargeAmount == null || chargeAmount.compareTo(BigDecimal.ZERO) != 1) { if (chargeAmount == null || chargeAmount.compareTo(BigDecimal.ZERO) != 1) {
this.helper.createJournalEntriesForShares(office, currencyCode, CASH_ACCOUNTS_FOR_SHARES.SHARES_REFERENCE.getValue(), this.helper.createJournalEntriesForShares(office, currencyCode, CashAccountsForShares.SHARES_REFERENCE.getValue(),
CASH_ACCOUNTS_FOR_SHARES.SHARES_SUSPENSE.getValue(), shareProductId, paymentTypeId, shareAccountId, transactionId, CashAccountsForShares.SHARES_SUSPENSE.getValue(), shareProductId, paymentTypeId, shareAccountId, transactionId,
transactionDate, amount); transactionDate, amount);
} else { } else {
this.helper.createDebitJournalEntryForShares(office, currencyCode, CASH_ACCOUNTS_FOR_SHARES.SHARES_REFERENCE.getValue(), this.helper.createDebitJournalEntryForShares(office, currencyCode, CashAccountsForShares.SHARES_REFERENCE.getValue(),
shareProductId, paymentTypeId, shareAccountId, transactionId, transactionDate, amount); shareProductId, paymentTypeId, shareAccountId, transactionId, transactionDate, amount);
this.helper.createCreditJournalEntryForShares(office, currencyCode, CASH_ACCOUNTS_FOR_SHARES.SHARES_SUSPENSE.getValue(), this.helper.createCreditJournalEntryForShares(office, currencyCode, CashAccountsForShares.SHARES_SUSPENSE.getValue(),
shareProductId, paymentTypeId, shareAccountId, transactionId, transactionDate, amount.subtract(chargeAmount)); shareProductId, paymentTypeId, shareAccountId, transactionId, transactionDate, amount.subtract(chargeAmount));
this.helper.createCashBasedJournalEntryForSharesCharges(office, currencyCode, CASH_ACCOUNTS_FOR_SHARES.INCOME_FROM_FEES, this.helper.createCashBasedJournalEntryForSharesCharges(office, currencyCode, CashAccountsForShares.INCOME_FROM_FEES,
shareProductId, shareAccountId, transactionId, transactionDate, chargeAmount, feePayments); shareProductId, shareAccountId, transactionId, transactionDate, chargeAmount, feePayments);
} }
} else if (transactionDTO.getTransactionStatus().isApproved()) { } else if (transactionDTO.getTransactionStatus().isApproved()) {
@@ -111,21 +111,21 @@ public class CashBasedAccountingProcessorForShares implements AccountingProcesso
if (chargeAmount != null && chargeAmount.compareTo(BigDecimal.ZERO) == 1) { if (chargeAmount != null && chargeAmount.compareTo(BigDecimal.ZERO) == 1) {
amountForJE = amount.subtract(chargeAmount); amountForJE = amount.subtract(chargeAmount);
} }
this.helper.createJournalEntriesForShares(office, currencyCode, CASH_ACCOUNTS_FOR_SHARES.SHARES_SUSPENSE.getValue(), this.helper.createJournalEntriesForShares(office, currencyCode, CashAccountsForShares.SHARES_SUSPENSE.getValue(),
CASH_ACCOUNTS_FOR_SHARES.SHARES_EQUITY.getValue(), shareProductId, paymentTypeId, shareAccountId, transactionId, CashAccountsForShares.SHARES_EQUITY.getValue(), shareProductId, paymentTypeId, shareAccountId, transactionId,
transactionDate, amountForJE); transactionDate, amountForJE);
} else if (transactionDTO.getTransactionStatus().isRejected()) { } else if (transactionDTO.getTransactionStatus().isRejected()) {
if (chargeAmount != null && chargeAmount.compareTo(BigDecimal.ZERO) == 1) { if (chargeAmount != null && chargeAmount.compareTo(BigDecimal.ZERO) == 1) {
this.helper.revertCashBasedJournalEntryForSharesCharges(office, currencyCode, CASH_ACCOUNTS_FOR_SHARES.INCOME_FROM_FEES, this.helper.revertCashBasedJournalEntryForSharesCharges(office, currencyCode, CashAccountsForShares.INCOME_FROM_FEES,
shareProductId, shareAccountId, transactionId, transactionDate, chargeAmount, feePayments); shareProductId, shareAccountId, transactionId, transactionDate, chargeAmount, feePayments);
this.helper.createDebitJournalEntryForShares(office, currencyCode, CASH_ACCOUNTS_FOR_SHARES.SHARES_SUSPENSE.getValue(), shareProductId, paymentTypeId, shareAccountId, this.helper.createDebitJournalEntryForShares(office, currencyCode, CashAccountsForShares.SHARES_SUSPENSE.getValue(), shareProductId, paymentTypeId, shareAccountId,
transactionId, transactionDate, amount.subtract(chargeAmount)); transactionId, transactionDate, amount.subtract(chargeAmount));
this.helper.createCreditJournalEntryForShares(office, currencyCode, CASH_ACCOUNTS_FOR_SHARES.SHARES_REFERENCE.getValue(), shareProductId, paymentTypeId, shareAccountId, this.helper.createCreditJournalEntryForShares(office, currencyCode, CashAccountsForShares.SHARES_REFERENCE.getValue(), shareProductId, paymentTypeId, shareAccountId,
transactionId, transactionDate, amount); transactionId, transactionDate, amount);
}else{ }else{
this.helper.createJournalEntriesForShares(office, currencyCode, CASH_ACCOUNTS_FOR_SHARES.SHARES_SUSPENSE.getValue(), this.helper.createJournalEntriesForShares(office, currencyCode, CashAccountsForShares.SHARES_SUSPENSE.getValue(),
CASH_ACCOUNTS_FOR_SHARES.SHARES_REFERENCE.getValue(), shareProductId, paymentTypeId, shareAccountId, transactionId, CashAccountsForShares.SHARES_REFERENCE.getValue(), shareProductId, paymentTypeId, shareAccountId, transactionId,
transactionDate, amount); transactionDate, amount);
} }
@@ -51,7 +51,7 @@ import org.apache.fineract.accounting.journalentry.domain.JournalEntryRepository
import org.apache.fineract.accounting.journalentry.domain.JournalEntryType; import org.apache.fineract.accounting.journalentry.domain.JournalEntryType;
import org.apache.fineract.accounting.journalentry.exception.JournalEntriesNotFoundException; import org.apache.fineract.accounting.journalentry.exception.JournalEntriesNotFoundException;
import org.apache.fineract.accounting.journalentry.exception.JournalEntryInvalidException; import org.apache.fineract.accounting.journalentry.exception.JournalEntryInvalidException;
import org.apache.fineract.accounting.journalentry.exception.JournalEntryInvalidException.GL_JOURNAL_ENTRY_INVALID_REASON; import org.apache.fineract.accounting.journalentry.exception.JournalEntryInvalidException.GlJournalEntryInvalidReason;
import org.apache.fineract.accounting.journalentry.exception.JournalEntryRuntimeException; import org.apache.fineract.accounting.journalentry.exception.JournalEntryRuntimeException;
import org.apache.fineract.accounting.journalentry.serialization.JournalEntryCommandFromApiJsonDeserializer; import org.apache.fineract.accounting.journalentry.serialization.JournalEntryCommandFromApiJsonDeserializer;
import org.apache.fineract.accounting.producttoaccountmapping.domain.PortfolioProductType; import org.apache.fineract.accounting.producttoaccountmapping.domain.PortfolioProductType;
@@ -169,7 +169,7 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
if (accountingRule.getAccountToCredit() == null) { if (accountingRule.getAccountToCredit() == null) {
if (journalEntryCommand.getCredits() == null) { throw new JournalEntryInvalidException( if (journalEntryCommand.getCredits() == null) { throw new JournalEntryInvalidException(
GL_JOURNAL_ENTRY_INVALID_REASON.NO_DEBITS_OR_CREDITS, null, null, null); } GlJournalEntryInvalidReason.NO_DEBITS_OR_CREDITS, null, null, null); }
if (journalEntryCommand.getDebits() != null) { if (journalEntryCommand.getDebits() != null) {
checkDebitOrCreditAccountsAreValid(accountingRule, journalEntryCommand.getCredits(), checkDebitOrCreditAccountsAreValid(accountingRule, journalEntryCommand.getCredits(),
journalEntryCommand.getDebits()); journalEntryCommand.getDebits());
@@ -188,7 +188,7 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
if (accountingRule.getAccountToDebit() == null) { if (accountingRule.getAccountToDebit() == null) {
if (journalEntryCommand.getDebits() == null) { throw new JournalEntryInvalidException( if (journalEntryCommand.getDebits() == null) { throw new JournalEntryInvalidException(
GL_JOURNAL_ENTRY_INVALID_REASON.NO_DEBITS_OR_CREDITS, null, null, null); } GlJournalEntryInvalidReason.NO_DEBITS_OR_CREDITS, null, null, null); }
if (journalEntryCommand.getCredits() != null) { if (journalEntryCommand.getCredits() != null) {
checkDebitOrCreditAccountsAreValid(accountingRule, journalEntryCommand.getCredits(), checkDebitOrCreditAccountsAreValid(accountingRule, journalEntryCommand.getCredits(),
journalEntryCommand.getDebits()); journalEntryCommand.getDebits());
@@ -228,10 +228,10 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
* 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); } GlJournalEntryInvalidReason.INVALID_DEBIT_OR_CREDIT_ACCOUNTS, null, null, null); }
for (final 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); } GlJournalEntryInvalidReason.INVALID_DEBIT_OR_CREDIT_ACCOUNTS, null, null, null); }
} }
} }
@@ -283,16 +283,16 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
BigDecimal debitsSum = BigDecimal.ZERO; BigDecimal debitsSum = BigDecimal.ZERO;
for (final SingleDebitOrCreditEntryCommand creditEntryCommand : credits) { for (final SingleDebitOrCreditEntryCommand creditEntryCommand : credits) {
if (creditEntryCommand.getAmount() == null || creditEntryCommand.getGlAccountId() == null) { throw new JournalEntryInvalidException( if (creditEntryCommand.getAmount() == null || creditEntryCommand.getGlAccountId() == null) { throw new JournalEntryInvalidException(
GL_JOURNAL_ENTRY_INVALID_REASON.DEBIT_CREDIT_ACCOUNT_OR_AMOUNT_EMPTY, null, null, null); } GlJournalEntryInvalidReason.DEBIT_CREDIT_ACCOUNT_OR_AMOUNT_EMPTY, null, null, null); }
creditsSum = creditsSum.add(creditEntryCommand.getAmount()); creditsSum = creditsSum.add(creditEntryCommand.getAmount());
} }
for (final SingleDebitOrCreditEntryCommand debitEntryCommand : debits) { for (final SingleDebitOrCreditEntryCommand debitEntryCommand : debits) {
if (debitEntryCommand.getAmount() == null || debitEntryCommand.getGlAccountId() == null) { throw new JournalEntryInvalidException( if (debitEntryCommand.getAmount() == null || debitEntryCommand.getGlAccountId() == null) { throw new JournalEntryInvalidException(
GL_JOURNAL_ENTRY_INVALID_REASON.DEBIT_CREDIT_ACCOUNT_OR_AMOUNT_EMPTY, null, null, null); } GlJournalEntryInvalidReason.DEBIT_CREDIT_ACCOUNT_OR_AMOUNT_EMPTY, null, null, null); }
debitsSum = debitsSum.add(debitEntryCommand.getAmount()); debitsSum = debitsSum.add(debitEntryCommand.getAmount());
} }
if (creditsSum.compareTo(debitsSum) != 0) { throw new JournalEntryInvalidException( if (creditsSum.compareTo(debitsSum) != 0) { throw new JournalEntryInvalidException(
GL_JOURNAL_ENTRY_INVALID_REASON.DEBIT_CREDIT_SUM_MISMATCH, null, null, null); } GlJournalEntryInvalidReason.DEBIT_CREDIT_SUM_MISMATCH, null, null, null); }
} }
private void validateGLAccountForTransaction(final GLAccount creditOrDebitAccountHead) { private void validateGLAccountForTransaction(final GLAccount creditOrDebitAccountHead) {
@@ -301,10 +301,10 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
* disabled * disabled
**/ **/
if (creditOrDebitAccountHead.isDisabled()) { if (creditOrDebitAccountHead.isDisabled()) {
throw new JournalEntryInvalidException(GL_JOURNAL_ENTRY_INVALID_REASON.GL_ACCOUNT_DISABLED, null, throw new JournalEntryInvalidException(GlJournalEntryInvalidReason.GL_ACCOUNT_DISABLED, null,
creditOrDebitAccountHead.getName(), creditOrDebitAccountHead.getGlCode()); creditOrDebitAccountHead.getName(), creditOrDebitAccountHead.getGlCode());
} else if (!creditOrDebitAccountHead.isManualEntriesAllowed()) { throw new JournalEntryInvalidException( } else if (!creditOrDebitAccountHead.isManualEntriesAllowed()) { throw new JournalEntryInvalidException(
GL_JOURNAL_ENTRY_INVALID_REASON.GL_ACCOUNT_MANUAL_ENTRIES_NOT_PERMITTED, null, creditOrDebitAccountHead.getName(), GlJournalEntryInvalidReason.GL_ACCOUNT_MANUAL_ENTRIES_NOT_PERMITTED, null, creditOrDebitAccountHead.getName(),
creditOrDebitAccountHead.getGlCode()); } creditOrDebitAccountHead.getGlCode()); }
} }
@@ -338,7 +338,7 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
|| latestGLClosureByBranch.getClosingDate().equals(journalEntriesTransactionDate)) { || latestGLClosureByBranch.getClosingDate().equals(journalEntriesTransactionDate)) {
final String accountName = null; final String accountName = null;
final String accountGLCode = null; final String accountGLCode = null;
throw new JournalEntryInvalidException(GL_JOURNAL_ENTRY_INVALID_REASON.ACCOUNTING_CLOSED, throw new JournalEntryInvalidException(GlJournalEntryInvalidReason.ACCOUNTING_CLOSED,
latestGLClosureByBranch.getClosingDate(), accountName, accountGLCode); latestGLClosureByBranch.getClosingDate(), accountName, accountGLCode);
} }
} }
@@ -578,13 +578,13 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
final Date transactionDate = entryLocalDate.toDateTimeAtStartOfDay().toDate(); final Date transactionDate = entryLocalDate.toDateTimeAtStartOfDay().toDate();
// shouldn't be in the future // shouldn't be in the future
final Date todaysDate = new Date(); final Date todaysDate = new Date();
if (transactionDate.after(todaysDate)) { throw new JournalEntryInvalidException(GL_JOURNAL_ENTRY_INVALID_REASON.FUTURE_DATE, if (transactionDate.after(todaysDate)) { throw new JournalEntryInvalidException(GlJournalEntryInvalidReason.FUTURE_DATE,
transactionDate, null, null); } transactionDate, null, null); }
// shouldn't be before an accounting closure // shouldn't be before an accounting closure
final GLClosure latestGLClosure = this.glClosureRepository.getLatestGLClosureByBranch(command.getOfficeId()); final GLClosure latestGLClosure = this.glClosureRepository.getLatestGLClosureByBranch(command.getOfficeId());
if (latestGLClosure != null) { if (latestGLClosure != null) {
if (latestGLClosure.getClosingDate().after(transactionDate) || latestGLClosure.getClosingDate().equals(transactionDate)) { throw new JournalEntryInvalidException( if (latestGLClosure.getClosingDate().after(transactionDate) || latestGLClosure.getClosingDate().equals(transactionDate)) { throw new JournalEntryInvalidException(
GL_JOURNAL_ENTRY_INVALID_REASON.ACCOUNTING_CLOSED, latestGLClosure.getClosingDate(), null, null); } GlJournalEntryInvalidReason.ACCOUNTING_CLOSED, latestGLClosure.getClosingDate(), null, null); }
} }
/*** check if credits and debits are valid **/ /*** check if credits and debits are valid **/
@@ -593,7 +593,7 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
// atleast one debit or credit must be present // atleast one debit or credit must be present
if (credits == null || credits.length <= 0 || debits == null || debits.length <= 0) { throw new JournalEntryInvalidException( if (credits == null || credits.length <= 0 || debits == null || debits.length <= 0) { throw new JournalEntryInvalidException(
GL_JOURNAL_ENTRY_INVALID_REASON.NO_DEBITS_OR_CREDITS, null, null, null); } GlJournalEntryInvalidReason.NO_DEBITS_OR_CREDITS, null, null, null); }
checkDebitAndCreditAmounts(credits, debits); checkDebitAndCreditAmounts(credits, debits);
} }
@@ -27,9 +27,9 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.accounting.common.AccountingConstants.LOAN_PRODUCT_ACCOUNTING_PARAMS; import org.apache.fineract.accounting.common.AccountingConstants.LoanProductAccountingParams;
import org.apache.fineract.accounting.common.AccountingConstants.SAVINGS_PRODUCT_ACCOUNTING_PARAMS; import org.apache.fineract.accounting.common.AccountingConstants.SavingProductAccountingParams;
import org.apache.fineract.accounting.common.AccountingConstants.SHARES_PRODUCT_ACCOUNTING_PARAMS; import org.apache.fineract.accounting.common.AccountingConstants.SharesProductAccountingParams;
import org.apache.fineract.accounting.common.AccountingRuleType; import org.apache.fineract.accounting.common.AccountingRuleType;
import org.apache.fineract.accounting.glaccount.domain.GLAccount; import org.apache.fineract.accounting.glaccount.domain.GLAccount;
import org.apache.fineract.accounting.producttoaccountmapping.service.ProductToGLAccountMappingWritePlatformService; import org.apache.fineract.accounting.producttoaccountmapping.service.ProductToGLAccountMappingWritePlatformService;
@@ -92,49 +92,49 @@ public final class ProductToGLAccountMappingFromApiJsonDeserializer {
if (isCashBasedAccounting(accountingRuleType) || isAccrualBasedAccounting(accountingRuleType)) { if (isCashBasedAccounting(accountingRuleType) || isAccrualBasedAccounting(accountingRuleType)) {
final Long fundAccountId = this.fromApiJsonHelper.extractLongNamed(LOAN_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue(), final Long fundAccountId = this.fromApiJsonHelper.extractLongNamed(LoanProductAccountingParams.FUND_SOURCE.getValue(),
element); element);
baseDataValidator.reset().parameter(LOAN_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue()).value(fundAccountId).notNull() baseDataValidator.reset().parameter(LoanProductAccountingParams.FUND_SOURCE.getValue()).value(fundAccountId).notNull()
.integerGreaterThanZero(); .integerGreaterThanZero();
final Long loanPortfolioAccountId = this.fromApiJsonHelper.extractLongNamed( final Long loanPortfolioAccountId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.LOAN_PORTFOLIO.getValue(), element); LoanProductAccountingParams.LOAN_PORTFOLIO.getValue(), element);
baseDataValidator.reset().parameter(LOAN_PRODUCT_ACCOUNTING_PARAMS.LOAN_PORTFOLIO.getValue()).value(loanPortfolioAccountId) baseDataValidator.reset().parameter(LoanProductAccountingParams.LOAN_PORTFOLIO.getValue()).value(loanPortfolioAccountId)
.notNull().integerGreaterThanZero(); .notNull().integerGreaterThanZero();
final Long incomeFromInterestId = this.fromApiJsonHelper.extractLongNamed( final Long incomeFromInterestId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_LOANS.getValue(), element); LoanProductAccountingParams.INTEREST_ON_LOANS.getValue(), element);
baseDataValidator.reset().parameter(LOAN_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_LOANS.getValue()).value(incomeFromInterestId) baseDataValidator.reset().parameter(LoanProductAccountingParams.INTEREST_ON_LOANS.getValue()).value(incomeFromInterestId)
.notNull().integerGreaterThanZero(); .notNull().integerGreaterThanZero();
final Long incomeFromFeeId = this.fromApiJsonHelper.extractLongNamed( final Long incomeFromFeeId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), element); LoanProductAccountingParams.INCOME_FROM_FEES.getValue(), element);
baseDataValidator.reset().parameter(LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue()).value(incomeFromFeeId) baseDataValidator.reset().parameter(LoanProductAccountingParams.INCOME_FROM_FEES.getValue()).value(incomeFromFeeId)
.notNull().integerGreaterThanZero(); .notNull().integerGreaterThanZero();
final Long incomeFromPenaltyId = this.fromApiJsonHelper.extractLongNamed( final Long incomeFromPenaltyId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue(), element); LoanProductAccountingParams.INCOME_FROM_PENALTIES.getValue(), element);
baseDataValidator.reset().parameter(LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue()).value(incomeFromPenaltyId) baseDataValidator.reset().parameter(LoanProductAccountingParams.INCOME_FROM_PENALTIES.getValue()).value(incomeFromPenaltyId)
.notNull().integerGreaterThanZero(); .notNull().integerGreaterThanZero();
final Long incomeFromRecoveryAccountId = this.fromApiJsonHelper.extractLongNamed( final Long incomeFromRecoveryAccountId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_RECOVERY.getValue(), element); LoanProductAccountingParams.INCOME_FROM_RECOVERY.getValue(), element);
baseDataValidator.reset().parameter(LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_RECOVERY.getValue()) baseDataValidator.reset().parameter(LoanProductAccountingParams.INCOME_FROM_RECOVERY.getValue())
.value(incomeFromRecoveryAccountId).notNull().integerGreaterThanZero(); .value(incomeFromRecoveryAccountId).notNull().integerGreaterThanZero();
final Long writeOffAccountId = this.fromApiJsonHelper.extractLongNamed( final Long writeOffAccountId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue(), element); LoanProductAccountingParams.LOSSES_WRITTEN_OFF.getValue(), element);
baseDataValidator.reset().parameter(LOAN_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue()).value(writeOffAccountId) baseDataValidator.reset().parameter(LoanProductAccountingParams.LOSSES_WRITTEN_OFF.getValue()).value(writeOffAccountId)
.notNull().integerGreaterThanZero(); .notNull().integerGreaterThanZero();
final Long overpaymentAccountId = this.fromApiJsonHelper.extractLongNamed( final Long overpaymentAccountId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.OVERPAYMENT.getValue(), element); LoanProductAccountingParams.OVERPAYMENT.getValue(), element);
baseDataValidator.reset().parameter(LOAN_PRODUCT_ACCOUNTING_PARAMS.OVERPAYMENT.getValue()).value(overpaymentAccountId) baseDataValidator.reset().parameter(LoanProductAccountingParams.OVERPAYMENT.getValue()).value(overpaymentAccountId)
.notNull().integerGreaterThanZero(); .notNull().integerGreaterThanZero();
final Long transfersInSuspenseAccountId = this.fromApiJsonHelper.extractLongNamed( final Long transfersInSuspenseAccountId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(), element); LoanProductAccountingParams.TRANSFERS_SUSPENSE.getValue(), element);
baseDataValidator.reset().parameter(LOAN_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue()) baseDataValidator.reset().parameter(LoanProductAccountingParams.TRANSFERS_SUSPENSE.getValue())
.value(transfersInSuspenseAccountId).notNull().integerGreaterThanZero(); .value(transfersInSuspenseAccountId).notNull().integerGreaterThanZero();
} }
@@ -142,18 +142,18 @@ public final class ProductToGLAccountMappingFromApiJsonDeserializer {
if (isAccrualBasedAccounting(accountingRuleType)) { if (isAccrualBasedAccounting(accountingRuleType)) {
final Long receivableInterestAccountId = this.fromApiJsonHelper.extractLongNamed( final Long receivableInterestAccountId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.INTEREST_RECEIVABLE.getValue(), element); LoanProductAccountingParams.INTEREST_RECEIVABLE.getValue(), element);
baseDataValidator.reset().parameter(LOAN_PRODUCT_ACCOUNTING_PARAMS.INTEREST_RECEIVABLE.getValue()) baseDataValidator.reset().parameter(LoanProductAccountingParams.INTEREST_RECEIVABLE.getValue())
.value(receivableInterestAccountId).notNull().integerGreaterThanZero(); .value(receivableInterestAccountId).notNull().integerGreaterThanZero();
final Long receivableFeeAccountId = this.fromApiJsonHelper.extractLongNamed( final Long receivableFeeAccountId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.FEES_RECEIVABLE.getValue(), element); LoanProductAccountingParams.FEES_RECEIVABLE.getValue(), element);
baseDataValidator.reset().parameter(LOAN_PRODUCT_ACCOUNTING_PARAMS.FEES_RECEIVABLE.getValue()).value(receivableFeeAccountId) baseDataValidator.reset().parameter(LoanProductAccountingParams.FEES_RECEIVABLE.getValue()).value(receivableFeeAccountId)
.notNull().integerGreaterThanZero(); .notNull().integerGreaterThanZero();
final Long receivablePenaltyAccountId = this.fromApiJsonHelper.extractLongNamed( final Long receivablePenaltyAccountId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.PENALTIES_RECEIVABLE.getValue(), element); LoanProductAccountingParams.PENALTIES_RECEIVABLE.getValue(), element);
baseDataValidator.reset().parameter(LOAN_PRODUCT_ACCOUNTING_PARAMS.PENALTIES_RECEIVABLE.getValue()) baseDataValidator.reset().parameter(LoanProductAccountingParams.PENALTIES_RECEIVABLE.getValue())
.value(receivablePenaltyAccountId).notNull().integerGreaterThanZero(); .value(receivablePenaltyAccountId).notNull().integerGreaterThanZero();
} }
@@ -177,57 +177,57 @@ public final class ProductToGLAccountMappingFromApiJsonDeserializer {
if (isCashBasedAccounting(accountingRuleType)) { if (isCashBasedAccounting(accountingRuleType)) {
final Long savingsControlAccountId = this.fromApiJsonHelper.extractLongNamed( final Long savingsControlAccountId = this.fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_CONTROL.getValue(), element); SavingProductAccountingParams.SAVINGS_CONTROL.getValue(), element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_CONTROL.getValue()) baseDataValidator.reset().parameter(SavingProductAccountingParams.SAVINGS_CONTROL.getValue())
.value(savingsControlAccountId).notNull().integerGreaterThanZero(); .value(savingsControlAccountId).notNull().integerGreaterThanZero();
final Long savingsReferenceAccountId = this.fromApiJsonHelper.extractLongNamed( final Long savingsReferenceAccountId = this.fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_REFERENCE.getValue(), element); SavingProductAccountingParams.SAVINGS_REFERENCE.getValue(), element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_REFERENCE.getValue()) baseDataValidator.reset().parameter(SavingProductAccountingParams.SAVINGS_REFERENCE.getValue())
.value(savingsReferenceAccountId).notNull().integerGreaterThanZero(); .value(savingsReferenceAccountId).notNull().integerGreaterThanZero();
final Long transfersInSuspenseAccountId = this.fromApiJsonHelper.extractLongNamed( final Long transfersInSuspenseAccountId = this.fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(), element); SavingProductAccountingParams.TRANSFERS_SUSPENSE.getValue(), element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue()) baseDataValidator.reset().parameter(SavingProductAccountingParams.TRANSFERS_SUSPENSE.getValue())
.value(transfersInSuspenseAccountId).notNull().integerGreaterThanZero(); .value(transfersInSuspenseAccountId).notNull().integerGreaterThanZero();
final Long interestOnSavingsAccountId = this.fromApiJsonHelper.extractLongNamed( final Long interestOnSavingsAccountId = this.fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_SAVINGS.getValue(), element); SavingProductAccountingParams.INTEREST_ON_SAVINGS.getValue(), element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_SAVINGS.getValue()) baseDataValidator.reset().parameter(SavingProductAccountingParams.INTEREST_ON_SAVINGS.getValue())
.value(interestOnSavingsAccountId).notNull().integerGreaterThanZero(); .value(interestOnSavingsAccountId).notNull().integerGreaterThanZero();
final Long incomeFromFeeId = this.fromApiJsonHelper.extractLongNamed( final Long incomeFromFeeId = this.fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), element); SavingProductAccountingParams.INCOME_FROM_FEES.getValue(), element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue()).value(incomeFromFeeId) baseDataValidator.reset().parameter(SavingProductAccountingParams.INCOME_FROM_FEES.getValue()).value(incomeFromFeeId)
.notNull().integerGreaterThanZero(); .notNull().integerGreaterThanZero();
final Long incomeFromPenaltyId = this.fromApiJsonHelper.extractLongNamed( final Long incomeFromPenaltyId = this.fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue(), element); SavingProductAccountingParams.INCOME_FROM_PENALTIES.getValue(), element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue()) baseDataValidator.reset().parameter(SavingProductAccountingParams.INCOME_FROM_PENALTIES.getValue())
.value(incomeFromPenaltyId).notNull().integerGreaterThanZero(); .value(incomeFromPenaltyId).notNull().integerGreaterThanZero();
final Boolean isDormancyTrackingActive = this.fromApiJsonHelper.extractBooleanNamed(isDormancyTrackingActiveParamName, element); final Boolean isDormancyTrackingActive = this.fromApiJsonHelper.extractBooleanNamed(isDormancyTrackingActiveParamName, element);
if(null != isDormancyTrackingActive && isDormancyTrackingActive){ if(null != isDormancyTrackingActive && isDormancyTrackingActive){
final Long escheatLiabilityId = this.fromApiJsonHelper.extractLongNamed( final Long escheatLiabilityId = this.fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.ESCHEAT_LIABILITY.getValue(), element); SavingProductAccountingParams.ESCHEAT_LIABILITY.getValue(), element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.ESCHEAT_LIABILITY.getValue()) baseDataValidator.reset().parameter(SavingProductAccountingParams.ESCHEAT_LIABILITY.getValue())
.value(escheatLiabilityId).notNull().integerGreaterThanZero(); .value(escheatLiabilityId).notNull().integerGreaterThanZero();
} }
if (!accountType.equals(DepositAccountType.RECURRING_DEPOSIT) && !accountType.equals(DepositAccountType.FIXED_DEPOSIT)) { if (!accountType.equals(DepositAccountType.RECURRING_DEPOSIT) && !accountType.equals(DepositAccountType.FIXED_DEPOSIT)) {
final Long overdraftAccount = this.fromApiJsonHelper.extractLongNamed( final Long overdraftAccount = this.fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), element); SavingProductAccountingParams.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.OVERDRAFT_PORTFOLIO_CONTROL.getValue()) baseDataValidator.reset().parameter(SavingProductAccountingParams.OVERDRAFT_PORTFOLIO_CONTROL.getValue())
.value(overdraftAccount).notNull().integerGreaterThanZero(); .value(overdraftAccount).notNull().integerGreaterThanZero();
final Long incomeFromInterest = this.fromApiJsonHelper.extractLongNamed( final Long incomeFromInterest = this.fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_INTEREST.getValue(), element); SavingProductAccountingParams.INCOME_FROM_INTEREST.getValue(), element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_INTEREST.getValue()) baseDataValidator.reset().parameter(SavingProductAccountingParams.INCOME_FROM_INTEREST.getValue())
.value(incomeFromInterest).notNull().integerGreaterThanZero(); .value(incomeFromInterest).notNull().integerGreaterThanZero();
final Long writtenOff = this.fromApiJsonHelper.extractLongNamed( final Long writtenOff = this.fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue(), element); SavingProductAccountingParams.LOSSES_WRITTEN_OFF.getValue(), element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue()).value(writtenOff) baseDataValidator.reset().parameter(SavingProductAccountingParams.LOSSES_WRITTEN_OFF.getValue()).value(writtenOff)
.notNull().integerGreaterThanZero(); .notNull().integerGreaterThanZero();
} }
@@ -253,23 +253,23 @@ public final class ProductToGLAccountMappingFromApiJsonDeserializer {
if (isCashBasedAccounting(accountingRuleType)) { if (isCashBasedAccounting(accountingRuleType)) {
final Long shareReferenceId = this.fromApiJsonHelper.extractLongNamed( final Long shareReferenceId = this.fromApiJsonHelper.extractLongNamed(
SHARES_PRODUCT_ACCOUNTING_PARAMS.SHARES_REFERENCE.getValue(), element); SharesProductAccountingParams.SHARES_REFERENCE.getValue(), element);
baseDataValidator.reset().parameter(SHARES_PRODUCT_ACCOUNTING_PARAMS.SHARES_REFERENCE.getValue()) baseDataValidator.reset().parameter(SharesProductAccountingParams.SHARES_REFERENCE.getValue())
.value(shareReferenceId).notNull().integerGreaterThanZero(); .value(shareReferenceId).notNull().integerGreaterThanZero();
final Long shareSuspenseId = this.fromApiJsonHelper.extractLongNamed( final Long shareSuspenseId = this.fromApiJsonHelper.extractLongNamed(
SHARES_PRODUCT_ACCOUNTING_PARAMS.SHARES_SUSPENSE.getValue(), element); SharesProductAccountingParams.SHARES_SUSPENSE.getValue(), element);
baseDataValidator.reset().parameter(SHARES_PRODUCT_ACCOUNTING_PARAMS.SHARES_SUSPENSE.getValue()) baseDataValidator.reset().parameter(SharesProductAccountingParams.SHARES_SUSPENSE.getValue())
.value(shareSuspenseId).notNull().integerGreaterThanZero(); .value(shareSuspenseId).notNull().integerGreaterThanZero();
final Long incomeFromFeeAccountId = this.fromApiJsonHelper.extractLongNamed( final Long incomeFromFeeAccountId = this.fromApiJsonHelper.extractLongNamed(
SHARES_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), element); SharesProductAccountingParams.INCOME_FROM_FEES.getValue(), element);
baseDataValidator.reset().parameter(SHARES_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue()) baseDataValidator.reset().parameter(SharesProductAccountingParams.INCOME_FROM_FEES.getValue())
.value(incomeFromFeeAccountId).notNull().integerGreaterThanZero(); .value(incomeFromFeeAccountId).notNull().integerGreaterThanZero();
final Long shareEquityId = this.fromApiJsonHelper.extractLongNamed( final Long shareEquityId = this.fromApiJsonHelper.extractLongNamed(
SHARES_PRODUCT_ACCOUNTING_PARAMS.SHARES_EQUITY.getValue(), element); SharesProductAccountingParams.SHARES_EQUITY.getValue(), element);
baseDataValidator.reset().parameter(SHARES_PRODUCT_ACCOUNTING_PARAMS.SHARES_EQUITY.getValue()) baseDataValidator.reset().parameter(SharesProductAccountingParams.SHARES_EQUITY.getValue())
.value(shareEquityId).notNull().integerGreaterThanZero(); .value(shareEquityId).notNull().integerGreaterThanZero();
} }
@@ -21,9 +21,9 @@ package org.apache.fineract.accounting.producttoaccountmapping.service;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.apache.fineract.accounting.common.AccountingConstants.ACCRUAL_ACCOUNTS_FOR_LOAN; import org.apache.fineract.accounting.common.AccountingConstants.AccrualAccountsForLoan;
import org.apache.fineract.accounting.common.AccountingConstants.CASH_ACCOUNTS_FOR_LOAN; import org.apache.fineract.accounting.common.AccountingConstants.CashAccountsForLoan;
import org.apache.fineract.accounting.common.AccountingConstants.LOAN_PRODUCT_ACCOUNTING_PARAMS; import org.apache.fineract.accounting.common.AccountingConstants.LoanProductAccountingParams;
import org.apache.fineract.accounting.common.AccountingRuleType; import org.apache.fineract.accounting.common.AccountingRuleType;
import org.apache.fineract.accounting.glaccount.domain.GLAccountRepository; import org.apache.fineract.accounting.glaccount.domain.GLAccountRepository;
import org.apache.fineract.accounting.glaccount.domain.GLAccountRepositoryWrapper; import org.apache.fineract.accounting.glaccount.domain.GLAccountRepositoryWrapper;
@@ -126,32 +126,32 @@ public class LoanProductToGLAccountMappingHelper extends ProductToGLAccountMappi
final AccountingRuleType accountingRuleType) { final AccountingRuleType accountingRuleType) {
final Map<String, Object> changes = new HashMap<>(); final Map<String, Object> changes = new HashMap<>();
final Long fundAccountId = this.fromApiJsonHelper.extractLongNamed(LOAN_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue(), element); final Long fundAccountId = this.fromApiJsonHelper.extractLongNamed(LoanProductAccountingParams.FUND_SOURCE.getValue(), element);
final Long loanPortfolioAccountId = this.fromApiJsonHelper.extractLongNamed( final Long loanPortfolioAccountId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.LOAN_PORTFOLIO.getValue(), element); LoanProductAccountingParams.LOAN_PORTFOLIO.getValue(), element);
final Long incomeFromInterestId = this.fromApiJsonHelper.extractLongNamed( final Long incomeFromInterestId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_LOANS.getValue(), element); LoanProductAccountingParams.INTEREST_ON_LOANS.getValue(), element);
final Long incomeFromFeeId = this.fromApiJsonHelper.extractLongNamed(LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), final Long incomeFromFeeId = this.fromApiJsonHelper.extractLongNamed(LoanProductAccountingParams.INCOME_FROM_FEES.getValue(),
element); element);
final Long incomeFromPenaltyId = this.fromApiJsonHelper.extractLongNamed( final Long incomeFromPenaltyId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue(), element); LoanProductAccountingParams.INCOME_FROM_PENALTIES.getValue(), element);
final Long incomeFromRecoveryAccountId = this.fromApiJsonHelper.extractLongNamed( final Long incomeFromRecoveryAccountId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_RECOVERY.getValue(), element); LoanProductAccountingParams.INCOME_FROM_RECOVERY.getValue(), element);
final Long writeOffAccountId = this.fromApiJsonHelper.extractLongNamed( final Long writeOffAccountId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue(), element); LoanProductAccountingParams.LOSSES_WRITTEN_OFF.getValue(), element);
final Long overPaymentAccountId = this.fromApiJsonHelper.extractLongNamed(LOAN_PRODUCT_ACCOUNTING_PARAMS.OVERPAYMENT.getValue(), final Long overPaymentAccountId = this.fromApiJsonHelper.extractLongNamed(LoanProductAccountingParams.OVERPAYMENT.getValue(),
element); element);
final Long transfersInSuspenseAccountId = this.fromApiJsonHelper.extractLongNamed( final Long transfersInSuspenseAccountId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(), element); LoanProductAccountingParams.TRANSFERS_SUSPENSE.getValue(), element);
final Long receivableInterestAccountId = this.fromApiJsonHelper.extractLongNamed( final Long receivableInterestAccountId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.INTEREST_RECEIVABLE.getValue(), element); LoanProductAccountingParams.INTEREST_RECEIVABLE.getValue(), element);
final Long receivableFeeAccountId = this.fromApiJsonHelper.extractLongNamed( final Long receivableFeeAccountId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.FEES_RECEIVABLE.getValue(), element); LoanProductAccountingParams.FEES_RECEIVABLE.getValue(), element);
final Long receivablePenaltyAccountId = this.fromApiJsonHelper.extractLongNamed( final Long receivablePenaltyAccountId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.PENALTIES_RECEIVABLE.getValue(), element); LoanProductAccountingParams.PENALTIES_RECEIVABLE.getValue(), element);
switch (accountingRuleType) { switch (accountingRuleType) {
case NONE: case NONE:
@@ -182,9 +182,9 @@ public class LoanProductToGLAccountMappingHelper extends ProductToGLAccountMappi
final Long incomeFromRecoveryAccountId, final Long receivableInterestAccountId, final Long receivableFeeAccountId, final Long incomeFromRecoveryAccountId, final Long receivableInterestAccountId, final Long receivableFeeAccountId,
final Long receivablePenaltyAccountId) { final Long receivablePenaltyAccountId) {
changes.put(LOAN_PRODUCT_ACCOUNTING_PARAMS.INTEREST_RECEIVABLE.getValue(), receivableInterestAccountId); changes.put(LoanProductAccountingParams.INTEREST_RECEIVABLE.getValue(), receivableInterestAccountId);
changes.put(LOAN_PRODUCT_ACCOUNTING_PARAMS.FEES_RECEIVABLE.getValue(), receivableFeeAccountId); changes.put(LoanProductAccountingParams.FEES_RECEIVABLE.getValue(), receivableFeeAccountId);
changes.put(LOAN_PRODUCT_ACCOUNTING_PARAMS.PENALTIES_RECEIVABLE.getValue(), receivablePenaltyAccountId); changes.put(LoanProductAccountingParams.PENALTIES_RECEIVABLE.getValue(), receivablePenaltyAccountId);
populateChangesForCashBasedAccounting(changes, fundAccountId, loanPortfolioAccountId, incomeFromInterestId, incomeFromFeeId, populateChangesForCashBasedAccounting(changes, fundAccountId, loanPortfolioAccountId, incomeFromInterestId, incomeFromFeeId,
incomeFromPenaltyId, writeOffAccountId, overPaymentAccountId, transfersInSuspenseAccountId, incomeFromRecoveryAccountId); incomeFromPenaltyId, writeOffAccountId, overPaymentAccountId, transfersInSuspenseAccountId, incomeFromRecoveryAccountId);
@@ -195,15 +195,15 @@ public class LoanProductToGLAccountMappingHelper extends ProductToGLAccountMappi
final Long loanPortfolioAccountId, final Long incomeFromInterestId, final Long incomeFromFeeId, final Long incomeFromPenaltyId, final Long loanPortfolioAccountId, final Long incomeFromInterestId, final Long incomeFromFeeId, final Long incomeFromPenaltyId,
final Long writeOffAccountId, final Long overPaymentAccountId, final Long transfersInSuspenseAccountId, final Long writeOffAccountId, final Long overPaymentAccountId, final Long transfersInSuspenseAccountId,
final Long incomeFromRecoveryAccountId) { final Long incomeFromRecoveryAccountId) {
changes.put(LOAN_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue(), fundAccountId); changes.put(LoanProductAccountingParams.FUND_SOURCE.getValue(), fundAccountId);
changes.put(LOAN_PRODUCT_ACCOUNTING_PARAMS.LOAN_PORTFOLIO.getValue(), loanPortfolioAccountId); changes.put(LoanProductAccountingParams.LOAN_PORTFOLIO.getValue(), loanPortfolioAccountId);
changes.put(LOAN_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_LOANS.getValue(), incomeFromInterestId); changes.put(LoanProductAccountingParams.INTEREST_ON_LOANS.getValue(), incomeFromInterestId);
changes.put(LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), incomeFromFeeId); changes.put(LoanProductAccountingParams.INCOME_FROM_FEES.getValue(), incomeFromFeeId);
changes.put(LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue(), incomeFromPenaltyId); changes.put(LoanProductAccountingParams.INCOME_FROM_PENALTIES.getValue(), incomeFromPenaltyId);
changes.put(LOAN_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue(), writeOffAccountId); changes.put(LoanProductAccountingParams.LOSSES_WRITTEN_OFF.getValue(), writeOffAccountId);
changes.put(LOAN_PRODUCT_ACCOUNTING_PARAMS.OVERPAYMENT.getValue(), overPaymentAccountId); changes.put(LoanProductAccountingParams.OVERPAYMENT.getValue(), overPaymentAccountId);
changes.put(LOAN_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(), transfersInSuspenseAccountId); changes.put(LoanProductAccountingParams.TRANSFERS_SUSPENSE.getValue(), transfersInSuspenseAccountId);
changes.put(LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_RECOVERY.getValue(), incomeFromRecoveryAccountId); changes.put(LoanProductAccountingParams.INCOME_FROM_RECOVERY.getValue(), incomeFromRecoveryAccountId);
} }
@@ -223,76 +223,76 @@ public class LoanProductToGLAccountMappingHelper extends ProductToGLAccountMappi
break; break;
case CASH_BASED: case CASH_BASED:
// asset // asset
mergeLoanToAssetAccountMappingChanges(element, LOAN_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue(), loanProductId, mergeLoanToAssetAccountMappingChanges(element, LoanProductAccountingParams.FUND_SOURCE.getValue(), loanProductId,
CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue(), CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE.toString(), changes); CashAccountsForLoan.FUND_SOURCE.getValue(), CashAccountsForLoan.FUND_SOURCE.toString(), changes);
mergeLoanToAssetAccountMappingChanges(element, LOAN_PRODUCT_ACCOUNTING_PARAMS.LOAN_PORTFOLIO.getValue(), loanProductId, mergeLoanToAssetAccountMappingChanges(element, LoanProductAccountingParams.LOAN_PORTFOLIO.getValue(), loanProductId,
CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO.getValue(), CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO.toString(), changes); CashAccountsForLoan.LOAN_PORTFOLIO.getValue(), CashAccountsForLoan.LOAN_PORTFOLIO.toString(), changes);
mergeLoanToAssetAccountMappingChanges(element, LOAN_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(), loanProductId, mergeLoanToAssetAccountMappingChanges(element, LoanProductAccountingParams.TRANSFERS_SUSPENSE.getValue(), loanProductId,
CASH_ACCOUNTS_FOR_LOAN.TRANSFERS_SUSPENSE.getValue(), CASH_ACCOUNTS_FOR_LOAN.TRANSFERS_SUSPENSE.toString(), changes); CashAccountsForLoan.TRANSFERS_SUSPENSE.getValue(), CashAccountsForLoan.TRANSFERS_SUSPENSE.toString(), changes);
// income // income
mergeLoanToIncomeAccountMappingChanges(element, LOAN_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_LOANS.getValue(), loanProductId, mergeLoanToIncomeAccountMappingChanges(element, LoanProductAccountingParams.INTEREST_ON_LOANS.getValue(), loanProductId,
CASH_ACCOUNTS_FOR_LOAN.INTEREST_ON_LOANS.getValue(), CASH_ACCOUNTS_FOR_LOAN.INTEREST_ON_LOANS.toString(), changes); CashAccountsForLoan.INTEREST_ON_LOANS.getValue(), CashAccountsForLoan.INTEREST_ON_LOANS.toString(), changes);
mergeLoanToIncomeAccountMappingChanges(element, LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), loanProductId, mergeLoanToIncomeAccountMappingChanges(element, LoanProductAccountingParams.INCOME_FROM_FEES.getValue(), loanProductId,
CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_FEES.getValue(), CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_FEES.toString(), changes); CashAccountsForLoan.INCOME_FROM_FEES.getValue(), CashAccountsForLoan.INCOME_FROM_FEES.toString(), changes);
mergeLoanToIncomeAccountMappingChanges(element, LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue(), mergeLoanToIncomeAccountMappingChanges(element, LoanProductAccountingParams.INCOME_FROM_PENALTIES.getValue(),
loanProductId, CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_PENALTIES.getValue(), loanProductId, CashAccountsForLoan.INCOME_FROM_PENALTIES.getValue(),
CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_PENALTIES.toString(), changes); CashAccountsForLoan.INCOME_FROM_PENALTIES.toString(), changes);
mergeLoanToIncomeAccountMappingChanges(element, LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_RECOVERY.getValue(), mergeLoanToIncomeAccountMappingChanges(element, LoanProductAccountingParams.INCOME_FROM_RECOVERY.getValue(),
loanProductId, CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_RECOVERY.getValue(), loanProductId, CashAccountsForLoan.INCOME_FROM_RECOVERY.getValue(),
CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_RECOVERY.toString(), changes); CashAccountsForLoan.INCOME_FROM_RECOVERY.toString(), changes);
// expenses // expenses
mergeLoanToExpenseAccountMappingChanges(element, LOAN_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue(), mergeLoanToExpenseAccountMappingChanges(element, LoanProductAccountingParams.LOSSES_WRITTEN_OFF.getValue(),
loanProductId, CASH_ACCOUNTS_FOR_LOAN.LOSSES_WRITTEN_OFF.getValue(), loanProductId, CashAccountsForLoan.LOSSES_WRITTEN_OFF.getValue(),
CASH_ACCOUNTS_FOR_LOAN.LOSSES_WRITTEN_OFF.toString(), changes); CashAccountsForLoan.LOSSES_WRITTEN_OFF.toString(), changes);
// liabilities // liabilities
mergeLoanToLiabilityAccountMappingChanges(element, LOAN_PRODUCT_ACCOUNTING_PARAMS.OVERPAYMENT.getValue(), loanProductId, mergeLoanToLiabilityAccountMappingChanges(element, LoanProductAccountingParams.OVERPAYMENT.getValue(), loanProductId,
CASH_ACCOUNTS_FOR_LOAN.OVERPAYMENT.getValue(), CASH_ACCOUNTS_FOR_LOAN.OVERPAYMENT.toString(), changes); CashAccountsForLoan.OVERPAYMENT.getValue(), CashAccountsForLoan.OVERPAYMENT.toString(), changes);
break; break;
case ACCRUAL_UPFRONT: case ACCRUAL_UPFRONT:
// fall through to periodic accrual // fall through to periodic accrual
case ACCRUAL_PERIODIC: case ACCRUAL_PERIODIC:
// assets (including receivables) // assets (including receivables)
mergeLoanToAssetAccountMappingChanges(element, LOAN_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue(), loanProductId, mergeLoanToAssetAccountMappingChanges(element, LoanProductAccountingParams.FUND_SOURCE.getValue(), loanProductId,
ACCRUAL_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue(), ACCRUAL_ACCOUNTS_FOR_LOAN.FUND_SOURCE.toString(), changes); AccrualAccountsForLoan.FUND_SOURCE.getValue(), AccrualAccountsForLoan.FUND_SOURCE.toString(), changes);
mergeLoanToAssetAccountMappingChanges(element, LOAN_PRODUCT_ACCOUNTING_PARAMS.LOAN_PORTFOLIO.getValue(), loanProductId, mergeLoanToAssetAccountMappingChanges(element, LoanProductAccountingParams.LOAN_PORTFOLIO.getValue(), loanProductId,
ACCRUAL_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO.getValue(), ACCRUAL_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO.toString(), changes); AccrualAccountsForLoan.LOAN_PORTFOLIO.getValue(), AccrualAccountsForLoan.LOAN_PORTFOLIO.toString(), changes);
mergeLoanToAssetAccountMappingChanges(element, LOAN_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(), loanProductId, mergeLoanToAssetAccountMappingChanges(element, LoanProductAccountingParams.TRANSFERS_SUSPENSE.getValue(), loanProductId,
ACCRUAL_ACCOUNTS_FOR_LOAN.TRANSFERS_SUSPENSE.getValue(), ACCRUAL_ACCOUNTS_FOR_LOAN.TRANSFERS_SUSPENSE.toString(), AccrualAccountsForLoan.TRANSFERS_SUSPENSE.getValue(), AccrualAccountsForLoan.TRANSFERS_SUSPENSE.toString(),
changes); changes);
mergeLoanToAssetAccountMappingChanges(element, LOAN_PRODUCT_ACCOUNTING_PARAMS.INTEREST_RECEIVABLE.getValue(), mergeLoanToAssetAccountMappingChanges(element, LoanProductAccountingParams.INTEREST_RECEIVABLE.getValue(),
loanProductId, ACCRUAL_ACCOUNTS_FOR_LOAN.INTEREST_RECEIVABLE.getValue(), loanProductId, AccrualAccountsForLoan.INTEREST_RECEIVABLE.getValue(),
ACCRUAL_ACCOUNTS_FOR_LOAN.INTEREST_RECEIVABLE.toString(), changes); AccrualAccountsForLoan.INTEREST_RECEIVABLE.toString(), changes);
mergeLoanToAssetAccountMappingChanges(element, LOAN_PRODUCT_ACCOUNTING_PARAMS.FEES_RECEIVABLE.getValue(), loanProductId, mergeLoanToAssetAccountMappingChanges(element, LoanProductAccountingParams.FEES_RECEIVABLE.getValue(), loanProductId,
ACCRUAL_ACCOUNTS_FOR_LOAN.FEES_RECEIVABLE.getValue(), ACCRUAL_ACCOUNTS_FOR_LOAN.FEES_RECEIVABLE.toString(), changes); AccrualAccountsForLoan.FEES_RECEIVABLE.getValue(), AccrualAccountsForLoan.FEES_RECEIVABLE.toString(), changes);
mergeLoanToAssetAccountMappingChanges(element, LOAN_PRODUCT_ACCOUNTING_PARAMS.PENALTIES_RECEIVABLE.getValue(), mergeLoanToAssetAccountMappingChanges(element, LoanProductAccountingParams.PENALTIES_RECEIVABLE.getValue(),
loanProductId, ACCRUAL_ACCOUNTS_FOR_LOAN.PENALTIES_RECEIVABLE.getValue(), loanProductId, AccrualAccountsForLoan.PENALTIES_RECEIVABLE.getValue(),
ACCRUAL_ACCOUNTS_FOR_LOAN.PENALTIES_RECEIVABLE.toString(), changes); AccrualAccountsForLoan.PENALTIES_RECEIVABLE.toString(), changes);
// income // income
mergeLoanToIncomeAccountMappingChanges(element, LOAN_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_LOANS.getValue(), loanProductId, mergeLoanToIncomeAccountMappingChanges(element, LoanProductAccountingParams.INTEREST_ON_LOANS.getValue(), loanProductId,
ACCRUAL_ACCOUNTS_FOR_LOAN.INTEREST_ON_LOANS.getValue(), ACCRUAL_ACCOUNTS_FOR_LOAN.INTEREST_ON_LOANS.toString(), AccrualAccountsForLoan.INTEREST_ON_LOANS.getValue(), AccrualAccountsForLoan.INTEREST_ON_LOANS.toString(),
changes); changes);
mergeLoanToIncomeAccountMappingChanges(element, LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), loanProductId, mergeLoanToIncomeAccountMappingChanges(element, LoanProductAccountingParams.INCOME_FROM_FEES.getValue(), loanProductId,
ACCRUAL_ACCOUNTS_FOR_LOAN.INCOME_FROM_FEES.getValue(), ACCRUAL_ACCOUNTS_FOR_LOAN.INCOME_FROM_FEES.toString(), AccrualAccountsForLoan.INCOME_FROM_FEES.getValue(), AccrualAccountsForLoan.INCOME_FROM_FEES.toString(),
changes); changes);
mergeLoanToIncomeAccountMappingChanges(element, LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue(), mergeLoanToIncomeAccountMappingChanges(element, LoanProductAccountingParams.INCOME_FROM_PENALTIES.getValue(),
loanProductId, ACCRUAL_ACCOUNTS_FOR_LOAN.INCOME_FROM_PENALTIES.getValue(), loanProductId, AccrualAccountsForLoan.INCOME_FROM_PENALTIES.getValue(),
ACCRUAL_ACCOUNTS_FOR_LOAN.INCOME_FROM_PENALTIES.toString(), changes); AccrualAccountsForLoan.INCOME_FROM_PENALTIES.toString(), changes);
mergeLoanToIncomeAccountMappingChanges(element, LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_RECOVERY.getValue(), mergeLoanToIncomeAccountMappingChanges(element, LoanProductAccountingParams.INCOME_FROM_RECOVERY.getValue(),
loanProductId, ACCRUAL_ACCOUNTS_FOR_LOAN.INCOME_FROM_RECOVERY.getValue(), loanProductId, AccrualAccountsForLoan.INCOME_FROM_RECOVERY.getValue(),
ACCRUAL_ACCOUNTS_FOR_LOAN.INCOME_FROM_RECOVERY.toString(), changes); AccrualAccountsForLoan.INCOME_FROM_RECOVERY.toString(), changes);
// expenses // expenses
mergeLoanToExpenseAccountMappingChanges(element, LOAN_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue(), mergeLoanToExpenseAccountMappingChanges(element, LoanProductAccountingParams.LOSSES_WRITTEN_OFF.getValue(),
loanProductId, ACCRUAL_ACCOUNTS_FOR_LOAN.LOSSES_WRITTEN_OFF.getValue(), loanProductId, AccrualAccountsForLoan.LOSSES_WRITTEN_OFF.getValue(),
ACCRUAL_ACCOUNTS_FOR_LOAN.LOSSES_WRITTEN_OFF.toString(), changes); AccrualAccountsForLoan.LOSSES_WRITTEN_OFF.toString(), changes);
// liabilities // liabilities
mergeLoanToLiabilityAccountMappingChanges(element, LOAN_PRODUCT_ACCOUNTING_PARAMS.OVERPAYMENT.getValue(), loanProductId, mergeLoanToLiabilityAccountMappingChanges(element, LoanProductAccountingParams.OVERPAYMENT.getValue(), loanProductId,
CASH_ACCOUNTS_FOR_LOAN.OVERPAYMENT.getValue(), CASH_ACCOUNTS_FOR_LOAN.OVERPAYMENT.toString(), changes); CashAccountsForLoan.OVERPAYMENT.getValue(), CashAccountsForLoan.OVERPAYMENT.toString(), changes);
break; break;
} }
} }
@@ -27,8 +27,8 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.apache.fineract.accounting.common.AccountingConstants.CASH_ACCOUNTS_FOR_LOAN; import org.apache.fineract.accounting.common.AccountingConstants.CashAccountsForLoan;
import org.apache.fineract.accounting.common.AccountingConstants.LOAN_PRODUCT_ACCOUNTING_PARAMS; import org.apache.fineract.accounting.common.AccountingConstants.LoanProductAccountingParams;
import org.apache.fineract.accounting.glaccount.domain.GLAccount; import org.apache.fineract.accounting.glaccount.domain.GLAccount;
import org.apache.fineract.accounting.glaccount.domain.GLAccountRepository; import org.apache.fineract.accounting.glaccount.domain.GLAccountRepository;
import org.apache.fineract.accounting.glaccount.domain.GLAccountRepositoryWrapper; import org.apache.fineract.accounting.glaccount.domain.GLAccountRepositoryWrapper;
@@ -136,16 +136,16 @@ public class ProductToGLAccountMappingHelper {
public void savePaymentChannelToFundSourceMappings(final JsonCommand command, final JsonElement element, final Long productId, public void savePaymentChannelToFundSourceMappings(final JsonCommand command, final JsonElement element, final Long productId,
final Map<String, Object> changes, final PortfolioProductType portfolioProductType) { final Map<String, Object> changes, final PortfolioProductType portfolioProductType) {
final JsonArray paymentChannelMappingArray = this.fromApiJsonHelper.extractJsonArrayNamed( final JsonArray paymentChannelMappingArray = this.fromApiJsonHelper.extractJsonArrayNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(), element); LoanProductAccountingParams.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(), element);
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(LoanProductAccountingParams.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(),
command.jsonFragment(LOAN_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue())); command.jsonFragment(LoanProductAccountingParams.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue()));
} }
for (int i = 0; i < paymentChannelMappingArray.size(); i++) { for (int i = 0; i < paymentChannelMappingArray.size(); i++) {
final JsonObject jsonObject = paymentChannelMappingArray.get(i).getAsJsonObject(); final JsonObject jsonObject = paymentChannelMappingArray.get(i).getAsJsonObject();
final Long paymentTypeId = jsonObject.get(LOAN_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_TYPE.getValue()).getAsLong(); final Long paymentTypeId = jsonObject.get(LoanProductAccountingParams.PAYMENT_TYPE.getValue()).getAsLong();
final Long paymentSpecificFundAccountId = jsonObject.get(LOAN_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue()).getAsLong(); final Long paymentSpecificFundAccountId = jsonObject.get(LoanProductAccountingParams.FUND_SOURCE.getValue()).getAsLong();
savePaymentChannelToFundSourceMapping(productId, paymentTypeId, paymentSpecificFundAccountId, portfolioProductType); savePaymentChannelToFundSourceMapping(productId, paymentTypeId, paymentSpecificFundAccountId, portfolioProductType);
} }
} }
@@ -164,21 +164,21 @@ public class ProductToGLAccountMappingHelper {
final 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 = LoanProductAccountingParams.PENALTY_INCOME_ACCOUNT_MAPPING.getValue();
} else { } else {
arrayName = LOAN_PRODUCT_ACCOUNTING_PARAMS.FEE_INCOME_ACCOUNT_MAPPING.getValue(); arrayName = LoanProductAccountingParams.FEE_INCOME_ACCOUNT_MAPPING.getValue();
} }
final JsonArray chargeToIncomeAccountMappingArray = this.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(LoanProductAccountingParams.FEE_INCOME_ACCOUNT_MAPPING.getValue(),
command.jsonFragment(LOAN_PRODUCT_ACCOUNTING_PARAMS.FEE_INCOME_ACCOUNT_MAPPING.getValue())); command.jsonFragment(LoanProductAccountingParams.FEE_INCOME_ACCOUNT_MAPPING.getValue()));
} }
for (int i = 0; i < chargeToIncomeAccountMappingArray.size(); i++) { for (int i = 0; i < chargeToIncomeAccountMappingArray.size(); i++) {
final JsonObject jsonObject = chargeToIncomeAccountMappingArray.get(i).getAsJsonObject(); final JsonObject jsonObject = chargeToIncomeAccountMappingArray.get(i).getAsJsonObject();
final Long chargeId = jsonObject.get(LOAN_PRODUCT_ACCOUNTING_PARAMS.CHARGE_ID.getValue()).getAsLong(); final Long chargeId = jsonObject.get(LoanProductAccountingParams.CHARGE_ID.getValue()).getAsLong();
final Long incomeAccountId = jsonObject.get(LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_ACCOUNT_ID.getValue()).getAsLong(); final Long incomeAccountId = jsonObject.get(LoanProductAccountingParams.INCOME_ACCOUNT_ID.getValue()).getAsLong();
saveChargeToFundSourceMapping(productId, chargeId, incomeAccountId, portfolioProductType, isPenalty); saveChargeToFundSourceMapping(productId, chargeId, incomeAccountId, portfolioProductType, isPenalty);
} }
} }
@@ -199,11 +199,11 @@ public class ProductToGLAccountMappingHelper {
if (isPenalty) { if (isPenalty) {
existingChargeToIncomeAccountMappings = this.accountMappingRepository.findAllPenaltyToIncomeAccountMappings(productId, existingChargeToIncomeAccountMappings = this.accountMappingRepository.findAllPenaltyToIncomeAccountMappings(productId,
portfolioProductType.getValue()); portfolioProductType.getValue());
arrayFragmentName = LOAN_PRODUCT_ACCOUNTING_PARAMS.PENALTY_INCOME_ACCOUNT_MAPPING.getValue(); arrayFragmentName = LoanProductAccountingParams.PENALTY_INCOME_ACCOUNT_MAPPING.getValue();
} else { } else {
existingChargeToIncomeAccountMappings = this.accountMappingRepository.findAllFeeToIncomeAccountMappings(productId, existingChargeToIncomeAccountMappings = this.accountMappingRepository.findAllFeeToIncomeAccountMappings(productId,
portfolioProductType.getValue()); portfolioProductType.getValue());
arrayFragmentName = LOAN_PRODUCT_ACCOUNTING_PARAMS.FEE_INCOME_ACCOUNT_MAPPING.getValue(); arrayFragmentName = LoanProductAccountingParams.FEE_INCOME_ACCOUNT_MAPPING.getValue();
} }
final JsonArray chargeToIncomeAccountMappingArray = this.fromApiJsonHelper.extractJsonArrayNamed(arrayFragmentName, element); final JsonArray chargeToIncomeAccountMappingArray = this.fromApiJsonHelper.extractJsonArrayNamed(arrayFragmentName, element);
@@ -225,8 +225,8 @@ public class ProductToGLAccountMappingHelper {
for (int i = 0; i < chargeToIncomeAccountMappingArray.size(); i++) { for (int i = 0; i < chargeToIncomeAccountMappingArray.size(); i++) {
final JsonObject jsonObject = chargeToIncomeAccountMappingArray.get(i).getAsJsonObject(); final JsonObject jsonObject = chargeToIncomeAccountMappingArray.get(i).getAsJsonObject();
final Long chargeId = jsonObject.get(LOAN_PRODUCT_ACCOUNTING_PARAMS.CHARGE_ID.getValue()).getAsLong(); final Long chargeId = jsonObject.get(LoanProductAccountingParams.CHARGE_ID.getValue()).getAsLong();
final Long incomeAccountId = jsonObject.get(LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_ACCOUNT_ID.getValue()).getAsLong(); final Long incomeAccountId = jsonObject.get(LoanProductAccountingParams.INCOME_ACCOUNT_ID.getValue()).getAsLong();
inputChargeToIncomeAccountMap.put(chargeId, incomeAccountId); inputChargeToIncomeAccountMap.put(chargeId, incomeAccountId);
} }
@@ -252,11 +252,11 @@ public class ProductToGLAccountMappingHelper {
if (!newGLAccountId.equals(chargeToIncomeAccountMapping.getGlAccount().getId())) { if (!newGLAccountId.equals(chargeToIncomeAccountMapping.getGlAccount().getId())) {
final GLAccount glAccount; final GLAccount glAccount;
if (isPenalty) { if (isPenalty) {
glAccount = getAccountByIdAndType(LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_ACCOUNT_ID.getValue(), glAccount = getAccountByIdAndType(LoanProductAccountingParams.INCOME_ACCOUNT_ID.getValue(),
GLAccountType.INCOME, newGLAccountId); GLAccountType.INCOME, newGLAccountId);
} else { } else {
List<GLAccountType> allowedAccountTypes = getAllowedAccountTypesForFeeMapping(); List<GLAccountType> allowedAccountTypes = getAllowedAccountTypesForFeeMapping();
glAccount = getAccountByIdAndType(LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_ACCOUNT_ID.getValue(), glAccount = getAccountByIdAndType(LoanProductAccountingParams.INCOME_ACCOUNT_ID.getValue(),
allowedAccountTypes, newGLAccountId); allowedAccountTypes, newGLAccountId);
} }
chargeToIncomeAccountMapping.setGlAccount(glAccount); chargeToIncomeAccountMapping.setGlAccount(glAccount);
@@ -292,7 +292,7 @@ public class ProductToGLAccountMappingHelper {
final List<ProductToGLAccountMapping> existingPaymentChannelToFundSourceMappings = this.accountMappingRepository final List<ProductToGLAccountMapping> existingPaymentChannelToFundSourceMappings = this.accountMappingRepository
.findAllPaymentTypeToFundSourceMappings(productId, portfolioProductType.getValue()); .findAllPaymentTypeToFundSourceMappings(productId, portfolioProductType.getValue());
final JsonArray paymentChannelMappingArray = this.fromApiJsonHelper.extractJsonArrayNamed( final JsonArray paymentChannelMappingArray = this.fromApiJsonHelper.extractJsonArrayNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(), element); LoanProductAccountingParams.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
@@ -305,14 +305,14 @@ public class ProductToGLAccountMappingHelper {
final Set<Long> existingPaymentTypes = new HashSet<>(); final Set<Long> existingPaymentTypes = new HashSet<>();
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(LoanProductAccountingParams.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(),
command.jsonFragment(LOAN_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue())); command.jsonFragment(LoanProductAccountingParams.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue()));
} }
for (int i = 0; i < paymentChannelMappingArray.size(); i++) { for (int i = 0; i < paymentChannelMappingArray.size(); i++) {
final JsonObject jsonObject = paymentChannelMappingArray.get(i).getAsJsonObject(); final JsonObject jsonObject = paymentChannelMappingArray.get(i).getAsJsonObject();
final Long paymentTypeId = jsonObject.get(LOAN_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_TYPE.getValue()).getAsLong(); final Long paymentTypeId = jsonObject.get(LoanProductAccountingParams.PAYMENT_TYPE.getValue()).getAsLong();
final Long paymentSpecificFundAccountId = jsonObject.get(LOAN_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue()).getAsLong(); final Long paymentSpecificFundAccountId = jsonObject.get(LoanProductAccountingParams.FUND_SOURCE.getValue()).getAsLong();
inputPaymentChannelFundSourceMap.put(paymentTypeId, paymentSpecificFundAccountId); inputPaymentChannelFundSourceMap.put(paymentTypeId, paymentSpecificFundAccountId);
} }
@@ -336,7 +336,7 @@ public class ProductToGLAccountMappingHelper {
if (inputPaymentChannelFundSourceMap.containsKey(currentPaymentChannelId)) { if (inputPaymentChannelFundSourceMap.containsKey(currentPaymentChannelId)) {
final Long newGLAccountId = inputPaymentChannelFundSourceMap.get(currentPaymentChannelId); final Long newGLAccountId = inputPaymentChannelFundSourceMap.get(currentPaymentChannelId);
if (!newGLAccountId.equals(existingPaymentChannelToFundSourceMapping.getGlAccount().getId())) { if (!newGLAccountId.equals(existingPaymentChannelToFundSourceMapping.getGlAccount().getId())) {
final GLAccount glAccount = getAccountByIdAndType(LOAN_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue(), final GLAccount glAccount = getAccountByIdAndType(LoanProductAccountingParams.FUND_SOURCE.getValue(),
GLAccountType.ASSET, newGLAccountId); GLAccountType.ASSET, newGLAccountId);
existingPaymentChannelToFundSourceMapping.setGlAccount(glAccount); existingPaymentChannelToFundSourceMapping.setGlAccount(glAccount);
this.accountMappingRepository.save(existingPaymentChannelToFundSourceMapping); this.accountMappingRepository.save(existingPaymentChannelToFundSourceMapping);
@@ -366,10 +366,10 @@ 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) {
final PaymentType paymentType = this.paymentTypeRepositoryWrapper.findOneWithNotFoundDetection(paymentTypeId); final PaymentType paymentType = this.paymentTypeRepositoryWrapper.findOneWithNotFoundDetection(paymentTypeId);
final GLAccount glAccount = getAccountByIdAndType(LOAN_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue(), GLAccountType.ASSET, final GLAccount glAccount = getAccountByIdAndType(LoanProductAccountingParams.FUND_SOURCE.getValue(), GLAccountType.ASSET,
paymentTypeSpecificFundAccountId); paymentTypeSpecificFundAccountId);
final ProductToGLAccountMapping accountMapping = new ProductToGLAccountMapping(glAccount, productId, final ProductToGLAccountMapping accountMapping = new ProductToGLAccountMapping(glAccount, productId,
portfolioProductType.getValue(), CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue(), paymentType); portfolioProductType.getValue(), CashAccountsForLoan.FUND_SOURCE.getValue(), paymentType);
this.accountMappingRepository.save(accountMapping); this.accountMappingRepository.save(accountMapping);
} }
@@ -389,16 +389,16 @@ public class ProductToGLAccountMappingHelper {
* Both CASH and Accrual placeholders have the same value for income * Both CASH and Accrual placeholders have the same value for income
* from Interest and penalties * from Interest and penalties
**/ **/
CASH_ACCOUNTS_FOR_LOAN placeHolderAccountType; CashAccountsForLoan placeHolderAccountType;
if (isPenalty) { if (isPenalty) {
glAccount = getAccountByIdAndType(LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_ACCOUNT_ID.getValue(), GLAccountType.INCOME, glAccount = getAccountByIdAndType(LoanProductAccountingParams.INCOME_ACCOUNT_ID.getValue(), GLAccountType.INCOME,
incomeAccountId); incomeAccountId);
placeHolderAccountType = CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_PENALTIES; placeHolderAccountType = CashAccountsForLoan.INCOME_FROM_PENALTIES;
} else { } else {
List<GLAccountType> allowedAccountTypes = getAllowedAccountTypesForFeeMapping(); List<GLAccountType> allowedAccountTypes = getAllowedAccountTypesForFeeMapping();
glAccount = getAccountByIdAndType(LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_ACCOUNT_ID.getValue(), allowedAccountTypes, glAccount = getAccountByIdAndType(LoanProductAccountingParams.INCOME_ACCOUNT_ID.getValue(), allowedAccountTypes,
incomeAccountId); incomeAccountId);
placeHolderAccountType = CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_FEES; placeHolderAccountType = CashAccountsForLoan.INCOME_FROM_FEES;
} }
final ProductToGLAccountMapping accountMapping = new ProductToGLAccountMapping(glAccount, productId, final ProductToGLAccountMapping accountMapping = new ProductToGLAccountMapping(glAccount, productId,
portfolioProductType.getValue(), placeHolderAccountType.getValue(), charge); portfolioProductType.getValue(), placeHolderAccountType.getValue(), charge);
@@ -24,13 +24,13 @@ import java.util.ArrayList;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.fineract.accounting.common.AccountingConstants.ACCRUAL_ACCOUNTS_FOR_LOAN; import org.apache.fineract.accounting.common.AccountingConstants.AccrualAccountsForLoan;
import org.apache.fineract.accounting.common.AccountingConstants.CASH_ACCOUNTS_FOR_LOAN; import org.apache.fineract.accounting.common.AccountingConstants.CashAccountsForLoan;
import org.apache.fineract.accounting.common.AccountingConstants.CASH_ACCOUNTS_FOR_SAVINGS; import org.apache.fineract.accounting.common.AccountingConstants.CashAccountsForSavings;
import org.apache.fineract.accounting.common.AccountingConstants.CASH_ACCOUNTS_FOR_SHARES; import org.apache.fineract.accounting.common.AccountingConstants.CashAccountsForShares;
import org.apache.fineract.accounting.common.AccountingConstants.LOAN_PRODUCT_ACCOUNTING_DATA_PARAMS; import org.apache.fineract.accounting.common.AccountingConstants.LoanProductAccountingDataParams;
import org.apache.fineract.accounting.common.AccountingConstants.SAVINGS_PRODUCT_ACCOUNTING_DATA_PARAMS; import org.apache.fineract.accounting.common.AccountingConstants.SavingProductAccountingDataParams;
import org.apache.fineract.accounting.common.AccountingConstants.SHARES_PRODUCT_ACCOUNTING_PARAMS; import org.apache.fineract.accounting.common.AccountingConstants.SharesProductAccountingParams;
import org.apache.fineract.accounting.common.AccountingRuleType; import org.apache.fineract.accounting.common.AccountingRuleType;
import org.apache.fineract.accounting.glaccount.data.GLAccountData; import org.apache.fineract.accounting.glaccount.data.GLAccountData;
import org.apache.fineract.accounting.producttoaccountmapping.data.ChargeToGLAccountMapper; import org.apache.fineract.accounting.producttoaccountmapping.data.ChargeToGLAccountMapper;
@@ -116,31 +116,31 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
for (final Map<String, Object> productToGLAccountMap : listOfProductToGLAccountMaps) { for (final Map<String, Object> productToGLAccountMap : listOfProductToGLAccountMaps) {
final Integer financialAccountType = (Integer) productToGLAccountMap.get("financialAccountType"); final Integer financialAccountType = (Integer) productToGLAccountMap.get("financialAccountType");
final CASH_ACCOUNTS_FOR_LOAN glAccountForLoan = CASH_ACCOUNTS_FOR_LOAN.fromInt(financialAccountType); final CashAccountsForLoan glAccountForLoan = CashAccountsForLoan.fromInt(financialAccountType);
final Long glAccountId = (Long) productToGLAccountMap.get("glAccountId"); final Long glAccountId = (Long) productToGLAccountMap.get("glAccountId");
final String glAccountName = (String) productToGLAccountMap.get("glAccountName"); final String glAccountName = (String) productToGLAccountMap.get("glAccountName");
final String glCode = (String) productToGLAccountMap.get("glCode"); final String glCode = (String) productToGLAccountMap.get("glCode");
final GLAccountData gLAccountData = new GLAccountData(glAccountId, glAccountName, glCode); final GLAccountData gLAccountData = new GLAccountData(glAccountId, glAccountName, glCode);
if (glAccountForLoan.equals(CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE)) { if (glAccountForLoan.equals(CashAccountsForLoan.FUND_SOURCE)) {
accountMappingDetails.put(LOAN_PRODUCT_ACCOUNTING_DATA_PARAMS.FUND_SOURCE.getValue(), gLAccountData); accountMappingDetails.put(LoanProductAccountingDataParams.FUND_SOURCE.getValue(), gLAccountData);
} else if (glAccountForLoan.equals(CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_FEES)) { } else if (glAccountForLoan.equals(CashAccountsForLoan.INCOME_FROM_FEES)) {
accountMappingDetails.put(LOAN_PRODUCT_ACCOUNTING_DATA_PARAMS.INCOME_FROM_FEES.getValue(), gLAccountData); accountMappingDetails.put(LoanProductAccountingDataParams.INCOME_FROM_FEES.getValue(), gLAccountData);
} else if (glAccountForLoan.equals(CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_PENALTIES)) { } else if (glAccountForLoan.equals(CashAccountsForLoan.INCOME_FROM_PENALTIES)) {
accountMappingDetails.put(LOAN_PRODUCT_ACCOUNTING_DATA_PARAMS.INCOME_FROM_PENALTIES.getValue(), gLAccountData); accountMappingDetails.put(LoanProductAccountingDataParams.INCOME_FROM_PENALTIES.getValue(), gLAccountData);
} else if (glAccountForLoan.equals(CASH_ACCOUNTS_FOR_LOAN.INTEREST_ON_LOANS)) { } else if (glAccountForLoan.equals(CashAccountsForLoan.INTEREST_ON_LOANS)) {
accountMappingDetails.put(LOAN_PRODUCT_ACCOUNTING_DATA_PARAMS.INTEREST_ON_LOANS.getValue(), gLAccountData); accountMappingDetails.put(LoanProductAccountingDataParams.INTEREST_ON_LOANS.getValue(), gLAccountData);
} else if (glAccountForLoan.equals(CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO)) { } else if (glAccountForLoan.equals(CashAccountsForLoan.LOAN_PORTFOLIO)) {
accountMappingDetails.put(LOAN_PRODUCT_ACCOUNTING_DATA_PARAMS.LOAN_PORTFOLIO.getValue(), gLAccountData); accountMappingDetails.put(LoanProductAccountingDataParams.LOAN_PORTFOLIO.getValue(), gLAccountData);
} else if (glAccountForLoan.equals(CASH_ACCOUNTS_FOR_LOAN.TRANSFERS_SUSPENSE)) { } else if (glAccountForLoan.equals(CashAccountsForLoan.TRANSFERS_SUSPENSE)) {
accountMappingDetails.put(LOAN_PRODUCT_ACCOUNTING_DATA_PARAMS.TRANSFERS_SUSPENSE.getValue(), gLAccountData); accountMappingDetails.put(LoanProductAccountingDataParams.TRANSFERS_SUSPENSE.getValue(), gLAccountData);
} else if (glAccountForLoan.equals(CASH_ACCOUNTS_FOR_LOAN.LOSSES_WRITTEN_OFF)) { } else if (glAccountForLoan.equals(CashAccountsForLoan.LOSSES_WRITTEN_OFF)) {
accountMappingDetails.put(LOAN_PRODUCT_ACCOUNTING_DATA_PARAMS.LOSSES_WRITTEN_OFF.getValue(), gLAccountData); accountMappingDetails.put(LoanProductAccountingDataParams.LOSSES_WRITTEN_OFF.getValue(), gLAccountData);
} else if (glAccountForLoan.equals(CASH_ACCOUNTS_FOR_LOAN.OVERPAYMENT)) { } else if (glAccountForLoan.equals(CashAccountsForLoan.OVERPAYMENT)) {
accountMappingDetails.put(LOAN_PRODUCT_ACCOUNTING_DATA_PARAMS.OVERPAYMENT.getValue(), gLAccountData); accountMappingDetails.put(LoanProductAccountingDataParams.OVERPAYMENT.getValue(), gLAccountData);
} else if (glAccountForLoan.equals(CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_RECOVERY)) { } else if (glAccountForLoan.equals(CashAccountsForLoan.INCOME_FROM_RECOVERY)) {
accountMappingDetails.put(LOAN_PRODUCT_ACCOUNTING_DATA_PARAMS.INCOME_FROM_RECOVERY.getValue(), gLAccountData); accountMappingDetails.put(LoanProductAccountingDataParams.INCOME_FROM_RECOVERY.getValue(), gLAccountData);
} }
} }
} else if (AccountingRuleType.ACCRUAL_UPFRONT.getValue().equals(accountingType) } else if (AccountingRuleType.ACCRUAL_UPFRONT.getValue().equals(accountingType)
@@ -148,37 +148,37 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
for (final Map<String, Object> productToGLAccountMap : listOfProductToGLAccountMaps) { for (final Map<String, Object> productToGLAccountMap : listOfProductToGLAccountMaps) {
final Integer financialAccountType = (Integer) productToGLAccountMap.get("financialAccountType"); final Integer financialAccountType = (Integer) productToGLAccountMap.get("financialAccountType");
final ACCRUAL_ACCOUNTS_FOR_LOAN glAccountForLoan = ACCRUAL_ACCOUNTS_FOR_LOAN.fromInt(financialAccountType); final AccrualAccountsForLoan glAccountForLoan = AccrualAccountsForLoan.fromInt(financialAccountType);
final Long glAccountId = (Long) productToGLAccountMap.get("glAccountId"); final Long glAccountId = (Long) productToGLAccountMap.get("glAccountId");
final String glAccountName = (String) productToGLAccountMap.get("glAccountName"); final String glAccountName = (String) productToGLAccountMap.get("glAccountName");
final String glCode = (String) productToGLAccountMap.get("glCode"); final String glCode = (String) productToGLAccountMap.get("glCode");
final GLAccountData gLAccountData = new GLAccountData(glAccountId, glAccountName, glCode); final GLAccountData gLAccountData = new GLAccountData(glAccountId, glAccountName, glCode);
if (glAccountForLoan.equals(ACCRUAL_ACCOUNTS_FOR_LOAN.FUND_SOURCE)) { if (glAccountForLoan.equals(AccrualAccountsForLoan.FUND_SOURCE)) {
accountMappingDetails.put(LOAN_PRODUCT_ACCOUNTING_DATA_PARAMS.FUND_SOURCE.getValue(), gLAccountData); accountMappingDetails.put(LoanProductAccountingDataParams.FUND_SOURCE.getValue(), gLAccountData);
} else if (glAccountForLoan.equals(ACCRUAL_ACCOUNTS_FOR_LOAN.INCOME_FROM_FEES)) { } else if (glAccountForLoan.equals(AccrualAccountsForLoan.INCOME_FROM_FEES)) {
accountMappingDetails.put(LOAN_PRODUCT_ACCOUNTING_DATA_PARAMS.INCOME_FROM_FEES.getValue(), gLAccountData); accountMappingDetails.put(LoanProductAccountingDataParams.INCOME_FROM_FEES.getValue(), gLAccountData);
} else if (glAccountForLoan.equals(ACCRUAL_ACCOUNTS_FOR_LOAN.INCOME_FROM_PENALTIES)) { } else if (glAccountForLoan.equals(AccrualAccountsForLoan.INCOME_FROM_PENALTIES)) {
accountMappingDetails.put(LOAN_PRODUCT_ACCOUNTING_DATA_PARAMS.INCOME_FROM_PENALTIES.getValue(), gLAccountData); accountMappingDetails.put(LoanProductAccountingDataParams.INCOME_FROM_PENALTIES.getValue(), gLAccountData);
} else if (glAccountForLoan.equals(ACCRUAL_ACCOUNTS_FOR_LOAN.INTEREST_ON_LOANS)) { } else if (glAccountForLoan.equals(AccrualAccountsForLoan.INTEREST_ON_LOANS)) {
accountMappingDetails.put(LOAN_PRODUCT_ACCOUNTING_DATA_PARAMS.INTEREST_ON_LOANS.getValue(), gLAccountData); accountMappingDetails.put(LoanProductAccountingDataParams.INTEREST_ON_LOANS.getValue(), gLAccountData);
} else if (glAccountForLoan.equals(ACCRUAL_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO)) { } else if (glAccountForLoan.equals(AccrualAccountsForLoan.LOAN_PORTFOLIO)) {
accountMappingDetails.put(LOAN_PRODUCT_ACCOUNTING_DATA_PARAMS.LOAN_PORTFOLIO.getValue(), gLAccountData); accountMappingDetails.put(LoanProductAccountingDataParams.LOAN_PORTFOLIO.getValue(), gLAccountData);
} else if (glAccountForLoan.equals(ACCRUAL_ACCOUNTS_FOR_LOAN.OVERPAYMENT)) { } else if (glAccountForLoan.equals(AccrualAccountsForLoan.OVERPAYMENT)) {
accountMappingDetails.put(LOAN_PRODUCT_ACCOUNTING_DATA_PARAMS.OVERPAYMENT.getValue(), gLAccountData); accountMappingDetails.put(LoanProductAccountingDataParams.OVERPAYMENT.getValue(), gLAccountData);
} else if (glAccountForLoan.equals(ACCRUAL_ACCOUNTS_FOR_LOAN.TRANSFERS_SUSPENSE)) { } else if (glAccountForLoan.equals(AccrualAccountsForLoan.TRANSFERS_SUSPENSE)) {
accountMappingDetails.put(LOAN_PRODUCT_ACCOUNTING_DATA_PARAMS.TRANSFERS_SUSPENSE.getValue(), gLAccountData); accountMappingDetails.put(LoanProductAccountingDataParams.TRANSFERS_SUSPENSE.getValue(), gLAccountData);
} else if (glAccountForLoan.equals(ACCRUAL_ACCOUNTS_FOR_LOAN.LOSSES_WRITTEN_OFF)) { } else if (glAccountForLoan.equals(AccrualAccountsForLoan.LOSSES_WRITTEN_OFF)) {
accountMappingDetails.put(LOAN_PRODUCT_ACCOUNTING_DATA_PARAMS.LOSSES_WRITTEN_OFF.getValue(), gLAccountData); accountMappingDetails.put(LoanProductAccountingDataParams.LOSSES_WRITTEN_OFF.getValue(), gLAccountData);
} else if (glAccountForLoan.equals(ACCRUAL_ACCOUNTS_FOR_LOAN.INTEREST_RECEIVABLE)) { } else if (glAccountForLoan.equals(AccrualAccountsForLoan.INTEREST_RECEIVABLE)) {
accountMappingDetails.put(LOAN_PRODUCT_ACCOUNTING_DATA_PARAMS.INTEREST_RECEIVABLE.getValue(), gLAccountData); accountMappingDetails.put(LoanProductAccountingDataParams.INTEREST_RECEIVABLE.getValue(), gLAccountData);
} else if (glAccountForLoan.equals(ACCRUAL_ACCOUNTS_FOR_LOAN.FEES_RECEIVABLE)) { } else if (glAccountForLoan.equals(AccrualAccountsForLoan.FEES_RECEIVABLE)) {
accountMappingDetails.put(LOAN_PRODUCT_ACCOUNTING_DATA_PARAMS.FEES_RECEIVABLE.getValue(), gLAccountData); accountMappingDetails.put(LoanProductAccountingDataParams.FEES_RECEIVABLE.getValue(), gLAccountData);
} else if (glAccountForLoan.equals(ACCRUAL_ACCOUNTS_FOR_LOAN.PENALTIES_RECEIVABLE)) { } else if (glAccountForLoan.equals(AccrualAccountsForLoan.PENALTIES_RECEIVABLE)) {
accountMappingDetails.put(LOAN_PRODUCT_ACCOUNTING_DATA_PARAMS.PENALTIES_RECEIVABLE.getValue(), gLAccountData); accountMappingDetails.put(LoanProductAccountingDataParams.PENALTIES_RECEIVABLE.getValue(), gLAccountData);
} else if ((glAccountForLoan.equals(ACCRUAL_ACCOUNTS_FOR_LOAN.INCOME_FROM_RECOVERY))) { } else if ((glAccountForLoan.equals(AccrualAccountsForLoan.INCOME_FROM_RECOVERY))) {
accountMappingDetails.put(LOAN_PRODUCT_ACCOUNTING_DATA_PARAMS.INCOME_FROM_RECOVERY.getValue(), gLAccountData); accountMappingDetails.put(LoanProductAccountingDataParams.INCOME_FROM_RECOVERY.getValue(), gLAccountData);
} }
} }
@@ -202,33 +202,33 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
for (final Map<String, Object> productToGLAccountMap : listOfProductToGLAccountMaps) { for (final Map<String, Object> productToGLAccountMap : listOfProductToGLAccountMaps) {
final Integer financialAccountType = (Integer) productToGLAccountMap.get("financialAccountType"); final Integer financialAccountType = (Integer) productToGLAccountMap.get("financialAccountType");
final CASH_ACCOUNTS_FOR_SAVINGS glAccountForSavings = CASH_ACCOUNTS_FOR_SAVINGS.fromInt(financialAccountType); final CashAccountsForSavings glAccountForSavings = CashAccountsForSavings.fromInt(financialAccountType);
final Long glAccountId = (Long) productToGLAccountMap.get("glAccountId"); final Long glAccountId = (Long) productToGLAccountMap.get("glAccountId");
final String glAccountName = (String) productToGLAccountMap.get("glAccountName"); final String glAccountName = (String) productToGLAccountMap.get("glAccountName");
final String glCode = (String) productToGLAccountMap.get("glCode"); final String glCode = (String) productToGLAccountMap.get("glCode");
final GLAccountData gLAccountData = new GLAccountData(glAccountId, glAccountName, glCode); final GLAccountData gLAccountData = new GLAccountData(glAccountId, glAccountName, glCode);
if (glAccountForSavings.equals(CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_REFERENCE)) { if (glAccountForSavings.equals(CashAccountsForSavings.SAVINGS_REFERENCE)) {
accountMappingDetails.put(SAVINGS_PRODUCT_ACCOUNTING_DATA_PARAMS.SAVINGS_REFERENCE.getValue(), gLAccountData); accountMappingDetails.put(SavingProductAccountingDataParams.SAVINGS_REFERENCE.getValue(), gLAccountData);
} else if (glAccountForSavings.equals(CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL)) { } else if (glAccountForSavings.equals(CashAccountsForSavings.SAVINGS_CONTROL)) {
accountMappingDetails.put(SAVINGS_PRODUCT_ACCOUNTING_DATA_PARAMS.SAVINGS_CONTROL.getValue(), gLAccountData); accountMappingDetails.put(SavingProductAccountingDataParams.SAVINGS_CONTROL.getValue(), gLAccountData);
} else if (glAccountForSavings.equals(CASH_ACCOUNTS_FOR_SAVINGS.INCOME_FROM_FEES)) { } else if (glAccountForSavings.equals(CashAccountsForSavings.INCOME_FROM_FEES)) {
accountMappingDetails.put(SAVINGS_PRODUCT_ACCOUNTING_DATA_PARAMS.INCOME_FROM_FEES.getValue(), gLAccountData); accountMappingDetails.put(SavingProductAccountingDataParams.INCOME_FROM_FEES.getValue(), gLAccountData);
} else if (glAccountForSavings.equals(CASH_ACCOUNTS_FOR_SAVINGS.INCOME_FROM_PENALTIES)) { } else if (glAccountForSavings.equals(CashAccountsForSavings.INCOME_FROM_PENALTIES)) {
accountMappingDetails.put(SAVINGS_PRODUCT_ACCOUNTING_DATA_PARAMS.INCOME_FROM_PENALTIES.getValue(), gLAccountData); accountMappingDetails.put(SavingProductAccountingDataParams.INCOME_FROM_PENALTIES.getValue(), gLAccountData);
} else if (glAccountForSavings.equals(CASH_ACCOUNTS_FOR_SAVINGS.TRANSFERS_SUSPENSE)) { } else if (glAccountForSavings.equals(CashAccountsForSavings.TRANSFERS_SUSPENSE)) {
accountMappingDetails.put(SAVINGS_PRODUCT_ACCOUNTING_DATA_PARAMS.TRANSFERS_SUSPENSE.getValue(), gLAccountData); accountMappingDetails.put(SavingProductAccountingDataParams.TRANSFERS_SUSPENSE.getValue(), gLAccountData);
} else if (glAccountForSavings.equals(CASH_ACCOUNTS_FOR_SAVINGS.INTEREST_ON_SAVINGS)) { } else if (glAccountForSavings.equals(CashAccountsForSavings.INTEREST_ON_SAVINGS)) {
accountMappingDetails.put(SAVINGS_PRODUCT_ACCOUNTING_DATA_PARAMS.INTEREST_ON_SAVINGS.getValue(), gLAccountData); accountMappingDetails.put(SavingProductAccountingDataParams.INTEREST_ON_SAVINGS.getValue(), gLAccountData);
} else if (glAccountForSavings.equals(CASH_ACCOUNTS_FOR_SAVINGS.OVERDRAFT_PORTFOLIO_CONTROL)) { } else if (glAccountForSavings.equals(CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL)) {
accountMappingDetails.put(SAVINGS_PRODUCT_ACCOUNTING_DATA_PARAMS.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), gLAccountData); accountMappingDetails.put(SavingProductAccountingDataParams.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), gLAccountData);
} else if (glAccountForSavings.equals(CASH_ACCOUNTS_FOR_SAVINGS.LOSSES_WRITTEN_OFF)) { } else if (glAccountForSavings.equals(CashAccountsForSavings.LOSSES_WRITTEN_OFF)) {
accountMappingDetails.put(SAVINGS_PRODUCT_ACCOUNTING_DATA_PARAMS.LOSSES_WRITTEN_OFF.getValue(), gLAccountData); accountMappingDetails.put(SavingProductAccountingDataParams.LOSSES_WRITTEN_OFF.getValue(), gLAccountData);
} else if (glAccountForSavings.equals(CASH_ACCOUNTS_FOR_SAVINGS.INCOME_FROM_INTEREST)) { } else if (glAccountForSavings.equals(CashAccountsForSavings.INCOME_FROM_INTEREST)) {
accountMappingDetails.put(SAVINGS_PRODUCT_ACCOUNTING_DATA_PARAMS.INCOME_FROM_INTEREST.getValue(), gLAccountData); accountMappingDetails.put(SavingProductAccountingDataParams.INCOME_FROM_INTEREST.getValue(), gLAccountData);
} else if (glAccountForSavings.equals(CASH_ACCOUNTS_FOR_SAVINGS.ESCHEAT_LIABILITY)) { } else if (glAccountForSavings.equals(CashAccountsForSavings.ESCHEAT_LIABILITY)) {
accountMappingDetails.put(SAVINGS_PRODUCT_ACCOUNTING_DATA_PARAMS.ESCHEAT_LIABILITY.getValue(), gLAccountData); accountMappingDetails.put(SavingProductAccountingDataParams.ESCHEAT_LIABILITY.getValue(), gLAccountData);
} }
} }
} }
@@ -343,21 +343,21 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
if (AccountingRuleType.CASH_BASED.getValue().equals(accountingType)) { if (AccountingRuleType.CASH_BASED.getValue().equals(accountingType)) {
for (final Map<String, Object> productToGLAccountMap : listOfProductToGLAccountMaps) { for (final Map<String, Object> productToGLAccountMap : listOfProductToGLAccountMaps) {
final Integer financialAccountType = (Integer) productToGLAccountMap.get("financialAccountType"); final Integer financialAccountType = (Integer) productToGLAccountMap.get("financialAccountType");
final CASH_ACCOUNTS_FOR_SHARES glAccountForShares = CASH_ACCOUNTS_FOR_SHARES.fromInt(financialAccountType); final CashAccountsForShares glAccountForShares = CashAccountsForShares.fromInt(financialAccountType);
final Long glAccountId = (Long) productToGLAccountMap.get("glAccountId"); final Long glAccountId = (Long) productToGLAccountMap.get("glAccountId");
final String glAccountName = (String) productToGLAccountMap.get("glAccountName"); final String glAccountName = (String) productToGLAccountMap.get("glAccountName");
final String glCode = (String) productToGLAccountMap.get("glCode"); final String glCode = (String) productToGLAccountMap.get("glCode");
final GLAccountData gLAccountData = new GLAccountData(glAccountId, glAccountName, glCode); final GLAccountData gLAccountData = new GLAccountData(glAccountId, glAccountName, glCode);
if (glAccountForShares.equals(CASH_ACCOUNTS_FOR_SHARES.SHARES_REFERENCE)) { if (glAccountForShares.equals(CashAccountsForShares.SHARES_REFERENCE)) {
accountMappingDetails.put(SHARES_PRODUCT_ACCOUNTING_PARAMS.SHARES_REFERENCE.getValue(), gLAccountData); accountMappingDetails.put(SharesProductAccountingParams.SHARES_REFERENCE.getValue(), gLAccountData);
} else if (glAccountForShares.equals(CASH_ACCOUNTS_FOR_SHARES.SHARES_SUSPENSE)) { } else if (glAccountForShares.equals(CashAccountsForShares.SHARES_SUSPENSE)) {
accountMappingDetails.put(SHARES_PRODUCT_ACCOUNTING_PARAMS.SHARES_SUSPENSE.getValue(), gLAccountData); accountMappingDetails.put(SharesProductAccountingParams.SHARES_SUSPENSE.getValue(), gLAccountData);
} else if (glAccountForShares.equals(CASH_ACCOUNTS_FOR_SHARES.INCOME_FROM_FEES)) { } else if (glAccountForShares.equals(CashAccountsForShares.INCOME_FROM_FEES)) {
accountMappingDetails.put(SHARES_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), gLAccountData); accountMappingDetails.put(SharesProductAccountingParams.INCOME_FROM_FEES.getValue(), gLAccountData);
} else if (glAccountForShares.equals(CASH_ACCOUNTS_FOR_SHARES.SHARES_EQUITY)) { } else if (glAccountForShares.equals(CashAccountsForShares.SHARES_EQUITY)) {
accountMappingDetails.put(SHARES_PRODUCT_ACCOUNTING_PARAMS.SHARES_EQUITY.getValue(), gLAccountData); accountMappingDetails.put(SharesProductAccountingParams.SHARES_EQUITY.getValue(), gLAccountData);
} }
} }
} }
@@ -25,13 +25,13 @@ import com.google.gson.JsonElement;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import org.apache.fineract.accounting.common.AccountingConstants.ACCRUAL_ACCOUNTS_FOR_LOAN; import org.apache.fineract.accounting.common.AccountingConstants.AccrualAccountsForLoan;
import org.apache.fineract.accounting.common.AccountingConstants.CASH_ACCOUNTS_FOR_LOAN; import org.apache.fineract.accounting.common.AccountingConstants.CashAccountsForLoan;
import org.apache.fineract.accounting.common.AccountingConstants.CASH_ACCOUNTS_FOR_SAVINGS; import org.apache.fineract.accounting.common.AccountingConstants.CashAccountsForSavings;
import org.apache.fineract.accounting.common.AccountingConstants.CASH_ACCOUNTS_FOR_SHARES; import org.apache.fineract.accounting.common.AccountingConstants.CashAccountsForShares;
import org.apache.fineract.accounting.common.AccountingConstants.LOAN_PRODUCT_ACCOUNTING_PARAMS; import org.apache.fineract.accounting.common.AccountingConstants.LoanProductAccountingParams;
import org.apache.fineract.accounting.common.AccountingConstants.SAVINGS_PRODUCT_ACCOUNTING_PARAMS; import org.apache.fineract.accounting.common.AccountingConstants.SavingProductAccountingParams;
import org.apache.fineract.accounting.common.AccountingConstants.SHARES_PRODUCT_ACCOUNTING_PARAMS; import org.apache.fineract.accounting.common.AccountingConstants.SharesProductAccountingParams;
import org.apache.fineract.accounting.common.AccountingRuleType; import org.apache.fineract.accounting.common.AccountingRuleType;
import org.apache.fineract.accounting.producttoaccountmapping.serialization.ProductToGLAccountMappingFromApiJsonDeserializer; import org.apache.fineract.accounting.producttoaccountmapping.serialization.ProductToGLAccountMappingFromApiJsonDeserializer;
import org.apache.fineract.infrastructure.core.api.JsonCommand; import org.apache.fineract.infrastructure.core.api.JsonCommand;
@@ -76,38 +76,38 @@ public class ProductToGLAccountMappingWritePlatformServiceImpl implements Produc
case CASH_BASED: case CASH_BASED:
// asset // asset
this.loanProductToGLAccountMappingHelper this.loanProductToGLAccountMappingHelper
.saveLoanToAssetAccountMapping(element, LOAN_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue(), loanProductId, .saveLoanToAssetAccountMapping(element, LoanProductAccountingParams.FUND_SOURCE.getValue(), loanProductId,
CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue()); CashAccountsForLoan.FUND_SOURCE.getValue());
this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element, this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
LOAN_PRODUCT_ACCOUNTING_PARAMS.LOAN_PORTFOLIO.getValue(), loanProductId, LoanProductAccountingParams.LOAN_PORTFOLIO.getValue(), loanProductId,
CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO.getValue()); CashAccountsForLoan.LOAN_PORTFOLIO.getValue());
this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element, this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
LOAN_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(), loanProductId, LoanProductAccountingParams.TRANSFERS_SUSPENSE.getValue(), loanProductId,
CASH_ACCOUNTS_FOR_LOAN.TRANSFERS_SUSPENSE.getValue()); CashAccountsForLoan.TRANSFERS_SUSPENSE.getValue());
// income // income
this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element, this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
LOAN_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_LOANS.getValue(), loanProductId, LoanProductAccountingParams.INTEREST_ON_LOANS.getValue(), loanProductId,
CASH_ACCOUNTS_FOR_LOAN.INTEREST_ON_LOANS.getValue()); CashAccountsForLoan.INTEREST_ON_LOANS.getValue());
this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element, this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), loanProductId, LoanProductAccountingParams.INCOME_FROM_FEES.getValue(), loanProductId,
CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_FEES.getValue()); CashAccountsForLoan.INCOME_FROM_FEES.getValue());
this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element, this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue(), loanProductId, LoanProductAccountingParams.INCOME_FROM_PENALTIES.getValue(), loanProductId,
CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_PENALTIES.getValue()); CashAccountsForLoan.INCOME_FROM_PENALTIES.getValue());
this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element, this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_RECOVERY.getValue(), loanProductId, LoanProductAccountingParams.INCOME_FROM_RECOVERY.getValue(), loanProductId,
CASH_ACCOUNTS_FOR_LOAN.INCOME_FROM_RECOVERY.getValue()); CashAccountsForLoan.INCOME_FROM_RECOVERY.getValue());
// expenses // expenses
this.loanProductToGLAccountMappingHelper.saveLoanToExpenseAccountMapping(element, this.loanProductToGLAccountMappingHelper.saveLoanToExpenseAccountMapping(element,
LOAN_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue(), loanProductId, LoanProductAccountingParams.LOSSES_WRITTEN_OFF.getValue(), loanProductId,
CASH_ACCOUNTS_FOR_LOAN.LOSSES_WRITTEN_OFF.getValue()); CashAccountsForLoan.LOSSES_WRITTEN_OFF.getValue());
// liabilities // liabilities
this.loanProductToGLAccountMappingHelper this.loanProductToGLAccountMappingHelper
.saveLoanToLiabilityAccountMapping(element, LOAN_PRODUCT_ACCOUNTING_PARAMS.OVERPAYMENT.getValue(), loanProductId, .saveLoanToLiabilityAccountMapping(element, LoanProductAccountingParams.OVERPAYMENT.getValue(), loanProductId,
CASH_ACCOUNTS_FOR_LOAN.OVERPAYMENT.getValue()); CashAccountsForLoan.OVERPAYMENT.getValue());
// advanced accounting mappings // advanced accounting mappings
this.loanProductToGLAccountMappingHelper.savePaymentChannelToFundSourceMappings(command, element, loanProductId, null); this.loanProductToGLAccountMappingHelper.savePaymentChannelToFundSourceMappings(command, element, loanProductId, null);
@@ -118,47 +118,47 @@ public class ProductToGLAccountMappingWritePlatformServiceImpl implements Produc
case ACCRUAL_PERIODIC: case ACCRUAL_PERIODIC:
// assets (including receivables) // assets (including receivables)
this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element, this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
LOAN_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue(), loanProductId, LoanProductAccountingParams.FUND_SOURCE.getValue(), loanProductId,
ACCRUAL_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue()); AccrualAccountsForLoan.FUND_SOURCE.getValue());
this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element, this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
LOAN_PRODUCT_ACCOUNTING_PARAMS.LOAN_PORTFOLIO.getValue(), loanProductId, LoanProductAccountingParams.LOAN_PORTFOLIO.getValue(), loanProductId,
ACCRUAL_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO.getValue()); AccrualAccountsForLoan.LOAN_PORTFOLIO.getValue());
this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element, this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
LOAN_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(), loanProductId, LoanProductAccountingParams.TRANSFERS_SUSPENSE.getValue(), loanProductId,
ACCRUAL_ACCOUNTS_FOR_LOAN.TRANSFERS_SUSPENSE.getValue()); AccrualAccountsForLoan.TRANSFERS_SUSPENSE.getValue());
this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element, this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
LOAN_PRODUCT_ACCOUNTING_PARAMS.INTEREST_RECEIVABLE.getValue(), loanProductId, LoanProductAccountingParams.INTEREST_RECEIVABLE.getValue(), loanProductId,
ACCRUAL_ACCOUNTS_FOR_LOAN.INTEREST_RECEIVABLE.getValue()); AccrualAccountsForLoan.INTEREST_RECEIVABLE.getValue());
this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element, this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
LOAN_PRODUCT_ACCOUNTING_PARAMS.FEES_RECEIVABLE.getValue(), loanProductId, LoanProductAccountingParams.FEES_RECEIVABLE.getValue(), loanProductId,
ACCRUAL_ACCOUNTS_FOR_LOAN.FEES_RECEIVABLE.getValue()); AccrualAccountsForLoan.FEES_RECEIVABLE.getValue());
this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element, this.loanProductToGLAccountMappingHelper.saveLoanToAssetAccountMapping(element,
LOAN_PRODUCT_ACCOUNTING_PARAMS.PENALTIES_RECEIVABLE.getValue(), loanProductId, LoanProductAccountingParams.PENALTIES_RECEIVABLE.getValue(), loanProductId,
ACCRUAL_ACCOUNTS_FOR_LOAN.PENALTIES_RECEIVABLE.getValue()); AccrualAccountsForLoan.PENALTIES_RECEIVABLE.getValue());
// income // income
this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element, this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
LOAN_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_LOANS.getValue(), loanProductId, LoanProductAccountingParams.INTEREST_ON_LOANS.getValue(), loanProductId,
ACCRUAL_ACCOUNTS_FOR_LOAN.INTEREST_ON_LOANS.getValue()); AccrualAccountsForLoan.INTEREST_ON_LOANS.getValue());
this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element, this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), loanProductId, LoanProductAccountingParams.INCOME_FROM_FEES.getValue(), loanProductId,
ACCRUAL_ACCOUNTS_FOR_LOAN.INCOME_FROM_FEES.getValue()); AccrualAccountsForLoan.INCOME_FROM_FEES.getValue());
this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element, this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue(), loanProductId, LoanProductAccountingParams.INCOME_FROM_PENALTIES.getValue(), loanProductId,
ACCRUAL_ACCOUNTS_FOR_LOAN.INCOME_FROM_PENALTIES.getValue()); AccrualAccountsForLoan.INCOME_FROM_PENALTIES.getValue());
this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element, this.loanProductToGLAccountMappingHelper.saveLoanToIncomeAccountMapping(element,
LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_RECOVERY.getValue(), loanProductId, LoanProductAccountingParams.INCOME_FROM_RECOVERY.getValue(), loanProductId,
ACCRUAL_ACCOUNTS_FOR_LOAN.INCOME_FROM_RECOVERY.getValue()); AccrualAccountsForLoan.INCOME_FROM_RECOVERY.getValue());
// expenses // expenses
this.loanProductToGLAccountMappingHelper.saveLoanToExpenseAccountMapping(element, this.loanProductToGLAccountMappingHelper.saveLoanToExpenseAccountMapping(element,
LOAN_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue(), loanProductId, LoanProductAccountingParams.LOSSES_WRITTEN_OFF.getValue(), loanProductId,
ACCRUAL_ACCOUNTS_FOR_LOAN.LOSSES_WRITTEN_OFF.getValue()); AccrualAccountsForLoan.LOSSES_WRITTEN_OFF.getValue());
// liabilities // liabilities
this.loanProductToGLAccountMappingHelper.saveLoanToLiabilityAccountMapping(element, this.loanProductToGLAccountMappingHelper.saveLoanToLiabilityAccountMapping(element,
LOAN_PRODUCT_ACCOUNTING_PARAMS.OVERPAYMENT.getValue(), loanProductId, LoanProductAccountingParams.OVERPAYMENT.getValue(), loanProductId,
ACCRUAL_ACCOUNTS_FOR_LOAN.OVERPAYMENT.getValue()); AccrualAccountsForLoan.OVERPAYMENT.getValue());
// advanced accounting mappings // advanced accounting mappings
this.loanProductToGLAccountMappingHelper.savePaymentChannelToFundSourceMappings(command, element, loanProductId, null); this.loanProductToGLAccountMappingHelper.savePaymentChannelToFundSourceMappings(command, element, loanProductId, null);
@@ -181,54 +181,54 @@ public class ProductToGLAccountMappingWritePlatformServiceImpl implements Produc
case CASH_BASED: case CASH_BASED:
// asset // asset
this.savingsProductToGLAccountMappingHelper.saveSavingsToAssetAccountMapping(element, this.savingsProductToGLAccountMappingHelper.saveSavingsToAssetAccountMapping(element,
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_REFERENCE.getValue(), savingProductId, SavingProductAccountingParams.SAVINGS_REFERENCE.getValue(), savingProductId,
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_REFERENCE.getValue()); CashAccountsForSavings.SAVINGS_REFERENCE.getValue());
if (!accountType.equals(DepositAccountType.RECURRING_DEPOSIT) && !accountType.equals(DepositAccountType.FIXED_DEPOSIT)) { if (!accountType.equals(DepositAccountType.RECURRING_DEPOSIT) && !accountType.equals(DepositAccountType.FIXED_DEPOSIT)) {
this.savingsProductToGLAccountMappingHelper.saveSavingsToAssetAccountMapping(element, this.savingsProductToGLAccountMappingHelper.saveSavingsToAssetAccountMapping(element,
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), savingProductId, SavingProductAccountingParams.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), savingProductId,
CASH_ACCOUNTS_FOR_SAVINGS.OVERDRAFT_PORTFOLIO_CONTROL.getValue()); CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue());
} }
// income // income
this.savingsProductToGLAccountMappingHelper.saveSavingsToIncomeAccountMapping(element, this.savingsProductToGLAccountMappingHelper.saveSavingsToIncomeAccountMapping(element,
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), savingProductId, SavingProductAccountingParams.INCOME_FROM_FEES.getValue(), savingProductId,
CASH_ACCOUNTS_FOR_SAVINGS.INCOME_FROM_FEES.getValue()); CashAccountsForSavings.INCOME_FROM_FEES.getValue());
this.savingsProductToGLAccountMappingHelper.saveSavingsToIncomeAccountMapping(element, this.savingsProductToGLAccountMappingHelper.saveSavingsToIncomeAccountMapping(element,
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue(), savingProductId, SavingProductAccountingParams.INCOME_FROM_PENALTIES.getValue(), savingProductId,
CASH_ACCOUNTS_FOR_SAVINGS.INCOME_FROM_PENALTIES.getValue()); CashAccountsForSavings.INCOME_FROM_PENALTIES.getValue());
if (!accountType.equals(DepositAccountType.RECURRING_DEPOSIT) && !accountType.equals(DepositAccountType.FIXED_DEPOSIT)) { if (!accountType.equals(DepositAccountType.RECURRING_DEPOSIT) && !accountType.equals(DepositAccountType.FIXED_DEPOSIT)) {
this.savingsProductToGLAccountMappingHelper.saveSavingsToIncomeAccountMapping(element, this.savingsProductToGLAccountMappingHelper.saveSavingsToIncomeAccountMapping(element,
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_INTEREST.getValue(), savingProductId, SavingProductAccountingParams.INCOME_FROM_INTEREST.getValue(), savingProductId,
CASH_ACCOUNTS_FOR_SAVINGS.INCOME_FROM_INTEREST.getValue()); CashAccountsForSavings.INCOME_FROM_INTEREST.getValue());
} }
// expenses // expenses
this.savingsProductToGLAccountMappingHelper.saveSavingsToExpenseAccountMapping(element, this.savingsProductToGLAccountMappingHelper.saveSavingsToExpenseAccountMapping(element,
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_SAVINGS.getValue(), savingProductId, SavingProductAccountingParams.INTEREST_ON_SAVINGS.getValue(), savingProductId,
CASH_ACCOUNTS_FOR_SAVINGS.INTEREST_ON_SAVINGS.getValue()); CashAccountsForSavings.INTEREST_ON_SAVINGS.getValue());
if (!accountType.equals(DepositAccountType.RECURRING_DEPOSIT) && !accountType.equals(DepositAccountType.FIXED_DEPOSIT)) { if (!accountType.equals(DepositAccountType.RECURRING_DEPOSIT) && !accountType.equals(DepositAccountType.FIXED_DEPOSIT)) {
this.savingsProductToGLAccountMappingHelper.saveSavingsToExpenseAccountMapping(element, this.savingsProductToGLAccountMappingHelper.saveSavingsToExpenseAccountMapping(element,
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue(), savingProductId, SavingProductAccountingParams.LOSSES_WRITTEN_OFF.getValue(), savingProductId,
CASH_ACCOUNTS_FOR_SAVINGS.LOSSES_WRITTEN_OFF.getValue()); CashAccountsForSavings.LOSSES_WRITTEN_OFF.getValue());
} }
// liability // liability
this.savingsProductToGLAccountMappingHelper.saveSavingsToLiabilityAccountMapping(element, this.savingsProductToGLAccountMappingHelper.saveSavingsToLiabilityAccountMapping(element,
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_CONTROL.getValue(), savingProductId, SavingProductAccountingParams.SAVINGS_CONTROL.getValue(), savingProductId,
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL.getValue()); CashAccountsForSavings.SAVINGS_CONTROL.getValue());
this.savingsProductToGLAccountMappingHelper.saveSavingsToLiabilityAccountMapping(element, this.savingsProductToGLAccountMappingHelper.saveSavingsToLiabilityAccountMapping(element,
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(), savingProductId, SavingProductAccountingParams.TRANSFERS_SUSPENSE.getValue(), savingProductId,
CASH_ACCOUNTS_FOR_SAVINGS.TRANSFERS_SUSPENSE.getValue()); CashAccountsForSavings.TRANSFERS_SUSPENSE.getValue());
final Boolean isDormancyTrackingActive = this.fromApiJsonHelper.extractBooleanNamed(isDormancyTrackingActiveParamName, element); final Boolean isDormancyTrackingActive = this.fromApiJsonHelper.extractBooleanNamed(isDormancyTrackingActiveParamName, element);
if(null != isDormancyTrackingActive && isDormancyTrackingActive){ if(null != isDormancyTrackingActive && isDormancyTrackingActive){
this.savingsProductToGLAccountMappingHelper.saveSavingsToLiabilityAccountMapping(element, this.savingsProductToGLAccountMappingHelper.saveSavingsToLiabilityAccountMapping(element,
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.ESCHEAT_LIABILITY.getValue(), savingProductId, SavingProductAccountingParams.ESCHEAT_LIABILITY.getValue(), savingProductId,
CASH_ACCOUNTS_FOR_SAVINGS.ESCHEAT_LIABILITY.getValue()); CashAccountsForSavings.ESCHEAT_LIABILITY.getValue());
} }
// advanced accounting mappings // advanced accounting mappings
@@ -257,23 +257,23 @@ public class ProductToGLAccountMappingWritePlatformServiceImpl implements Produc
case CASH_BASED: case CASH_BASED:
// asset // asset
this.shareProductToGLAccountMappingHelper.saveSharesToAssetAccountMapping(element, this.shareProductToGLAccountMappingHelper.saveSharesToAssetAccountMapping(element,
SHARES_PRODUCT_ACCOUNTING_PARAMS.SHARES_REFERENCE.getValue(), shareProductId, SharesProductAccountingParams.SHARES_REFERENCE.getValue(), shareProductId,
CASH_ACCOUNTS_FOR_SHARES.SHARES_REFERENCE.getValue()); CashAccountsForShares.SHARES_REFERENCE.getValue());
// income // income
this.shareProductToGLAccountMappingHelper.saveSharesToIncomeAccountMapping(element, this.shareProductToGLAccountMappingHelper.saveSharesToIncomeAccountMapping(element,
SHARES_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), shareProductId, SharesProductAccountingParams.INCOME_FROM_FEES.getValue(), shareProductId,
CASH_ACCOUNTS_FOR_SHARES.INCOME_FROM_FEES.getValue()); CashAccountsForShares.INCOME_FROM_FEES.getValue());
// expenses // expenses
this.shareProductToGLAccountMappingHelper.saveSharesToEquityAccountMapping(element, this.shareProductToGLAccountMappingHelper.saveSharesToEquityAccountMapping(element,
SHARES_PRODUCT_ACCOUNTING_PARAMS.SHARES_EQUITY.getValue(), shareProductId, SharesProductAccountingParams.SHARES_EQUITY.getValue(), shareProductId,
CASH_ACCOUNTS_FOR_SHARES.SHARES_EQUITY.getValue()); CashAccountsForShares.SHARES_EQUITY.getValue());
// liability // liability
this.shareProductToGLAccountMappingHelper.saveSharesToLiabilityAccountMapping(element, this.shareProductToGLAccountMappingHelper.saveSharesToLiabilityAccountMapping(element,
SHARES_PRODUCT_ACCOUNTING_PARAMS.SHARES_SUSPENSE.getValue(), shareProductId, SharesProductAccountingParams.SHARES_SUSPENSE.getValue(), shareProductId,
CASH_ACCOUNTS_FOR_SHARES.SHARES_SUSPENSE.getValue()); CashAccountsForShares.SHARES_SUSPENSE.getValue());
// advanced accounting mappings // advanced accounting mappings
this.savingsProductToGLAccountMappingHelper.savePaymentChannelToFundSourceMappings(command, element, shareProductId, null); this.savingsProductToGLAccountMappingHelper.savePaymentChannelToFundSourceMappings(command, element, shareProductId, null);
@@ -21,8 +21,8 @@ package org.apache.fineract.accounting.producttoaccountmapping.service;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.apache.fineract.accounting.common.AccountingConstants.CASH_ACCOUNTS_FOR_SAVINGS; import org.apache.fineract.accounting.common.AccountingConstants.CashAccountsForSavings;
import org.apache.fineract.accounting.common.AccountingConstants.SAVINGS_PRODUCT_ACCOUNTING_PARAMS; import org.apache.fineract.accounting.common.AccountingConstants.SavingProductAccountingParams;
import org.apache.fineract.accounting.common.AccountingRuleType; import org.apache.fineract.accounting.common.AccountingRuleType;
import org.apache.fineract.accounting.glaccount.domain.GLAccountRepository; import org.apache.fineract.accounting.glaccount.domain.GLAccountRepository;
import org.apache.fineract.accounting.glaccount.domain.GLAccountRepositoryWrapper; import org.apache.fineract.accounting.glaccount.domain.GLAccountRepositoryWrapper;
@@ -133,36 +133,36 @@ public class SavingsProductToGLAccountMappingHelper extends ProductToGLAccountMa
final Map<String, Object> changes = new HashMap<>(); final Map<String, Object> changes = new HashMap<>();
final Long savingsReferenceId = this.fromApiJsonHelper.extractLongNamed( final Long savingsReferenceId = this.fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_REFERENCE.getValue(), element); SavingProductAccountingParams.SAVINGS_REFERENCE.getValue(), element);
final Long incomeFromFeesId = this.fromApiJsonHelper.extractLongNamed( final Long incomeFromFeesId = this.fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), element); SavingProductAccountingParams.INCOME_FROM_FEES.getValue(), element);
final Long incomeFromPenaltiesId = this.fromApiJsonHelper.extractLongNamed( final Long incomeFromPenaltiesId = this.fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue(), element); SavingProductAccountingParams.INCOME_FROM_PENALTIES.getValue(), element);
final Long interestOnSavingsId = this.fromApiJsonHelper.extractLongNamed( final Long interestOnSavingsId = this.fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_SAVINGS.getValue(), element); SavingProductAccountingParams.INTEREST_ON_SAVINGS.getValue(), element);
final Long savingsControlId = this.fromApiJsonHelper.extractLongNamed(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_CONTROL.getValue(), final Long savingsControlId = this.fromApiJsonHelper.extractLongNamed(SavingProductAccountingParams.SAVINGS_CONTROL.getValue(),
element); element);
final Long transfersInSuspenseAccountId = this.fromApiJsonHelper.extractLongNamed( final Long transfersInSuspenseAccountId = this.fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(), element); SavingProductAccountingParams.TRANSFERS_SUSPENSE.getValue(), element);
final Long overdraftControlId = this.fromApiJsonHelper.extractLongNamed( final Long overdraftControlId = this.fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), element); SavingProductAccountingParams.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), element);
final Long incomeFromInterest = this.fromApiJsonHelper.extractLongNamed( final Long incomeFromInterest = this.fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_INTEREST.getValue(), element); SavingProductAccountingParams.INCOME_FROM_INTEREST.getValue(), element);
final Long writeOffId = this.fromApiJsonHelper.extractLongNamed(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue(), final Long writeOffId = this.fromApiJsonHelper.extractLongNamed(SavingProductAccountingParams.LOSSES_WRITTEN_OFF.getValue(),
element); element);
switch (accountingRuleType) { switch (accountingRuleType) {
case NONE: case NONE:
break; break;
case CASH_BASED: case CASH_BASED:
changes.put(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_CONTROL.getValue(), savingsControlId); changes.put(SavingProductAccountingParams.SAVINGS_CONTROL.getValue(), savingsControlId);
changes.put(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_REFERENCE.getValue(), savingsReferenceId); changes.put(SavingProductAccountingParams.SAVINGS_REFERENCE.getValue(), savingsReferenceId);
changes.put(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_SAVINGS.getValue(), interestOnSavingsId); changes.put(SavingProductAccountingParams.INTEREST_ON_SAVINGS.getValue(), interestOnSavingsId);
changes.put(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), incomeFromFeesId); changes.put(SavingProductAccountingParams.INCOME_FROM_FEES.getValue(), incomeFromFeesId);
changes.put(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue(), incomeFromPenaltiesId); changes.put(SavingProductAccountingParams.INCOME_FROM_PENALTIES.getValue(), incomeFromPenaltiesId);
changes.put(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(), transfersInSuspenseAccountId); changes.put(SavingProductAccountingParams.TRANSFERS_SUSPENSE.getValue(), transfersInSuspenseAccountId);
changes.put(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), overdraftControlId); changes.put(SavingProductAccountingParams.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), overdraftControlId);
changes.put(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_INTEREST.getValue(), incomeFromInterest); changes.put(SavingProductAccountingParams.INCOME_FROM_INTEREST.getValue(), incomeFromInterest);
changes.put(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue(), writeOffId); changes.put(SavingProductAccountingParams.LOSSES_WRITTEN_OFF.getValue(), writeOffId);
break; break;
case ACCRUAL_PERIODIC: case ACCRUAL_PERIODIC:
break; break;
@@ -190,44 +190,44 @@ public class SavingsProductToGLAccountMappingHelper extends ProductToGLAccountMa
break; break;
case CASH_BASED: case CASH_BASED:
// asset // asset
mergeSavingsToAssetAccountMappingChanges(element, SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_REFERENCE.getValue(), mergeSavingsToAssetAccountMappingChanges(element, SavingProductAccountingParams.SAVINGS_REFERENCE.getValue(),
savingsProductId, CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_REFERENCE.getValue(), savingsProductId, CashAccountsForSavings.SAVINGS_REFERENCE.getValue(),
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_REFERENCE.toString(), changes); CashAccountsForSavings.SAVINGS_REFERENCE.toString(), changes);
mergeSavingsToAssetAccountMappingChanges(element, SAVINGS_PRODUCT_ACCOUNTING_PARAMS.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), mergeSavingsToAssetAccountMappingChanges(element, SavingProductAccountingParams.OVERDRAFT_PORTFOLIO_CONTROL.getValue(),
savingsProductId, CASH_ACCOUNTS_FOR_SAVINGS.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), savingsProductId, CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(),
CASH_ACCOUNTS_FOR_SAVINGS.OVERDRAFT_PORTFOLIO_CONTROL.toString(), changes); CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.toString(), changes);
// income // income
mergeSavingsToIncomeAccountMappingChanges(element, SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), mergeSavingsToIncomeAccountMappingChanges(element, SavingProductAccountingParams.INCOME_FROM_FEES.getValue(),
savingsProductId, CASH_ACCOUNTS_FOR_SAVINGS.INCOME_FROM_FEES.getValue(), savingsProductId, CashAccountsForSavings.INCOME_FROM_FEES.getValue(),
CASH_ACCOUNTS_FOR_SAVINGS.INCOME_FROM_FEES.toString(), changes); CashAccountsForSavings.INCOME_FROM_FEES.toString(), changes);
mergeSavingsToIncomeAccountMappingChanges(element, SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue(), mergeSavingsToIncomeAccountMappingChanges(element, SavingProductAccountingParams.INCOME_FROM_PENALTIES.getValue(),
savingsProductId, CASH_ACCOUNTS_FOR_SAVINGS.INCOME_FROM_PENALTIES.getValue(), savingsProductId, CashAccountsForSavings.INCOME_FROM_PENALTIES.getValue(),
CASH_ACCOUNTS_FOR_SAVINGS.INCOME_FROM_PENALTIES.toString(), changes); CashAccountsForSavings.INCOME_FROM_PENALTIES.toString(), changes);
mergeSavingsToIncomeAccountMappingChanges(element, SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_INTEREST.getValue(), mergeSavingsToIncomeAccountMappingChanges(element, SavingProductAccountingParams.INCOME_FROM_INTEREST.getValue(),
savingsProductId, CASH_ACCOUNTS_FOR_SAVINGS.INCOME_FROM_INTEREST.getValue(), savingsProductId, CashAccountsForSavings.INCOME_FROM_INTEREST.getValue(),
CASH_ACCOUNTS_FOR_SAVINGS.INCOME_FROM_INTEREST.toString(), changes); CashAccountsForSavings.INCOME_FROM_INTEREST.toString(), changes);
// expenses // expenses
mergeSavingsToExpenseAccountMappingChanges(element, SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_SAVINGS.getValue(), mergeSavingsToExpenseAccountMappingChanges(element, SavingProductAccountingParams.INTEREST_ON_SAVINGS.getValue(),
savingsProductId, CASH_ACCOUNTS_FOR_SAVINGS.INTEREST_ON_SAVINGS.getValue(), savingsProductId, CashAccountsForSavings.INTEREST_ON_SAVINGS.getValue(),
CASH_ACCOUNTS_FOR_SAVINGS.INTEREST_ON_SAVINGS.toString(), changes); CashAccountsForSavings.INTEREST_ON_SAVINGS.toString(), changes);
mergeSavingsToExpenseAccountMappingChanges(element, SAVINGS_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue(), mergeSavingsToExpenseAccountMappingChanges(element, SavingProductAccountingParams.LOSSES_WRITTEN_OFF.getValue(),
savingsProductId, CASH_ACCOUNTS_FOR_SAVINGS.LOSSES_WRITTEN_OFF.getValue(), savingsProductId, CashAccountsForSavings.LOSSES_WRITTEN_OFF.getValue(),
CASH_ACCOUNTS_FOR_SAVINGS.LOSSES_WRITTEN_OFF.toString(), changes); CashAccountsForSavings.LOSSES_WRITTEN_OFF.toString(), changes);
// liability // liability
mergeSavingsToLiabilityAccountMappingChanges(element, SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_CONTROL.getValue(), mergeSavingsToLiabilityAccountMappingChanges(element, SavingProductAccountingParams.SAVINGS_CONTROL.getValue(),
savingsProductId, CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL.getValue(), savingsProductId, CashAccountsForSavings.SAVINGS_CONTROL.getValue(),
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL.toString(), changes); CashAccountsForSavings.SAVINGS_CONTROL.toString(), changes);
mergeSavingsToLiabilityAccountMappingChanges(element, SAVINGS_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(), mergeSavingsToLiabilityAccountMappingChanges(element, SavingProductAccountingParams.TRANSFERS_SUSPENSE.getValue(),
savingsProductId, CASH_ACCOUNTS_FOR_SAVINGS.TRANSFERS_SUSPENSE.getValue(), savingsProductId, CashAccountsForSavings.TRANSFERS_SUSPENSE.getValue(),
CASH_ACCOUNTS_FOR_SAVINGS.TRANSFERS_SUSPENSE.toString(), changes); CashAccountsForSavings.TRANSFERS_SUSPENSE.toString(), changes);
createOrmergeSavingsToLiabilityAccountMappingChanges(element, SAVINGS_PRODUCT_ACCOUNTING_PARAMS.ESCHEAT_LIABILITY.getValue(), createOrmergeSavingsToLiabilityAccountMappingChanges(element, SavingProductAccountingParams.ESCHEAT_LIABILITY.getValue(),
savingsProductId, CASH_ACCOUNTS_FOR_SAVINGS.ESCHEAT_LIABILITY.getValue(), savingsProductId, CashAccountsForSavings.ESCHEAT_LIABILITY.getValue(),
changes); changes);
break; break;
case ACCRUAL_PERIODIC: case ACCRUAL_PERIODIC:
@@ -21,8 +21,8 @@ package org.apache.fineract.accounting.producttoaccountmapping.service;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.apache.fineract.accounting.common.AccountingConstants.CASH_ACCOUNTS_FOR_SHARES; import org.apache.fineract.accounting.common.AccountingConstants.CashAccountsForShares;
import org.apache.fineract.accounting.common.AccountingConstants.SHARES_PRODUCT_ACCOUNTING_PARAMS; import org.apache.fineract.accounting.common.AccountingConstants.SharesProductAccountingParams;
import org.apache.fineract.accounting.common.AccountingRuleType; import org.apache.fineract.accounting.common.AccountingRuleType;
import org.apache.fineract.accounting.glaccount.domain.GLAccountRepository; import org.apache.fineract.accounting.glaccount.domain.GLAccountRepository;
import org.apache.fineract.accounting.glaccount.domain.GLAccountRepositoryWrapper; import org.apache.fineract.accounting.glaccount.domain.GLAccountRepositoryWrapper;
@@ -124,23 +124,23 @@ public class ShareProductToGLAccountMappingHelper extends ProductToGLAccountMapp
final AccountingRuleType accountingRuleType) { final AccountingRuleType accountingRuleType) {
final Map<String, Object> changes = new HashMap<>(); final Map<String, Object> changes = new HashMap<>();
final Long shareReferenceId = this.fromApiJsonHelper.extractLongNamed(SHARES_PRODUCT_ACCOUNTING_PARAMS.SHARES_REFERENCE.getValue(), final Long shareReferenceId = this.fromApiJsonHelper.extractLongNamed(SharesProductAccountingParams.SHARES_REFERENCE.getValue(),
element); element);
final Long incomeFromFeeAccountId = this.fromApiJsonHelper.extractLongNamed( final Long incomeFromFeeAccountId = this.fromApiJsonHelper.extractLongNamed(
SHARES_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), element); SharesProductAccountingParams.INCOME_FROM_FEES.getValue(), element);
final Long shareSuspenseId = this.fromApiJsonHelper.extractLongNamed(SHARES_PRODUCT_ACCOUNTING_PARAMS.SHARES_SUSPENSE.getValue(), final Long shareSuspenseId = this.fromApiJsonHelper.extractLongNamed(SharesProductAccountingParams.SHARES_SUSPENSE.getValue(),
element); element);
final Long shareEquityId = this.fromApiJsonHelper.extractLongNamed(SHARES_PRODUCT_ACCOUNTING_PARAMS.SHARES_EQUITY.getValue(), final Long shareEquityId = this.fromApiJsonHelper.extractLongNamed(SharesProductAccountingParams.SHARES_EQUITY.getValue(),
element); element);
switch (accountingRuleType) { switch (accountingRuleType) {
case NONE: case NONE:
break; break;
case CASH_BASED: case CASH_BASED:
changes.put(SHARES_PRODUCT_ACCOUNTING_PARAMS.SHARES_REFERENCE.getValue(), shareReferenceId); changes.put(SharesProductAccountingParams.SHARES_REFERENCE.getValue(), shareReferenceId);
changes.put(SHARES_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), incomeFromFeeAccountId); changes.put(SharesProductAccountingParams.INCOME_FROM_FEES.getValue(), incomeFromFeeAccountId);
changes.put(SHARES_PRODUCT_ACCOUNTING_PARAMS.SHARES_SUSPENSE.getValue(), shareSuspenseId); changes.put(SharesProductAccountingParams.SHARES_SUSPENSE.getValue(), shareSuspenseId);
changes.put(SHARES_PRODUCT_ACCOUNTING_PARAMS.SHARES_EQUITY.getValue(), shareEquityId); changes.put(SharesProductAccountingParams.SHARES_EQUITY.getValue(), shareEquityId);
break; break;
case ACCRUAL_PERIODIC: case ACCRUAL_PERIODIC:
break; break;
@@ -168,24 +168,24 @@ public class ShareProductToGLAccountMappingHelper extends ProductToGLAccountMapp
break; break;
case CASH_BASED: case CASH_BASED:
// asset // asset
mergeSharesToAssetAccountMappingChanges(element, SHARES_PRODUCT_ACCOUNTING_PARAMS.SHARES_REFERENCE.getValue(), mergeSharesToAssetAccountMappingChanges(element, SharesProductAccountingParams.SHARES_REFERENCE.getValue(),
sharesProductId, CASH_ACCOUNTS_FOR_SHARES.SHARES_REFERENCE.getValue(), sharesProductId, CashAccountsForShares.SHARES_REFERENCE.getValue(),
CASH_ACCOUNTS_FOR_SHARES.SHARES_REFERENCE.toString(), changes); CashAccountsForShares.SHARES_REFERENCE.toString(), changes);
// income // income
mergeSharesToIncomeAccountMappingChanges(element, SHARES_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), mergeSharesToIncomeAccountMappingChanges(element, SharesProductAccountingParams.INCOME_FROM_FEES.getValue(),
sharesProductId, CASH_ACCOUNTS_FOR_SHARES.INCOME_FROM_FEES.getValue(), sharesProductId, CashAccountsForShares.INCOME_FROM_FEES.getValue(),
CASH_ACCOUNTS_FOR_SHARES.INCOME_FROM_FEES.toString(), changes); CashAccountsForShares.INCOME_FROM_FEES.toString(), changes);
// liability // liability
mergeSharesToLiabilityAccountMappingChanges(element, SHARES_PRODUCT_ACCOUNTING_PARAMS.SHARES_SUSPENSE.getValue(), mergeSharesToLiabilityAccountMappingChanges(element, SharesProductAccountingParams.SHARES_SUSPENSE.getValue(),
sharesProductId, CASH_ACCOUNTS_FOR_SHARES.SHARES_SUSPENSE.getValue(), sharesProductId, CashAccountsForShares.SHARES_SUSPENSE.getValue(),
CASH_ACCOUNTS_FOR_SHARES.SHARES_SUSPENSE.toString(), changes); CashAccountsForShares.SHARES_SUSPENSE.toString(), changes);
// equity // equity
mergeSharesToEquityAccountMappingChanges(element, SHARES_PRODUCT_ACCOUNTING_PARAMS.SHARES_EQUITY.getValue(), mergeSharesToEquityAccountMappingChanges(element, SharesProductAccountingParams.SHARES_EQUITY.getValue(),
sharesProductId, CASH_ACCOUNTS_FOR_SHARES.SHARES_EQUITY.getValue(), sharesProductId, CashAccountsForShares.SHARES_EQUITY.getValue(),
CASH_ACCOUNTS_FOR_SHARES.SHARES_EQUITY.toString(), changes); CashAccountsForShares.SHARES_EQUITY.toString(), changes);
break; break;
case ACCRUAL_PERIODIC: case ACCRUAL_PERIODIC:
break; break;
@@ -27,7 +27,7 @@ import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainR
public class AccountingRuleInvalidException extends AbstractPlatformDomainRuleException { public class AccountingRuleInvalidException extends AbstractPlatformDomainRuleException {
/*** enum of reasons for invalid Accounting Closure **/ /*** enum of reasons for invalid Accounting Closure **/
public static enum GL_CLOSURE_INVALID_REASON { public static enum GlClosureInvalidReason {
FUTURE_DATE, ACCOUNTING_CLOSED; FUTURE_DATE, ACCOUNTING_CLOSED;
public String errorMessage() { public String errorMessage() {
@@ -45,7 +45,7 @@ public class AccountingRuleInvalidException extends AbstractPlatformDomainRuleEx
} }
} }
public AccountingRuleInvalidException(final GL_CLOSURE_INVALID_REASON reason, final Date date) { public AccountingRuleInvalidException(final GlClosureInvalidReason reason, final Date date) {
super(reason.errorCode(), reason.errorMessage(), date); super(reason.errorCode(), reason.errorMessage(), date);
} }
} }
@@ -199,7 +199,7 @@ public class BulkImportWorkbookServiceImpl implements BulkImportWorkbookService
SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_INHERITABLETHREADLOCAL); SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_INHERITABLETHREADLOCAL);
final Long documentId = this.documentWritePlatformService.createInternalDocument( final Long documentId = this.documentWritePlatformService.createInternalDocument(
DocumentWritePlatformServiceJpaRepositoryImpl.DOCUMENT_MANAGEMENT_ENTITY.IMPORT.name(), DocumentWritePlatformServiceJpaRepositoryImpl.DocumentManagementEntity.IMPORT.name(),
this.securityContext.authenticatedUser().getId(), null, clonedInputStreamWorkbook, this.securityContext.authenticatedUser().getId(), null, clonedInputStreamWorkbook,
URLConnection.guessContentTypeFromName(fileName), fileName, null, fileName); URLConnection.guessContentTypeFromName(fileName), fileName, null, fileName);
final Document document = this.documentRepository.findById(documentId).orElse(null); final Document document = this.documentRepository.findById(documentId).orElse(null);
@@ -41,8 +41,8 @@ import org.apache.fineract.organisation.office.domain.Office;
import org.apache.fineract.organisation.office.domain.OfficeRepository; import org.apache.fineract.organisation.office.domain.OfficeRepository;
import org.apache.fineract.portfolio.client.domain.Client; import org.apache.fineract.portfolio.client.domain.Client;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BUSINESS_ENTITY; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEntity;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BUSINESS_EVENTS; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEvents;
import org.apache.fineract.portfolio.common.service.BusinessEventListner; import org.apache.fineract.portfolio.common.service.BusinessEventListner;
import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService; import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.group.domain.Group; import org.apache.fineract.portfolio.group.domain.Group;
@@ -97,15 +97,15 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
@PostConstruct @PostConstruct
public void addListners() { public void addListners() {
this.businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.LOAN_APPROVED, new SendSmsOnLoanApproved()); this.businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.LOAN_APPROVED, new SendSmsOnLoanApproved());
this.businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.LOAN_REJECTED, new SendSmsOnLoanRejected()); this.businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.LOAN_REJECTED, new SendSmsOnLoanRejected());
this.businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.LOAN_MAKE_REPAYMENT, new SendSmsOnLoanRepayment()); this.businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.LOAN_MAKE_REPAYMENT, new SendSmsOnLoanRepayment());
this.businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.CLIENTS_ACTIVATE, new ClientActivatedListener()); this.businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.CLIENTS_ACTIVATE, new ClientActivatedListener());
this.businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.CLIENTS_REJECT, new ClientRejectedListener()); this.businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.CLIENTS_REJECT, new ClientRejectedListener());
this.businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.SAVINGS_ACTIVATE, new SavingsAccountActivatedListener()); this.businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.SAVINGS_ACTIVATE, new SavingsAccountActivatedListener());
this.businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.SAVINGS_REJECT, new SavingsAccountRejectedListener()); this.businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.SAVINGS_REJECT, new SavingsAccountRejectedListener());
this.businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.SAVINGS_DEPOSIT, new SavingsAccountTransactionListener(true)); this.businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.SAVINGS_DEPOSIT, new SavingsAccountTransactionListener(true));
this.businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.SAVINGS_WITHDRAWAL, new SavingsAccountTransactionListener(false)); this.businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.SAVINGS_WITHDRAWAL, new SavingsAccountTransactionListener(false));
} }
private void notifyRejectedLoanOwner(Loan loan) { private void notifyRejectedLoanOwner(Loan loan) {
@@ -392,7 +392,7 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
private abstract class SmsBusinessEventAdapter implements BusinessEventListner { private abstract class SmsBusinessEventAdapter implements BusinessEventListner {
@Override @Override
public void businessEventToBeExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventToBeExecuted(Map<BusinessEntity, Object> businessEventEntity) {
//Nothing to do //Nothing to do
} }
} }
@@ -400,8 +400,8 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
private class SendSmsOnLoanApproved extends SmsBusinessEventAdapter{ private class SendSmsOnLoanApproved extends SmsBusinessEventAdapter{
@Override @Override
public void businessEventWasExecuted(Map<BusinessEventNotificationConstants.BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventWasExecuted(Map<BusinessEventNotificationConstants.BusinessEntity, Object> businessEventEntity) {
Object entity = businessEventEntity.get(BusinessEventNotificationConstants.BUSINESS_ENTITY.LOAN); Object entity = businessEventEntity.get(BusinessEventNotificationConstants.BusinessEntity.LOAN);
if (entity instanceof Loan) { if (entity instanceof Loan) {
Loan loan = (Loan) entity; Loan loan = (Loan) entity;
notifyAcceptedLoanOwner(loan); notifyAcceptedLoanOwner(loan);
@@ -412,8 +412,8 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
private class SendSmsOnLoanRejected extends SmsBusinessEventAdapter{ private class SendSmsOnLoanRejected extends SmsBusinessEventAdapter{
@Override @Override
public void businessEventWasExecuted(Map<BusinessEventNotificationConstants.BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventWasExecuted(Map<BusinessEventNotificationConstants.BusinessEntity, Object> businessEventEntity) {
Object entity = businessEventEntity.get(BusinessEventNotificationConstants.BUSINESS_ENTITY.LOAN); Object entity = businessEventEntity.get(BusinessEventNotificationConstants.BusinessEntity.LOAN);
if (entity instanceof Loan) { if (entity instanceof Loan) {
Loan loan = (Loan) entity; Loan loan = (Loan) entity;
notifyRejectedLoanOwner(loan); notifyRejectedLoanOwner(loan);
@@ -424,8 +424,8 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
private class SendSmsOnLoanRepayment extends SmsBusinessEventAdapter{ private class SendSmsOnLoanRepayment extends SmsBusinessEventAdapter{
@Override @Override
public void businessEventWasExecuted(Map<BusinessEventNotificationConstants.BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventWasExecuted(Map<BusinessEventNotificationConstants.BusinessEntity, Object> businessEventEntity) {
Object entity = businessEventEntity.get(BusinessEventNotificationConstants.BUSINESS_ENTITY.LOAN_TRANSACTION); Object entity = businessEventEntity.get(BusinessEventNotificationConstants.BusinessEntity.LOAN_TRANSACTION);
if (entity instanceof LoanTransaction) { if (entity instanceof LoanTransaction) {
LoanTransaction loanTransaction = (LoanTransaction) entity; LoanTransaction loanTransaction = (LoanTransaction) entity;
sendSmsForLoanRepayment(loanTransaction); sendSmsForLoanRepayment(loanTransaction);
@@ -436,8 +436,8 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
private class ClientActivatedListener extends SmsBusinessEventAdapter { private class ClientActivatedListener extends SmsBusinessEventAdapter {
@Override @Override
public void businessEventWasExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Object entity = businessEventEntity.get(BusinessEventNotificationConstants.BUSINESS_ENTITY.CLIENT); Object entity = businessEventEntity.get(BusinessEventNotificationConstants.BusinessEntity.CLIENT);
if(entity instanceof Client) { if(entity instanceof Client) {
notifyClientActivated((Client)entity); notifyClientActivated((Client)entity);
} }
@@ -447,8 +447,8 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
private class ClientRejectedListener extends SmsBusinessEventAdapter { private class ClientRejectedListener extends SmsBusinessEventAdapter {
@Override @Override
public void businessEventWasExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Object entity = businessEventEntity.get(BusinessEventNotificationConstants.BUSINESS_ENTITY.CLIENT); Object entity = businessEventEntity.get(BusinessEventNotificationConstants.BusinessEntity.CLIENT);
if(entity instanceof Client) { if(entity instanceof Client) {
notifyClientRejected((Client)entity); notifyClientRejected((Client)entity);
} }
@@ -459,8 +459,8 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
private class SavingsAccountActivatedListener extends SmsBusinessEventAdapter{ private class SavingsAccountActivatedListener extends SmsBusinessEventAdapter{
@Override @Override
public void businessEventWasExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Object entity = businessEventEntity.get(BusinessEventNotificationConstants.BUSINESS_ENTITY.SAVING); Object entity = businessEventEntity.get(BusinessEventNotificationConstants.BusinessEntity.SAVING);
if(entity instanceof SavingsAccount) { if(entity instanceof SavingsAccount) {
notifySavingsAccountActivated((SavingsAccount)entity); notifySavingsAccountActivated((SavingsAccount)entity);
} }
@@ -471,8 +471,8 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
private class SavingsAccountRejectedListener extends SmsBusinessEventAdapter { private class SavingsAccountRejectedListener extends SmsBusinessEventAdapter {
@Override @Override
public void businessEventWasExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Object entity = businessEventEntity.get(BusinessEventNotificationConstants.BUSINESS_ENTITY.SAVING); Object entity = businessEventEntity.get(BusinessEventNotificationConstants.BusinessEntity.SAVING);
if(entity instanceof SavingsAccount) { if(entity instanceof SavingsAccount) {
notifySavingsAccountRejected((SavingsAccount)entity); notifySavingsAccountRejected((SavingsAccount)entity);
} }
@@ -488,8 +488,8 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
} }
@Override @Override
public void businessEventWasExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Object entity = businessEventEntity.get(BusinessEventNotificationConstants.BUSINESS_ENTITY.SAVINGS_TRANSACTION); Object entity = businessEventEntity.get(BusinessEventNotificationConstants.BusinessEntity.SAVINGS_TRANSACTION);
if(entity instanceof SavingsAccountTransaction) { if(entity instanceof SavingsAccountTransaction) {
sendSmsForSavingsTransaction((SavingsAccountTransaction)entity, this.isDeposit); sendSmsForSavingsTransaction((SavingsAccountTransaction)entity, this.isDeposit);
} }
@@ -27,19 +27,19 @@ public class CodeConstants {
* Enum of all parameters passed in while creating/updating a code and code * Enum of all parameters passed in while creating/updating a code and code
* value * value
***/ ***/
public static enum CODEVALUE_JSON_INPUT_PARAMS { public static enum CodevalueJSONinputParams {
CODEVALUE_ID("id"), NAME("name"), POSITION("position"), DESCRIPTION("description"), IS_ACTIVE("isActive"), CODEVALUE_ID("id"), NAME("name"), POSITION("position"), DESCRIPTION("description"), IS_ACTIVE("isActive"),
IS_MANDATORY("isMandatory"); IS_MANDATORY("isMandatory");
private final String value; private final String value;
private CODEVALUE_JSON_INPUT_PARAMS(final String value) { private CodevalueJSONinputParams(final String value) {
this.value = value; this.value = value;
} }
private static final Set<String> values = new HashSet<>(); private static final Set<String> values = new HashSet<>();
static { static {
for (final CODEVALUE_JSON_INPUT_PARAMS type : CODEVALUE_JSON_INPUT_PARAMS.values()) { for (final CodevalueJSONinputParams type : CodevalueJSONinputParams.values()) {
values.add(type.value); values.add(type.value);
} }
} }
@@ -45,7 +45,7 @@ import javax.ws.rs.core.UriInfo;
import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.commands.domain.CommandWrapper;
import org.apache.fineract.commands.service.CommandWrapperBuilder; import org.apache.fineract.commands.service.CommandWrapperBuilder;
import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService; import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService;
import org.apache.fineract.infrastructure.codes.CodeConstants.CODEVALUE_JSON_INPUT_PARAMS; import org.apache.fineract.infrastructure.codes.CodeConstants.CodevalueJSONinputParams;
import org.apache.fineract.infrastructure.codes.data.CodeData; import org.apache.fineract.infrastructure.codes.data.CodeData;
import org.apache.fineract.infrastructure.codes.data.CodeValueData; import org.apache.fineract.infrastructure.codes.data.CodeValueData;
import org.apache.fineract.infrastructure.codes.service.CodeValueReadPlatformService; import org.apache.fineract.infrastructure.codes.service.CodeValueReadPlatformService;
@@ -71,10 +71,10 @@ public class CodeValuesApiResource {
* The set of parameters that are supported in response for {@link CodeData} * The set of parameters that are supported in response for {@link CodeData}
*/ */
private final Set<String> RESPONSE_DATA_PARAMETERS = new HashSet<>( private final Set<String> RESPONSE_DATA_PARAMETERS = new HashSet<>(
Arrays.asList(CODEVALUE_JSON_INPUT_PARAMS.CODEVALUE_ID.getValue(), Arrays.asList(CodevalueJSONinputParams.CODEVALUE_ID.getValue(),
CODEVALUE_JSON_INPUT_PARAMS.NAME.getValue(), CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue(), CodevalueJSONinputParams.NAME.getValue(), CodevalueJSONinputParams.POSITION.getValue(),
CODEVALUE_JSON_INPUT_PARAMS.IS_MANDATORY.getValue(), CodevalueJSONinputParams.IS_MANDATORY.getValue(),
CODEVALUE_JSON_INPUT_PARAMS.DESCRIPTION.getValue())); CodevalueJSONinputParams.DESCRIPTION.getValue()));
private final String resourceNameForPermissions = "CODEVALUE"; private final String resourceNameForPermissions = "CODEVALUE";
private final PlatformSecurityContext context; private final PlatformSecurityContext context;
@@ -27,7 +27,7 @@ import javax.persistence.ManyToOne;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.UniqueConstraint; import javax.persistence.UniqueConstraint;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.infrastructure.codes.CodeConstants.CODEVALUE_JSON_INPUT_PARAMS; import org.apache.fineract.infrastructure.codes.CodeConstants.CodevalueJSONinputParams;
import org.apache.fineract.infrastructure.codes.data.CodeValueData; import org.apache.fineract.infrastructure.codes.data.CodeValueData;
import org.apache.fineract.infrastructure.core.api.JsonCommand; import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom; import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
@@ -84,10 +84,10 @@ public class CodeValue extends AbstractPersistableCustom {
public static CodeValue fromJson(final Code code, final JsonCommand command) { public static CodeValue fromJson(final Code code, final JsonCommand command) {
final String label = command.stringValueOfParameterNamed(CODEVALUE_JSON_INPUT_PARAMS.NAME.getValue()); final String label = command.stringValueOfParameterNamed(CodevalueJSONinputParams.NAME.getValue());
Integer position = command.integerValueSansLocaleOfParameterNamed(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue()); Integer position = command.integerValueSansLocaleOfParameterNamed(CodevalueJSONinputParams.POSITION.getValue());
String description = command.stringValueOfParameterNamed(CODEVALUE_JSON_INPUT_PARAMS.DESCRIPTION.getValue()); String description = command.stringValueOfParameterNamed(CodevalueJSONinputParams.DESCRIPTION.getValue());
Boolean isActiveObj = command.booleanObjectValueOfParameterNamed(CODEVALUE_JSON_INPUT_PARAMS.IS_ACTIVE.getValue()); Boolean isActiveObj = command.booleanObjectValueOfParameterNamed(CodevalueJSONinputParams.IS_ACTIVE.getValue());
boolean isActive = true; boolean isActive = true;
if (isActiveObj != null) { if (isActiveObj != null) {
isActive = isActiveObj; isActive = isActiveObj;
@@ -97,7 +97,7 @@ public class CodeValue extends AbstractPersistableCustom {
} }
Boolean mandatory = command.booleanPrimitiveValueOfParameterNamed( Boolean mandatory = command.booleanPrimitiveValueOfParameterNamed(
CODEVALUE_JSON_INPUT_PARAMS.IS_MANDATORY.getValue()); CodevalueJSONinputParams.IS_MANDATORY.getValue());
// if the "mandatory" Boolean object is null, then set it to false by default // if the "mandatory" Boolean object is null, then set it to false by default
if (mandatory == null) { if (mandatory == null) {
@@ -111,28 +111,28 @@ public class CodeValue extends AbstractPersistableCustom {
final Map<String, Object> actualChanges = new LinkedHashMap<>(2); final Map<String, Object> actualChanges = new LinkedHashMap<>(2);
final String labelParamName = CODEVALUE_JSON_INPUT_PARAMS.NAME.getValue(); final String labelParamName = CodevalueJSONinputParams.NAME.getValue();
if (command.isChangeInStringParameterNamed(labelParamName, this.label)) { if (command.isChangeInStringParameterNamed(labelParamName, this.label)) {
final String newValue = command.stringValueOfParameterNamed(labelParamName); final String newValue = command.stringValueOfParameterNamed(labelParamName);
actualChanges.put(labelParamName, newValue); actualChanges.put(labelParamName, newValue);
this.label = StringUtils.defaultIfEmpty(newValue, null); this.label = StringUtils.defaultIfEmpty(newValue, null);
} }
final String decriptionParamName = CODEVALUE_JSON_INPUT_PARAMS.DESCRIPTION.getValue(); final String decriptionParamName = CodevalueJSONinputParams.DESCRIPTION.getValue();
if (command.isChangeInStringParameterNamed(decriptionParamName, this.description)) { if (command.isChangeInStringParameterNamed(decriptionParamName, this.description)) {
final String newValue = command.stringValueOfParameterNamed(decriptionParamName); final String newValue = command.stringValueOfParameterNamed(decriptionParamName);
actualChanges.put(decriptionParamName, newValue); actualChanges.put(decriptionParamName, newValue);
this.description = StringUtils.defaultIfEmpty(newValue, null); this.description = StringUtils.defaultIfEmpty(newValue, null);
} }
final String positionParamName = CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue(); final String positionParamName = CodevalueJSONinputParams.POSITION.getValue();
if (command.isChangeInIntegerSansLocaleParameterNamed(positionParamName, this.position)) { if (command.isChangeInIntegerSansLocaleParameterNamed(positionParamName, this.position)) {
final Integer newValue = command.integerValueSansLocaleOfParameterNamed(positionParamName); final Integer newValue = command.integerValueSansLocaleOfParameterNamed(positionParamName);
actualChanges.put(positionParamName, newValue); actualChanges.put(positionParamName, newValue);
this.position = newValue.intValue(); this.position = newValue.intValue();
} }
final String isActiveParamName = CODEVALUE_JSON_INPUT_PARAMS.IS_ACTIVE.getValue(); final String isActiveParamName = CodevalueJSONinputParams.IS_ACTIVE.getValue();
if (command.isChangeInBooleanParameterNamed(isActiveParamName, this.isActive)) { if (command.isChangeInBooleanParameterNamed(isActiveParamName, this.isActive)) {
final Boolean newValue = command.booleanPrimitiveValueOfParameterNamed(isActiveParamName); final Boolean newValue = command.booleanPrimitiveValueOfParameterNamed(isActiveParamName);
actualChanges.put(isActiveParamName, newValue); actualChanges.put(isActiveParamName, newValue);
@@ -26,7 +26,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.infrastructure.codes.CodeConstants.CODEVALUE_JSON_INPUT_PARAMS; import org.apache.fineract.infrastructure.codes.CodeConstants.CodevalueJSONinputParams;
import org.apache.fineract.infrastructure.core.data.ApiParameterError; import org.apache.fineract.infrastructure.core.data.ApiParameterError;
import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder; import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder;
import org.apache.fineract.infrastructure.core.exception.InvalidJsonException; import org.apache.fineract.infrastructure.core.exception.InvalidJsonException;
@@ -44,7 +44,7 @@ public final class CodeValueCommandFromApiJsonDeserializer {
/** /**
* The parameters supported for this command. * The parameters supported for this command.
*/ */
private final Set<String> supportedParameters = CODEVALUE_JSON_INPUT_PARAMS.getAllValues(); private final Set<String> supportedParameters = CodevalueJSONinputParams.getAllValues();
private final FromJsonHelper fromApiJsonHelper; private final FromJsonHelper fromApiJsonHelper;
@Autowired @Autowired
@@ -63,24 +63,24 @@ public final class CodeValueCommandFromApiJsonDeserializer {
final JsonElement element = this.fromApiJsonHelper.parse(json); final JsonElement element = this.fromApiJsonHelper.parse(json);
final String name = this.fromApiJsonHelper.extractStringNamed(CODEVALUE_JSON_INPUT_PARAMS.NAME.getValue(), element); final String name = this.fromApiJsonHelper.extractStringNamed(CodevalueJSONinputParams.NAME.getValue(), element);
baseDataValidator.reset().parameter(CODEVALUE_JSON_INPUT_PARAMS.NAME.getValue()).value(name).notBlank().notExceedingLengthOf(100); baseDataValidator.reset().parameter(CodevalueJSONinputParams.NAME.getValue()).value(name).notBlank().notExceedingLengthOf(100);
if (this.fromApiJsonHelper.parameterExists(CODEVALUE_JSON_INPUT_PARAMS.DESCRIPTION.getValue(), element)) { if (this.fromApiJsonHelper.parameterExists(CodevalueJSONinputParams.DESCRIPTION.getValue(), element)) {
final String description = this.fromApiJsonHelper.extractStringNamed(CODEVALUE_JSON_INPUT_PARAMS.DESCRIPTION.getValue(), final String description = this.fromApiJsonHelper.extractStringNamed(CodevalueJSONinputParams.DESCRIPTION.getValue(),
element); element);
baseDataValidator.reset().parameter(CODEVALUE_JSON_INPUT_PARAMS.DESCRIPTION.getValue()).value(description) baseDataValidator.reset().parameter(CodevalueJSONinputParams.DESCRIPTION.getValue()).value(description)
.notExceedingLengthOf(500); .notExceedingLengthOf(500);
} }
if (this.fromApiJsonHelper.parameterExists(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue(), element)) { if (this.fromApiJsonHelper.parameterExists(CodevalueJSONinputParams.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(), element); this.fromApiJsonHelper.extractIntegerSansLocaleNamed(CodevalueJSONinputParams.POSITION.getValue(), element);
} }
if (this.fromApiJsonHelper.parameterExists(CODEVALUE_JSON_INPUT_PARAMS.IS_ACTIVE.getValue(), element)) { if (this.fromApiJsonHelper.parameterExists(CodevalueJSONinputParams.IS_ACTIVE.getValue(), element)) {
final Boolean isActive = this.fromApiJsonHelper.extractBooleanNamed(CODEVALUE_JSON_INPUT_PARAMS.IS_ACTIVE.getValue(), element); final Boolean isActive = this.fromApiJsonHelper.extractBooleanNamed(CodevalueJSONinputParams.IS_ACTIVE.getValue(), element);
baseDataValidator.reset().parameter(CODEVALUE_JSON_INPUT_PARAMS.IS_ACTIVE.getValue()).value(isActive).validateForBooleanValue(); baseDataValidator.reset().parameter(CodevalueJSONinputParams.IS_ACTIVE.getValue()).value(isActive).validateForBooleanValue();
} }
throwExceptionIfValidationWarningsExist(dataValidationErrors); throwExceptionIfValidationWarningsExist(dataValidationErrors);
@@ -97,26 +97,26 @@ public final class CodeValueCommandFromApiJsonDeserializer {
final JsonElement element = this.fromApiJsonHelper.parse(json); final JsonElement element = this.fromApiJsonHelper.parse(json);
if (this.fromApiJsonHelper.parameterExists(CODEVALUE_JSON_INPUT_PARAMS.NAME.getValue(), element)) { if (this.fromApiJsonHelper.parameterExists(CodevalueJSONinputParams.NAME.getValue(), element)) {
final String name = this.fromApiJsonHelper.extractStringNamed(CODEVALUE_JSON_INPUT_PARAMS.NAME.getValue(), element); final String name = this.fromApiJsonHelper.extractStringNamed(CodevalueJSONinputParams.NAME.getValue(), element);
baseDataValidator.reset().parameter(CODEVALUE_JSON_INPUT_PARAMS.NAME.getValue()).value(name).notBlank() baseDataValidator.reset().parameter(CodevalueJSONinputParams.NAME.getValue()).value(name).notBlank()
.notExceedingLengthOf(100); .notExceedingLengthOf(100);
} }
if (this.fromApiJsonHelper.parameterExists(CODEVALUE_JSON_INPUT_PARAMS.DESCRIPTION.getValue(), element)) { if (this.fromApiJsonHelper.parameterExists(CodevalueJSONinputParams.DESCRIPTION.getValue(), element)) {
final String description = this.fromApiJsonHelper.extractStringNamed(CODEVALUE_JSON_INPUT_PARAMS.DESCRIPTION.getValue(), final String description = this.fromApiJsonHelper.extractStringNamed(CodevalueJSONinputParams.DESCRIPTION.getValue(),
element); element);
baseDataValidator.reset().parameter(CODEVALUE_JSON_INPUT_PARAMS.DESCRIPTION.getValue()).value(description) baseDataValidator.reset().parameter(CodevalueJSONinputParams.DESCRIPTION.getValue()).value(description)
.notExceedingLengthOf(500); .notExceedingLengthOf(500);
} }
if (this.fromApiJsonHelper.parameterExists(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue(), element)) { if (this.fromApiJsonHelper.parameterExists(CodevalueJSONinputParams.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(), element); this.fromApiJsonHelper.extractIntegerSansLocaleNamed(CodevalueJSONinputParams.POSITION.getValue(), element);
} }
if (this.fromApiJsonHelper.parameterExists(CODEVALUE_JSON_INPUT_PARAMS.IS_ACTIVE.getValue(), element)) { if (this.fromApiJsonHelper.parameterExists(CodevalueJSONinputParams.IS_ACTIVE.getValue(), element)) {
final Boolean isActive = this.fromApiJsonHelper.extractBooleanNamed(CODEVALUE_JSON_INPUT_PARAMS.IS_ACTIVE.getValue(), element); final Boolean isActive = this.fromApiJsonHelper.extractBooleanNamed(CodevalueJSONinputParams.IS_ACTIVE.getValue(), element);
baseDataValidator.reset().parameter(CODEVALUE_JSON_INPUT_PARAMS.IS_ACTIVE.getValue()).value(isActive).validateForBooleanValue(); baseDataValidator.reset().parameter(CodevalueJSONinputParams.IS_ACTIVE.getValue()).value(isActive).validateForBooleanValue();
} }
throwExceptionIfValidationWarningsExist(dataValidationErrors); throwExceptionIfValidationWarningsExist(dataValidationErrors);
@@ -26,8 +26,8 @@ import javax.persistence.Entity;
import javax.persistence.Table; import javax.persistence.Table;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.infrastructure.configuration.data.ExternalServicesPropertiesData; import org.apache.fineract.infrastructure.configuration.data.ExternalServicesPropertiesData;
import org.apache.fineract.infrastructure.configuration.service.ExternalServicesConstants.EXTERNALSERVICEPROPERTIES_JSON_INPUT_PARAMS; import org.apache.fineract.infrastructure.configuration.service.ExternalServicesConstants.ExternalservicePropertiesJSONinputParams;
import org.apache.fineract.infrastructure.configuration.service.ExternalServicesConstants.SMTP_JSON_INPUT_PARAMS; import org.apache.fineract.infrastructure.configuration.service.ExternalServicesConstants.SMTPJSONinputParams;
import org.apache.fineract.infrastructure.core.api.JsonCommand; import org.apache.fineract.infrastructure.core.api.JsonCommand;
@Entity @Entity
@@ -51,18 +51,18 @@ public class ExternalServicesProperties {
} }
public static ExternalServicesProperties fromJson(final ExternalService externalService, final JsonCommand command) { public static ExternalServicesProperties fromJson(final ExternalService externalService, final JsonCommand command) {
final String name = command.stringValueOfParameterNamed(EXTERNALSERVICEPROPERTIES_JSON_INPUT_PARAMS.NAME.getValue()); final String name = command.stringValueOfParameterNamed(ExternalservicePropertiesJSONinputParams.NAME.getValue());
final String value = command.stringValueOfParameterNamed(EXTERNALSERVICEPROPERTIES_JSON_INPUT_PARAMS.VALUE.getValue()); final String value = command.stringValueOfParameterNamed(ExternalservicePropertiesJSONinputParams.VALUE.getValue());
return new ExternalServicesProperties(new ExternalServicePropertiesPK(externalService.getId(), name), value); return new ExternalServicesProperties(new ExternalServicePropertiesPK(externalService.getId(), name), value);
} }
public Map<String, Object> update(final JsonCommand command, String paramName) { public Map<String, Object> update(final JsonCommand command, String paramName) {
final Map<String, Object> actualChanges = new LinkedHashMap<>(2); final Map<String, Object> actualChanges = new LinkedHashMap<>(2);
final String valueParamName = EXTERNALSERVICEPROPERTIES_JSON_INPUT_PARAMS.VALUE.getValue(); final String valueParamName = ExternalservicePropertiesJSONinputParams.VALUE.getValue();
if (command.isChangeInStringParameterNamed(paramName, this.value)) { if (command.isChangeInStringParameterNamed(paramName, this.value)) {
final String newValue = command.stringValueOfParameterNamed(paramName); final String newValue = command.stringValueOfParameterNamed(paramName);
if (paramName.equals(SMTP_JSON_INPUT_PARAMS.PASSWORD.getValue()) && newValue.equals("XXXX")) { if (paramName.equals(SMTPJSONinputParams.PASSWORD.getValue()) && newValue.equals("XXXX")) {
// If Param Name is Password and ParamValue is XXXX that means // If Param Name is Password and ParamValue is XXXX that means
// the password has not been changed. // the password has not been changed.
} else { } else {
@@ -24,10 +24,10 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.infrastructure.configuration.exception.ExternalServiceConfigurationNotFoundException; import org.apache.fineract.infrastructure.configuration.exception.ExternalServiceConfigurationNotFoundException;
import org.apache.fineract.infrastructure.configuration.service.ExternalServicesConstants.NOTIFICATION_JSON_INPUT_PARAMS; import org.apache.fineract.infrastructure.configuration.service.ExternalServicesConstants.NotificationJSONinputParams;
import org.apache.fineract.infrastructure.configuration.service.ExternalServicesConstants.S3_JSON_INPUT_PARAMS; import org.apache.fineract.infrastructure.configuration.service.ExternalServicesConstants.S3JSONinputParams;
import org.apache.fineract.infrastructure.configuration.service.ExternalServicesConstants.SMS_JSON_INPUT_PARAMS; import org.apache.fineract.infrastructure.configuration.service.ExternalServicesConstants.SMSJSONinputParams;
import org.apache.fineract.infrastructure.configuration.service.ExternalServicesConstants.SMTP_JSON_INPUT_PARAMS; import org.apache.fineract.infrastructure.configuration.service.ExternalServicesConstants.SMTPJSONinputParams;
import org.apache.fineract.infrastructure.core.exception.InvalidJsonException; import org.apache.fineract.infrastructure.core.exception.InvalidJsonException;
import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper; import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -36,10 +36,10 @@ import org.springframework.stereotype.Component;
@Component @Component
public class ExternalServicesPropertiesCommandFromApiJsonDeserializer { public class ExternalServicesPropertiesCommandFromApiJsonDeserializer {
private final Set<String> S3SupportedParameters = S3_JSON_INPUT_PARAMS.getAllValues(); private final Set<String> S3SupportedParameters = S3JSONinputParams.getAllValues();
private final Set<String> SMTPSupportedParameters = SMTP_JSON_INPUT_PARAMS.getAllValues(); private final Set<String> SMTPSupportedParameters = SMTPJSONinputParams.getAllValues();
private final Set<String> SMSSupportedParameters = SMS_JSON_INPUT_PARAMS.getAllValues(); private final Set<String> SMSSupportedParameters = SMSJSONinputParams.getAllValues();
private final Set<String> NotificationSupportedParameters = NOTIFICATION_JSON_INPUT_PARAMS.getAllValues(); private final Set<String> NotificationSupportedParameters = NotificationJSONinputParams.getAllValues();
private final FromJsonHelper fromApiJsonHelper; private final FromJsonHelper fromApiJsonHelper;
@Autowired @Autowired
@@ -48,19 +48,19 @@ public class ExternalServicesConstants {
public static final String NOTIFICATION_GCM_END_POINT = "gcm_end_point"; public static final String NOTIFICATION_GCM_END_POINT = "gcm_end_point";
public static final String NOTIFICATION_FCM_END_POINT = "fcm_end_point"; public static final String NOTIFICATION_FCM_END_POINT = "fcm_end_point";
public static enum EXTERNALSERVICEPROPERTIES_JSON_INPUT_PARAMS { public static enum ExternalservicePropertiesJSONinputParams {
EXTERNAL_SERVICE_ID("external_service_id"), NAME("name"), VALUE("value"); EXTERNAL_SERVICE_ID("external_service_id"), NAME("name"), VALUE("value");
private final String value; private final String value;
private EXTERNALSERVICEPROPERTIES_JSON_INPUT_PARAMS(final String value) { private ExternalservicePropertiesJSONinputParams(final String value) {
this.value = value; this.value = value;
} }
private static final Set<String> values = new HashSet<>(); private static final Set<String> values = new HashSet<>();
static { static {
for (final EXTERNALSERVICEPROPERTIES_JSON_INPUT_PARAMS type : EXTERNALSERVICEPROPERTIES_JSON_INPUT_PARAMS.values()) { for (final ExternalservicePropertiesJSONinputParams type : ExternalservicePropertiesJSONinputParams.values()) {
values.add(type.value); values.add(type.value);
} }
} }
@@ -79,19 +79,19 @@ public class ExternalServicesConstants {
} }
} }
public static enum SMTP_JSON_INPUT_PARAMS { public static enum SMTPJSONinputParams {
USERNAME("username"), PASSWORD("password"), HOST("host"), PORT("port"), USETLS("useTLS"), FROM_EMAIL("fromEmail"), FROM_NAME("fromName"); USERNAME("username"), PASSWORD("password"), HOST("host"), PORT("port"), USETLS("useTLS"), FROM_EMAIL("fromEmail"), FROM_NAME("fromName");
private final String value; private final String value;
private SMTP_JSON_INPUT_PARAMS(final String value) { private SMTPJSONinputParams(final String value) {
this.value = value; this.value = value;
} }
private static final Set<String> values = new HashSet<>(); private static final Set<String> values = new HashSet<>();
static { static {
for (final SMTP_JSON_INPUT_PARAMS type : SMTP_JSON_INPUT_PARAMS.values()) { for (final SMTPJSONinputParams type : SMTPJSONinputParams.values()) {
values.add(type.value); values.add(type.value);
} }
} }
@@ -110,19 +110,19 @@ public class ExternalServicesConstants {
} }
} }
public static enum SMS_JSON_INPUT_PARAMS { public static enum SMSJSONinputParams {
HASTNAME("host_name"), PORT("port_number"), END_POINT("end_point"), TENANT_APP_KEY("tenant_app_key"); HASTNAME("host_name"), PORT("port_number"), END_POINT("end_point"), TENANT_APP_KEY("tenant_app_key");
private final String value; private final String value;
private SMS_JSON_INPUT_PARAMS(final String value) { private SMSJSONinputParams(final String value) {
this.value = value; this.value = value;
} }
private static final Set<String> values = new HashSet<>(); private static final Set<String> values = new HashSet<>();
static { static {
for (final SMS_JSON_INPUT_PARAMS type : SMS_JSON_INPUT_PARAMS.values()) { for (final SMSJSONinputParams type : SMSJSONinputParams.values()) {
values.add(type.value); values.add(type.value);
} }
} }
@@ -141,19 +141,19 @@ public class ExternalServicesConstants {
} }
} }
public static enum S3_JSON_INPUT_PARAMS { public static enum S3JSONinputParams {
S3_ACCESS_KEY("s3_access_key"), S3_BUCKET_NAME("s3_bucket_name"), S3_SECRET_KEY("s3_secret_key"); S3_ACCESS_KEY("s3_access_key"), S3_BUCKET_NAME("s3_bucket_name"), S3_SECRET_KEY("s3_secret_key");
private final String value; private final String value;
private S3_JSON_INPUT_PARAMS(final String value) { private S3JSONinputParams(final String value) {
this.value = value; this.value = value;
} }
private static final Set<String> values = new HashSet<>(); private static final Set<String> values = new HashSet<>();
static { static {
for (final S3_JSON_INPUT_PARAMS type : S3_JSON_INPUT_PARAMS.values()) { for (final S3JSONinputParams type : S3JSONinputParams.values()) {
values.add(type.value); values.add(type.value);
} }
} }
@@ -172,19 +172,19 @@ public class ExternalServicesConstants {
} }
} }
public static enum NOTIFICATION_JSON_INPUT_PARAMS { public static enum NotificationJSONinputParams {
SERVER_KEY("server_key"), GCM_END_POINT("gcm_end_point"), FCM_END_POINT("fcm_end_point"); SERVER_KEY("server_key"), GCM_END_POINT("gcm_end_point"), FCM_END_POINT("fcm_end_point");
private final String value; private final String value;
private NOTIFICATION_JSON_INPUT_PARAMS(final String value) { private NotificationJSONinputParams(final String value) {
this.value = value; this.value = value;
} }
private static final Set<String> values = new HashSet<>(); private static final Set<String> values = new HashSet<>();
static { static {
for (final NOTIFICATION_JSON_INPUT_PARAMS type : NOTIFICATION_JSON_INPUT_PARAMS.values()) { for (final NotificationJSONinputParams type : NotificationJSONinputParams.values()) {
values.add(type.value); values.add(type.value);
} }
} }
@@ -42,7 +42,7 @@ import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.apache.fineract.infrastructure.core.domain.Base64EncodedImage; import org.apache.fineract.infrastructure.core.domain.Base64EncodedImage;
import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer; import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer;
import org.apache.fineract.infrastructure.documentmanagement.contentrepository.ContentRepositoryUtils; import org.apache.fineract.infrastructure.documentmanagement.contentrepository.ContentRepositoryUtils;
import org.apache.fineract.infrastructure.documentmanagement.contentrepository.ContentRepositoryUtils.IMAGE_FILE_EXTENSION; import org.apache.fineract.infrastructure.documentmanagement.contentrepository.ContentRepositoryUtils.ImageFileExtension;
import org.apache.fineract.infrastructure.documentmanagement.data.ImageData; import org.apache.fineract.infrastructure.documentmanagement.data.ImageData;
import org.apache.fineract.infrastructure.documentmanagement.exception.InvalidEntityTypeForImageManagementException; import org.apache.fineract.infrastructure.documentmanagement.exception.InvalidEntityTypeForImageManagementException;
import org.apache.fineract.infrastructure.documentmanagement.service.ImageReadPlatformService; import org.apache.fineract.infrastructure.documentmanagement.service.ImageReadPlatformService;
@@ -121,9 +121,9 @@ public class ImagesApiResource {
@QueryParam("maxWidth") final Integer maxWidth, @QueryParam("maxHeight") final Integer maxHeight, @QueryParam("maxWidth") final Integer maxWidth, @QueryParam("maxHeight") final Integer maxHeight,
@QueryParam("output") final String output) { @QueryParam("output") final String output) {
validateEntityTypeforImage(entityName); validateEntityTypeforImage(entityName);
if (ENTITY_TYPE_FOR_IMAGES.CLIENTS.toString().equalsIgnoreCase(entityName)) { if (EntityTypeForImages.CLIENTS.toString().equalsIgnoreCase(entityName)) {
this.context.authenticatedUser().validateHasReadPermission("CLIENTIMAGE"); this.context.authenticatedUser().validateHasReadPermission("CLIENTIMAGE");
} else if (ENTITY_TYPE_FOR_IMAGES.STAFF.toString().equalsIgnoreCase(entityName)) { } else if (EntityTypeForImages.STAFF.toString().equalsIgnoreCase(entityName)) {
this.context.authenticatedUser().validateHasReadPermission("STAFFIMAGE"); this.context.authenticatedUser().validateHasReadPermission("STAFFIMAGE");
} }
@@ -133,11 +133,11 @@ public class ImagesApiResource {
final ImageData imageData = this.imageReadPlatformService.retrieveImage(entityName, entityId); final ImageData imageData = this.imageReadPlatformService.retrieveImage(entityName, entityId);
// TODO: Need a better way of determining image type // TODO: Need a better way of determining image type
String imageDataURISuffix = ContentRepositoryUtils.IMAGE_DATA_URI_SUFFIX.JPEG.getValue(); String imageDataURISuffix = ContentRepositoryUtils.ImageDataURIsuffix.JPEG.getValue();
if (StringUtils.endsWith(imageData.location(), ContentRepositoryUtils.IMAGE_FILE_EXTENSION.GIF.getValue())) { if (StringUtils.endsWith(imageData.location(), ContentRepositoryUtils.ImageFileExtension.GIF.getValue())) {
imageDataURISuffix = ContentRepositoryUtils.IMAGE_DATA_URI_SUFFIX.GIF.getValue(); imageDataURISuffix = ContentRepositoryUtils.ImageDataURIsuffix.GIF.getValue();
} else if (StringUtils.endsWith(imageData.location(), ContentRepositoryUtils.IMAGE_FILE_EXTENSION.PNG.getValue())) { } else if (StringUtils.endsWith(imageData.location(), ContentRepositoryUtils.ImageFileExtension.PNG.getValue())) {
imageDataURISuffix = ContentRepositoryUtils.IMAGE_DATA_URI_SUFFIX.PNG.getValue(); imageDataURISuffix = ContentRepositoryUtils.ImageDataURIsuffix.PNG.getValue();
} }
final String clientImageAsBase64Text = imageDataURISuffix + Base64.encodeBytes(imageData.getContentOfSize(maxWidth, maxHeight)); final String clientImageAsBase64Text = imageDataURISuffix + Base64.encodeBytes(imageData.getContentOfSize(maxWidth, maxHeight));
@@ -151,9 +151,9 @@ public class ImagesApiResource {
@QueryParam("maxWidth") final Integer maxWidth, @QueryParam("maxHeight") final Integer maxHeight, @QueryParam("maxWidth") final Integer maxWidth, @QueryParam("maxHeight") final Integer maxHeight,
@QueryParam("output") String output) { @QueryParam("output") String output) {
validateEntityTypeforImage(entityName); validateEntityTypeforImage(entityName);
if (ENTITY_TYPE_FOR_IMAGES.CLIENTS.toString().equalsIgnoreCase(entityName)) { if (EntityTypeForImages.CLIENTS.toString().equalsIgnoreCase(entityName)) {
this.context.authenticatedUser().validateHasReadPermission("CLIENTIMAGE"); this.context.authenticatedUser().validateHasReadPermission("CLIENTIMAGE");
} else if (ENTITY_TYPE_FOR_IMAGES.STAFF.toString().equalsIgnoreCase(entityName)) { } else if (EntityTypeForImages.STAFF.toString().equalsIgnoreCase(entityName)) {
this.context.authenticatedUser().validateHasReadPermission("STAFFIMAGE"); this.context.authenticatedUser().validateHasReadPermission("STAFFIMAGE");
} }
@@ -162,7 +162,7 @@ public class ImagesApiResource {
final ResponseBuilder response = Response.ok(imageData.getContentOfSize(maxWidth, maxHeight)); final ResponseBuilder response = Response.ok(imageData.getContentOfSize(maxWidth, maxHeight));
String dispositionType = "inline_octet".equals(output) ? "inline" : "attachment"; String dispositionType = "inline_octet".equals(output) ? "inline" : "attachment";
response.header("Content-Disposition", dispositionType + "; filename=\"" + imageData.getEntityDisplayName() response.header("Content-Disposition", dispositionType + "; filename=\"" + imageData.getEntityDisplayName()
+ IMAGE_FILE_EXTENSION.JPEG + "\""); + ImageFileExtension.JPEG + "\"");
// TODO: Need a better way of determining image type // TODO: Need a better way of determining image type
@@ -207,7 +207,7 @@ public class ImagesApiResource {
} }
/*** Entities for document Management **/ /*** Entities for document Management **/
public static enum ENTITY_TYPE_FOR_IMAGES { public static enum EntityTypeForImages {
STAFF, CLIENTS; STAFF, CLIENTS;
@Override @Override
@@ -221,7 +221,7 @@ public class ImagesApiResource {
} }
private static boolean checkValidEntityType(final String entityType) { private static boolean checkValidEntityType(final String entityType) {
for (final ENTITY_TYPE_FOR_IMAGES entities : ENTITY_TYPE_FOR_IMAGES.values()) { for (final EntityTypeForImages entities : EntityTypeForImages.values()) {
if (entities.name().equalsIgnoreCase(entityType)) { return true; } if (entities.name().equalsIgnoreCase(entityType)) { return true; }
} }
return false; return false;
@@ -33,12 +33,12 @@ public class ContentRepositoryUtils {
private static final Random random = new Random(); private static final Random random = new Random();
public static enum IMAGE_MIME_TYPE { public static enum ImageMIMEtype {
GIF("image/gif"), JPEG("image/jpeg"), PNG("image/png"); GIF("image/gif"), JPEG("image/jpeg"), PNG("image/png");
private final String value; private final String value;
private IMAGE_MIME_TYPE(final String value) { private ImageMIMEtype(final String value) {
this.value = value; this.value = value;
} }
@@ -46,27 +46,27 @@ public class ContentRepositoryUtils {
return this.value; return this.value;
} }
public static IMAGE_MIME_TYPE fromFileExtension(IMAGE_FILE_EXTENSION fileExtension) { public static ImageMIMEtype fromFileExtension(ImageFileExtension fileExtension) {
switch (fileExtension) { switch (fileExtension) {
case GIF: case GIF:
return IMAGE_MIME_TYPE.GIF; return ImageMIMEtype.GIF;
case JPG: case JPG:
case JPEG: case JPEG:
return IMAGE_MIME_TYPE.JPEG; return ImageMIMEtype.JPEG;
case PNG: case PNG:
return IMAGE_MIME_TYPE.PNG; return ImageMIMEtype.PNG;
default: default:
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
} }
} }
public static enum IMAGE_FILE_EXTENSION { public static enum ImageFileExtension {
GIF(".gif"), JPEG(".jpeg"), JPG(".jpg"), PNG(".png"); GIF(".gif"), JPEG(".jpeg"), JPG(".jpg"), PNG(".png");
private final String value; private final String value;
private IMAGE_FILE_EXTENSION(final String value) { private ImageFileExtension(final String value) {
this.value = value; this.value = value;
} }
@@ -78,27 +78,27 @@ public class ContentRepositoryUtils {
return this.value.substring(1); return this.value.substring(1);
} }
public IMAGE_FILE_EXTENSION getFileExtension() { public ImageFileExtension getFileExtension() {
switch (this) { switch (this) {
case GIF: case GIF:
return IMAGE_FILE_EXTENSION.GIF; return ImageFileExtension.GIF;
case JPEG: case JPEG:
return IMAGE_FILE_EXTENSION.JPEG; return ImageFileExtension.JPEG;
case PNG: case PNG:
return IMAGE_FILE_EXTENSION.PNG; return ImageFileExtension.PNG;
default: default:
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
} }
} }
public static enum IMAGE_DATA_URI_SUFFIX { public static enum ImageDataURIsuffix {
GIF("data:" + IMAGE_MIME_TYPE.GIF.getValue() + ";base64,"), JPEG("data:" + IMAGE_MIME_TYPE.JPEG.getValue() + ";base64,"), PNG( GIF("data:" + ImageMIMEtype.GIF.getValue() + ";base64,"), JPEG("data:" + ImageMIMEtype.JPEG.getValue() + ";base64,"), PNG(
"data:" + IMAGE_MIME_TYPE.PNG.getValue() + ";base64,"); "data:" + ImageMIMEtype.PNG.getValue() + ";base64,");
private final String value; private final String value;
private IMAGE_DATA_URI_SUFFIX(final String value) { private ImageDataURIsuffix(final String value) {
this.value = value; this.value = value;
} }
@@ -113,8 +113,8 @@ public class ContentRepositoryUtils {
* @param mimeType * @param mimeType
*/ */
public static void validateImageMimeType(final String mimeType) { public static void validateImageMimeType(final String mimeType) {
if (!(mimeType.equalsIgnoreCase(IMAGE_MIME_TYPE.GIF.getValue()) || mimeType.equalsIgnoreCase(IMAGE_MIME_TYPE.JPEG.getValue()) || mimeType if (!(mimeType.equalsIgnoreCase(ImageMIMEtype.GIF.getValue()) || mimeType.equalsIgnoreCase(ImageMIMEtype.JPEG.getValue()) || mimeType
.equalsIgnoreCase(IMAGE_MIME_TYPE.PNG.getValue()))) { throw new ImageUploadException(); } .equalsIgnoreCase(ImageMIMEtype.PNG.getValue()))) { throw new ImageUploadException(); }
} }
/** /**
@@ -125,15 +125,15 @@ public class ContentRepositoryUtils {
public static Base64EncodedImage extractImageFromDataURL(final String dataURL) { public static Base64EncodedImage extractImageFromDataURL(final String dataURL) {
String fileExtension = ""; String fileExtension = "";
String base64EncodedString = null; String base64EncodedString = null;
if (StringUtils.startsWith(dataURL, IMAGE_DATA_URI_SUFFIX.GIF.getValue())) { if (StringUtils.startsWith(dataURL, ImageDataURIsuffix.GIF.getValue())) {
base64EncodedString = dataURL.replaceAll(IMAGE_DATA_URI_SUFFIX.GIF.getValue(), ""); base64EncodedString = dataURL.replaceAll(ImageDataURIsuffix.GIF.getValue(), "");
fileExtension = IMAGE_FILE_EXTENSION.GIF.getValue(); fileExtension = ImageFileExtension.GIF.getValue();
} else if (StringUtils.startsWith(dataURL, IMAGE_DATA_URI_SUFFIX.PNG.getValue())) { } else if (StringUtils.startsWith(dataURL, ImageDataURIsuffix.PNG.getValue())) {
base64EncodedString = dataURL.replaceAll(IMAGE_DATA_URI_SUFFIX.PNG.getValue(), ""); base64EncodedString = dataURL.replaceAll(ImageDataURIsuffix.PNG.getValue(), "");
fileExtension = IMAGE_FILE_EXTENSION.PNG.getValue(); fileExtension = ImageFileExtension.PNG.getValue();
} else if (StringUtils.startsWith(dataURL, IMAGE_DATA_URI_SUFFIX.JPEG.getValue())) { } else if (StringUtils.startsWith(dataURL, ImageDataURIsuffix.JPEG.getValue())) {
base64EncodedString = dataURL.replaceAll(IMAGE_DATA_URI_SUFFIX.JPEG.getValue(), ""); base64EncodedString = dataURL.replaceAll(ImageDataURIsuffix.JPEG.getValue(), "");
fileExtension = IMAGE_FILE_EXTENSION.JPEG.getValue(); fileExtension = ImageFileExtension.JPEG.getValue();
} else { } else {
throw new ImageDataURLNotValidException(); throw new ImageDataURLNotValidException();
} }
@@ -48,7 +48,7 @@ public class ImageData {
private final String entityDisplayName; private final String entityDisplayName;
private File file; private File file;
private ContentRepositoryUtils.IMAGE_FILE_EXTENSION fileExtension; private ContentRepositoryUtils.ImageFileExtension fileExtension;
private InputStream inputStream; private InputStream inputStream;
public ImageData(final Long imageId, final String location, final Integer storageType, final String entityDisplayName) { public ImageData(final Long imageId, final String location, final Integer storageType, final String entityDisplayName) {
@@ -94,7 +94,7 @@ public class ImageData {
int newWidth = (int) (src.getWidth() / scaleRatio); int newWidth = (int) (src.getWidth() / scaleRatio);
int newHeight = (int) (src.getHeight() / scaleRatio); int newHeight = (int) (src.getHeight() / scaleRatio);
int colorModel = fileExtension == ContentRepositoryUtils.IMAGE_FILE_EXTENSION.JPEG ? BufferedImage.TYPE_INT_RGB int colorModel = fileExtension == ContentRepositoryUtils.ImageFileExtension.JPEG ? BufferedImage.TYPE_INT_RGB
: BufferedImage.TYPE_INT_ARGB; : BufferedImage.TYPE_INT_ARGB;
BufferedImage target = new BufferedImage(newWidth, newHeight, colorModel); BufferedImage target = new BufferedImage(newWidth, newHeight, colorModel);
Graphics2D g = target.createGraphics(); Graphics2D g = target.createGraphics();
@@ -135,12 +135,12 @@ public class ImageData {
} }
private void setImageContentType(String filename) { private void setImageContentType(String filename) {
fileExtension = ContentRepositoryUtils.IMAGE_FILE_EXTENSION.JPEG; fileExtension = ContentRepositoryUtils.ImageFileExtension.JPEG;
if (StringUtils.endsWith(filename.toLowerCase(), ContentRepositoryUtils.IMAGE_FILE_EXTENSION.GIF.getValue())) { if (StringUtils.endsWith(filename.toLowerCase(), ContentRepositoryUtils.ImageFileExtension.GIF.getValue())) {
fileExtension = ContentRepositoryUtils.IMAGE_FILE_EXTENSION.GIF; fileExtension = ContentRepositoryUtils.ImageFileExtension.GIF;
} else if (StringUtils.endsWith(filename, ContentRepositoryUtils.IMAGE_FILE_EXTENSION.PNG.getValue())) { } else if (StringUtils.endsWith(filename, ContentRepositoryUtils.ImageFileExtension.PNG.getValue())) {
fileExtension = ContentRepositoryUtils.IMAGE_FILE_EXTENSION.PNG; fileExtension = ContentRepositoryUtils.ImageFileExtension.PNG;
} }
} }
@@ -152,7 +152,7 @@ public class ImageData {
} }
public String contentType() { public String contentType() {
return ContentRepositoryUtils.IMAGE_MIME_TYPE.fromFileExtension(this.fileExtension).getValue(); return ContentRepositoryUtils.ImageMIMEtype.fromFileExtension(this.fileExtension).getValue();
} }
public StorageType storageType() { public StorageType storageType() {
@@ -168,14 +168,14 @@ public class DocumentWritePlatformServiceJpaRepositoryImpl implements DocumentWr
} }
private static boolean checkValidEntityType(final String entityType) { private static boolean checkValidEntityType(final String entityType) {
for (final DOCUMENT_MANAGEMENT_ENTITY entities : DOCUMENT_MANAGEMENT_ENTITY.values()) { for (final DocumentManagementEntity entities : DocumentManagementEntity.values()) {
if (entities.name().equalsIgnoreCase(entityType)) { return true; } if (entities.name().equalsIgnoreCase(entityType)) { return true; }
} }
return false; return false;
} }
/*** Entities for document Management **/ /*** Entities for document Management **/
public static enum DOCUMENT_MANAGEMENT_ENTITY { public static enum DocumentManagementEntity {
CLIENTS, CLIENT_IDENTIFIERS, STAFF, LOANS, SAVINGS, GROUPS,IMPORT; CLIENTS, CLIENT_IDENTIFIERS, STAFF, LOANS, SAVINGS, GROUPS,IMPORT;
@Override @Override
@@ -22,7 +22,7 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import org.apache.fineract.infrastructure.core.domain.JdbcSupport; import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
import org.apache.fineract.infrastructure.core.service.RoutingDataSource; import org.apache.fineract.infrastructure.core.service.RoutingDataSource;
import org.apache.fineract.infrastructure.documentmanagement.api.ImagesApiResource.ENTITY_TYPE_FOR_IMAGES; import org.apache.fineract.infrastructure.documentmanagement.api.ImagesApiResource.EntityTypeForImages;
import org.apache.fineract.infrastructure.documentmanagement.contentrepository.ContentRepository; import org.apache.fineract.infrastructure.documentmanagement.contentrepository.ContentRepository;
import org.apache.fineract.infrastructure.documentmanagement.contentrepository.ContentRepositoryFactory; import org.apache.fineract.infrastructure.documentmanagement.contentrepository.ContentRepositoryFactory;
import org.apache.fineract.infrastructure.documentmanagement.data.ImageData; import org.apache.fineract.infrastructure.documentmanagement.data.ImageData;
@@ -64,9 +64,9 @@ public class ImageReadPlatformServiceImpl implements ImageReadPlatformService {
public String schema(String entityType) { public String schema(String entityType) {
StringBuilder builder = new StringBuilder("image.id as id, image.location as location, image.storage_type_enum as storageType "); StringBuilder builder = new StringBuilder("image.id as id, image.location as location, image.storage_type_enum as storageType ");
if (ENTITY_TYPE_FOR_IMAGES.CLIENTS.toString().equalsIgnoreCase(entityType)) { if (EntityTypeForImages.CLIENTS.toString().equalsIgnoreCase(entityType)) {
builder.append(" from m_image image , m_client client " + " where client.image_id = image.id and client.id=?"); builder.append(" from m_image image , m_client client " + " where client.image_id = image.id and client.id=?");
} else if (ENTITY_TYPE_FOR_IMAGES.STAFF.toString().equalsIgnoreCase(entityType)) { } else if (EntityTypeForImages.STAFF.toString().equalsIgnoreCase(entityType)) {
builder.append("from m_image image , m_staff staff " + " where staff.image_id = image.id and staff.id=?"); builder.append("from m_image image , m_staff staff " + " where staff.image_id = image.id and staff.id=?");
} }
return builder.toString(); return builder.toString();
@@ -87,10 +87,10 @@ public class ImageReadPlatformServiceImpl implements ImageReadPlatformService {
try { try {
Object owner; Object owner;
String displayName = null; String displayName = null;
if (ENTITY_TYPE_FOR_IMAGES.CLIENTS.toString().equalsIgnoreCase(entityType)) { if (EntityTypeForImages.CLIENTS.toString().equalsIgnoreCase(entityType)) {
owner = this.clientRepositoryWrapper.findOneWithNotFoundDetection(entityId); owner = this.clientRepositoryWrapper.findOneWithNotFoundDetection(entityId);
displayName = ((Client) owner).getDisplayName(); displayName = ((Client) owner).getDisplayName();
} else if (ENTITY_TYPE_FOR_IMAGES.STAFF.toString().equalsIgnoreCase(entityType)) { } else if (EntityTypeForImages.STAFF.toString().equalsIgnoreCase(entityType)) {
owner = this.staffRepositoryWrapper.findOneWithNotFoundDetection(entityId); owner = this.staffRepositoryWrapper.findOneWithNotFoundDetection(entityId);
displayName = ((Staff) owner).displayName(); displayName = ((Staff) owner).displayName();
} }
@@ -21,7 +21,7 @@ package org.apache.fineract.infrastructure.documentmanagement.service;
import java.io.InputStream; import java.io.InputStream;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.apache.fineract.infrastructure.core.domain.Base64EncodedImage; import org.apache.fineract.infrastructure.core.domain.Base64EncodedImage;
import org.apache.fineract.infrastructure.documentmanagement.api.ImagesApiResource.ENTITY_TYPE_FOR_IMAGES; import org.apache.fineract.infrastructure.documentmanagement.api.ImagesApiResource.EntityTypeForImages;
import org.apache.fineract.infrastructure.documentmanagement.contentrepository.ContentRepository; import org.apache.fineract.infrastructure.documentmanagement.contentrepository.ContentRepository;
import org.apache.fineract.infrastructure.documentmanagement.contentrepository.ContentRepositoryFactory; import org.apache.fineract.infrastructure.documentmanagement.contentrepository.ContentRepositoryFactory;
import org.apache.fineract.infrastructure.documentmanagement.domain.Image; import org.apache.fineract.infrastructure.documentmanagement.domain.Image;
@@ -80,14 +80,14 @@ public class ImageWritePlatformServiceJpaRepositoryImpl implements ImageWritePla
public CommandProcessingResult deleteImage(String entityName, final Long clientId) { public CommandProcessingResult deleteImage(String entityName, final Long clientId) {
Object owner = null; Object owner = null;
Image image = null; Image image = null;
if (ENTITY_TYPE_FOR_IMAGES.CLIENTS.toString().equals(entityName)) { if (EntityTypeForImages.CLIENTS.toString().equals(entityName)) {
owner = this.clientRepositoryWrapper.findOneWithNotFoundDetection(clientId); owner = this.clientRepositoryWrapper.findOneWithNotFoundDetection(clientId);
Client client = (Client) owner; Client client = (Client) owner;
image = client.getImage(); image = client.getImage();
client.setImage(null); client.setImage(null);
this.clientRepositoryWrapper.save(client); this.clientRepositoryWrapper.save(client);
} else if (ENTITY_TYPE_FOR_IMAGES.STAFF.toString().equals(entityName)) { } else if (EntityTypeForImages.STAFF.toString().equals(entityName)) {
owner = this.staffRepositoryWrapper.findOneWithNotFoundDetection(clientId); owner = this.staffRepositoryWrapper.findOneWithNotFoundDetection(clientId);
Staff staff = (Staff) owner; Staff staff = (Staff) owner;
image = staff.getImage(); image = staff.getImage();
@@ -114,11 +114,11 @@ public class ImageWritePlatformServiceJpaRepositoryImpl implements ImageWritePla
private Object deletePreviousImage(String entityName, final Long entityId) { private Object deletePreviousImage(String entityName, final Long entityId) {
Object owner = null; Object owner = null;
Image image = null; Image image = null;
if (ENTITY_TYPE_FOR_IMAGES.CLIENTS.toString().equals(entityName)) { if (EntityTypeForImages.CLIENTS.toString().equals(entityName)) {
Client client = this.clientRepositoryWrapper.findOneWithNotFoundDetection(entityId); Client client = this.clientRepositoryWrapper.findOneWithNotFoundDetection(entityId);
image = client.getImage(); image = client.getImage();
owner = client; owner = client;
} else if (ENTITY_TYPE_FOR_IMAGES.STAFF.toString().equals(entityName)) { } else if (EntityTypeForImages.STAFF.toString().equals(entityName)) {
Staff staff = this.staffRepositoryWrapper.findOneWithNotFoundDetection(entityId); Staff staff = this.staffRepositoryWrapper.findOneWithNotFoundDetection(entityId);
image = staff.getImage(); image = staff.getImage();
owner = staff; owner = staff;
@@ -27,7 +27,7 @@ public class FineractEntityAccessConstants {
/*** /***
* Enum of all parameters passed in while creating/updating an entity access * Enum of all parameters passed in while creating/updating an entity access
***/ ***/
public static enum ENTITY_ACCESS_JSON_INPUT_PARAMS { public static enum EntityAccessJSONinputParams {
ENTITY_TYPE("entityType"), ENTITY_TYPE("entityType"),
ENTITY_ID("entityId"), ENTITY_ID("entityId"),
ENTITY_ACCESS_TYPE_ID("entityAccessTypeId"), ENTITY_ACCESS_TYPE_ID("entityAccessTypeId"),
@@ -37,7 +37,7 @@ public class FineractEntityAccessConstants {
private final String value; private final String value;
private ENTITY_ACCESS_JSON_INPUT_PARAMS(final String value) { private EntityAccessJSONinputParams(final String value) {
this.value = value; this.value = value;
} }
@@ -73,13 +73,13 @@ public class FineractEntityAccess extends AbstractPersistableCustom {
public static FineractEntityAccess fromJson(final CodeValue accessType, final JsonCommand command) { public static FineractEntityAccess fromJson(final CodeValue accessType, final JsonCommand command) {
final String entityType = command.stringValueOfParameterNamed( final String entityType = command.stringValueOfParameterNamed(
FineractEntityAccessConstants.ENTITY_ACCESS_JSON_INPUT_PARAMS.ENTITY_TYPE.getValue()); FineractEntityAccessConstants.EntityAccessJSONinputParams.ENTITY_TYPE.getValue());
final Long entityId = command.longValueOfParameterNamed( final Long entityId = command.longValueOfParameterNamed(
FineractEntityAccessConstants.ENTITY_ACCESS_JSON_INPUT_PARAMS.ENTITY_ID.getValue()); FineractEntityAccessConstants.EntityAccessJSONinputParams.ENTITY_ID.getValue());
final String secondEntityType = command.stringValueOfParameterNamed( final String secondEntityType = command.stringValueOfParameterNamed(
FineractEntityAccessConstants.ENTITY_ACCESS_JSON_INPUT_PARAMS.SECOND_ENTITY_ID.getValue()); FineractEntityAccessConstants.EntityAccessJSONinputParams.SECOND_ENTITY_ID.getValue());
final Long secondEntityId = command.longValueOfParameterNamed( final Long secondEntityId = command.longValueOfParameterNamed(
FineractEntityAccessConstants.ENTITY_ACCESS_JSON_INPUT_PARAMS.SECOND_ENTITY_ID.getValue()); FineractEntityAccessConstants.EntityAccessJSONinputParams.SECOND_ENTITY_ID.getValue());
return new FineractEntityAccess (entityType, entityId, accessType, return new FineractEntityAccess (entityType, entityId, accessType,
secondEntityType, secondEntityId); secondEntityType, secondEntityId);
@@ -92,14 +92,14 @@ public class FineractEntityAccess extends AbstractPersistableCustom {
String paramName = null; String paramName = null;
paramName = FineractEntityAccessConstants.ENTITY_ACCESS_JSON_INPUT_PARAMS.ENTITY_TYPE.getValue(); paramName = FineractEntityAccessConstants.EntityAccessJSONinputParams.ENTITY_TYPE.getValue();
if (command.isChangeInStringParameterNamed(paramName, this.entityType)) { if (command.isChangeInStringParameterNamed(paramName, this.entityType)) {
final String newValue = command.stringValueOfParameterNamed(paramName); final String newValue = command.stringValueOfParameterNamed(paramName);
actualChanges.put(paramName, newValue); actualChanges.put(paramName, newValue);
this.entityType = newValue; this.entityType = newValue;
} }
paramName = FineractEntityAccessConstants.ENTITY_ACCESS_JSON_INPUT_PARAMS.ENTITY_ID.getValue(); paramName = FineractEntityAccessConstants.EntityAccessJSONinputParams.ENTITY_ID.getValue();
if (command.isChangeInLongParameterNamed(paramName, getEntityId())) { if (command.isChangeInLongParameterNamed(paramName, getEntityId())) {
this.entityId = command.longValueOfParameterNamed(paramName); this.entityId = command.longValueOfParameterNamed(paramName);
actualChanges.put(paramName, this.entityId); actualChanges.put(paramName, this.entityId);
@@ -110,20 +110,20 @@ public class FineractEntityAccess extends AbstractPersistableCustom {
existingAccessTypeId = this.accessType.getId(); existingAccessTypeId = this.accessType.getId();
} }
paramName = FineractEntityAccessConstants.ENTITY_ACCESS_JSON_INPUT_PARAMS.ENTITY_ACCESS_TYPE_ID.getValue(); paramName = FineractEntityAccessConstants.EntityAccessJSONinputParams.ENTITY_ACCESS_TYPE_ID.getValue();
if (command.isChangeInLongParameterNamed(paramName, existingAccessTypeId)) { if (command.isChangeInLongParameterNamed(paramName, existingAccessTypeId)) {
final Long newValue = command.longValueOfParameterNamed(paramName); final Long newValue = command.longValueOfParameterNamed(paramName);
actualChanges.put(paramName, newValue); actualChanges.put(paramName, newValue);
} }
paramName = FineractEntityAccessConstants.ENTITY_ACCESS_JSON_INPUT_PARAMS.SECOND_ENTITY_TYPE.getValue(); paramName = FineractEntityAccessConstants.EntityAccessJSONinputParams.SECOND_ENTITY_TYPE.getValue();
if (command.isChangeInStringParameterNamed(paramName, this.secondEntityType)) { if (command.isChangeInStringParameterNamed(paramName, this.secondEntityType)) {
final String newValue = command.stringValueOfParameterNamed(paramName); final String newValue = command.stringValueOfParameterNamed(paramName);
actualChanges.put(paramName, newValue); actualChanges.put(paramName, newValue);
this.secondEntityType = newValue; this.secondEntityType = newValue;
} }
paramName = FineractEntityAccessConstants.ENTITY_ACCESS_JSON_INPUT_PARAMS.SECOND_ENTITY_ID.getValue(); paramName = FineractEntityAccessConstants.EntityAccessJSONinputParams.SECOND_ENTITY_ID.getValue();
if (command.isChangeInLongParameterNamed(paramName, getSecondEntityId())) { if (command.isChangeInLongParameterNamed(paramName, getSecondEntityId())) {
this.secondEntityId = command.longValueOfParameterNamed(paramName); this.secondEntityId = command.longValueOfParameterNamed(paramName);
actualChanges.put(paramName, this.secondEntityId); actualChanges.put(paramName, this.secondEntityId);
@@ -36,8 +36,8 @@ import org.apache.fineract.notification.eventandlistener.SpringEventPublisher;
import org.apache.fineract.organisation.office.domain.OfficeRepository; import org.apache.fineract.organisation.office.domain.OfficeRepository;
import org.apache.fineract.portfolio.client.domain.Client; import org.apache.fineract.portfolio.client.domain.Client;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BUSINESS_ENTITY; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEntity;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BUSINESS_EVENTS; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEvents;
import org.apache.fineract.portfolio.common.service.BusinessEventListner; import org.apache.fineract.portfolio.common.service.BusinessEventListner;
import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService; import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.loanaccount.domain.Loan; import org.apache.fineract.portfolio.loanaccount.domain.Loan;
@@ -82,58 +82,58 @@ public class NotificationDomainServiceImpl implements NotificationDomainService
@PostConstruct @PostConstruct
public void addListeners() { public void addListeners() {
businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.CLIENTS_CREATE, businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.CLIENTS_CREATE,
new ClientCreatedListener()); new ClientCreatedListener());
businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.SAVINGS_APPROVE, businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.SAVINGS_APPROVE,
new SavingsAccountApprovedListener()); new SavingsAccountApprovedListener());
businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.CENTERS_CREATE, businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.CENTERS_CREATE,
new CenterCreatedListener()); new CenterCreatedListener());
businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.GROUPS_CREATE, businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.GROUPS_CREATE,
new GroupCreatedListener()); new GroupCreatedListener());
businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.SAVINGS_DEPOSIT, businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.SAVINGS_DEPOSIT,
new SavingsAccountDepositListener()); new SavingsAccountDepositListener());
businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.SHARE_PRODUCT_DIVIDENDS_CREATE, businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.SHARE_PRODUCT_DIVIDENDS_CREATE,
new ShareProductDividendCreatedListener()); new ShareProductDividendCreatedListener());
businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.FIXED_DEPOSIT_ACCOUNT_CREATE, businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.FIXED_DEPOSIT_ACCOUNT_CREATE,
new FixedDepositAccountCreatedListener()); new FixedDepositAccountCreatedListener());
businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.RECURRING_DEPOSIT_ACCOUNT_CREATE, businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.RECURRING_DEPOSIT_ACCOUNT_CREATE,
new RecurringDepositAccountCreatedListener()); new RecurringDepositAccountCreatedListener());
businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.SAVINGS_POST_INTEREST, businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.SAVINGS_POST_INTEREST,
new SavingsPostInterestListener()); new SavingsPostInterestListener());
businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.LOAN_CREATE, businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.LOAN_CREATE,
new LoanCreatedListener()); new LoanCreatedListener());
businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.LOAN_APPROVED, businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.LOAN_APPROVED,
new LoanApprovedListener()); new LoanApprovedListener());
businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.LOAN_CLOSE, businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.LOAN_CLOSE,
new LoanClosedListener()); new LoanClosedListener());
businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.LOAN_CLOSE_AS_RESCHEDULE, businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.LOAN_CLOSE_AS_RESCHEDULE,
new LoanCloseAsRescheduledListener()); new LoanCloseAsRescheduledListener());
businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.LOAN_MAKE_REPAYMENT, businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.LOAN_MAKE_REPAYMENT,
new LoanMakeRepaymentListener()); new LoanMakeRepaymentListener());
businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.LOAN_PRODUCT_CREATE, businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.LOAN_PRODUCT_CREATE,
new LoanProductCreatedListener()); new LoanProductCreatedListener());
businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.SAVINGS_CREATE, businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.SAVINGS_CREATE,
new SavingsAccountCreatedListener()); new SavingsAccountCreatedListener());
businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.SAVINGS_CLOSE, businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.SAVINGS_CLOSE,
new SavingsAccountClosedListener()); new SavingsAccountClosedListener());
businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.SHARE_ACCOUNT_CREATE, businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.SHARE_ACCOUNT_CREATE,
new ShareAccountCreatedListener()); new ShareAccountCreatedListener());
businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.SHARE_ACCOUNT_APPROVE, businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.SHARE_ACCOUNT_APPROVE,
new ShareAccountApprovedListener()); new ShareAccountApprovedListener());
} }
private abstract class NotificationBusinessEventAdapter implements BusinessEventListner { private abstract class NotificationBusinessEventAdapter implements BusinessEventListner {
@Override @Override
public void businessEventToBeExecuted(Map<BusinessEventNotificationConstants.BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventToBeExecuted(Map<BusinessEventNotificationConstants.BusinessEntity, Object> businessEventEntity) {
} }
} }
private class ClientCreatedListener extends NotificationBusinessEventAdapter { private class ClientCreatedListener extends NotificationBusinessEventAdapter {
@Override @Override
public void businessEventWasExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Client client; Client client;
Object entity = businessEventEntity.get(BusinessEventNotificationConstants.BUSINESS_ENTITY.CLIENT); Object entity = businessEventEntity.get(BusinessEventNotificationConstants.BusinessEntity.CLIENT);
if (entity != null) { if (entity != null) {
client = (Client) entity; client = (Client) entity;
buildNotification( buildNotification(
@@ -152,9 +152,9 @@ public class NotificationDomainServiceImpl implements NotificationDomainService
private class CenterCreatedListener extends NotificationBusinessEventAdapter { private class CenterCreatedListener extends NotificationBusinessEventAdapter {
@Override @Override
public void businessEventWasExecuted(Map<BusinessEventNotificationConstants.BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventWasExecuted(Map<BusinessEventNotificationConstants.BusinessEntity, Object> businessEventEntity) {
CommandProcessingResult commandProcessingResult; CommandProcessingResult commandProcessingResult;
Object entity = businessEventEntity.get(BUSINESS_ENTITY.GROUP); Object entity = businessEventEntity.get(BusinessEntity.GROUP);
if (entity != null) { if (entity != null) {
commandProcessingResult = (CommandProcessingResult) entity; commandProcessingResult = (CommandProcessingResult) entity;
buildNotification( buildNotification(
@@ -173,9 +173,9 @@ public class NotificationDomainServiceImpl implements NotificationDomainService
private class GroupCreatedListener extends NotificationBusinessEventAdapter { private class GroupCreatedListener extends NotificationBusinessEventAdapter {
@Override @Override
public void businessEventWasExecuted(Map<BusinessEventNotificationConstants.BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventWasExecuted(Map<BusinessEventNotificationConstants.BusinessEntity, Object> businessEventEntity) {
CommandProcessingResult commandProcessingResult; CommandProcessingResult commandProcessingResult;
Object entity = businessEventEntity.get(BUSINESS_ENTITY.GROUP); Object entity = businessEventEntity.get(BusinessEntity.GROUP);
if (entity != null) { if (entity != null) {
commandProcessingResult = (CommandProcessingResult) entity; commandProcessingResult = (CommandProcessingResult) entity;
buildNotification( buildNotification(
@@ -194,9 +194,9 @@ public class NotificationDomainServiceImpl implements NotificationDomainService
private class SavingsAccountDepositListener extends NotificationBusinessEventAdapter { private class SavingsAccountDepositListener extends NotificationBusinessEventAdapter {
@Override @Override
public void businessEventWasExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
SavingsAccountTransaction savingsAccountTransaction; SavingsAccountTransaction savingsAccountTransaction;
Object entity = businessEventEntity.get(BUSINESS_ENTITY.SAVINGS_TRANSACTION); Object entity = businessEventEntity.get(BusinessEntity.SAVINGS_TRANSACTION);
if (entity != null) { if (entity != null) {
savingsAccountTransaction = (SavingsAccountTransaction) entity; savingsAccountTransaction = (SavingsAccountTransaction) entity;
buildNotification( buildNotification(
@@ -215,9 +215,9 @@ public class NotificationDomainServiceImpl implements NotificationDomainService
private class ShareProductDividendCreatedListener extends NotificationBusinessEventAdapter { private class ShareProductDividendCreatedListener extends NotificationBusinessEventAdapter {
@Override @Override
public void businessEventWasExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Long shareProductId; Long shareProductId;
Object entity = businessEventEntity.get(BUSINESS_ENTITY.SHARE_PRODUCT); Object entity = businessEventEntity.get(BusinessEntity.SHARE_PRODUCT);
if (entity != null) { if (entity != null) {
shareProductId = (Long) entity; shareProductId = (Long) entity;
buildNotification( buildNotification(
@@ -236,9 +236,9 @@ public class NotificationDomainServiceImpl implements NotificationDomainService
private class FixedDepositAccountCreatedListener extends NotificationBusinessEventAdapter { private class FixedDepositAccountCreatedListener extends NotificationBusinessEventAdapter {
@Override @Override
public void businessEventWasExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
FixedDepositAccount fixedDepositAccount; FixedDepositAccount fixedDepositAccount;
Object entity = businessEventEntity.get(BUSINESS_ENTITY.DEPOSIT_ACCOUNT); Object entity = businessEventEntity.get(BusinessEntity.DEPOSIT_ACCOUNT);
if (entity != null) { if (entity != null) {
fixedDepositAccount = (FixedDepositAccount) entity; fixedDepositAccount = (FixedDepositAccount) entity;
buildNotification( buildNotification(
@@ -257,9 +257,9 @@ public class NotificationDomainServiceImpl implements NotificationDomainService
private class RecurringDepositAccountCreatedListener extends NotificationBusinessEventAdapter { private class RecurringDepositAccountCreatedListener extends NotificationBusinessEventAdapter {
@Override @Override
public void businessEventWasExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
RecurringDepositAccount recurringDepositAccount; RecurringDepositAccount recurringDepositAccount;
Object entity = businessEventEntity.get(BUSINESS_ENTITY.DEPOSIT_ACCOUNT); Object entity = businessEventEntity.get(BusinessEntity.DEPOSIT_ACCOUNT);
if (entity != null) { if (entity != null) {
recurringDepositAccount = (RecurringDepositAccount) entity; recurringDepositAccount = (RecurringDepositAccount) entity;
buildNotification( buildNotification(
@@ -278,9 +278,9 @@ public class NotificationDomainServiceImpl implements NotificationDomainService
private class SavingsAccountApprovedListener extends NotificationBusinessEventAdapter { private class SavingsAccountApprovedListener extends NotificationBusinessEventAdapter {
@Override @Override
public void businessEventWasExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
SavingsAccount savingsAccount; SavingsAccount savingsAccount;
Object entity = businessEventEntity.get(BUSINESS_ENTITY.SAVING); Object entity = businessEventEntity.get(BusinessEntity.SAVING);
if (entity != null) { if (entity != null) {
savingsAccount = (SavingsAccount) entity; savingsAccount = (SavingsAccount) entity;
if (savingsAccount.depositAccountType().equals(DepositAccountType.FIXED_DEPOSIT)) { if (savingsAccount.depositAccountType().equals(DepositAccountType.FIXED_DEPOSIT)) {
@@ -324,9 +324,9 @@ public class NotificationDomainServiceImpl implements NotificationDomainService
private class SavingsPostInterestListener extends NotificationBusinessEventAdapter { private class SavingsPostInterestListener extends NotificationBusinessEventAdapter {
@Override @Override
public void businessEventWasExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
SavingsAccount savingsAccount; SavingsAccount savingsAccount;
Object entity = businessEventEntity.get(BUSINESS_ENTITY.SAVING); Object entity = businessEventEntity.get(BusinessEntity.SAVING);
if (entity != null) { if (entity != null) {
savingsAccount = (SavingsAccount) entity; savingsAccount = (SavingsAccount) entity;
buildNotification( buildNotification(
@@ -345,9 +345,9 @@ public class NotificationDomainServiceImpl implements NotificationDomainService
private class LoanCreatedListener extends NotificationBusinessEventAdapter { private class LoanCreatedListener extends NotificationBusinessEventAdapter {
@Override @Override
public void businessEventWasExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Loan loan; Loan loan;
Object entity = businessEventEntity.get(BUSINESS_ENTITY.LOAN); Object entity = businessEventEntity.get(BusinessEntity.LOAN);
if (entity != null) { if (entity != null) {
loan = (Loan) entity; loan = (Loan) entity;
buildNotification( buildNotification(
@@ -367,9 +367,9 @@ public class NotificationDomainServiceImpl implements NotificationDomainService
private class LoanApprovedListener extends NotificationBusinessEventAdapter { private class LoanApprovedListener extends NotificationBusinessEventAdapter {
@Override @Override
public void businessEventWasExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Loan loan; Loan loan;
Object entity = businessEventEntity.get(BUSINESS_ENTITY.LOAN); Object entity = businessEventEntity.get(BusinessEntity.LOAN);
if (entity != null) { if (entity != null) {
loan = (Loan) entity; loan = (Loan) entity;
buildNotification( buildNotification(
@@ -388,10 +388,10 @@ public class NotificationDomainServiceImpl implements NotificationDomainService
private class LoanClosedListener extends NotificationBusinessEventAdapter { private class LoanClosedListener extends NotificationBusinessEventAdapter {
@Override @Override
public void businessEventWasExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Loan loan; Loan loan;
Object entity = businessEventEntity.get(BUSINESS_ENTITY.LOAN); Object entity = businessEventEntity.get(BusinessEntity.LOAN);
if (entity != null) { if (entity != null) {
loan = (Loan) entity; loan = (Loan) entity;
buildNotification( buildNotification(
@@ -410,9 +410,9 @@ public class NotificationDomainServiceImpl implements NotificationDomainService
private class LoanCloseAsRescheduledListener extends NotificationBusinessEventAdapter { private class LoanCloseAsRescheduledListener extends NotificationBusinessEventAdapter {
@Override @Override
public void businessEventWasExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Loan loan; Loan loan;
Object entity = businessEventEntity.get(BUSINESS_ENTITY.LOAN); Object entity = businessEventEntity.get(BusinessEntity.LOAN);
if (entity != null) { if (entity != null) {
loan = (Loan) entity; loan = (Loan) entity;
buildNotification( buildNotification(
@@ -431,9 +431,9 @@ public class NotificationDomainServiceImpl implements NotificationDomainService
private class LoanMakeRepaymentListener extends NotificationBusinessEventAdapter { private class LoanMakeRepaymentListener extends NotificationBusinessEventAdapter {
@Override @Override
public void businessEventWasExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Loan loan; Loan loan;
Object entity = businessEventEntity.get(BUSINESS_ENTITY.LOAN); Object entity = businessEventEntity.get(BusinessEntity.LOAN);
if (entity != null) { if (entity != null) {
loan = (Loan) entity; loan = (Loan) entity;
buildNotification( buildNotification(
@@ -452,10 +452,10 @@ public class NotificationDomainServiceImpl implements NotificationDomainService
private class LoanProductCreatedListener extends NotificationBusinessEventAdapter { private class LoanProductCreatedListener extends NotificationBusinessEventAdapter {
@Override @Override
public void businessEventWasExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
LoanProduct loanProduct; LoanProduct loanProduct;
Object entity = businessEventEntity.get(BUSINESS_ENTITY.LOAN_PRODUCT); Object entity = businessEventEntity.get(BusinessEntity.LOAN_PRODUCT);
if (entity != null) { if (entity != null) {
loanProduct = (LoanProduct) entity; loanProduct = (LoanProduct) entity;
buildNotification( buildNotification(
@@ -474,9 +474,9 @@ public class NotificationDomainServiceImpl implements NotificationDomainService
private class SavingsAccountCreatedListener extends NotificationBusinessEventAdapter { private class SavingsAccountCreatedListener extends NotificationBusinessEventAdapter {
@Override @Override
public void businessEventWasExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
SavingsAccount savingsAccount; SavingsAccount savingsAccount;
Object entity = businessEventEntity.get(BUSINESS_ENTITY.SAVING); Object entity = businessEventEntity.get(BusinessEntity.SAVING);
if (entity != null) { if (entity != null) {
savingsAccount = (SavingsAccount) entity; savingsAccount = (SavingsAccount) entity;
buildNotification( buildNotification(
@@ -495,9 +495,9 @@ public class NotificationDomainServiceImpl implements NotificationDomainService
private class SavingsAccountClosedListener extends NotificationBusinessEventAdapter { private class SavingsAccountClosedListener extends NotificationBusinessEventAdapter {
@Override @Override
public void businessEventWasExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
SavingsAccount savingsAccount; SavingsAccount savingsAccount;
Object entity = businessEventEntity.get(BUSINESS_ENTITY.SAVING); Object entity = businessEventEntity.get(BusinessEntity.SAVING);
if (entity != null) { if (entity != null) {
savingsAccount = (SavingsAccount) entity; savingsAccount = (SavingsAccount) entity;
buildNotification( buildNotification(
@@ -516,9 +516,9 @@ public class NotificationDomainServiceImpl implements NotificationDomainService
private class ShareAccountCreatedListener extends NotificationBusinessEventAdapter { private class ShareAccountCreatedListener extends NotificationBusinessEventAdapter {
@Override @Override
public void businessEventWasExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
ShareAccount shareAccount; ShareAccount shareAccount;
Object entity = businessEventEntity.get(BUSINESS_ENTITY.SHARE_ACCOUNT); Object entity = businessEventEntity.get(BusinessEntity.SHARE_ACCOUNT);
if (entity != null) { if (entity != null) {
shareAccount = (ShareAccount) entity; shareAccount = (ShareAccount) entity;
buildNotification( buildNotification(
@@ -537,9 +537,9 @@ public class NotificationDomainServiceImpl implements NotificationDomainService
private class ShareAccountApprovedListener extends NotificationBusinessEventAdapter { private class ShareAccountApprovedListener extends NotificationBusinessEventAdapter {
@Override @Override
public void businessEventWasExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
ShareAccount shareAccount; ShareAccount shareAccount;
Object entity = businessEventEntity.get(BUSINESS_ENTITY.SHARE_ACCOUNT); Object entity = businessEventEntity.get(BusinessEntity.SHARE_ACCOUNT);
if (entity != null) { if (entity != null) {
shareAccount = (ShareAccount) entity; shareAccount = (ShareAccount) entity;
buildNotification( buildNotification(
@@ -25,7 +25,7 @@ import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourc
*/ */
public class StaffRoleException extends AbstractPlatformResourceNotFoundException { public class StaffRoleException extends AbstractPlatformResourceNotFoundException {
public static enum STAFF_ROLE { public static enum StaffRole {
LOAN_OFFICER, BRANCH_MANAGER,SAVINGS_OFFICER; LOAN_OFFICER, BRANCH_MANAGER,SAVINGS_OFFICER;
@Override @Override
@@ -34,7 +34,7 @@ public class StaffRoleException extends AbstractPlatformResourceNotFoundExceptio
} }
} }
public StaffRoleException(final Long id, final STAFF_ROLE role) { public StaffRoleException(final Long id, final StaffRole role) {
super("error.msg.staff.id.invalid.role", "Staff with identifier " + id + " is not a " + role.toString(), id); super("error.msg.staff.id.invalid.role", "Staff with identifier " + id + " is not a " + role.toString(), id);
} }
} }
@@ -22,7 +22,7 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import javax.persistence.PersistenceException; import javax.persistence.PersistenceException;
import org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.fineract.accounting.common.AccountingConstants.FINANCIAL_ACTIVITY; import org.apache.fineract.accounting.common.AccountingConstants.FinancialActivity;
import org.apache.fineract.accounting.financialactivityaccount.domain.FinancialActivityAccount; import org.apache.fineract.accounting.financialactivityaccount.domain.FinancialActivityAccount;
import org.apache.fineract.accounting.financialactivityaccount.domain.FinancialActivityAccountRepositoryWrapper; import org.apache.fineract.accounting.financialactivityaccount.domain.FinancialActivityAccountRepositoryWrapper;
import org.apache.fineract.accounting.glaccount.domain.GLAccount; import org.apache.fineract.accounting.glaccount.domain.GLAccount;
@@ -411,9 +411,9 @@ public class TellerWritePlatformServiceJpaImpl implements TellerWritePlatformSer
// Pass the journal entries // Pass the journal entries
FinancialActivityAccount mainVaultFinancialActivityAccount = this.financialActivityAccountRepositoryWrapper FinancialActivityAccount mainVaultFinancialActivityAccount = this.financialActivityAccountRepositoryWrapper
.findByFinancialActivityTypeWithNotFoundDetection(FINANCIAL_ACTIVITY.CASH_AT_MAINVAULT.getValue()); .findByFinancialActivityTypeWithNotFoundDetection(FinancialActivity.CASH_AT_MAINVAULT.getValue());
FinancialActivityAccount tellerCashFinancialActivityAccount = this.financialActivityAccountRepositoryWrapper FinancialActivityAccount tellerCashFinancialActivityAccount = this.financialActivityAccountRepositoryWrapper
.findByFinancialActivityTypeWithNotFoundDetection(FINANCIAL_ACTIVITY.CASH_AT_TELLER.getValue()); .findByFinancialActivityTypeWithNotFoundDetection(FinancialActivity.CASH_AT_TELLER.getValue());
GLAccount creditAccount = null; GLAccount creditAccount = null;
GLAccount debitAccount = null; GLAccount debitAccount = null;
if (txnType.equals(CashierTxnType.ALLOCATE)) { if (txnType.equals(CashierTxnType.ALLOCATE)) {
@@ -25,7 +25,7 @@ public class CalendarConstants {
public static final String CALENDAR_RESOURCE_NAME = "calendar"; public static final String CALENDAR_RESOURCE_NAME = "calendar";
public static enum CALENDAR_SUPPORTED_PARAMETERS { public static enum CalendarSupportedParameters {
CALENDAR_ID("id"), ENTITY_TYPE("entityType"), ENTITY_ID("entityId"), TITLE("title"), DESCRIPTION("description"), LOCATION( CALENDAR_ID("id"), ENTITY_TYPE("entityType"), ENTITY_ID("entityId"), TITLE("title"), DESCRIPTION("description"), LOCATION(
"location"), START_DATE("startDate"), END_DATE("endDate"), CREATED_DATE("createdDate"), DURATION("duration"), TYPE_ID( "location"), START_DATE("startDate"), END_DATE("endDate"), CREATED_DATE("createdDate"), DURATION("duration"), TYPE_ID(
"typeId"), REPEATING("repeating"), REMIND_BY_ID("remindById"), FIRST_REMINDER("firstReminder"), SECOND_REMINDER( "typeId"), REPEATING("repeating"), REMIND_BY_ID("remindById"), FIRST_REMINDER("firstReminder"), SECOND_REMINDER(
@@ -36,13 +36,13 @@ public class CalendarConstants {
private final String value; private final String value;
private CALENDAR_SUPPORTED_PARAMETERS(final String value) { private CalendarSupportedParameters(final String value) {
this.value = value; this.value = value;
} }
private static final Set<String> values = new HashSet<>(); private static final Set<String> values = new HashSet<>();
static { static {
for (final CALENDAR_SUPPORTED_PARAMETERS param : CALENDAR_SUPPORTED_PARAMETERS.values()) { for (final CalendarSupportedParameters param : CalendarSupportedParameters.values()) {
values.add(param.value); values.add(param.value);
} }
} }
@@ -42,7 +42,7 @@ import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder;
import org.apache.fineract.infrastructure.core.domain.AbstractAuditableCustom; import org.apache.fineract.infrastructure.core.domain.AbstractAuditableCustom;
import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException; import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException;
import org.apache.fineract.infrastructure.core.service.DateUtils; import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.portfolio.calendar.CalendarConstants.CALENDAR_SUPPORTED_PARAMETERS; import org.apache.fineract.portfolio.calendar.CalendarConstants.CalendarSupportedParameters;
import org.apache.fineract.portfolio.calendar.exception.CalendarDateException; import org.apache.fineract.portfolio.calendar.exception.CalendarDateException;
import org.apache.fineract.portfolio.calendar.exception.CalendarParameterUpdateNotSupportedException; import org.apache.fineract.portfolio.calendar.exception.CalendarParameterUpdateNotSupportedException;
import org.apache.fineract.portfolio.calendar.service.CalendarUtils; import org.apache.fineract.portfolio.calendar.service.CalendarUtils;
@@ -113,7 +113,7 @@ public class Calendar extends AbstractAuditableCustom {
final CalendarType calendarType = CalendarType.fromInt(typeId); final CalendarType calendarType = CalendarType.fromInt(typeId);
if (calendarType.isCollection() && !repeating) { if (calendarType.isCollection() && !repeating) {
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.REPEATING.getValue()) baseDataValidator.reset().parameter(CalendarSupportedParameters.REPEATING.getValue())
.failWithCodeNoParameterAddedToErrorCode("must.repeat.for.collection.calendar"); .failWithCodeNoParameterAddedToErrorCode("must.repeat.for.collection.calendar");
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); } if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
} }
@@ -172,20 +172,20 @@ public class Calendar extends AbstractAuditableCustom {
// final Integer entityTypeId = // final Integer entityTypeId =
// CalendarEntityType.valueOf(command.getSupportedEntityType().toUpperCase()).getValue(); // CalendarEntityType.valueOf(command.getSupportedEntityType().toUpperCase()).getValue();
Date meetingtime=null; Date meetingtime=null;
final String title = command.stringValueOfParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.TITLE.getValue()); final String title = command.stringValueOfParameterNamed(CalendarSupportedParameters.TITLE.getValue());
final String description = command.stringValueOfParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.DESCRIPTION.getValue()); final String description = command.stringValueOfParameterNamed(CalendarSupportedParameters.DESCRIPTION.getValue());
final String location = command.stringValueOfParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.LOCATION.getValue()); final String location = command.stringValueOfParameterNamed(CalendarSupportedParameters.LOCATION.getValue());
final LocalDate startDate = command.localDateValueOfParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.START_DATE.getValue()); final LocalDate startDate = command.localDateValueOfParameterNamed(CalendarSupportedParameters.START_DATE.getValue());
final LocalDate endDate = command.localDateValueOfParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.END_DATE.getValue()); final LocalDate endDate = command.localDateValueOfParameterNamed(CalendarSupportedParameters.END_DATE.getValue());
final Integer duration = command.integerValueSansLocaleOfParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.DURATION.getValue()); final Integer duration = command.integerValueSansLocaleOfParameterNamed(CalendarSupportedParameters.DURATION.getValue());
final Integer typeId = command.integerValueSansLocaleOfParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.TYPE_ID.getValue()); final Integer typeId = command.integerValueSansLocaleOfParameterNamed(CalendarSupportedParameters.TYPE_ID.getValue());
final boolean repeating = command.booleanPrimitiveValueOfParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.REPEATING.getValue()); final boolean repeating = command.booleanPrimitiveValueOfParameterNamed(CalendarSupportedParameters.REPEATING.getValue());
final Integer remindById = command.integerValueSansLocaleOfParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.REMIND_BY_ID.getValue()); final Integer remindById = command.integerValueSansLocaleOfParameterNamed(CalendarSupportedParameters.REMIND_BY_ID.getValue());
final Integer firstReminder = command.integerValueSansLocaleOfParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.FIRST_REMINDER final Integer firstReminder = command.integerValueSansLocaleOfParameterNamed(CalendarSupportedParameters.FIRST_REMINDER
.getValue()); .getValue());
final Integer secondReminder = command.integerValueSansLocaleOfParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.SECOND_REMINDER final Integer secondReminder = command.integerValueSansLocaleOfParameterNamed(CalendarSupportedParameters.SECOND_REMINDER
.getValue()); .getValue());
final LocalDateTime time= command.localTimeValueOfParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.MEETING_TIME.getValue()); final LocalDateTime time= command.localTimeValueOfParameterNamed(CalendarSupportedParameters.MEETING_TIME.getValue());
if(time!=null){ if(time!=null){
meetingtime=time.toDate(); meetingtime=time.toDate();
} }
@@ -213,7 +213,7 @@ public class Calendar extends AbstractAuditableCustom {
getStartDateLocalDate()); getStartDateLocalDate());
} else { } else {
actualChanges.put(CALENDAR_SUPPORTED_PARAMETERS.START_DATE.getValue(), newMeetingStartDate.toString()); actualChanges.put(CalendarSupportedParameters.START_DATE.getValue(), newMeetingStartDate.toString());
this.startDate = newMeetingStartDate.toDate(); this.startDate = newMeetingStartDate.toDate();
/* /*
@@ -251,27 +251,27 @@ public class Calendar extends AbstractAuditableCustom {
final Map<String, Object> actualChanges = new LinkedHashMap<>(9); final Map<String, Object> actualChanges = new LinkedHashMap<>(9);
if (command.isChangeInStringParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.TITLE.getValue(), this.title)) { if (command.isChangeInStringParameterNamed(CalendarSupportedParameters.TITLE.getValue(), this.title)) {
final String newValue = command.stringValueOfParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.TITLE.getValue()); final String newValue = command.stringValueOfParameterNamed(CalendarSupportedParameters.TITLE.getValue());
actualChanges.put(CALENDAR_SUPPORTED_PARAMETERS.TITLE.getValue(), newValue); actualChanges.put(CalendarSupportedParameters.TITLE.getValue(), newValue);
this.title = StringUtils.defaultIfEmpty(newValue, null); this.title = StringUtils.defaultIfEmpty(newValue, null);
} }
if (command.isChangeInStringParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.DESCRIPTION.getValue(), this.description)) { if (command.isChangeInStringParameterNamed(CalendarSupportedParameters.DESCRIPTION.getValue(), this.description)) {
final String newValue = command.stringValueOfParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.DESCRIPTION.getValue()); final String newValue = command.stringValueOfParameterNamed(CalendarSupportedParameters.DESCRIPTION.getValue());
actualChanges.put(CALENDAR_SUPPORTED_PARAMETERS.DESCRIPTION.getValue(), newValue); actualChanges.put(CalendarSupportedParameters.DESCRIPTION.getValue(), newValue);
this.description = StringUtils.defaultIfEmpty(newValue, null); this.description = StringUtils.defaultIfEmpty(newValue, null);
} }
if (command.isChangeInStringParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.LOCATION.getValue(), this.location)) { if (command.isChangeInStringParameterNamed(CalendarSupportedParameters.LOCATION.getValue(), this.location)) {
final String newValue = command.stringValueOfParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.LOCATION.getValue()); final String newValue = command.stringValueOfParameterNamed(CalendarSupportedParameters.LOCATION.getValue());
actualChanges.put(CALENDAR_SUPPORTED_PARAMETERS.LOCATION.getValue(), newValue); actualChanges.put(CalendarSupportedParameters.LOCATION.getValue(), newValue);
this.location = StringUtils.defaultIfEmpty(newValue, null); this.location = StringUtils.defaultIfEmpty(newValue, null);
} }
final String dateFormatAsInput = command.dateFormat(); final String dateFormatAsInput = command.dateFormat();
final String localeAsInput = command.locale(); final String localeAsInput = command.locale();
final String startDateParamName = CALENDAR_SUPPORTED_PARAMETERS.START_DATE.getValue(); final String startDateParamName = CalendarSupportedParameters.START_DATE.getValue();
if (command.isChangeInLocalDateParameterNamed(startDateParamName, getStartDateLocalDate())) { if (command.isChangeInLocalDateParameterNamed(startDateParamName, getStartDateLocalDate())) {
final String valueAsInput = command.stringValueOfParameterNamed(startDateParamName); final String valueAsInput = command.stringValueOfParameterNamed(startDateParamName);
@@ -295,7 +295,7 @@ public class Calendar extends AbstractAuditableCustom {
} }
} }
final String endDateParamName = CALENDAR_SUPPORTED_PARAMETERS.END_DATE.getValue(); final String endDateParamName = CalendarSupportedParameters.END_DATE.getValue();
if (command.isChangeInLocalDateParameterNamed(endDateParamName, getEndDateLocalDate())) { if (command.isChangeInLocalDateParameterNamed(endDateParamName, getEndDateLocalDate())) {
final String valueAsInput = command.stringValueOfParameterNamed(endDateParamName); final String valueAsInput = command.stringValueOfParameterNamed(endDateParamName);
actualChanges.put(endDateParamName, valueAsInput); actualChanges.put(endDateParamName, valueAsInput);
@@ -306,7 +306,7 @@ public class Calendar extends AbstractAuditableCustom {
this.endDate = newValue.toDate(); this.endDate = newValue.toDate();
} }
final String durationParamName = CALENDAR_SUPPORTED_PARAMETERS.DURATION.getValue(); final String durationParamName = CalendarSupportedParameters.DURATION.getValue();
if (command.isChangeInIntegerSansLocaleParameterNamed(durationParamName, this.duration)) { if (command.isChangeInIntegerSansLocaleParameterNamed(durationParamName, this.duration)) {
final Integer newValue = command.integerValueSansLocaleOfParameterNamed(durationParamName); final Integer newValue = command.integerValueSansLocaleOfParameterNamed(durationParamName);
actualChanges.put(durationParamName, newValue); actualChanges.put(durationParamName, newValue);
@@ -316,7 +316,7 @@ public class Calendar extends AbstractAuditableCustom {
// Do not allow to change calendar type // Do not allow to change calendar type
// TODO: AA Instead of throwing an exception, do not allow meeting // TODO: AA Instead of throwing an exception, do not allow meeting
// calendar type to update. // calendar type to update.
final String typeParamName = CALENDAR_SUPPORTED_PARAMETERS.TYPE_ID.getValue(); final String typeParamName = CalendarSupportedParameters.TYPE_ID.getValue();
if (command.isChangeInIntegerSansLocaleParameterNamed(typeParamName, this.typeId)) { if (command.isChangeInIntegerSansLocaleParameterNamed(typeParamName, this.typeId)) {
final Integer newValue = command.integerValueSansLocaleOfParameterNamed(typeParamName); final Integer newValue = command.integerValueSansLocaleOfParameterNamed(typeParamName);
final String defaultUserMessage = "Meeting calendar type update is not supported"; final String defaultUserMessage = "Meeting calendar type update is not supported";
@@ -332,7 +332,7 @@ public class Calendar extends AbstractAuditableCustom {
*/ */
} }
final String repeatingParamName = CALENDAR_SUPPORTED_PARAMETERS.REPEATING.getValue(); final String repeatingParamName = CalendarSupportedParameters.REPEATING.getValue();
if (command.isChangeInBooleanParameterNamed(repeatingParamName, this.repeating)) { if (command.isChangeInBooleanParameterNamed(repeatingParamName, this.repeating)) {
final boolean newValue = command.booleanPrimitiveValueOfParameterNamed(repeatingParamName); final boolean newValue = command.booleanPrimitiveValueOfParameterNamed(repeatingParamName);
actualChanges.put(repeatingParamName, newValue); actualChanges.put(repeatingParamName, newValue);
@@ -347,7 +347,7 @@ public class Calendar extends AbstractAuditableCustom {
final CalendarType calendarType = CalendarType.fromInt(this.typeId); final CalendarType calendarType = CalendarType.fromInt(this.typeId);
if (calendarType.isCollection() && !this.repeating) { if (calendarType.isCollection() && !this.repeating) {
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.REPEATING.getValue()) baseDataValidator.reset().parameter(CalendarSupportedParameters.REPEATING.getValue())
.failWithCodeNoParameterAddedToErrorCode("must.repeat.for.collection.calendar"); .failWithCodeNoParameterAddedToErrorCode("must.repeat.for.collection.calendar");
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); } if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
} }
@@ -378,32 +378,32 @@ public class Calendar extends AbstractAuditableCustom {
this.recurrence = StringUtils.defaultIfEmpty(newRecurrence, null); this.recurrence = StringUtils.defaultIfEmpty(newRecurrence, null);
} }
final String remindByParamName = CALENDAR_SUPPORTED_PARAMETERS.REMIND_BY_ID.getValue(); final String remindByParamName = CalendarSupportedParameters.REMIND_BY_ID.getValue();
if (command.isChangeInIntegerSansLocaleParameterNamed(remindByParamName, this.remindById)) { if (command.isChangeInIntegerSansLocaleParameterNamed(remindByParamName, this.remindById)) {
final Integer newValue = command.integerValueSansLocaleOfParameterNamed(remindByParamName); final Integer newValue = command.integerValueSansLocaleOfParameterNamed(remindByParamName);
actualChanges.put(remindByParamName, newValue); actualChanges.put(remindByParamName, newValue);
this.remindById = newValue; this.remindById = newValue;
} }
final String firstRemindarParamName = CALENDAR_SUPPORTED_PARAMETERS.FIRST_REMINDER.getValue(); final String firstRemindarParamName = CalendarSupportedParameters.FIRST_REMINDER.getValue();
if (command.isChangeInIntegerSansLocaleParameterNamed(firstRemindarParamName, this.firstReminder)) { if (command.isChangeInIntegerSansLocaleParameterNamed(firstRemindarParamName, this.firstReminder)) {
final Integer newValue = command.integerValueSansLocaleOfParameterNamed(firstRemindarParamName); final Integer newValue = command.integerValueSansLocaleOfParameterNamed(firstRemindarParamName);
actualChanges.put(firstRemindarParamName, newValue); actualChanges.put(firstRemindarParamName, newValue);
this.firstReminder = newValue; this.firstReminder = newValue;
} }
final String secondRemindarParamName = CALENDAR_SUPPORTED_PARAMETERS.SECOND_REMINDER.getValue(); final String secondRemindarParamName = CalendarSupportedParameters.SECOND_REMINDER.getValue();
if (command.isChangeInIntegerSansLocaleParameterNamed(secondRemindarParamName, this.secondReminder)) { if (command.isChangeInIntegerSansLocaleParameterNamed(secondRemindarParamName, this.secondReminder)) {
final Integer newValue = command.integerValueSansLocaleOfParameterNamed(secondRemindarParamName); final Integer newValue = command.integerValueSansLocaleOfParameterNamed(secondRemindarParamName);
actualChanges.put(secondRemindarParamName, newValue); actualChanges.put(secondRemindarParamName, newValue);
this.secondReminder = newValue; this.secondReminder = newValue;
} }
final String timeFormat = command.stringValueOfParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.Time_Format.getValue()); final String timeFormat = command.stringValueOfParameterNamed(CalendarSupportedParameters.Time_Format.getValue());
final String time = CALENDAR_SUPPORTED_PARAMETERS.MEETING_TIME.getValue(); final String time = CalendarSupportedParameters.MEETING_TIME.getValue();
if (command.isChangeInTimeParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.MEETING_TIME.getValue(), this.meetingtime,timeFormat)) { if (command.isChangeInTimeParameterNamed(CalendarSupportedParameters.MEETING_TIME.getValue(), this.meetingtime,timeFormat)) {
final String newValue = command.stringValueOfParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.MEETING_TIME.getValue()); final String newValue = command.stringValueOfParameterNamed(CalendarSupportedParameters.MEETING_TIME.getValue());
actualChanges.put(CALENDAR_SUPPORTED_PARAMETERS.MEETING_TIME.getValue(), newValue); actualChanges.put(CalendarSupportedParameters.MEETING_TIME.getValue(), newValue);
LocalDateTime timeInLocalDateTimeFormat=command.localTimeValueOfParameterNamed(time); LocalDateTime timeInLocalDateTimeFormat=command.localTimeValueOfParameterNamed(time);
if(timeInLocalDateTimeFormat!=null){ if(timeInLocalDateTimeFormat!=null){
this.meetingtime= timeInLocalDateTimeFormat.toDate(); this.meetingtime= timeInLocalDateTimeFormat.toDate();
@@ -546,8 +546,8 @@ public class Calendar extends AbstractAuditableCustom {
private static String constructRecurrence(final JsonCommand command, final Calendar calendar) { private static String constructRecurrence(final JsonCommand command, final Calendar calendar) {
final boolean repeating; final boolean repeating;
if (command.parameterExists(CALENDAR_SUPPORTED_PARAMETERS.REPEATING.getValue())) { if (command.parameterExists(CalendarSupportedParameters.REPEATING.getValue())) {
repeating = command.booleanPrimitiveValueOfParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.REPEATING.getValue()); repeating = command.booleanPrimitiveValueOfParameterNamed(CalendarSupportedParameters.REPEATING.getValue());
} else if (calendar != null) { } else if (calendar != null) {
repeating = calendar.isRepeating(); repeating = calendar.isRepeating();
} else { } else {
@@ -555,22 +555,22 @@ public class Calendar extends AbstractAuditableCustom {
} }
if (repeating) { if (repeating) {
final Integer frequency = command.integerValueOfParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.FREQUENCY.getValue()); final Integer frequency = command.integerValueOfParameterNamed(CalendarSupportedParameters.FREQUENCY.getValue());
final CalendarFrequencyType frequencyType = CalendarFrequencyType.fromInt(frequency); final CalendarFrequencyType frequencyType = CalendarFrequencyType.fromInt(frequency);
final Integer interval = command.integerValueOfParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.INTERVAL.getValue()); final Integer interval = command.integerValueOfParameterNamed(CalendarSupportedParameters.INTERVAL.getValue());
Integer repeatsOnDay = null; Integer repeatsOnDay = null;
if (frequencyType.isWeekly()) { if (frequencyType.isWeekly()) {
repeatsOnDay = command.integerValueOfParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.REPEATS_ON_DAY.getValue()); repeatsOnDay = command.integerValueOfParameterNamed(CalendarSupportedParameters.REPEATS_ON_DAY.getValue());
} }
Integer repeatsOnNthDayOfMonth = null; Integer repeatsOnNthDayOfMonth = null;
if (frequencyType.isMonthly()) { if (frequencyType.isMonthly()) {
repeatsOnNthDayOfMonth = command.integerValueOfParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.REPEATS_ON_NTH_DAY_OF_MONTH repeatsOnNthDayOfMonth = command.integerValueOfParameterNamed(CalendarSupportedParameters.REPEATS_ON_NTH_DAY_OF_MONTH
.getValue()); .getValue());
final NthDayType nthDay = NthDayType.fromInt(repeatsOnNthDayOfMonth); final NthDayType nthDay = NthDayType.fromInt(repeatsOnNthDayOfMonth);
repeatsOnDay = command.integerValueOfParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.REPEATS_ON_LAST_WEEKDAY_OF_MONTH repeatsOnDay = command.integerValueOfParameterNamed(CalendarSupportedParameters.REPEATS_ON_LAST_WEEKDAY_OF_MONTH
.getValue()); .getValue());
if (nthDay.isOnDay()) { if (nthDay.isOnDay()) {
repeatsOnNthDayOfMonth = command.integerValueOfParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.REPEATS_ON_DAY_OF_MONTH repeatsOnNthDayOfMonth = command.integerValueOfParameterNamed(CalendarSupportedParameters.REPEATS_ON_DAY_OF_MONTH
.getValue()); .getValue());
repeatsOnDay = null; repeatsOnDay = null;
} }
@@ -32,7 +32,7 @@ import org.apache.fineract.infrastructure.core.exception.InvalidJsonException;
import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException; import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException;
import org.apache.fineract.infrastructure.core.serialization.AbstractFromApiJsonDeserializer; import org.apache.fineract.infrastructure.core.serialization.AbstractFromApiJsonDeserializer;
import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper; import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
import org.apache.fineract.portfolio.calendar.CalendarConstants.CALENDAR_SUPPORTED_PARAMETERS; import org.apache.fineract.portfolio.calendar.CalendarConstants.CalendarSupportedParameters;
import org.apache.fineract.portfolio.calendar.command.CalendarCommand; import org.apache.fineract.portfolio.calendar.command.CalendarCommand;
import org.apache.fineract.portfolio.calendar.domain.CalendarEntityType; import org.apache.fineract.portfolio.calendar.domain.CalendarEntityType;
import org.apache.fineract.portfolio.calendar.domain.CalendarFrequencyType; import org.apache.fineract.portfolio.calendar.domain.CalendarFrequencyType;
@@ -50,7 +50,7 @@ public class CalendarCommandFromApiJsonDeserializer extends AbstractFromApiJsonD
/** /**
* The parameters supported for this command. * The parameters supported for this command.
*/ */
private final Set<String> supportedParameters = CALENDAR_SUPPORTED_PARAMETERS.getAllValues(); private final Set<String> supportedParameters = CalendarSupportedParameters.getAllValues();
private final FromJsonHelper fromApiJsonHelper; private final FromJsonHelper fromApiJsonHelper;
@@ -67,25 +67,25 @@ public class CalendarCommandFromApiJsonDeserializer extends AbstractFromApiJsonD
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, this.supportedParameters); this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, this.supportedParameters);
final JsonElement element = this.fromApiJsonHelper.parse(json); final JsonElement element = this.fromApiJsonHelper.parse(json);
final String title = this.fromApiJsonHelper.extractStringNamed(CALENDAR_SUPPORTED_PARAMETERS.TITLE.getValue(), element); final String title = this.fromApiJsonHelper.extractStringNamed(CalendarSupportedParameters.TITLE.getValue(), element);
final String description = this.fromApiJsonHelper.extractStringNamed(CALENDAR_SUPPORTED_PARAMETERS.DESCRIPTION.getValue(), element); final String description = this.fromApiJsonHelper.extractStringNamed(CalendarSupportedParameters.DESCRIPTION.getValue(), element);
final String location = this.fromApiJsonHelper.extractStringNamed(CALENDAR_SUPPORTED_PARAMETERS.LOCATION.getValue(), element); final String location = this.fromApiJsonHelper.extractStringNamed(CalendarSupportedParameters.LOCATION.getValue(), element);
final LocalDate startDate = this.fromApiJsonHelper.extractLocalDateNamed(CALENDAR_SUPPORTED_PARAMETERS.START_DATE.getValue(), final LocalDate startDate = this.fromApiJsonHelper.extractLocalDateNamed(CalendarSupportedParameters.START_DATE.getValue(),
element); element);
final LocalDate endDate = this.fromApiJsonHelper.extractLocalDateNamed(CALENDAR_SUPPORTED_PARAMETERS.END_DATE.getValue(), element); final LocalDate endDate = this.fromApiJsonHelper.extractLocalDateNamed(CalendarSupportedParameters.END_DATE.getValue(), element);
final LocalDate createdDate = this.fromApiJsonHelper.extractLocalDateNamed(CALENDAR_SUPPORTED_PARAMETERS.CREATED_DATE.getValue(), final LocalDate createdDate = this.fromApiJsonHelper.extractLocalDateNamed(CalendarSupportedParameters.CREATED_DATE.getValue(),
element); element);
final Integer duration = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(CALENDAR_SUPPORTED_PARAMETERS.DURATION.getValue(), final Integer duration = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(CalendarSupportedParameters.DURATION.getValue(),
element); element);
final Integer typeId = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(CALENDAR_SUPPORTED_PARAMETERS.TYPE_ID.getValue(), final Integer typeId = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(CalendarSupportedParameters.TYPE_ID.getValue(),
element); element);
final boolean repeating = this.fromApiJsonHelper.extractBooleanNamed(CALENDAR_SUPPORTED_PARAMETERS.REPEATING.getValue(), element); final boolean repeating = this.fromApiJsonHelper.extractBooleanNamed(CalendarSupportedParameters.REPEATING.getValue(), element);
final Integer remindById = this.fromApiJsonHelper.extractIntegerSansLocaleNamed( final Integer remindById = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(
CALENDAR_SUPPORTED_PARAMETERS.REMIND_BY_ID.getValue(), element); CalendarSupportedParameters.REMIND_BY_ID.getValue(), element);
final Integer firstReminder = this.fromApiJsonHelper.extractIntegerSansLocaleNamed( final Integer firstReminder = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(
CALENDAR_SUPPORTED_PARAMETERS.FIRST_REMINDER.getValue(), element); CalendarSupportedParameters.FIRST_REMINDER.getValue(), element);
final Integer secondReminder = this.fromApiJsonHelper.extractIntegerSansLocaleNamed( final Integer secondReminder = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(
CALENDAR_SUPPORTED_PARAMETERS.SECOND_REMINDER.getValue(), element); CalendarSupportedParameters.SECOND_REMINDER.getValue(), element);
return new CalendarCommand(title, description, location, startDate, endDate, createdDate, duration, typeId, repeating, remindById, return new CalendarCommand(title, description, location, startDate, endDate, createdDate, duration, typeId, repeating, remindById,
firstReminder, secondReminder); firstReminder, secondReminder);
@@ -103,107 +103,107 @@ public class CalendarCommandFromApiJsonDeserializer extends AbstractFromApiJsonD
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("calendar"); final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("calendar");
final String title = this.fromApiJsonHelper.extractStringNamed(CALENDAR_SUPPORTED_PARAMETERS.TITLE.getValue(), element); final String title = this.fromApiJsonHelper.extractStringNamed(CalendarSupportedParameters.TITLE.getValue(), element);
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.TITLE.getValue()).value(title).notBlank() baseDataValidator.reset().parameter(CalendarSupportedParameters.TITLE.getValue()).value(title).notBlank()
.notExceedingLengthOf(50); .notExceedingLengthOf(50);
if (this.fromApiJsonHelper.parameterExists(CALENDAR_SUPPORTED_PARAMETERS.DESCRIPTION.getValue(), element)) { if (this.fromApiJsonHelper.parameterExists(CalendarSupportedParameters.DESCRIPTION.getValue(), element)) {
final String description = this.fromApiJsonHelper.extractStringNamed(CALENDAR_SUPPORTED_PARAMETERS.DESCRIPTION.getValue(), final String description = this.fromApiJsonHelper.extractStringNamed(CalendarSupportedParameters.DESCRIPTION.getValue(),
element); element);
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.DESCRIPTION.getValue()).value(description).ignoreIfNull() baseDataValidator.reset().parameter(CalendarSupportedParameters.DESCRIPTION.getValue()).value(description).ignoreIfNull()
.notExceedingLengthOf(100); .notExceedingLengthOf(100);
} }
if (this.fromApiJsonHelper.parameterExists(CALENDAR_SUPPORTED_PARAMETERS.LOCATION.getValue(), element)) { if (this.fromApiJsonHelper.parameterExists(CalendarSupportedParameters.LOCATION.getValue(), element)) {
final String location = this.fromApiJsonHelper.extractStringNamed(CALENDAR_SUPPORTED_PARAMETERS.LOCATION.getValue(), element); final String location = this.fromApiJsonHelper.extractStringNamed(CalendarSupportedParameters.LOCATION.getValue(), element);
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.LOCATION.getValue()).value(location).ignoreIfNull() baseDataValidator.reset().parameter(CalendarSupportedParameters.LOCATION.getValue()).value(location).ignoreIfNull()
.notExceedingLengthOf(50); .notExceedingLengthOf(50);
} }
final String startDateStr = this.fromApiJsonHelper.extractStringNamed(CALENDAR_SUPPORTED_PARAMETERS.START_DATE.getValue(), element); final String startDateStr = this.fromApiJsonHelper.extractStringNamed(CalendarSupportedParameters.START_DATE.getValue(), element);
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.START_DATE.getValue()).value(startDateStr).notBlank(); baseDataValidator.reset().parameter(CalendarSupportedParameters.START_DATE.getValue()).value(startDateStr).notBlank();
if (!StringUtils.isBlank(startDateStr)) { if (!StringUtils.isBlank(startDateStr)) {
final LocalDate startDate = this.fromApiJsonHelper.extractLocalDateNamed(CALENDAR_SUPPORTED_PARAMETERS.START_DATE.getValue(), final LocalDate startDate = this.fromApiJsonHelper.extractLocalDateNamed(CalendarSupportedParameters.START_DATE.getValue(),
element); element);
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.START_DATE.getValue()).value(startDate).notNull(); baseDataValidator.reset().parameter(CalendarSupportedParameters.START_DATE.getValue()).value(startDate).notNull();
} }
if (this.fromApiJsonHelper.parameterExists(CALENDAR_SUPPORTED_PARAMETERS.END_DATE.getValue(), element)) { if (this.fromApiJsonHelper.parameterExists(CalendarSupportedParameters.END_DATE.getValue(), element)) {
final String endDateStr = this.fromApiJsonHelper.extractStringNamed(CALENDAR_SUPPORTED_PARAMETERS.END_DATE.getValue(), element); final String endDateStr = this.fromApiJsonHelper.extractStringNamed(CalendarSupportedParameters.END_DATE.getValue(), element);
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.END_DATE.getValue()).value(endDateStr).notBlank(); baseDataValidator.reset().parameter(CalendarSupportedParameters.END_DATE.getValue()).value(endDateStr).notBlank();
final LocalDate endDate = this.fromApiJsonHelper.extractLocalDateNamed(CALENDAR_SUPPORTED_PARAMETERS.END_DATE.getValue(), final LocalDate endDate = this.fromApiJsonHelper.extractLocalDateNamed(CalendarSupportedParameters.END_DATE.getValue(),
element); element);
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.END_DATE.getValue()).value(endDate).notNull(); baseDataValidator.reset().parameter(CalendarSupportedParameters.END_DATE.getValue()).value(endDate).notNull();
} }
if (this.fromApiJsonHelper.parameterExists(CALENDAR_SUPPORTED_PARAMETERS.DURATION.getValue(), element)) { if (this.fromApiJsonHelper.parameterExists(CalendarSupportedParameters.DURATION.getValue(), element)) {
final Integer duration = this.fromApiJsonHelper.extractIntegerSansLocaleNamed( final Integer duration = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(
CALENDAR_SUPPORTED_PARAMETERS.DURATION.getValue(), element); CalendarSupportedParameters.DURATION.getValue(), element);
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.DURATION.getValue()).value(duration).ignoreIfNull(); baseDataValidator.reset().parameter(CalendarSupportedParameters.DURATION.getValue()).value(duration).ignoreIfNull();
} }
final Integer typeId = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(CALENDAR_SUPPORTED_PARAMETERS.TYPE_ID.getValue(), final Integer typeId = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(CalendarSupportedParameters.TYPE_ID.getValue(),
element); element);
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.TYPE_ID.getValue()).value(typeId).notNull() baseDataValidator.reset().parameter(CalendarSupportedParameters.TYPE_ID.getValue()).value(typeId).notNull()
.inMinMaxRange(CalendarEntityType.getMinValue(), CalendarEntityType.getMaxValue()); .inMinMaxRange(CalendarEntityType.getMinValue(), CalendarEntityType.getMaxValue());
if (this.fromApiJsonHelper.parameterExists(CALENDAR_SUPPORTED_PARAMETERS.REPEATING.getValue(), element)) { if (this.fromApiJsonHelper.parameterExists(CalendarSupportedParameters.REPEATING.getValue(), element)) {
// FIXME - Throws NullPointerException when boolean value is null // FIXME - Throws NullPointerException when boolean value is null
final boolean repeating = this.fromApiJsonHelper.extractBooleanNamed(CALENDAR_SUPPORTED_PARAMETERS.REPEATING.getValue(), final boolean repeating = this.fromApiJsonHelper.extractBooleanNamed(CalendarSupportedParameters.REPEATING.getValue(),
element); element);
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.REPEATING.getValue()).value(repeating).notNull(); baseDataValidator.reset().parameter(CalendarSupportedParameters.REPEATING.getValue()).value(repeating).notNull();
if (repeating) { if (repeating) {
final Integer frequency = this.fromApiJsonHelper.extractIntegerSansLocaleNamed( final Integer frequency = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(
CALENDAR_SUPPORTED_PARAMETERS.FREQUENCY.getValue(), element); CalendarSupportedParameters.FREQUENCY.getValue(), element);
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.FREQUENCY.getValue()).value(frequency).notBlank() baseDataValidator.reset().parameter(CalendarSupportedParameters.FREQUENCY.getValue()).value(frequency).notBlank()
.inMinMaxRange(CalendarFrequencyType.getMinValue(), CalendarFrequencyType.getMaxValue()); .inMinMaxRange(CalendarFrequencyType.getMinValue(), CalendarFrequencyType.getMaxValue());
if (this.fromApiJsonHelper.parameterExists(CALENDAR_SUPPORTED_PARAMETERS.INTERVAL.getValue(), element)) { if (this.fromApiJsonHelper.parameterExists(CalendarSupportedParameters.INTERVAL.getValue(), element)) {
final Integer interval = this.fromApiJsonHelper.extractIntegerSansLocaleNamed( final Integer interval = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(
CALENDAR_SUPPORTED_PARAMETERS.INTERVAL.getValue(), element); CalendarSupportedParameters.INTERVAL.getValue(), element);
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.INTERVAL.getValue()).value(interval).notNull() baseDataValidator.reset().parameter(CalendarSupportedParameters.INTERVAL.getValue()).value(interval).notNull()
.integerGreaterThanZero(); .integerGreaterThanZero();
} }
if (CalendarFrequencyType.fromInt(frequency).isWeekly()) { if (CalendarFrequencyType.fromInt(frequency).isWeekly()) {
final Integer repeatsOnDay = this.fromApiJsonHelper.extractIntegerSansLocaleNamed( final Integer repeatsOnDay = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(
CALENDAR_SUPPORTED_PARAMETERS.REPEATS_ON_DAY.getValue(), element); CalendarSupportedParameters.REPEATS_ON_DAY.getValue(), element);
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.REPEATS_ON_DAY.getValue()).value(repeatsOnDay) baseDataValidator.reset().parameter(CalendarSupportedParameters.REPEATS_ON_DAY.getValue()).value(repeatsOnDay)
.notBlank().inMinMaxRange(CalendarWeekDaysType.getMinValue(), CalendarWeekDaysType.getMaxValue()); .notBlank().inMinMaxRange(CalendarWeekDaysType.getMinValue(), CalendarWeekDaysType.getMaxValue());
} else if (CalendarFrequencyType.fromInt(frequency).isMonthly()) { } else if (CalendarFrequencyType.fromInt(frequency).isMonthly()) {
CalendarUtils.validateNthDayOfMonthFrequency(baseDataValidator, CalendarUtils.validateNthDayOfMonthFrequency(baseDataValidator,
CALENDAR_SUPPORTED_PARAMETERS.REPEATS_ON_NTH_DAY_OF_MONTH.getValue(), CalendarSupportedParameters.REPEATS_ON_NTH_DAY_OF_MONTH.getValue(),
CALENDAR_SUPPORTED_PARAMETERS.REPEATS_ON_LAST_WEEKDAY_OF_MONTH.getValue(), element, this.fromApiJsonHelper); CalendarSupportedParameters.REPEATS_ON_LAST_WEEKDAY_OF_MONTH.getValue(), element, this.fromApiJsonHelper);
} }
} }
} }
if (this.fromApiJsonHelper.parameterExists(CALENDAR_SUPPORTED_PARAMETERS.REMIND_BY_ID.getValue(), element)) { if (this.fromApiJsonHelper.parameterExists(CalendarSupportedParameters.REMIND_BY_ID.getValue(), element)) {
final Integer remindById = this.fromApiJsonHelper.extractIntegerSansLocaleNamed( final Integer remindById = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(
CALENDAR_SUPPORTED_PARAMETERS.REMIND_BY_ID.getValue(), element); CalendarSupportedParameters.REMIND_BY_ID.getValue(), element);
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.REMIND_BY_ID.getValue()).value(remindById).ignoreIfNull() baseDataValidator.reset().parameter(CalendarSupportedParameters.REMIND_BY_ID.getValue()).value(remindById).ignoreIfNull()
.inMinMaxRange(CalendarRemindBy.getMinValue(), CalendarRemindBy.getMaxValue()); .inMinMaxRange(CalendarRemindBy.getMinValue(), CalendarRemindBy.getMaxValue());
} }
if (this.fromApiJsonHelper.parameterExists(CALENDAR_SUPPORTED_PARAMETERS.FIRST_REMINDER.getValue(), element)) { if (this.fromApiJsonHelper.parameterExists(CalendarSupportedParameters.FIRST_REMINDER.getValue(), element)) {
final Integer firstReminder = this.fromApiJsonHelper.extractIntegerSansLocaleNamed( final Integer firstReminder = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(
CALENDAR_SUPPORTED_PARAMETERS.FIRST_REMINDER.getValue(), element); CalendarSupportedParameters.FIRST_REMINDER.getValue(), element);
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.FIRST_REMINDER.getValue()).value(firstReminder) baseDataValidator.reset().parameter(CalendarSupportedParameters.FIRST_REMINDER.getValue()).value(firstReminder)
.ignoreIfNull().integerGreaterThanZero(); .ignoreIfNull().integerGreaterThanZero();
} }
if (this.fromApiJsonHelper.parameterExists(CALENDAR_SUPPORTED_PARAMETERS.SECOND_REMINDER.getValue(), element)) { if (this.fromApiJsonHelper.parameterExists(CalendarSupportedParameters.SECOND_REMINDER.getValue(), element)) {
final Integer secondReminder = this.fromApiJsonHelper.extractIntegerSansLocaleNamed( final Integer secondReminder = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(
CALENDAR_SUPPORTED_PARAMETERS.SECOND_REMINDER.getValue(), element); CalendarSupportedParameters.SECOND_REMINDER.getValue(), element);
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.SECOND_REMINDER.getValue()).value(secondReminder) baseDataValidator.reset().parameter(CalendarSupportedParameters.SECOND_REMINDER.getValue()).value(secondReminder)
.ignoreIfNull().integerGreaterThanZero(); .ignoreIfNull().integerGreaterThanZero();
} }
if (this.fromApiJsonHelper.parameterExists(CALENDAR_SUPPORTED_PARAMETERS.MEETING_TIME.getValue(), element)) { if (this.fromApiJsonHelper.parameterExists(CalendarSupportedParameters.MEETING_TIME.getValue(), element)) {
final LocalDateTime meetingTime = this.fromApiJsonHelper.extractLocalTimeNamed(CALENDAR_SUPPORTED_PARAMETERS.MEETING_TIME.getValue(), final LocalDateTime meetingTime = this.fromApiJsonHelper.extractLocalTimeNamed(CalendarSupportedParameters.MEETING_TIME.getValue(),
element); element);
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.MEETING_TIME.getValue()).value(meetingTime).ignoreIfNull(); baseDataValidator.reset().parameter(CalendarSupportedParameters.MEETING_TIME.getValue()).value(meetingTime).ignoreIfNull();
} }
@@ -223,130 +223,130 @@ public class CalendarCommandFromApiJsonDeserializer extends AbstractFromApiJsonD
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("calendar"); final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("calendar");
if (this.fromApiJsonHelper.parameterExists(CALENDAR_SUPPORTED_PARAMETERS.RESCHEDULE_BASED_ON_MEETING_DATES.getValue(), element)) { if (this.fromApiJsonHelper.parameterExists(CalendarSupportedParameters.RESCHEDULE_BASED_ON_MEETING_DATES.getValue(), element)) {
final Boolean rescheduleBasedOnMeetingDates = this.fromApiJsonHelper.extractBooleanNamed( final Boolean rescheduleBasedOnMeetingDates = this.fromApiJsonHelper.extractBooleanNamed(
CALENDAR_SUPPORTED_PARAMETERS.RESCHEDULE_BASED_ON_MEETING_DATES.getValue(), element); CalendarSupportedParameters.RESCHEDULE_BASED_ON_MEETING_DATES.getValue(), element);
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.RESCHEDULE_BASED_ON_MEETING_DATES.getValue()) baseDataValidator.reset().parameter(CalendarSupportedParameters.RESCHEDULE_BASED_ON_MEETING_DATES.getValue())
.value(rescheduleBasedOnMeetingDates).validateForBooleanValue(); .value(rescheduleBasedOnMeetingDates).validateForBooleanValue();
} }
if (this.fromApiJsonHelper.parameterExists(CALENDAR_SUPPORTED_PARAMETERS.PRESENT_MEETING_DATE.getValue(), element)) { if (this.fromApiJsonHelper.parameterExists(CalendarSupportedParameters.PRESENT_MEETING_DATE.getValue(), element)) {
final String presentMeetingDate = this.fromApiJsonHelper.extractStringNamed( final String presentMeetingDate = this.fromApiJsonHelper.extractStringNamed(
CALENDAR_SUPPORTED_PARAMETERS.PRESENT_MEETING_DATE.getValue(), element); CalendarSupportedParameters.PRESENT_MEETING_DATE.getValue(), element);
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.PRESENT_MEETING_DATE.getValue()).value(presentMeetingDate) baseDataValidator.reset().parameter(CalendarSupportedParameters.PRESENT_MEETING_DATE.getValue()).value(presentMeetingDate)
.notNull(); .notNull();
} }
if (this.fromApiJsonHelper.parameterExists(CALENDAR_SUPPORTED_PARAMETERS.NEW_MEETING_DATE.getValue(), element)) { if (this.fromApiJsonHelper.parameterExists(CalendarSupportedParameters.NEW_MEETING_DATE.getValue(), element)) {
final String newMeetingDate = this.fromApiJsonHelper.extractStringNamed( final String newMeetingDate = this.fromApiJsonHelper.extractStringNamed(
CALENDAR_SUPPORTED_PARAMETERS.NEW_MEETING_DATE.getValue(), element); CalendarSupportedParameters.NEW_MEETING_DATE.getValue(), element);
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.NEW_MEETING_DATE.getValue()).value(newMeetingDate).notNull(); baseDataValidator.reset().parameter(CalendarSupportedParameters.NEW_MEETING_DATE.getValue()).value(newMeetingDate).notNull();
} }
if (this.fromApiJsonHelper.parameterExists(CALENDAR_SUPPORTED_PARAMETERS.TITLE.getValue(), element)) { if (this.fromApiJsonHelper.parameterExists(CalendarSupportedParameters.TITLE.getValue(), element)) {
final String title = this.fromApiJsonHelper.extractStringNamed(CALENDAR_SUPPORTED_PARAMETERS.TITLE.getValue(), element); final String title = this.fromApiJsonHelper.extractStringNamed(CalendarSupportedParameters.TITLE.getValue(), element);
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.TITLE.getValue()).value(title).notBlank() baseDataValidator.reset().parameter(CalendarSupportedParameters.TITLE.getValue()).value(title).notBlank()
.notExceedingLengthOf(50); .notExceedingLengthOf(50);
} }
if (this.fromApiJsonHelper.parameterExists(CALENDAR_SUPPORTED_PARAMETERS.DESCRIPTION.getValue(), element)) { if (this.fromApiJsonHelper.parameterExists(CalendarSupportedParameters.DESCRIPTION.getValue(), element)) {
final String description = this.fromApiJsonHelper.extractStringNamed(CALENDAR_SUPPORTED_PARAMETERS.DESCRIPTION.getValue(), final String description = this.fromApiJsonHelper.extractStringNamed(CalendarSupportedParameters.DESCRIPTION.getValue(),
element); element);
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.DESCRIPTION.getValue()).value(description).ignoreIfNull() baseDataValidator.reset().parameter(CalendarSupportedParameters.DESCRIPTION.getValue()).value(description).ignoreIfNull()
.notExceedingLengthOf(100); .notExceedingLengthOf(100);
} }
if (this.fromApiJsonHelper.parameterExists(CALENDAR_SUPPORTED_PARAMETERS.LOCATION.getValue(), element)) { if (this.fromApiJsonHelper.parameterExists(CalendarSupportedParameters.LOCATION.getValue(), element)) {
final String location = this.fromApiJsonHelper.extractStringNamed(CALENDAR_SUPPORTED_PARAMETERS.LOCATION.getValue(), element); final String location = this.fromApiJsonHelper.extractStringNamed(CalendarSupportedParameters.LOCATION.getValue(), element);
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.LOCATION.getValue()).value(location).ignoreIfNull() baseDataValidator.reset().parameter(CalendarSupportedParameters.LOCATION.getValue()).value(location).ignoreIfNull()
.notExceedingLengthOf(50); .notExceedingLengthOf(50);
} }
if (this.fromApiJsonHelper.parameterExists(CALENDAR_SUPPORTED_PARAMETERS.START_DATE.getValue(), element)) { if (this.fromApiJsonHelper.parameterExists(CalendarSupportedParameters.START_DATE.getValue(), element)) {
final String startDateStr = this.fromApiJsonHelper.extractStringNamed(CALENDAR_SUPPORTED_PARAMETERS.START_DATE.getValue(), final String startDateStr = this.fromApiJsonHelper.extractStringNamed(CalendarSupportedParameters.START_DATE.getValue(),
element); element);
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.START_DATE.getValue()).value(startDateStr).notNull(); baseDataValidator.reset().parameter(CalendarSupportedParameters.START_DATE.getValue()).value(startDateStr).notNull();
final LocalDate startDate = this.fromApiJsonHelper.extractLocalDateNamed(CALENDAR_SUPPORTED_PARAMETERS.START_DATE.getValue(), final LocalDate startDate = this.fromApiJsonHelper.extractLocalDateNamed(CalendarSupportedParameters.START_DATE.getValue(),
element); element);
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.START_DATE.getValue()).value(startDate).notNull(); baseDataValidator.reset().parameter(CalendarSupportedParameters.START_DATE.getValue()).value(startDate).notNull();
} }
if (this.fromApiJsonHelper.parameterExists(CALENDAR_SUPPORTED_PARAMETERS.END_DATE.getValue(), element)) { if (this.fromApiJsonHelper.parameterExists(CalendarSupportedParameters.END_DATE.getValue(), element)) {
final LocalDate endDate = this.fromApiJsonHelper.extractLocalDateNamed(CALENDAR_SUPPORTED_PARAMETERS.END_DATE.getValue(), final LocalDate endDate = this.fromApiJsonHelper.extractLocalDateNamed(CalendarSupportedParameters.END_DATE.getValue(),
element); element);
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.END_DATE.getValue()).value(endDate).notNull(); baseDataValidator.reset().parameter(CalendarSupportedParameters.END_DATE.getValue()).value(endDate).notNull();
} }
if (this.fromApiJsonHelper.parameterExists(CALENDAR_SUPPORTED_PARAMETERS.DURATION.getValue(), element)) { if (this.fromApiJsonHelper.parameterExists(CalendarSupportedParameters.DURATION.getValue(), element)) {
final Integer duration = this.fromApiJsonHelper.extractIntegerSansLocaleNamed( final Integer duration = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(
CALENDAR_SUPPORTED_PARAMETERS.DURATION.getValue(), element); CalendarSupportedParameters.DURATION.getValue(), element);
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.DURATION.getValue()).value(duration).ignoreIfNull(); baseDataValidator.reset().parameter(CalendarSupportedParameters.DURATION.getValue()).value(duration).ignoreIfNull();
} }
// TODO: AA do not allow to change calendar type. // TODO: AA do not allow to change calendar type.
if (this.fromApiJsonHelper.parameterExists(CALENDAR_SUPPORTED_PARAMETERS.TYPE_ID.getValue(), element)) { if (this.fromApiJsonHelper.parameterExists(CalendarSupportedParameters.TYPE_ID.getValue(), element)) {
final Integer typeId = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(CALENDAR_SUPPORTED_PARAMETERS.TYPE_ID.getValue(), final Integer typeId = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(CalendarSupportedParameters.TYPE_ID.getValue(),
element); element);
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.TYPE_ID.getValue()).value(typeId).notNull() baseDataValidator.reset().parameter(CalendarSupportedParameters.TYPE_ID.getValue()).value(typeId).notNull()
.inMinMaxRange(CalendarEntityType.getMinValue(), CalendarEntityType.getMaxValue()); .inMinMaxRange(CalendarEntityType.getMinValue(), CalendarEntityType.getMaxValue());
} }
if (this.fromApiJsonHelper.parameterExists(CALENDAR_SUPPORTED_PARAMETERS.REPEATING.getValue(), element)) { if (this.fromApiJsonHelper.parameterExists(CalendarSupportedParameters.REPEATING.getValue(), element)) {
// FIXME - Throws NullPointerException when boolean value is null // FIXME - Throws NullPointerException when boolean value is null
final boolean repeating = this.fromApiJsonHelper.extractBooleanNamed(CALENDAR_SUPPORTED_PARAMETERS.REPEATING.getValue(), final boolean repeating = this.fromApiJsonHelper.extractBooleanNamed(CalendarSupportedParameters.REPEATING.getValue(),
element); element);
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.REPEATING.getValue()).value(repeating).notNull(); baseDataValidator.reset().parameter(CalendarSupportedParameters.REPEATING.getValue()).value(repeating).notNull();
if (repeating) { if (repeating) {
final Integer frequency = this.fromApiJsonHelper.extractIntegerSansLocaleNamed( final Integer frequency = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(
CALENDAR_SUPPORTED_PARAMETERS.FREQUENCY.getValue(), element); CalendarSupportedParameters.FREQUENCY.getValue(), element);
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.FREQUENCY.getValue()).value(frequency).notBlank() baseDataValidator.reset().parameter(CalendarSupportedParameters.FREQUENCY.getValue()).value(frequency).notBlank()
.inMinMaxRange(CalendarFrequencyType.getMinValue(), CalendarFrequencyType.getMaxValue()); .inMinMaxRange(CalendarFrequencyType.getMinValue(), CalendarFrequencyType.getMaxValue());
if (this.fromApiJsonHelper.parameterExists(CALENDAR_SUPPORTED_PARAMETERS.INTERVAL.getValue(), element)) { if (this.fromApiJsonHelper.parameterExists(CalendarSupportedParameters.INTERVAL.getValue(), element)) {
final Integer interval = this.fromApiJsonHelper.extractIntegerSansLocaleNamed( final Integer interval = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(
CALENDAR_SUPPORTED_PARAMETERS.INTERVAL.getValue(), element); CalendarSupportedParameters.INTERVAL.getValue(), element);
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.INTERVAL.getValue()).value(interval).notNull() baseDataValidator.reset().parameter(CalendarSupportedParameters.INTERVAL.getValue()).value(interval).notNull()
.integerGreaterThanZero(); .integerGreaterThanZero();
} }
if (CalendarFrequencyType.fromInt(frequency).isWeekly()) { if (CalendarFrequencyType.fromInt(frequency).isWeekly()) {
if (this.fromApiJsonHelper.parameterExists(CALENDAR_SUPPORTED_PARAMETERS.REPEATS_ON_DAY.getValue(), element)) { if (this.fromApiJsonHelper.parameterExists(CalendarSupportedParameters.REPEATS_ON_DAY.getValue(), element)) {
final Integer repeatsOnDay = this.fromApiJsonHelper.extractIntegerSansLocaleNamed( final Integer repeatsOnDay = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(
CALENDAR_SUPPORTED_PARAMETERS.REPEATS_ON_DAY.getValue(), element); CalendarSupportedParameters.REPEATS_ON_DAY.getValue(), element);
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.REPEATS_ON_DAY.getValue()).value(repeatsOnDay) baseDataValidator.reset().parameter(CalendarSupportedParameters.REPEATS_ON_DAY.getValue()).value(repeatsOnDay)
.notBlank().inMinMaxRange(CalendarWeekDaysType.getMinValue(), CalendarWeekDaysType.getMaxValue()); .notBlank().inMinMaxRange(CalendarWeekDaysType.getMinValue(), CalendarWeekDaysType.getMaxValue());
} }
} else if (CalendarFrequencyType.fromInt(frequency).isMonthly()) { } else if (CalendarFrequencyType.fromInt(frequency).isMonthly()) {
CalendarUtils.validateNthDayOfMonthFrequency(baseDataValidator, CalendarUtils.validateNthDayOfMonthFrequency(baseDataValidator,
CALENDAR_SUPPORTED_PARAMETERS.REPEATS_ON_NTH_DAY_OF_MONTH.getValue(), CalendarSupportedParameters.REPEATS_ON_NTH_DAY_OF_MONTH.getValue(),
CALENDAR_SUPPORTED_PARAMETERS.REPEATS_ON_LAST_WEEKDAY_OF_MONTH.getValue(), element, this.fromApiJsonHelper); CalendarSupportedParameters.REPEATS_ON_LAST_WEEKDAY_OF_MONTH.getValue(), element, this.fromApiJsonHelper);
} }
} }
} }
if (this.fromApiJsonHelper.parameterExists(CALENDAR_SUPPORTED_PARAMETERS.REMIND_BY_ID.getValue(), element)) { if (this.fromApiJsonHelper.parameterExists(CalendarSupportedParameters.REMIND_BY_ID.getValue(), element)) {
final Integer remindById = this.fromApiJsonHelper.extractIntegerSansLocaleNamed( final Integer remindById = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(
CALENDAR_SUPPORTED_PARAMETERS.REMIND_BY_ID.getValue(), element); CalendarSupportedParameters.REMIND_BY_ID.getValue(), element);
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.REMIND_BY_ID.getValue()).value(remindById).ignoreIfNull() baseDataValidator.reset().parameter(CalendarSupportedParameters.REMIND_BY_ID.getValue()).value(remindById).ignoreIfNull()
.inMinMaxRange(CalendarRemindBy.getMinValue(), CalendarRemindBy.getMaxValue()); .inMinMaxRange(CalendarRemindBy.getMinValue(), CalendarRemindBy.getMaxValue());
} }
if (this.fromApiJsonHelper.parameterExists(CALENDAR_SUPPORTED_PARAMETERS.FIRST_REMINDER.getValue(), element)) { if (this.fromApiJsonHelper.parameterExists(CalendarSupportedParameters.FIRST_REMINDER.getValue(), element)) {
final Integer firstReminder = this.fromApiJsonHelper.extractIntegerSansLocaleNamed( final Integer firstReminder = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(
CALENDAR_SUPPORTED_PARAMETERS.FIRST_REMINDER.getValue(), element); CalendarSupportedParameters.FIRST_REMINDER.getValue(), element);
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.FIRST_REMINDER.getValue()).value(firstReminder) baseDataValidator.reset().parameter(CalendarSupportedParameters.FIRST_REMINDER.getValue()).value(firstReminder)
.ignoreIfNull(); .ignoreIfNull();
} }
if (this.fromApiJsonHelper.parameterExists(CALENDAR_SUPPORTED_PARAMETERS.SECOND_REMINDER.getValue(), element)) { if (this.fromApiJsonHelper.parameterExists(CalendarSupportedParameters.SECOND_REMINDER.getValue(), element)) {
final Integer secondReminder = this.fromApiJsonHelper.extractIntegerSansLocaleNamed( final Integer secondReminder = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(
CALENDAR_SUPPORTED_PARAMETERS.SECOND_REMINDER.getValue(), element); CalendarSupportedParameters.SECOND_REMINDER.getValue(), element);
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.SECOND_REMINDER.getValue()).value(secondReminder) baseDataValidator.reset().parameter(CalendarSupportedParameters.SECOND_REMINDER.getValue()).value(secondReminder)
.ignoreIfNull(); .ignoreIfNull();
} }
if (this.fromApiJsonHelper.parameterExists(CALENDAR_SUPPORTED_PARAMETERS.MEETING_TIME.getValue(), element)) { if (this.fromApiJsonHelper.parameterExists(CalendarSupportedParameters.MEETING_TIME.getValue(), element)) {
final LocalDateTime startDate = this.fromApiJsonHelper.extractLocalTimeNamed(CALENDAR_SUPPORTED_PARAMETERS.MEETING_TIME.getValue(), final LocalDateTime startDate = this.fromApiJsonHelper.extractLocalTimeNamed(CalendarSupportedParameters.MEETING_TIME.getValue(),
element); element);
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.MEETING_TIME.getValue()).value(startDate).ignoreIfNull(); baseDataValidator.reset().parameter(CalendarSupportedParameters.MEETING_TIME.getValue()).value(startDate).ignoreIfNull();
} }
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist",
@@ -32,7 +32,7 @@ import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuilder; import org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuilder;
import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder; import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder;
import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException; import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException;
import org.apache.fineract.portfolio.calendar.CalendarConstants.CALENDAR_SUPPORTED_PARAMETERS; import org.apache.fineract.portfolio.calendar.CalendarConstants.CalendarSupportedParameters;
import org.apache.fineract.portfolio.calendar.domain.Calendar; import org.apache.fineract.portfolio.calendar.domain.Calendar;
import org.apache.fineract.portfolio.calendar.domain.CalendarEntityType; import org.apache.fineract.portfolio.calendar.domain.CalendarEntityType;
import org.apache.fineract.portfolio.calendar.domain.CalendarHistory; import org.apache.fineract.portfolio.calendar.domain.CalendarHistory;
@@ -125,7 +125,7 @@ public class CalendarWritePlatformServiceJpaRepositoryImpl implements CalendarWr
if (entityActivationDate != null) dateAsString = formatter.print(entityActivationDate); if (entityActivationDate != null) dateAsString = formatter.print(entityActivationDate);
final String errorMessage = "cannot.be.before." + entityType.name().toLowerCase() + ".activation.date"; final String errorMessage = "cannot.be.before." + entityType.name().toLowerCase() + ".activation.date";
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.START_DATE.getValue()).value(dateAsString) baseDataValidator.reset().parameter(CalendarSupportedParameters.START_DATE.getValue()).value(dateAsString)
.failWithCodeNoParameterAddedToErrorCode(errorMessage); .failWithCodeNoParameterAddedToErrorCode(errorMessage);
} }
@@ -244,7 +244,7 @@ public class CalendarWritePlatformServiceJpaRepositoryImpl implements CalendarWr
Map<String, Object> changes = null; Map<String, Object> changes = null;
final Boolean reschedulebasedOnMeetingDates = command final Boolean reschedulebasedOnMeetingDates = command
.booleanObjectValueOfParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.RESCHEDULE_BASED_ON_MEETING_DATES.getValue()); .booleanObjectValueOfParameterNamed(CalendarSupportedParameters.RESCHEDULE_BASED_ON_MEETING_DATES.getValue());
/* /*
* System allows to change the meeting date by two means, * System allows to change the meeting date by two means,
@@ -269,8 +269,8 @@ public class CalendarWritePlatformServiceJpaRepositoryImpl implements CalendarWr
if (reschedulebasedOnMeetingDates != null && reschedulebasedOnMeetingDates) { if (reschedulebasedOnMeetingDates != null && reschedulebasedOnMeetingDates) {
newMeetingDate = command.localDateValueOfParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.NEW_MEETING_DATE.getValue()); newMeetingDate = command.localDateValueOfParameterNamed(CalendarSupportedParameters.NEW_MEETING_DATE.getValue());
presentMeetingDate = command.localDateValueOfParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.PRESENT_MEETING_DATE.getValue()); presentMeetingDate = command.localDateValueOfParameterNamed(CalendarSupportedParameters.PRESENT_MEETING_DATE.getValue());
/* /*
* New meeting date proposed will become the new start date for the * New meeting date proposed will become the new start date for the
@@ -287,7 +287,7 @@ public class CalendarWritePlatformServiceJpaRepositoryImpl implements CalendarWr
// update calendar history table only if there is a change in // update calendar history table only if there is a change in
// calendar start date. // calendar start date.
if (reschedulebasedOnMeetingDates == null){ if (reschedulebasedOnMeetingDates == null){
presentMeetingDate = command.localDateValueOfParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.START_DATE.getValue()); presentMeetingDate = command.localDateValueOfParameterNamed(CalendarSupportedParameters.START_DATE.getValue());
} }
if (null != newMeetingDate) { if (null != newMeetingDate) {
final Date endDate = presentMeetingDate.minusDays(1).toDate(); final Date endDate = presentMeetingDate.minusDays(1).toDate();
@@ -23,7 +23,7 @@ import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainR
public class LoanChargeCannotBeDeletedException extends AbstractPlatformDomainRuleException { public class LoanChargeCannotBeDeletedException extends AbstractPlatformDomainRuleException {
/*** enum of reasons of why Loan Charge cannot be waived **/ /*** enum of reasons of why Loan Charge cannot be waived **/
public static enum LOAN_CHARGE_CANNOT_BE_DELETED_REASON { public static enum LoanChargeCannotBeDeletedReason {
ALREADY_PAID, ALREADY_WAIVED, LOAN_NOT_IN_SUBMITTED_AND_PENDING_APPROVAL_STAGE; ALREADY_PAID, ALREADY_WAIVED, LOAN_NOT_IN_SUBMITTED_AND_PENDING_APPROVAL_STAGE;
public String errorMessage() { public String errorMessage() {
@@ -45,7 +45,7 @@ public class LoanChargeCannotBeDeletedException extends AbstractPlatformDomainRu
} }
} }
public LoanChargeCannotBeDeletedException(final LOAN_CHARGE_CANNOT_BE_DELETED_REASON reason, final Long loanChargeId) { public LoanChargeCannotBeDeletedException(final LoanChargeCannotBeDeletedReason reason, final Long loanChargeId) {
super(reason.errorCode(), reason.errorMessage(), loanChargeId); super(reason.errorCode(), reason.errorMessage(), loanChargeId);
} }
} }
@@ -23,7 +23,7 @@ import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainR
public class LoanChargeCannotBePayedException extends AbstractPlatformDomainRuleException { public class LoanChargeCannotBePayedException extends AbstractPlatformDomainRuleException {
/*** enum of reasons of why Loan Charge cannot be waived **/ /*** enum of reasons of why Loan Charge cannot be waived **/
public static enum LOAN_CHARGE_CANNOT_BE_PAYED_REASON { public static enum LoanChargeCannotBePayedReason {
ALREADY_PAID, ALREADY_WAIVED, LOAN_INACTIVE, CHARGE_NOT_ACCOUNT_TRANSFER, CHARGE_NOT_PAYABLE; ALREADY_PAID, ALREADY_WAIVED, LOAN_INACTIVE, CHARGE_NOT_ACCOUNT_TRANSFER, CHARGE_NOT_PAYABLE;
public String errorMessage() { public String errorMessage() {
@@ -54,7 +54,7 @@ public class LoanChargeCannotBePayedException extends AbstractPlatformDomainRule
} }
} }
public LoanChargeCannotBePayedException(final LOAN_CHARGE_CANNOT_BE_PAYED_REASON reason, final Long loanChargeId) { public LoanChargeCannotBePayedException(final LoanChargeCannotBePayedReason reason, final Long loanChargeId) {
super(reason.errorCode(), reason.errorMessage(), loanChargeId); super(reason.errorCode(), reason.errorMessage(), loanChargeId);
} }
} }
@@ -23,7 +23,7 @@ import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainR
public class LoanChargeCannotBeUpdatedException extends AbstractPlatformDomainRuleException { public class LoanChargeCannotBeUpdatedException extends AbstractPlatformDomainRuleException {
/*** enum of reasons of why Loan Charge cannot be waived **/ /*** enum of reasons of why Loan Charge cannot be waived **/
public static enum LOAN_CHARGE_CANNOT_BE_UPDATED_REASON { public static enum LoanChargeCannotBeUpdatedReason {
ALREADY_PAID, ALREADY_WAIVED, LOAN_NOT_IN_SUBMITTED_AND_PENDING_APPROVAL_STAGE; ALREADY_PAID, ALREADY_WAIVED, LOAN_NOT_IN_SUBMITTED_AND_PENDING_APPROVAL_STAGE;
public String errorMessage() { public String errorMessage() {
@@ -45,7 +45,7 @@ public class LoanChargeCannotBeUpdatedException extends AbstractPlatformDomainRu
} }
} }
public LoanChargeCannotBeUpdatedException(final LOAN_CHARGE_CANNOT_BE_UPDATED_REASON reason, final Long loanChargeId) { public LoanChargeCannotBeUpdatedException(final LoanChargeCannotBeUpdatedReason reason, final Long loanChargeId) {
super(reason.errorCode(), reason.errorMessage(), loanChargeId); super(reason.errorCode(), reason.errorMessage(), loanChargeId);
} }
} }
@@ -23,7 +23,7 @@ import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainR
public class LoanChargeCannotBeWaivedException extends AbstractPlatformDomainRuleException { public class LoanChargeCannotBeWaivedException extends AbstractPlatformDomainRuleException {
/*** enum of reasons of why Loan Charge cannot be waived **/ /*** enum of reasons of why Loan Charge cannot be waived **/
public static enum LOAN_CHARGE_CANNOT_BE_WAIVED_REASON { public static enum LoanChargeCannotBeWaivedReason {
ALREADY_PAID, ALREADY_WAIVED, LOAN_INACTIVE, WAIVE_NOT_ALLOWED_FOR_CHARGE; ALREADY_PAID, ALREADY_WAIVED, LOAN_INACTIVE, WAIVE_NOT_ALLOWED_FOR_CHARGE;
public String errorMessage() { public String errorMessage() {
@@ -50,7 +50,7 @@ public class LoanChargeCannotBeWaivedException extends AbstractPlatformDomainRul
} }
} }
public LoanChargeCannotBeWaivedException(final LOAN_CHARGE_CANNOT_BE_WAIVED_REASON reason, final Long loanChargeId) { public LoanChargeCannotBeWaivedException(final LoanChargeCannotBeWaivedReason reason, final Long loanChargeId) {
super(reason.errorCode(), reason.errorMessage(), loanChargeId); super(reason.errorCode(), reason.errorMessage(), loanChargeId);
} }
} }
@@ -23,7 +23,7 @@ import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainR
public class SavingsAccountChargeCannotBeWaivedException extends AbstractPlatformDomainRuleException { public class SavingsAccountChargeCannotBeWaivedException extends AbstractPlatformDomainRuleException {
/*** enum of reasons of why Savings Account Charge cannot be waived **/ /*** enum of reasons of why Savings Account Charge cannot be waived **/
public static enum SAVINGS_ACCOUNT_CHARGE_CANNOT_BE_WAIVED_REASON { public static enum SavingsAccountChargeCannotBeWaivedReason {
ALREADY_PAID, ALREADY_WAIVED, SAVINGS_ACCOUNT_NOT_ACTIVE, SAVINGS_ACCOUNT_CLOSED; ALREADY_PAID, ALREADY_WAIVED, SAVINGS_ACCOUNT_NOT_ACTIVE, SAVINGS_ACCOUNT_CLOSED;
public String errorMessage() { public String errorMessage() {
@@ -49,7 +49,7 @@ public class SavingsAccountChargeCannotBeWaivedException extends AbstractPlatfor
} }
} }
public SavingsAccountChargeCannotBeWaivedException(final SAVINGS_ACCOUNT_CHARGE_CANNOT_BE_WAIVED_REASON reason, public SavingsAccountChargeCannotBeWaivedException(final SavingsAccountChargeCannotBeWaivedReason reason,
final Long savingsAccountChargeId) { final Long savingsAccountChargeId) {
super(reason.errorCode(), reason.errorMessage(), savingsAccountChargeId); super(reason.errorCode(), reason.errorMessage(), savingsAccountChargeId);
} }
@@ -65,8 +65,8 @@ import org.apache.fineract.portfolio.client.exception.ClientHasNoStaffException;
import org.apache.fineract.portfolio.client.exception.ClientMustBePendingToBeDeletedException; import org.apache.fineract.portfolio.client.exception.ClientMustBePendingToBeDeletedException;
import org.apache.fineract.portfolio.client.exception.InvalidClientSavingProductException; import org.apache.fineract.portfolio.client.exception.InvalidClientSavingProductException;
import org.apache.fineract.portfolio.client.exception.InvalidClientStateTransitionException; import org.apache.fineract.portfolio.client.exception.InvalidClientStateTransitionException;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BUSINESS_ENTITY; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEntity;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BUSINESS_EVENTS; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEvents;
import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService; import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.group.domain.Group; import org.apache.fineract.portfolio.group.domain.Group;
import org.apache.fineract.portfolio.group.domain.GroupRepository; import org.apache.fineract.portfolio.group.domain.GroupRepository;
@@ -301,8 +301,8 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
this.clientRepository.save(newClient); this.clientRepository.save(newClient);
if (newClient.isActive()) { if (newClient.isActive()) {
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.CLIENTS_ACTIVATE, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.CLIENTS_ACTIVATE,
constructEntityMap(BUSINESS_ENTITY.CLIENT, newClient)); constructEntityMap(BusinessEntity.CLIENT, newClient));
} }
if (newClient.isAccountNumberRequiresAutoGeneration()) { if (newClient.isAccountNumberRequiresAutoGeneration()) {
AccountNumberFormat accountNumberFormat = this.accountNumberFormatRepository.findByAccountType(EntityAccountType.CLIENT); AccountNumberFormat accountNumberFormat = this.accountNumberFormatRepository.findByAccountType(EntityAccountType.CLIENT);
@@ -338,8 +338,8 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
command.arrayOfParameterNamed(ClientApiConstants.datatables)); command.arrayOfParameterNamed(ClientApiConstants.datatables));
} }
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.CLIENTS_CREATE, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.CLIENTS_CREATE,
constructEntityMap(BUSINESS_ENTITY.CLIENT, newClient)); constructEntityMap(BusinessEntity.CLIENT, newClient));
this.entityDatatableChecksWritePlatformService.runTheCheck(newClient.getId(), EntityTables.CLIENT.getName(), this.entityDatatableChecksWritePlatformService.runTheCheck(newClient.getId(), EntityTables.CLIENT.getName(),
StatusEnum.CREATE.getCode().longValue(), EntityTables.CLIENT.getForeignKeyColumnNameOnDatatable()); StatusEnum.CREATE.getCode().longValue(), EntityTables.CLIENT.getForeignKeyColumnNameOnDatatable());
@@ -583,8 +583,8 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
client.activate(currentUser, fmt, activationDate); client.activate(currentUser, fmt, activationDate);
CommandProcessingResult result = openSavingsAccount(client, fmt); CommandProcessingResult result = openSavingsAccount(client, fmt);
this.clientRepository.saveAndFlush(client); this.clientRepository.saveAndFlush(client);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.CLIENTS_ACTIVATE, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.CLIENTS_ACTIVATE,
constructEntityMap(BUSINESS_ENTITY.CLIENT, client)); constructEntityMap(BusinessEntity.CLIENT, client));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
.withOfficeId(client.officeId()) // .withOfficeId(client.officeId()) //
@@ -837,8 +837,8 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
} }
client.reject(currentUser, rejectionReason, rejectionDate.toDate()); client.reject(currentUser, rejectionReason, rejectionDate.toDate());
this.clientRepository.saveAndFlush(client); this.clientRepository.saveAndFlush(client);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.CLIENTS_REJECT, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.CLIENTS_REJECT,
constructEntityMap(BUSINESS_ENTITY.CLIENT, client)); constructEntityMap(BusinessEntity.CLIENT, client));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
.withClientId(entityId) // .withClientId(entityId) //
@@ -956,8 +956,8 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
.build(); .build();
} }
private Map<BUSINESS_ENTITY, Object> constructEntityMap(final BUSINESS_ENTITY entityEvent, Object entity) { private Map<BusinessEntity, Object> constructEntityMap(final BusinessEntity entityEvent, Object entity) {
Map<BUSINESS_ENTITY, Object> map = new HashMap<>(1); Map<BusinessEntity, Object> map = new HashMap<>(1);
map.put(entityEvent, entity); map.put(entityEvent, entity);
return map; return map;
} }
@@ -28,18 +28,18 @@ public class CollateralApiConstants {
/*** /***
* Enum of all parameters passed in while creating/updating a collateral * Enum of all parameters passed in while creating/updating a collateral
***/ ***/
public static enum COLLATERAL_JSON_INPUT_PARAMS { public static enum CollateralJSONinputParams {
LOAN_ID("loanId"), COLLATERAL_ID("collateralId"), COLLATERAL_TYPE_ID("collateralTypeId"), VALUE("value"), DESCRIPTION("description"); LOAN_ID("loanId"), COLLATERAL_ID("collateralId"), COLLATERAL_TYPE_ID("collateralTypeId"), VALUE("value"), DESCRIPTION("description");
private final String value; private final String value;
private COLLATERAL_JSON_INPUT_PARAMS(final String value) { private CollateralJSONinputParams(final String value) {
this.value = value; this.value = value;
} }
private static final Set<String> values = new HashSet<>(); private static final Set<String> values = new HashSet<>();
static { static {
for (final COLLATERAL_JSON_INPUT_PARAMS type : COLLATERAL_JSON_INPUT_PARAMS.values()) { for (final CollateralJSONinputParams type : CollateralJSONinputParams.values()) {
values.add(type.value); values.add(type.value);
} }
} }
@@ -24,7 +24,7 @@ import java.util.List;
import org.apache.fineract.infrastructure.core.data.ApiParameterError; import org.apache.fineract.infrastructure.core.data.ApiParameterError;
import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder; import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder;
import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException; import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException;
import org.apache.fineract.portfolio.collateral.api.CollateralApiConstants.COLLATERAL_JSON_INPUT_PARAMS; import org.apache.fineract.portfolio.collateral.api.CollateralApiConstants.CollateralJSONinputParams;
/** /**
* Immutable command for creating or updating details of a Collateral. * Immutable command for creating or updating details of a Collateral.
@@ -58,11 +58,11 @@ public class CollateralCommand {
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("collateral"); final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("collateral");
baseDataValidator.reset().parameter(COLLATERAL_JSON_INPUT_PARAMS.COLLATERAL_TYPE_ID.getValue()).value(this.collateralTypeId) baseDataValidator.reset().parameter(CollateralJSONinputParams.COLLATERAL_TYPE_ID.getValue()).value(this.collateralTypeId)
.notNull().integerGreaterThanZero(); .notNull().integerGreaterThanZero();
baseDataValidator.reset().parameter(COLLATERAL_JSON_INPUT_PARAMS.VALUE.getValue()).value(this.value).ignoreIfNull() baseDataValidator.reset().parameter(CollateralJSONinputParams.VALUE.getValue()).value(this.value).ignoreIfNull()
.positiveAmount(); .positiveAmount();
baseDataValidator.reset().parameter(COLLATERAL_JSON_INPUT_PARAMS.DESCRIPTION.getValue()).value(this.description).ignoreIfNull() baseDataValidator.reset().parameter(CollateralJSONinputParams.DESCRIPTION.getValue()).value(this.description).ignoreIfNull()
.notExceedingLengthOf(500); .notExceedingLengthOf(500);
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist",
@@ -74,11 +74,11 @@ public class CollateralCommand {
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("collateral"); final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("collateral");
baseDataValidator.reset().parameter(COLLATERAL_JSON_INPUT_PARAMS.COLLATERAL_TYPE_ID.getValue()).value(this.collateralTypeId) baseDataValidator.reset().parameter(CollateralJSONinputParams.COLLATERAL_TYPE_ID.getValue()).value(this.collateralTypeId)
.ignoreIfNull().integerGreaterThanZero(); .ignoreIfNull().integerGreaterThanZero();
baseDataValidator.reset().parameter(COLLATERAL_JSON_INPUT_PARAMS.VALUE.getValue()).value(this.value).ignoreIfNull() baseDataValidator.reset().parameter(CollateralJSONinputParams.VALUE.getValue()).value(this.value).ignoreIfNull()
.positiveAmount(); .positiveAmount();
baseDataValidator.reset().parameter(COLLATERAL_JSON_INPUT_PARAMS.DESCRIPTION.getValue()).value(this.description).ignoreIfNull() baseDataValidator.reset().parameter(CollateralJSONinputParams.DESCRIPTION.getValue()).value(this.description).ignoreIfNull()
.notExceedingLengthOf(500); .notExceedingLengthOf(500);
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist",
@@ -31,7 +31,7 @@ import org.apache.fineract.infrastructure.codes.data.CodeValueData;
import org.apache.fineract.infrastructure.codes.domain.CodeValue; import org.apache.fineract.infrastructure.codes.domain.CodeValue;
import org.apache.fineract.infrastructure.core.api.JsonCommand; import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom; import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
import org.apache.fineract.portfolio.collateral.api.CollateralApiConstants.COLLATERAL_JSON_INPUT_PARAMS; import org.apache.fineract.portfolio.collateral.api.CollateralApiConstants.CollateralJSONinputParams;
import org.apache.fineract.portfolio.collateral.data.CollateralData; import org.apache.fineract.portfolio.collateral.data.CollateralData;
import org.apache.fineract.portfolio.loanaccount.domain.Loan; import org.apache.fineract.portfolio.loanaccount.domain.Loan;
@@ -79,8 +79,8 @@ public class LoanCollateral extends AbstractPersistableCustom {
} }
public static LoanCollateral fromJson(final Loan loan, final CodeValue collateralType, final JsonCommand command) { public static LoanCollateral fromJson(final Loan loan, final CodeValue collateralType, final JsonCommand command) {
final String description = command.stringValueOfParameterNamed(COLLATERAL_JSON_INPUT_PARAMS.DESCRIPTION.getValue()); final String description = command.stringValueOfParameterNamed(CollateralJSONinputParams.DESCRIPTION.getValue());
final BigDecimal value = command.bigDecimalValueOfParameterNamed(COLLATERAL_JSON_INPUT_PARAMS.VALUE.getValue()); final BigDecimal value = command.bigDecimalValueOfParameterNamed(CollateralJSONinputParams.VALUE.getValue());
return new LoanCollateral(loan, collateralType, value, description); return new LoanCollateral(loan, collateralType, value, description);
} }
@@ -88,20 +88,20 @@ public class LoanCollateral extends AbstractPersistableCustom {
final Map<String, Object> actualChanges = new LinkedHashMap<>(7); final Map<String, Object> actualChanges = new LinkedHashMap<>(7);
final String collateralTypeIdParamName = COLLATERAL_JSON_INPUT_PARAMS.COLLATERAL_TYPE_ID.getValue(); final String collateralTypeIdParamName = CollateralJSONinputParams.COLLATERAL_TYPE_ID.getValue();
if (command.isChangeInLongParameterNamed(collateralTypeIdParamName, this.type.getId())) { if (command.isChangeInLongParameterNamed(collateralTypeIdParamName, this.type.getId())) {
final Long newValue = command.longValueOfParameterNamed(collateralTypeIdParamName); final Long newValue = command.longValueOfParameterNamed(collateralTypeIdParamName);
actualChanges.put(collateralTypeIdParamName, newValue); actualChanges.put(collateralTypeIdParamName, newValue);
} }
final String descriptionParamName = COLLATERAL_JSON_INPUT_PARAMS.DESCRIPTION.getValue(); final String descriptionParamName = CollateralJSONinputParams.DESCRIPTION.getValue();
if (command.isChangeInStringParameterNamed(descriptionParamName, this.description)) { if (command.isChangeInStringParameterNamed(descriptionParamName, this.description)) {
final String newValue = command.stringValueOfParameterNamed(descriptionParamName); final String newValue = command.stringValueOfParameterNamed(descriptionParamName);
actualChanges.put(descriptionParamName, newValue); actualChanges.put(descriptionParamName, newValue);
this.description = StringUtils.defaultIfEmpty(newValue, null); this.description = StringUtils.defaultIfEmpty(newValue, null);
} }
final String valueParamName = COLLATERAL_JSON_INPUT_PARAMS.VALUE.getValue(); final String valueParamName = CollateralJSONinputParams.VALUE.getValue();
if (command.isChangeInBigDecimalParameterNamed(valueParamName, this.value)) { if (command.isChangeInBigDecimalParameterNamed(valueParamName, this.value)) {
final BigDecimal newValue = command.bigDecimalValueOfParameterNamed(valueParamName); final BigDecimal newValue = command.bigDecimalValueOfParameterNamed(valueParamName);
actualChanges.put(valueParamName, newValue); actualChanges.put(valueParamName, newValue);
@@ -23,7 +23,7 @@ import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainR
public class CollateralCannotBeCreatedException extends AbstractPlatformDomainRuleException { public class CollateralCannotBeCreatedException extends AbstractPlatformDomainRuleException {
/*** enum of reasons of why Loan Charge cannot be waived **/ /*** enum of reasons of why Loan Charge cannot be waived **/
public static enum LOAN_COLLATERAL_CANNOT_BE_CREATED_REASON { public static enum LoanCollateralCannotBeCreatedReason {
LOAN_NOT_IN_SUBMITTED_AND_PENDING_APPROVAL_STAGE; LOAN_NOT_IN_SUBMITTED_AND_PENDING_APPROVAL_STAGE;
public String errorMessage() { public String errorMessage() {
@@ -37,7 +37,7 @@ public class CollateralCannotBeCreatedException extends AbstractPlatformDomainRu
} }
} }
public CollateralCannotBeCreatedException(final LOAN_COLLATERAL_CANNOT_BE_CREATED_REASON reason, final Long loanId) { public CollateralCannotBeCreatedException(final LoanCollateralCannotBeCreatedReason reason, final Long loanId) {
super(reason.errorCode(), reason.errorMessage(), loanId); super(reason.errorCode(), reason.errorMessage(), loanId);
} }
} }
@@ -23,7 +23,7 @@ import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainR
public class CollateralCannotBeDeletedException extends AbstractPlatformDomainRuleException { public class CollateralCannotBeDeletedException extends AbstractPlatformDomainRuleException {
/*** enum of reasons of why Loan Charge cannot be waived **/ /*** enum of reasons of why Loan Charge cannot be waived **/
public static enum LOAN_COLLATERAL_CANNOT_BE_DELETED_REASON { public static enum LoanCollateralCannotBeDeletedReason {
LOAN_NOT_IN_SUBMITTED_AND_PENDING_APPROVAL_STAGE; LOAN_NOT_IN_SUBMITTED_AND_PENDING_APPROVAL_STAGE;
public String errorMessage() { public String errorMessage() {
@@ -37,7 +37,7 @@ public class CollateralCannotBeDeletedException extends AbstractPlatformDomainRu
} }
} }
public CollateralCannotBeDeletedException(final LOAN_COLLATERAL_CANNOT_BE_DELETED_REASON reason, final Long loanId, public CollateralCannotBeDeletedException(final LoanCollateralCannotBeDeletedReason reason, final Long loanId,
final Long loanCollateralId) { final Long loanCollateralId) {
super(reason.errorCode(), reason.errorMessage(), loanId, loanCollateralId); super(reason.errorCode(), reason.errorMessage(), loanId, loanCollateralId);
} }
@@ -23,7 +23,7 @@ import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainR
public class CollateralCannotBeUpdatedException extends AbstractPlatformDomainRuleException { public class CollateralCannotBeUpdatedException extends AbstractPlatformDomainRuleException {
/*** enum of reasons of why Loan Charge cannot be waived **/ /*** enum of reasons of why Loan Charge cannot be waived **/
public static enum LOAN_COLLATERAL_CANNOT_BE_UPDATED_REASON { public static enum LoanCollateralCannotBeUpdatedReason {
LOAN_NOT_IN_SUBMITTED_AND_PENDING_APPROVAL_STAGE; LOAN_NOT_IN_SUBMITTED_AND_PENDING_APPROVAL_STAGE;
public String errorMessage() { public String errorMessage() {
@@ -37,7 +37,7 @@ public class CollateralCannotBeUpdatedException extends AbstractPlatformDomainRu
} }
} }
public CollateralCannotBeUpdatedException(final LOAN_COLLATERAL_CANNOT_BE_UPDATED_REASON reason, final Long loanCollateralId) { public CollateralCannotBeUpdatedException(final LoanCollateralCannotBeUpdatedReason reason, final Long loanCollateralId) {
super(reason.errorCode(), reason.errorMessage(), loanCollateralId); super(reason.errorCode(), reason.errorMessage(), loanCollateralId);
} }
} }
@@ -31,7 +31,7 @@ import org.apache.fineract.infrastructure.core.exception.InvalidJsonException;
import org.apache.fineract.infrastructure.core.serialization.AbstractFromApiJsonDeserializer; import org.apache.fineract.infrastructure.core.serialization.AbstractFromApiJsonDeserializer;
import org.apache.fineract.infrastructure.core.serialization.FromApiJsonDeserializer; import org.apache.fineract.infrastructure.core.serialization.FromApiJsonDeserializer;
import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper; import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
import org.apache.fineract.portfolio.collateral.api.CollateralApiConstants.COLLATERAL_JSON_INPUT_PARAMS; import org.apache.fineract.portfolio.collateral.api.CollateralApiConstants.CollateralJSONinputParams;
import org.apache.fineract.portfolio.collateral.command.CollateralCommand; import org.apache.fineract.portfolio.collateral.command.CollateralCommand;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -55,7 +55,7 @@ public final class CollateralCommandFromApiJsonDeserializer extends AbstractFrom
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();
final Set<String> supportedParameters = COLLATERAL_JSON_INPUT_PARAMS.getAllValues(); final Set<String> supportedParameters = CollateralJSONinputParams.getAllValues();
supportedParameters.add("locale"); supportedParameters.add("locale");
supportedParameters.add("dateFormat"); supportedParameters.add("dateFormat");
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, supportedParameters); this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, supportedParameters);
@@ -64,10 +64,10 @@ public final class CollateralCommandFromApiJsonDeserializer extends AbstractFrom
final JsonObject topLevelJsonElement = element.getAsJsonObject(); final JsonObject topLevelJsonElement = element.getAsJsonObject();
final Locale locale = this.fromApiJsonHelper.extractLocaleParameter(topLevelJsonElement); final Locale locale = this.fromApiJsonHelper.extractLocaleParameter(topLevelJsonElement);
final Long collateralTypeId = this.fromApiJsonHelper.extractLongNamed(COLLATERAL_JSON_INPUT_PARAMS.COLLATERAL_TYPE_ID.getValue(), final Long collateralTypeId = this.fromApiJsonHelper.extractLongNamed(CollateralJSONinputParams.COLLATERAL_TYPE_ID.getValue(),
element); element);
final String description = this.fromApiJsonHelper.extractStringNamed(COLLATERAL_JSON_INPUT_PARAMS.DESCRIPTION.getValue(), element); final String description = this.fromApiJsonHelper.extractStringNamed(CollateralJSONinputParams.DESCRIPTION.getValue(), element);
final BigDecimal value = this.fromApiJsonHelper.extractBigDecimalNamed(COLLATERAL_JSON_INPUT_PARAMS.VALUE.getValue(), element, final BigDecimal value = this.fromApiJsonHelper.extractBigDecimalNamed(CollateralJSONinputParams.VALUE.getValue(), element,
locale); locale);
return new CollateralCommand(collateralTypeId, value, description); return new CollateralCommand(collateralTypeId, value, description);
@@ -27,16 +27,16 @@ import org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuild
import org.apache.fineract.infrastructure.core.exception.PlatformDataIntegrityException; import org.apache.fineract.infrastructure.core.exception.PlatformDataIntegrityException;
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
import org.apache.fineract.portfolio.collateral.api.CollateralApiConstants; import org.apache.fineract.portfolio.collateral.api.CollateralApiConstants;
import org.apache.fineract.portfolio.collateral.api.CollateralApiConstants.COLLATERAL_JSON_INPUT_PARAMS; import org.apache.fineract.portfolio.collateral.api.CollateralApiConstants.CollateralJSONinputParams;
import org.apache.fineract.portfolio.collateral.command.CollateralCommand; import org.apache.fineract.portfolio.collateral.command.CollateralCommand;
import org.apache.fineract.portfolio.collateral.domain.LoanCollateral; import org.apache.fineract.portfolio.collateral.domain.LoanCollateral;
import org.apache.fineract.portfolio.collateral.domain.LoanCollateralRepository; import org.apache.fineract.portfolio.collateral.domain.LoanCollateralRepository;
import org.apache.fineract.portfolio.collateral.exception.CollateralCannotBeCreatedException; import org.apache.fineract.portfolio.collateral.exception.CollateralCannotBeCreatedException;
import org.apache.fineract.portfolio.collateral.exception.CollateralCannotBeCreatedException.LOAN_COLLATERAL_CANNOT_BE_CREATED_REASON; import org.apache.fineract.portfolio.collateral.exception.CollateralCannotBeCreatedException.LoanCollateralCannotBeCreatedReason;
import org.apache.fineract.portfolio.collateral.exception.CollateralCannotBeDeletedException; import org.apache.fineract.portfolio.collateral.exception.CollateralCannotBeDeletedException;
import org.apache.fineract.portfolio.collateral.exception.CollateralCannotBeDeletedException.LOAN_COLLATERAL_CANNOT_BE_DELETED_REASON; import org.apache.fineract.portfolio.collateral.exception.CollateralCannotBeDeletedException.LoanCollateralCannotBeDeletedReason;
import org.apache.fineract.portfolio.collateral.exception.CollateralCannotBeUpdatedException; import org.apache.fineract.portfolio.collateral.exception.CollateralCannotBeUpdatedException;
import org.apache.fineract.portfolio.collateral.exception.CollateralCannotBeUpdatedException.LOAN_COLLATERAL_CANNOT_BE_UPDATED_REASON; import org.apache.fineract.portfolio.collateral.exception.CollateralCannotBeUpdatedException.LoanCollateralCannotBeUpdatedReason;
import org.apache.fineract.portfolio.collateral.exception.CollateralNotFoundException; import org.apache.fineract.portfolio.collateral.exception.CollateralNotFoundException;
import org.apache.fineract.portfolio.collateral.serialization.CollateralCommandFromApiJsonDeserializer; import org.apache.fineract.portfolio.collateral.serialization.CollateralCommandFromApiJsonDeserializer;
import org.apache.fineract.portfolio.loanaccount.domain.Loan; import org.apache.fineract.portfolio.loanaccount.domain.Loan;
@@ -89,7 +89,7 @@ public class CollateralWritePlatformServiceJpaRepositoryImpl implements Collater
* are yet to be approved * are yet to be approved
**/ **/
if (!loan.status().isSubmittedAndPendingApproval()) { throw new CollateralCannotBeCreatedException( if (!loan.status().isSubmittedAndPendingApproval()) { throw new CollateralCannotBeCreatedException(
LOAN_COLLATERAL_CANNOT_BE_CREATED_REASON.LOAN_NOT_IN_SUBMITTED_AND_PENDING_APPROVAL_STAGE, loan.getId()); } LoanCollateralCannotBeCreatedReason.LOAN_NOT_IN_SUBMITTED_AND_PENDING_APPROVAL_STAGE, loan.getId()); }
this.collateralRepository.save(collateral); this.collateralRepository.save(collateral);
@@ -122,7 +122,7 @@ public class CollateralWritePlatformServiceJpaRepositoryImpl implements Collater
final Map<String, Object> changes = collateralForUpdate.update(command); final Map<String, Object> changes = collateralForUpdate.update(command);
if (changes.containsKey(COLLATERAL_JSON_INPUT_PARAMS.COLLATERAL_TYPE_ID.getValue())) { if (changes.containsKey(CollateralJSONinputParams.COLLATERAL_TYPE_ID.getValue())) {
collateralType = this.codeValueRepository.findOneByCodeNameAndIdWithNotFoundDetection( collateralType = this.codeValueRepository.findOneByCodeNameAndIdWithNotFoundDetection(
CollateralApiConstants.COLLATERAL_CODE_NAME, collateralTypeId); CollateralApiConstants.COLLATERAL_CODE_NAME, collateralTypeId);
@@ -134,7 +134,7 @@ public class CollateralWritePlatformServiceJpaRepositoryImpl implements Collater
* them are yet to be approved * them are yet to be approved
**/ **/
if (!loan.status().isSubmittedAndPendingApproval()) { throw new CollateralCannotBeUpdatedException( if (!loan.status().isSubmittedAndPendingApproval()) { throw new CollateralCannotBeUpdatedException(
LOAN_COLLATERAL_CANNOT_BE_UPDATED_REASON.LOAN_NOT_IN_SUBMITTED_AND_PENDING_APPROVAL_STAGE, loan.getId()); } LoanCollateralCannotBeUpdatedReason.LOAN_NOT_IN_SUBMITTED_AND_PENDING_APPROVAL_STAGE, loan.getId()); }
if (!changes.isEmpty()) { if (!changes.isEmpty()) {
this.collateralRepository.saveAndFlush(collateralForUpdate); this.collateralRepository.saveAndFlush(collateralForUpdate);
@@ -164,7 +164,7 @@ public class CollateralWritePlatformServiceJpaRepositoryImpl implements Collater
* are yet to be approved * are yet to be approved
**/ **/
if (!loan.status().isSubmittedAndPendingApproval()) { throw new CollateralCannotBeDeletedException( if (!loan.status().isSubmittedAndPendingApproval()) { throw new CollateralCannotBeDeletedException(
LOAN_COLLATERAL_CANNOT_BE_DELETED_REASON.LOAN_NOT_IN_SUBMITTED_AND_PENDING_APPROVAL_STAGE, loanId, collateralId); } LoanCollateralCannotBeDeletedReason.LOAN_NOT_IN_SUBMITTED_AND_PENDING_APPROVAL_STAGE, loanId, collateralId); }
this.collateralRepository.delete(collateral); this.collateralRepository.delete(collateral);
return new CommandProcessingResultBuilder().withCommandId(commandId).withLoanId(loanId).withEntityId(collateralId).build(); return new CommandProcessingResultBuilder().withCommandId(commandId).withLoanId(loanId).withEntityId(collateralId).build();
@@ -23,7 +23,7 @@ import java.util.Set;
public class BusinessEventNotificationConstants { public class BusinessEventNotificationConstants {
public static enum BUSINESS_EVENTS { public static enum BusinessEvents {
LOAN_APPROVED("loan_approved"), LOAN_REJECTED("loan_reject"), LOAN_UNDO_APPROVAL("loan_undo_approval"), LOAN_UNDO_DISBURSAL( LOAN_APPROVED("loan_approved"), LOAN_REJECTED("loan_reject"), LOAN_UNDO_APPROVAL("loan_undo_approval"), LOAN_UNDO_DISBURSAL(
"loan_undo_disbursal"), LOAN_UNDO_LASTDISBURSAL("loan_undo_lastdisbursal"), LOAN_UNDO_TRANSACTION("loan_undo_transaction"), LOAN_ADJUST_TRANSACTION( "loan_undo_disbursal"), LOAN_UNDO_LASTDISBURSAL("loan_undo_lastdisbursal"), LOAN_UNDO_TRANSACTION("loan_undo_transaction"), LOAN_ADJUST_TRANSACTION(
"loan_adjust_transaction"), LOAN_MAKE_REPAYMENT("loan_repayment_transaction"), LOAN_WRITTEN_OFF("loan_writtenoff"), LOAN_UNDO_WRITTEN_OFF( "loan_adjust_transaction"), LOAN_MAKE_REPAYMENT("loan_repayment_transaction"), LOAN_WRITTEN_OFF("loan_writtenoff"), LOAN_UNDO_WRITTEN_OFF(
@@ -42,13 +42,13 @@ public class BusinessEventNotificationConstants {
private final String value; private final String value;
private BUSINESS_EVENTS(final String value) { private BusinessEvents(final String value) {
this.value = value; this.value = value;
} }
private static final Set<String> values = new HashSet<>(); private static final Set<String> values = new HashSet<>();
static { static {
for (final BUSINESS_EVENTS type : BUSINESS_EVENTS.values()) { for (final BusinessEvents type : BusinessEvents.values()) {
values.add(type.value); values.add(type.value);
} }
} }
@@ -62,14 +62,14 @@ public class BusinessEventNotificationConstants {
} }
} }
public static enum BUSINESS_ENTITY { public static enum BusinessEntity {
LOAN("loan"), LOAN_TRANSACTION("loan_transaction"), LOAN_CHARGE("loan_charge"), LOAN_ADJUSTED_TRANSACTION( LOAN("loan"), LOAN_TRANSACTION("loan_transaction"), LOAN_CHARGE("loan_charge"), LOAN_ADJUSTED_TRANSACTION(
"loan_adjusted_transaction"), SAVING("saving"), CLIENT("client"), SAVINGS_TRANSACTION("Savings Transaction"), GROUP("group"), "loan_adjusted_transaction"), SAVING("saving"), CLIENT("client"), SAVINGS_TRANSACTION("Savings Transaction"), GROUP("group"),
SHARE_ACCOUNT("share_account"), SHARE_PRODUCT("share_product"), DEPOSIT_ACCOUNT("deposit_account"), LOAN_PRODUCT("loan_product"); SHARE_ACCOUNT("share_account"), SHARE_PRODUCT("share_product"), DEPOSIT_ACCOUNT("deposit_account"), LOAN_PRODUCT("loan_product");
private final String value; private final String value;
private BUSINESS_ENTITY(final String value) { private BusinessEntity(final String value) {
this.value = value; this.value = value;
} }
@@ -19,7 +19,7 @@
package org.apache.fineract.portfolio.common.service; package org.apache.fineract.portfolio.common.service;
import java.util.Map; import java.util.Map;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BUSINESS_ENTITY; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEntity;
/** /**
* The interface to be implemented by classes that want to be informed when a * The interface to be implemented by classes that want to be informed when a
@@ -32,11 +32,11 @@ public interface BusinessEventListner {
/** /**
* Implement this method for notifications before executing Business Event * Implement this method for notifications before executing Business Event
*/ */
public void businessEventToBeExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity); public void businessEventToBeExecuted(Map<BusinessEntity, Object> businessEventEntity);
/** /**
* Implement this method for notifications after executing Business Event * Implement this method for notifications after executing Business Event
*/ */
public void businessEventWasExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity); public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity);
} }
@@ -19,8 +19,8 @@
package org.apache.fineract.portfolio.common.service; package org.apache.fineract.portfolio.common.service;
import java.util.Map; import java.util.Map;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BUSINESS_ENTITY; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEntity;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BUSINESS_EVENTS; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEvents;
/** /**
* Implemented class is responsible for notifying the business event to * Implemented class is responsible for notifying the business event to
@@ -33,24 +33,24 @@ public interface BusinessEventNotifierService {
* Method should be called to notify listeners before Business event * Method should be called to notify listeners before Business event
* execution for any pre-processing of event * execution for any pre-processing of event
*/ */
public void notifyBusinessEventToBeExecuted(BUSINESS_EVENTS businessEvent, Map<BUSINESS_ENTITY, Object> businessEventEntity); public void notifyBusinessEventToBeExecuted(BusinessEvents businessEvent, Map<BusinessEntity, Object> businessEventEntity);
/** /**
* Method should be called to notify listeners after Business event * Method should be called to notify listeners after Business event
* execution for any post-processing of event * execution for any post-processing of event
*/ */
public void notifyBusinessEventWasExecuted(BUSINESS_EVENTS businessEvent, Map<BUSINESS_ENTITY, Object> businessEventEntity); public void notifyBusinessEventWasExecuted(BusinessEvents businessEvent, Map<BusinessEntity, Object> businessEventEntity);
/** /**
* Method is to register a class as listener for pre-processing of any * Method is to register a class as listener for pre-processing of any
* Business event * Business event
*/ */
public void addBusinessEventPreListners(BUSINESS_EVENTS businessEvent, BusinessEventListner businessEventListner); public void addBusinessEventPreListners(BusinessEvents businessEvent, BusinessEventListner businessEventListner);
/** /**
* Method is to register a class as listener for post-processing of any * Method is to register a class as listener for post-processing of any
* Business event * Business event
*/ */
public void addBusinessEventPostListners(BUSINESS_EVENTS businessEvent, BusinessEventListner businessEventListner); public void addBusinessEventPostListners(BusinessEvents businessEvent, BusinessEventListner businessEventListner);
} }
@@ -22,15 +22,15 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BUSINESS_ENTITY; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEntity;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BUSINESS_EVENTS; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEvents;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@Service @Service
public class BusinessEventNotifierServiceImpl implements BusinessEventNotifierService { public class BusinessEventNotifierServiceImpl implements BusinessEventNotifierService {
private final Map<BUSINESS_EVENTS, List<BusinessEventListner>> preListners = new HashMap<>(5); private final Map<BusinessEvents, List<BusinessEventListner>> preListners = new HashMap<>(5);
private final Map<BUSINESS_EVENTS, List<BusinessEventListner>> postListners = new HashMap<>(5); private final Map<BusinessEvents, List<BusinessEventListner>> postListners = new HashMap<>(5);
/* /*
* (non-Javadoc) * (non-Javadoc)
@@ -39,11 +39,11 @@ public class BusinessEventNotifierServiceImpl implements BusinessEventNotifierSe
* org.apache.fineract.portfolio.common.service.BusinessEventNotifierService * org.apache.fineract.portfolio.common.service.BusinessEventNotifierService
* #notifyBusinessEventToBeExecuted * #notifyBusinessEventToBeExecuted
* (org.apache.fineract.portfolio.common.BusinessEventNotificationConstants * (org.apache.fineract.portfolio.common.BusinessEventNotificationConstants
* .BUSINESS_EVENTS, * .BusinessEvents,
* org.springframework.data.jpa.domain.AbstractPersistable) * org.springframework.data.jpa.domain.AbstractPersistable)
*/ */
@Override @Override
public void notifyBusinessEventToBeExecuted(BUSINESS_EVENTS businessEvent, Map<BUSINESS_ENTITY, Object> businessEventEntity) { public void notifyBusinessEventToBeExecuted(BusinessEvents businessEvent, Map<BusinessEntity, Object> businessEventEntity) {
List<BusinessEventListner> businessEventListners = this.preListners.get(businessEvent); List<BusinessEventListner> businessEventListners = this.preListners.get(businessEvent);
if (businessEventListners != null) { if (businessEventListners != null) {
for (BusinessEventListner eventListner : businessEventListners) { for (BusinessEventListner eventListner : businessEventListners) {
@@ -59,11 +59,11 @@ public class BusinessEventNotifierServiceImpl implements BusinessEventNotifierSe
* org.apache.fineract.portfolio.common.service.BusinessEventNotifierService * org.apache.fineract.portfolio.common.service.BusinessEventNotifierService
* #notifyBusinessEventWasExecuted * #notifyBusinessEventWasExecuted
* (org.apache.fineract.portfolio.common.BusinessEventNotificationConstants * (org.apache.fineract.portfolio.common.BusinessEventNotificationConstants
* .BUSINESS_EVENTS, * .BusinessEvents,
* org.springframework.data.jpa.domain.AbstractPersistable) * org.springframework.data.jpa.domain.AbstractPersistable)
*/ */
@Override @Override
public void notifyBusinessEventWasExecuted(BUSINESS_EVENTS businessEvent, Map<BUSINESS_ENTITY, Object> businessEventEntity) { public void notifyBusinessEventWasExecuted(BusinessEvents businessEvent, Map<BusinessEntity, Object> businessEventEntity) {
List<BusinessEventListner> businessEventListners = this.postListners.get(businessEvent); List<BusinessEventListner> businessEventListners = this.postListners.get(businessEvent);
if (businessEventListners != null) { if (businessEventListners != null) {
for (BusinessEventListner eventListner : businessEventListners) { for (BusinessEventListner eventListner : businessEventListners) {
@@ -79,11 +79,11 @@ public class BusinessEventNotifierServiceImpl implements BusinessEventNotifierSe
* org.apache.fineract.portfolio.common.service.BusinessEventNotifierService * org.apache.fineract.portfolio.common.service.BusinessEventNotifierService
* #addBusinessEventPreListners * #addBusinessEventPreListners
* (org.apache.fineract.portfolio.common.BusinessEventNotificationConstants * (org.apache.fineract.portfolio.common.BusinessEventNotificationConstants
* .BUSINESS_EVENTS, * .BusinessEvents,
* org.apache.fineract.portfolio.common.service.BusinessEventListner) * org.apache.fineract.portfolio.common.service.BusinessEventListner)
*/ */
@Override @Override
public void addBusinessEventPreListners(BUSINESS_EVENTS businessEvent, BusinessEventListner businessEventListner) { public void addBusinessEventPreListners(BusinessEvents businessEvent, BusinessEventListner businessEventListner) {
addBusinessEventListners(businessEvent, businessEventListner, preListners); addBusinessEventListners(businessEvent, businessEventListner, preListners);
} }
@@ -94,16 +94,16 @@ public class BusinessEventNotifierServiceImpl implements BusinessEventNotifierSe
* org.apache.fineract.portfolio.common.service.BusinessEventNotifierService * org.apache.fineract.portfolio.common.service.BusinessEventNotifierService
* #addBusinessEventPostListners * #addBusinessEventPostListners
* (org.apache.fineract.portfolio.common.BusinessEventNotificationConstants * (org.apache.fineract.portfolio.common.BusinessEventNotificationConstants
* .BUSINESS_EVENTS, * .BusinessEvents,
* org.apache.fineract.portfolio.common.service.BusinessEventListner) * org.apache.fineract.portfolio.common.service.BusinessEventListner)
*/ */
@Override @Override
public void addBusinessEventPostListners(BUSINESS_EVENTS businessEvent, BusinessEventListner businessEventListner) { public void addBusinessEventPostListners(BusinessEvents businessEvent, BusinessEventListner businessEventListner) {
addBusinessEventListners(businessEvent, businessEventListner, postListners); addBusinessEventListners(businessEvent, businessEventListner, postListners);
} }
private void addBusinessEventListners(BUSINESS_EVENTS businessEvent, BusinessEventListner businessEventListner, private void addBusinessEventListners(BusinessEvents businessEvent, BusinessEventListner businessEventListner,
final Map<BUSINESS_EVENTS, List<BusinessEventListner>> businessEventListnerMap) { final Map<BusinessEvents, List<BusinessEventListner>> businessEventListnerMap) {
List<BusinessEventListner> businessEventListners = businessEventListnerMap.get(businessEvent); List<BusinessEventListner> businessEventListners = businessEventListnerMap.get(businessEvent);
if (businessEventListners == null) { if (businessEventListners == null) {
businessEventListners = new ArrayList<>(); businessEventListners = new ArrayList<>();
@@ -60,8 +60,8 @@ import org.apache.fineract.portfolio.client.domain.Client;
import org.apache.fineract.portfolio.client.domain.ClientRepositoryWrapper; import org.apache.fineract.portfolio.client.domain.ClientRepositoryWrapper;
import org.apache.fineract.portfolio.client.service.LoanStatusMapper; import org.apache.fineract.portfolio.client.service.LoanStatusMapper;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BUSINESS_ENTITY; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEntity;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BUSINESS_EVENTS; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEvents;
import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService; import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.group.api.GroupingTypesApiConstants; import org.apache.fineract.portfolio.group.api.GroupingTypesApiConstants;
import org.apache.fineract.portfolio.group.domain.Group; import org.apache.fineract.portfolio.group.domain.Group;
@@ -289,8 +289,8 @@ public class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
CommandProcessingResult commandProcessingResult = createGroupingType(command, GroupTypes.CENTER, centerId); CommandProcessingResult commandProcessingResult = createGroupingType(command, GroupTypes.CENTER, centerId);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.CENTERS_CREATE, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.CENTERS_CREATE,
constructEntityMap(BUSINESS_ENTITY.GROUP, commandProcessingResult)); constructEntityMap(BusinessEntity.GROUP, commandProcessingResult));
return commandProcessingResult; return commandProcessingResult;
} }
@@ -307,8 +307,8 @@ public class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
CommandProcessingResult commandProcessingResult = createGroupingType(command, GroupTypes.GROUP, centerId); CommandProcessingResult commandProcessingResult = createGroupingType(command, GroupTypes.GROUP, centerId);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEventNotificationConstants.BUSINESS_EVENTS.GROUPS_CREATE, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEventNotificationConstants.BusinessEvents.GROUPS_CREATE,
constructEntityMap(BUSINESS_ENTITY.GROUP, commandProcessingResult)); constructEntityMap(BusinessEntity.GROUP, commandProcessingResult));
return commandProcessingResult; return commandProcessingResult;
} }
@@ -996,8 +996,8 @@ public class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
} }
} }
private Map<BusinessEventNotificationConstants.BUSINESS_ENTITY, Object> constructEntityMap(final BUSINESS_ENTITY entityEvent, Object entity) { private Map<BusinessEventNotificationConstants.BusinessEntity, Object> constructEntityMap(final BusinessEntity entityEvent, Object entity) {
Map<BUSINESS_ENTITY, Object> map = new HashMap<>(1); Map<BusinessEntity, Object> map = new HashMap<>(1);
map.put(entityEvent, entity); map.put(entityEvent, entity);
return map; return map;
} }
@@ -56,8 +56,8 @@ import org.apache.fineract.portfolio.account.domain.StandingInstructionRepositor
import org.apache.fineract.portfolio.account.domain.StandingInstructionStatus; import org.apache.fineract.portfolio.account.domain.StandingInstructionStatus;
import org.apache.fineract.portfolio.client.domain.Client; import org.apache.fineract.portfolio.client.domain.Client;
import org.apache.fineract.portfolio.client.exception.ClientNotActiveException; import org.apache.fineract.portfolio.client.exception.ClientNotActiveException;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BUSINESS_ENTITY; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEntity;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BUSINESS_EVENTS; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEvents;
import org.apache.fineract.portfolio.common.domain.PeriodFrequencyType; import org.apache.fineract.portfolio.common.domain.PeriodFrequencyType;
import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService; import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.group.domain.Group; import org.apache.fineract.portfolio.group.domain.Group;
@@ -151,8 +151,8 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
Boolean isHolidayValidationDone, final boolean isLoanToLoanTransfer) { Boolean isHolidayValidationDone, final boolean isLoanToLoanTransfer) {
AppUser currentUser = getAppUserIfPresent(); AppUser currentUser = getAppUserIfPresent();
checkClientOrGroupActive(loan); checkClientOrGroupActive(loan);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BUSINESS_EVENTS.LOAN_MAKE_REPAYMENT, this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_MAKE_REPAYMENT,
constructEntityMap(BUSINESS_ENTITY.LOAN, loan)); constructEntityMap(BusinessEntity.LOAN, loan));
// TODO: Is it required to validate transaction date with meeting dates // TODO: Is it required to validate transaction date with meeting dates
// if repayments is synced with meeting? // if repayments is synced with meeting?
@@ -222,8 +222,8 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
recalculateAccruals(loan); recalculateAccruals(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.LOAN_MAKE_REPAYMENT, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_MAKE_REPAYMENT,
constructEntityMap(BUSINESS_ENTITY.LOAN_TRANSACTION, newRepaymentTransaction)); constructEntityMap(BusinessEntity.LOAN_TRANSACTION, newRepaymentTransaction));
// disable all active standing orders linked to this loan if status changes to closed // disable all active standing orders linked to this loan if status changes to closed
disableStandingInstructionsLinkedToClosedLoan(loan); disableStandingInstructionsLinkedToClosedLoan(loan);
@@ -303,8 +303,8 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
AppUser currentUser = getAppUserIfPresent(); AppUser currentUser = getAppUserIfPresent();
boolean isAccountTransfer = true; boolean isAccountTransfer = true;
checkClientOrGroupActive(loan); checkClientOrGroupActive(loan);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BUSINESS_EVENTS.LOAN_CHARGE_PAYMENT, this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_CHARGE_PAYMENT,
constructEntityMap(BUSINESS_ENTITY.LOAN, loan)); constructEntityMap(BusinessEntity.LOAN, loan));
final List<Long> existingTransactionIds = new ArrayList<>(); final List<Long> existingTransactionIds = new ArrayList<>();
final List<Long> existingReversedTransactionIds = new ArrayList<>(); final List<Long> existingReversedTransactionIds = new ArrayList<>();
@@ -339,8 +339,8 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds, isAccountTransfer); postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds, isAccountTransfer);
recalculateAccruals(loan); recalculateAccruals(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.LOAN_CHARGE_PAYMENT, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_CHARGE_PAYMENT,
constructEntityMap(BUSINESS_ENTITY.LOAN_TRANSACTION, newPaymentTransaction)); constructEntityMap(BusinessEntity.LOAN_TRANSACTION, newPaymentTransaction));
return newPaymentTransaction; return newPaymentTransaction;
} }
@@ -385,8 +385,8 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
boolean isAccountTransfer = true; boolean isAccountTransfer = true;
final Loan loan = this.loanAccountAssembler.assembleFrom(accountId); final Loan loan = this.loanAccountAssembler.assembleFrom(accountId);
checkClientOrGroupActive(loan); checkClientOrGroupActive(loan);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BUSINESS_EVENTS.LOAN_REFUND, this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_REFUND,
constructEntityMap(BUSINESS_ENTITY.LOAN, loan)); constructEntityMap(BusinessEntity.LOAN, loan));
final List<Long> existingTransactionIds = new ArrayList<>(); final List<Long> existingTransactionIds = new ArrayList<>();
final List<Long> existingReversedTransactionIds = new ArrayList<>(); final List<Long> existingReversedTransactionIds = new ArrayList<>();
@@ -411,8 +411,8 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
} }
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds, isAccountTransfer); postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds, isAccountTransfer);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.LOAN_REFUND, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_REFUND,
constructEntityMap(BUSINESS_ENTITY.LOAN_TRANSACTION, newRefundTransaction)); constructEntityMap(BusinessEntity.LOAN_TRANSACTION, newRefundTransaction));
builderResult.withEntityId(newRefundTransaction.getId()) builderResult.withEntityId(newRefundTransaction.getId())
.withOfficeId(loan.getOfficeId()) .withOfficeId(loan.getOfficeId())
.withClientId(loan.getClientId()) .withClientId(loan.getClientId())
@@ -575,8 +575,8 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
BigDecimal transactionAmount, PaymentDetail paymentDetail, String noteText, String txnExternalId) { BigDecimal transactionAmount, PaymentDetail paymentDetail, String noteText, String txnExternalId) {
final Loan loan = this.loanAccountAssembler.assembleFrom(accountId); final Loan loan = this.loanAccountAssembler.assembleFrom(accountId);
checkClientOrGroupActive(loan); checkClientOrGroupActive(loan);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BUSINESS_EVENTS.LOAN_REFUND, this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_REFUND,
constructEntityMap(BUSINESS_ENTITY.LOAN, loan)); constructEntityMap(BusinessEntity.LOAN, loan));
final List<Long> existingTransactionIds = new ArrayList<>(); final List<Long> existingTransactionIds = new ArrayList<>();
final List<Long> existingReversedTransactionIds = new ArrayList<>(); final List<Long> existingReversedTransactionIds = new ArrayList<>();
AppUser currentUser = getAppUserIfPresent(); AppUser currentUser = getAppUserIfPresent();
@@ -603,8 +603,8 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds, false); postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds, false);
recalculateAccruals(loan); recalculateAccruals(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.LOAN_REFUND, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_REFUND,
constructEntityMap(BUSINESS_ENTITY.LOAN_TRANSACTION, newRefundTransaction)); constructEntityMap(BusinessEntity.LOAN_TRANSACTION, newRefundTransaction));
builderResult.withEntityId(newRefundTransaction.getId()) builderResult.withEntityId(newRefundTransaction.getId())
.withOfficeId(loan.getOfficeId()) .withOfficeId(loan.getOfficeId())
@@ -616,8 +616,8 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
@Override @Override
public Map<String, Object> foreCloseLoan(final Loan loan, final LocalDate foreClosureDate, final String noteText) { public Map<String, Object> foreCloseLoan(final Loan loan, final LocalDate foreClosureDate, final String noteText) {
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BUSINESS_EVENTS.LOAN_FORECLOSURE, this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_FORECLOSURE,
constructEntityMap(BUSINESS_ENTITY.LOAN, loan)); constructEntityMap(BusinessEntity.LOAN, loan));
MonetaryCurrency currency = loan.getCurrency(); MonetaryCurrency currency = loan.getCurrency();
LocalDateTime createdDate = DateUtils.getLocalDateTimeOfTenant(); LocalDateTime createdDate = DateUtils.getLocalDateTimeOfTenant();
final Map<String, Object> changes = new LinkedHashMap<>(); final Map<String, Object> changes = new LinkedHashMap<>();
@@ -721,14 +721,14 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
} }
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds, false); postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds, false);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.LOAN_FORECLOSURE, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_FORECLOSURE,
constructEntityMap(BUSINESS_ENTITY.LOAN_TRANSACTION, payment)); constructEntityMap(BusinessEntity.LOAN_TRANSACTION, payment));
return changes; return changes;
} }
private Map<BUSINESS_ENTITY, Object> constructEntityMap(final BUSINESS_ENTITY entityEvent, Object entity) { private Map<BusinessEntity, Object> constructEntityMap(final BusinessEntity entityEvent, Object entity) {
Map<BUSINESS_ENTITY, Object> map = new HashMap<>(1); Map<BusinessEntity, Object> map = new HashMap<>(1);
map.put(entityEvent, entity); map.put(entityEvent, entity);
return map; return map;
} }
@@ -28,7 +28,7 @@ public class GuarantorConstants {
/*** /***
* Enum of all parameters passed in while creating/updating a loan product * Enum of all parameters passed in while creating/updating a loan product
***/ ***/
public enum GUARANTOR_JSON_INPUT_PARAMS { public enum GuarantorJSONinputParams {
LOAN_ID("loanId"), CLIENT_RELATIONSHIP_TYPE_ID("clientRelationshipTypeId"), GUARANTOR_TYPE_ID("guarantorTypeId"), ENTITY_ID( LOAN_ID("loanId"), CLIENT_RELATIONSHIP_TYPE_ID("clientRelationshipTypeId"), GUARANTOR_TYPE_ID("guarantorTypeId"), ENTITY_ID(
"entityId"), FIRSTNAME("firstname"), LASTNAME("lastname"), ADDRESS_LINE_1("addressLine1"), ADDRESS_LINE_2("addressLine2"), CITY( "entityId"), FIRSTNAME("firstname"), LASTNAME("lastname"), ADDRESS_LINE_1("addressLine1"), ADDRESS_LINE_2("addressLine2"), CITY(
"city"), STATE("state"), ZIP("zip"), COUNTRY("country"), MOBILE_NUMBER("mobileNumber"), PHONE_NUMBER("housePhoneNumber"), COMMENT( "city"), STATE("state"), ZIP("zip"), COUNTRY("country"), MOBILE_NUMBER("mobileNumber"), PHONE_NUMBER("housePhoneNumber"), COMMENT(
@@ -36,13 +36,13 @@ public class GuarantorConstants {
private final String value; private final String value;
GUARANTOR_JSON_INPUT_PARAMS(final String value) { GuarantorJSONinputParams(final String value) {
this.value = value; this.value = value;
} }
private static final Set<String> values = new HashSet<>(); private static final Set<String> values = new HashSet<>();
static { static {
for (final GUARANTOR_JSON_INPUT_PARAMS type : GUARANTOR_JSON_INPUT_PARAMS.values()) { for (final GuarantorJSONinputParams type : GuarantorJSONinputParams.values()) {
values.add(type.value); values.add(type.value);
} }
} }
@@ -25,7 +25,7 @@ import java.util.List;
import org.apache.fineract.infrastructure.core.data.ApiParameterError; import org.apache.fineract.infrastructure.core.data.ApiParameterError;
import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder; import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder;
import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException; import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException;
import org.apache.fineract.portfolio.loanaccount.guarantor.GuarantorConstants.GUARANTOR_JSON_INPUT_PARAMS; import org.apache.fineract.portfolio.loanaccount.guarantor.GuarantorConstants.GuarantorJSONinputParams;
import org.apache.fineract.portfolio.loanaccount.guarantor.domain.GuarantorType; import org.apache.fineract.portfolio.loanaccount.guarantor.domain.GuarantorType;
import org.joda.time.LocalDate; import org.joda.time.LocalDate;
@@ -99,27 +99,27 @@ public class GuarantorCommand {
final DataValidatorBuilder baseDataValidator = getDataValidator(dataValidationErrors); final DataValidatorBuilder baseDataValidator = getDataValidator(dataValidationErrors);
baseDataValidator.reset().parameter(GUARANTOR_JSON_INPUT_PARAMS.CLIENT_RELATIONSHIP_TYPE_ID.getValue()) baseDataValidator.reset().parameter(GuarantorJSONinputParams.CLIENT_RELATIONSHIP_TYPE_ID.getValue())
.value(this.clientRelationshipTypeId).ignoreIfNull().integerGreaterThanZero(); .value(this.clientRelationshipTypeId).ignoreIfNull().integerGreaterThanZero();
baseDataValidator.reset().parameter(GUARANTOR_JSON_INPUT_PARAMS.GUARANTOR_TYPE_ID.getValue()).value(this.guarantorTypeId).notNull() baseDataValidator.reset().parameter(GuarantorJSONinputParams.GUARANTOR_TYPE_ID.getValue()).value(this.guarantorTypeId).notNull()
.inMinMaxRange(GuarantorType.getMinValue(), GuarantorType.getMaxValue()); .inMinMaxRange(GuarantorType.getMinValue(), GuarantorType.getMaxValue());
// validate for existing Client or Staff serving as gurantor // validate for existing Client or Staff serving as gurantor
if (!isExternalGuarantor()) { if (!isExternalGuarantor()) {
baseDataValidator.reset().parameter(GUARANTOR_JSON_INPUT_PARAMS.ENTITY_ID.getValue()).value(this.entityId).notNull() baseDataValidator.reset().parameter(GuarantorJSONinputParams.ENTITY_ID.getValue()).value(this.entityId).notNull()
.integerGreaterThanZero(); .integerGreaterThanZero();
baseDataValidator.reset().parameter(GUARANTOR_JSON_INPUT_PARAMS.SAVINGS_ID.getValue()).value(this.savingsId) baseDataValidator.reset().parameter(GuarantorJSONinputParams.SAVINGS_ID.getValue()).value(this.savingsId)
.longGreaterThanZero(); .longGreaterThanZero();
if (this.savingsId != null) { if (this.savingsId != null) {
baseDataValidator.reset().parameter(GUARANTOR_JSON_INPUT_PARAMS.AMOUNT.getValue()).value(this.amount).notNull() baseDataValidator.reset().parameter(GuarantorJSONinputParams.AMOUNT.getValue()).value(this.amount).notNull()
.positiveAmount(); .positiveAmount();
} }
} else { } else {
// validate for an external guarantor // validate for an external guarantor
baseDataValidator.reset().parameter(GUARANTOR_JSON_INPUT_PARAMS.FIRSTNAME.getValue()).value(this.firstname).notBlank() baseDataValidator.reset().parameter(GuarantorJSONinputParams.FIRSTNAME.getValue()).value(this.firstname).notBlank()
.notExceedingLengthOf(50); .notExceedingLengthOf(50);
baseDataValidator.reset().parameter(GUARANTOR_JSON_INPUT_PARAMS.LASTNAME.getValue()).value(this.lastname).notBlank() baseDataValidator.reset().parameter(GuarantorJSONinputParams.LASTNAME.getValue()).value(this.lastname).notBlank()
.notExceedingLengthOf(50); .notExceedingLengthOf(50);
validateNonMandatoryFieldsForMaxLength(baseDataValidator); validateNonMandatoryFieldsForMaxLength(baseDataValidator);
} }
@@ -133,20 +133,20 @@ public class GuarantorCommand {
final DataValidatorBuilder baseDataValidator = getDataValidator(dataValidationErrors); final DataValidatorBuilder baseDataValidator = getDataValidator(dataValidationErrors);
baseDataValidator.reset().parameter(GUARANTOR_JSON_INPUT_PARAMS.CLIENT_RELATIONSHIP_TYPE_ID.getValue()) baseDataValidator.reset().parameter(GuarantorJSONinputParams.CLIENT_RELATIONSHIP_TYPE_ID.getValue())
.value(this.clientRelationshipTypeId).ignoreIfNull().integerGreaterThanZero(); .value(this.clientRelationshipTypeId).ignoreIfNull().integerGreaterThanZero();
baseDataValidator.reset().parameter(GUARANTOR_JSON_INPUT_PARAMS.GUARANTOR_TYPE_ID.getValue()).value(this.guarantorTypeId) baseDataValidator.reset().parameter(GuarantorJSONinputParams.GUARANTOR_TYPE_ID.getValue()).value(this.guarantorTypeId)
.ignoreIfNull().inMinMaxRange(GuarantorType.getMinValue(), GuarantorType.getMaxValue()); .ignoreIfNull().inMinMaxRange(GuarantorType.getMinValue(), GuarantorType.getMaxValue());
// validate for existing Client or Staff serving as gurantor // validate for existing Client or Staff serving as gurantor
if (!isExternalGuarantor()) { if (!isExternalGuarantor()) {
baseDataValidator.reset().parameter(GUARANTOR_JSON_INPUT_PARAMS.ENTITY_ID.getValue()).value(this.entityId).ignoreIfNull() baseDataValidator.reset().parameter(GuarantorJSONinputParams.ENTITY_ID.getValue()).value(this.entityId).ignoreIfNull()
.integerGreaterThanZero(); .integerGreaterThanZero();
baseDataValidator.reset().parameter(GUARANTOR_JSON_INPUT_PARAMS.SAVINGS_ID.getValue()).value(this.savingsId) baseDataValidator.reset().parameter(GuarantorJSONinputParams.SAVINGS_ID.getValue()).value(this.savingsId)
.longGreaterThanZero(); .longGreaterThanZero();
if (this.savingsId != null) { if (this.savingsId != null) {
baseDataValidator.reset().parameter(GUARANTOR_JSON_INPUT_PARAMS.AMOUNT.getValue()).value(this.amount).notNull() baseDataValidator.reset().parameter(GuarantorJSONinputParams.AMOUNT.getValue()).value(this.amount).notNull()
.positiveAmount(); .positiveAmount();
} }
} else { } else {
@@ -155,9 +155,9 @@ public class GuarantorCommand {
// firstname and last name when a guarantor type is changed), to be // firstname and last name when a guarantor type is changed), to be
// corrected while // corrected while
// refactoring for maker checker // refactoring for maker checker
baseDataValidator.reset().parameter(GUARANTOR_JSON_INPUT_PARAMS.FIRSTNAME.getValue()).value(this.firstname).ignoreIfNull() baseDataValidator.reset().parameter(GuarantorJSONinputParams.FIRSTNAME.getValue()).value(this.firstname).ignoreIfNull()
.notExceedingLengthOf(50); .notExceedingLengthOf(50);
baseDataValidator.reset().parameter(GUARANTOR_JSON_INPUT_PARAMS.LASTNAME.getValue()).value(this.lastname).ignoreIfNull() baseDataValidator.reset().parameter(GuarantorJSONinputParams.LASTNAME.getValue()).value(this.lastname).ignoreIfNull()
.notExceedingLengthOf(50); .notExceedingLengthOf(50);
validateNonMandatoryFieldsForMaxLength(baseDataValidator); validateNonMandatoryFieldsForMaxLength(baseDataValidator);
@@ -174,23 +174,23 @@ public class GuarantorCommand {
*/ */
private void validateNonMandatoryFieldsForMaxLength(final DataValidatorBuilder baseDataValidator) { private void validateNonMandatoryFieldsForMaxLength(final DataValidatorBuilder baseDataValidator) {
// validate non mandatory fields for length // validate non mandatory fields for length
baseDataValidator.reset().parameter(GUARANTOR_JSON_INPUT_PARAMS.ADDRESS_LINE_1.getValue()).value(this.addressLine1).ignoreIfNull() baseDataValidator.reset().parameter(GuarantorJSONinputParams.ADDRESS_LINE_1.getValue()).value(this.addressLine1).ignoreIfNull()
.notExceedingLengthOf(500); .notExceedingLengthOf(500);
baseDataValidator.reset().parameter(GUARANTOR_JSON_INPUT_PARAMS.ADDRESS_LINE_2.getValue()).value(this.addressLine2).ignoreIfNull() baseDataValidator.reset().parameter(GuarantorJSONinputParams.ADDRESS_LINE_2.getValue()).value(this.addressLine2).ignoreIfNull()
.notExceedingLengthOf(500); .notExceedingLengthOf(500);
baseDataValidator.reset().parameter(GUARANTOR_JSON_INPUT_PARAMS.CITY.getValue()).value(this.city).ignoreIfNull() baseDataValidator.reset().parameter(GuarantorJSONinputParams.CITY.getValue()).value(this.city).ignoreIfNull()
.notExceedingLengthOf(50); .notExceedingLengthOf(50);
baseDataValidator.reset().parameter(GUARANTOR_JSON_INPUT_PARAMS.STATE.getValue()).value(this.state).ignoreIfNull() baseDataValidator.reset().parameter(GuarantorJSONinputParams.STATE.getValue()).value(this.state).ignoreIfNull()
.notExceedingLengthOf(50); .notExceedingLengthOf(50);
baseDataValidator.reset().parameter(GUARANTOR_JSON_INPUT_PARAMS.ZIP.getValue()).value(this.zip).ignoreIfNull() baseDataValidator.reset().parameter(GuarantorJSONinputParams.ZIP.getValue()).value(this.zip).ignoreIfNull()
.notExceedingLengthOf(50); .notExceedingLengthOf(50);
baseDataValidator.reset().parameter(GUARANTOR_JSON_INPUT_PARAMS.COUNTRY.getValue()).value(this.country).ignoreIfNull() baseDataValidator.reset().parameter(GuarantorJSONinputParams.COUNTRY.getValue()).value(this.country).ignoreIfNull()
.notExceedingLengthOf(50); .notExceedingLengthOf(50);
baseDataValidator.reset().parameter(GUARANTOR_JSON_INPUT_PARAMS.MOBILE_NUMBER.getValue()).value(this.mobileNumber).ignoreIfNull() baseDataValidator.reset().parameter(GuarantorJSONinputParams.MOBILE_NUMBER.getValue()).value(this.mobileNumber).ignoreIfNull()
.notExceedingLengthOf(20).validatePhoneNumber(); .notExceedingLengthOf(20).validatePhoneNumber();
baseDataValidator.reset().parameter(GUARANTOR_JSON_INPUT_PARAMS.PHONE_NUMBER.getValue()).value(this.housePhoneNumber) baseDataValidator.reset().parameter(GuarantorJSONinputParams.PHONE_NUMBER.getValue()).value(this.housePhoneNumber)
.ignoreIfNull().notExceedingLengthOf(20).validatePhoneNumber(); .ignoreIfNull().notExceedingLengthOf(20).validatePhoneNumber();
baseDataValidator.reset().parameter(GUARANTOR_JSON_INPUT_PARAMS.COMMENT.getValue()).value(this.comment).ignoreIfNull() baseDataValidator.reset().parameter(GuarantorJSONinputParams.COMMENT.getValue()).value(this.comment).ignoreIfNull()
.notExceedingLengthOf(500); .notExceedingLengthOf(500);
} }
@@ -38,7 +38,7 @@ import org.apache.fineract.infrastructure.codes.domain.CodeValue;
import org.apache.fineract.infrastructure.core.api.JsonCommand; import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom; import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
import org.apache.fineract.portfolio.loanaccount.domain.Loan; import org.apache.fineract.portfolio.loanaccount.domain.Loan;
import org.apache.fineract.portfolio.loanaccount.guarantor.GuarantorConstants.GUARANTOR_JSON_INPUT_PARAMS; import org.apache.fineract.portfolio.loanaccount.guarantor.GuarantorConstants.GuarantorJSONinputParams;
@Entity @Entity
@Table(name = "m_guarantor") @Table(name = "m_guarantor")
@@ -132,23 +132,23 @@ public class Guarantor extends AbstractPersistableCustom {
public static Guarantor fromJson(final Loan loan, final CodeValue clientRelationshipType, final JsonCommand command, public static Guarantor fromJson(final Loan loan, final CodeValue clientRelationshipType, final JsonCommand command,
final List<GuarantorFundingDetails> fundingDetails) { final List<GuarantorFundingDetails> fundingDetails) {
final Integer gurantorType = command.integerValueSansLocaleOfParameterNamed(GUARANTOR_JSON_INPUT_PARAMS.GUARANTOR_TYPE_ID final Integer gurantorType = command.integerValueSansLocaleOfParameterNamed(GuarantorJSONinputParams.GUARANTOR_TYPE_ID
.getValue()); .getValue());
final Long entityId = command.longValueOfParameterNamed(GUARANTOR_JSON_INPUT_PARAMS.ENTITY_ID.getValue()); final Long entityId = command.longValueOfParameterNamed(GuarantorJSONinputParams.ENTITY_ID.getValue());
final boolean active = true; final boolean active = true;
if (GuarantorType.EXTERNAL.getValue().equals(gurantorType)) { if (GuarantorType.EXTERNAL.getValue().equals(gurantorType)) {
final String firstname = command.stringValueOfParameterNamed(GUARANTOR_JSON_INPUT_PARAMS.FIRSTNAME.getValue()); final String firstname = command.stringValueOfParameterNamed(GuarantorJSONinputParams.FIRSTNAME.getValue());
final String lastname = command.stringValueOfParameterNamed(GUARANTOR_JSON_INPUT_PARAMS.LASTNAME.getValue()); final String lastname = command.stringValueOfParameterNamed(GuarantorJSONinputParams.LASTNAME.getValue());
final Date dateOfBirth = command.DateValueOfParameterNamed(GUARANTOR_JSON_INPUT_PARAMS.DATE_OF_BIRTH.getValue()); final Date dateOfBirth = command.DateValueOfParameterNamed(GuarantorJSONinputParams.DATE_OF_BIRTH.getValue());
final String addressLine1 = command.stringValueOfParameterNamed(GUARANTOR_JSON_INPUT_PARAMS.ADDRESS_LINE_1.getValue()); final String addressLine1 = command.stringValueOfParameterNamed(GuarantorJSONinputParams.ADDRESS_LINE_1.getValue());
final String addressLine2 = command.stringValueOfParameterNamed(GUARANTOR_JSON_INPUT_PARAMS.ADDRESS_LINE_2.getValue()); final String addressLine2 = command.stringValueOfParameterNamed(GuarantorJSONinputParams.ADDRESS_LINE_2.getValue());
final String city = command.stringValueOfParameterNamed(GUARANTOR_JSON_INPUT_PARAMS.CITY.getValue()); final String city = command.stringValueOfParameterNamed(GuarantorJSONinputParams.CITY.getValue());
final String state = command.stringValueOfParameterNamed(GUARANTOR_JSON_INPUT_PARAMS.STATE.getValue()); final String state = command.stringValueOfParameterNamed(GuarantorJSONinputParams.STATE.getValue());
final String country = command.stringValueOfParameterNamed(GUARANTOR_JSON_INPUT_PARAMS.COUNTRY.getValue()); final String country = command.stringValueOfParameterNamed(GuarantorJSONinputParams.COUNTRY.getValue());
final String zip = command.stringValueOfParameterNamed(GUARANTOR_JSON_INPUT_PARAMS.ZIP.getValue()); final String zip = command.stringValueOfParameterNamed(GuarantorJSONinputParams.ZIP.getValue());
final String housePhoneNumber = command.stringValueOfParameterNamed(GUARANTOR_JSON_INPUT_PARAMS.PHONE_NUMBER.getValue()); final String housePhoneNumber = command.stringValueOfParameterNamed(GuarantorJSONinputParams.PHONE_NUMBER.getValue());
final String mobilePhoneNumber = command.stringValueOfParameterNamed(GUARANTOR_JSON_INPUT_PARAMS.MOBILE_NUMBER.getValue()); final String mobilePhoneNumber = command.stringValueOfParameterNamed(GuarantorJSONinputParams.MOBILE_NUMBER.getValue());
final String comment = command.stringValueOfParameterNamed(GUARANTOR_JSON_INPUT_PARAMS.COMMENT.getValue()); final String comment = command.stringValueOfParameterNamed(GuarantorJSONinputParams.COMMENT.getValue());
return new Guarantor(loan, clientRelationshipType, gurantorType, entityId, firstname, lastname, dateOfBirth, addressLine1, return new Guarantor(loan, clientRelationshipType, gurantorType, entityId, firstname, lastname, dateOfBirth, addressLine1,
addressLine2, city, state, country, zip, housePhoneNumber, mobilePhoneNumber, comment, active, fundingDetails); addressLine2, city, state, country, zip, housePhoneNumber, mobilePhoneNumber, comment, active, fundingDetails);
@@ -163,21 +163,21 @@ public class Guarantor extends AbstractPersistableCustom {
final Map<String, Object> actualChanges = new LinkedHashMap<>(); final Map<String, Object> actualChanges = new LinkedHashMap<>();
handlePropertyUpdate(command, actualChanges, GUARANTOR_JSON_INPUT_PARAMS.CLIENT_RELATIONSHIP_TYPE_ID.getValue(), 0, true); handlePropertyUpdate(command, actualChanges, GuarantorJSONinputParams.CLIENT_RELATIONSHIP_TYPE_ID.getValue(), 0, true);
if (isExternalGuarantor()) { if (isExternalGuarantor()) {
handlePropertyUpdate(command, actualChanges, GUARANTOR_JSON_INPUT_PARAMS.FIRSTNAME.getValue(), this.firstname); handlePropertyUpdate(command, actualChanges, GuarantorJSONinputParams.FIRSTNAME.getValue(), this.firstname);
handlePropertyUpdate(command, actualChanges, GUARANTOR_JSON_INPUT_PARAMS.LASTNAME.getValue(), this.lastname); handlePropertyUpdate(command, actualChanges, GuarantorJSONinputParams.LASTNAME.getValue(), this.lastname);
handlePropertyUpdate(command, actualChanges, GUARANTOR_JSON_INPUT_PARAMS.DATE_OF_BIRTH.getValue(), this.dateOfBirth); handlePropertyUpdate(command, actualChanges, GuarantorJSONinputParams.DATE_OF_BIRTH.getValue(), this.dateOfBirth);
handlePropertyUpdate(command, actualChanges, GUARANTOR_JSON_INPUT_PARAMS.ADDRESS_LINE_1.getValue(), this.addressLine1); handlePropertyUpdate(command, actualChanges, GuarantorJSONinputParams.ADDRESS_LINE_1.getValue(), this.addressLine1);
handlePropertyUpdate(command, actualChanges, GUARANTOR_JSON_INPUT_PARAMS.ADDRESS_LINE_2.getValue(), this.addressLine2); handlePropertyUpdate(command, actualChanges, GuarantorJSONinputParams.ADDRESS_LINE_2.getValue(), this.addressLine2);
handlePropertyUpdate(command, actualChanges, GUARANTOR_JSON_INPUT_PARAMS.CITY.getValue(), this.city); handlePropertyUpdate(command, actualChanges, GuarantorJSONinputParams.CITY.getValue(), this.city);
handlePropertyUpdate(command, actualChanges, GUARANTOR_JSON_INPUT_PARAMS.STATE.getValue(), this.state); handlePropertyUpdate(command, actualChanges, GuarantorJSONinputParams.STATE.getValue(), this.state);
handlePropertyUpdate(command, actualChanges, GUARANTOR_JSON_INPUT_PARAMS.COUNTRY.getValue(), this.country); handlePropertyUpdate(command, actualChanges, GuarantorJSONinputParams.COUNTRY.getValue(), this.country);
handlePropertyUpdate(command, actualChanges, GUARANTOR_JSON_INPUT_PARAMS.ZIP.getValue(), this.zip); handlePropertyUpdate(command, actualChanges, GuarantorJSONinputParams.ZIP.getValue(), this.zip);
handlePropertyUpdate(command, actualChanges, GUARANTOR_JSON_INPUT_PARAMS.PHONE_NUMBER.getValue(), this.housePhoneNumber); handlePropertyUpdate(command, actualChanges, GuarantorJSONinputParams.PHONE_NUMBER.getValue(), this.housePhoneNumber);
handlePropertyUpdate(command, actualChanges, GUARANTOR_JSON_INPUT_PARAMS.MOBILE_NUMBER.getValue(), this.mobilePhoneNumber); handlePropertyUpdate(command, actualChanges, GuarantorJSONinputParams.MOBILE_NUMBER.getValue(), this.mobilePhoneNumber);
handlePropertyUpdate(command, actualChanges, GUARANTOR_JSON_INPUT_PARAMS.COMMENT.getValue(), this.comment); handlePropertyUpdate(command, actualChanges, GuarantorJSONinputParams.COMMENT.getValue(), this.comment);
updateExistingEntityToNull(); updateExistingEntityToNull();
} }
@@ -209,7 +209,7 @@ public class Guarantor extends AbstractPersistableCustom {
//propertyToBeUpdated = newValue; //propertyToBeUpdated = newValue;
// now update actual property // now update actual property
if (paramName.equals(GUARANTOR_JSON_INPUT_PARAMS.GUARANTOR_TYPE_ID.getValue())) { if (paramName.equals(GuarantorJSONinputParams.GUARANTOR_TYPE_ID.getValue())) {
this.gurantorType = newValue; this.gurantorType = newValue;
} }
} }
@@ -223,27 +223,27 @@ public class Guarantor extends AbstractPersistableCustom {
//propertyToBeUpdated = newValue; //propertyToBeUpdated = newValue;
// now update actual property // now update actual property
if (paramName.equals(GUARANTOR_JSON_INPUT_PARAMS.FIRSTNAME.getValue())) { if (paramName.equals(GuarantorJSONinputParams.FIRSTNAME.getValue())) {
this.firstname = newValue; this.firstname = newValue;
} else if (paramName.equals(GUARANTOR_JSON_INPUT_PARAMS.LASTNAME.getValue())) { } else if (paramName.equals(GuarantorJSONinputParams.LASTNAME.getValue())) {
this.lastname = newValue; this.lastname = newValue;
} else if (paramName.equals(GUARANTOR_JSON_INPUT_PARAMS.ADDRESS_LINE_1.getValue())) { } else if (paramName.equals(GuarantorJSONinputParams.ADDRESS_LINE_1.getValue())) {
this.addressLine1 = newValue; this.addressLine1 = newValue;
} else if (paramName.equals(GUARANTOR_JSON_INPUT_PARAMS.ADDRESS_LINE_2.getValue())) { } else if (paramName.equals(GuarantorJSONinputParams.ADDRESS_LINE_2.getValue())) {
this.addressLine2 = newValue; this.addressLine2 = newValue;
} else if (paramName.equals(GUARANTOR_JSON_INPUT_PARAMS.CITY.getValue())) { } else if (paramName.equals(GuarantorJSONinputParams.CITY.getValue())) {
this.city = newValue; this.city = newValue;
} else if (paramName.equals(GUARANTOR_JSON_INPUT_PARAMS.STATE.getValue())) { } else if (paramName.equals(GuarantorJSONinputParams.STATE.getValue())) {
this.state = newValue; this.state = newValue;
} else if (paramName.equals(GUARANTOR_JSON_INPUT_PARAMS.COUNTRY.getValue())) { } else if (paramName.equals(GuarantorJSONinputParams.COUNTRY.getValue())) {
this.country = newValue; this.country = newValue;
} else if (paramName.equals(GUARANTOR_JSON_INPUT_PARAMS.ZIP.getValue())) { } else if (paramName.equals(GuarantorJSONinputParams.ZIP.getValue())) {
this.zip = newValue; this.zip = newValue;
} else if (paramName.equals(GUARANTOR_JSON_INPUT_PARAMS.PHONE_NUMBER.getValue())) { } else if (paramName.equals(GuarantorJSONinputParams.PHONE_NUMBER.getValue())) {
this.housePhoneNumber = newValue; this.housePhoneNumber = newValue;
} else if (paramName.equals(GUARANTOR_JSON_INPUT_PARAMS.MOBILE_NUMBER.getValue())) { } else if (paramName.equals(GuarantorJSONinputParams.MOBILE_NUMBER.getValue())) {
this.mobilePhoneNumber = newValue; this.mobilePhoneNumber = newValue;
} else if (paramName.equals(GUARANTOR_JSON_INPUT_PARAMS.COMMENT.getValue())) { } else if (paramName.equals(GuarantorJSONinputParams.COMMENT.getValue())) {
this.comment = newValue; this.comment = newValue;
} }
} }
@@ -257,7 +257,7 @@ public class Guarantor extends AbstractPersistableCustom {
//propertyToBeUpdated = newValue; //propertyToBeUpdated = newValue;
// now update actual property // now update actual property
if (paramName.equals(GUARANTOR_JSON_INPUT_PARAMS.DATE_OF_BIRTH.getValue())) { if (paramName.equals(GuarantorJSONinputParams.DATE_OF_BIRTH.getValue())) {
this.dateOfBirth = newValue; this.dateOfBirth = newValue;
} }
} }
@@ -30,7 +30,7 @@ import org.apache.fineract.infrastructure.core.exception.InvalidJsonException;
import org.apache.fineract.infrastructure.core.serialization.AbstractFromApiJsonDeserializer; import org.apache.fineract.infrastructure.core.serialization.AbstractFromApiJsonDeserializer;
import org.apache.fineract.infrastructure.core.serialization.FromApiJsonDeserializer; import org.apache.fineract.infrastructure.core.serialization.FromApiJsonDeserializer;
import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper; import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
import org.apache.fineract.portfolio.loanaccount.guarantor.GuarantorConstants.GUARANTOR_JSON_INPUT_PARAMS; import org.apache.fineract.portfolio.loanaccount.guarantor.GuarantorConstants.GuarantorJSONinputParams;
import org.apache.fineract.portfolio.loanaccount.guarantor.command.GuarantorCommand; import org.apache.fineract.portfolio.loanaccount.guarantor.command.GuarantorCommand;
import org.joda.time.LocalDate; import org.joda.time.LocalDate;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -55,7 +55,7 @@ public final class GuarantorCommandFromApiJsonDeserializer extends AbstractFromA
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();
final Set<String> supportedParameters = GUARANTOR_JSON_INPUT_PARAMS.getAllValues(); final Set<String> supportedParameters = GuarantorJSONinputParams.getAllValues();
supportedParameters.add("locale"); supportedParameters.add("locale");
supportedParameters.add("dateFormat"); supportedParameters.add("dateFormat");
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, supportedParameters); this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, supportedParameters);
@@ -69,29 +69,29 @@ public final class GuarantorCommandFromApiJsonDeserializer extends AbstractFromA
private GuarantorCommand extractGuarantorCommand(final JsonElement element, final Locale locale, final String dateFormat) { private GuarantorCommand extractGuarantorCommand(final JsonElement element, final Locale locale, final String dateFormat) {
final Long clientRelationshipTypeId = this.fromApiJsonHelper.extractLongNamed( final Long clientRelationshipTypeId = this.fromApiJsonHelper.extractLongNamed(
GUARANTOR_JSON_INPUT_PARAMS.CLIENT_RELATIONSHIP_TYPE_ID.getValue(), element); GuarantorJSONinputParams.CLIENT_RELATIONSHIP_TYPE_ID.getValue(), element);
final Integer guarantorTypeId = this.fromApiJsonHelper.extractIntegerSansLocaleNamed( final Integer guarantorTypeId = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(
GUARANTOR_JSON_INPUT_PARAMS.GUARANTOR_TYPE_ID.getValue(), element); GuarantorJSONinputParams.GUARANTOR_TYPE_ID.getValue(), element);
final Long entityId = this.fromApiJsonHelper.extractLongNamed(GUARANTOR_JSON_INPUT_PARAMS.ENTITY_ID.getValue(), element); final Long entityId = this.fromApiJsonHelper.extractLongNamed(GuarantorJSONinputParams.ENTITY_ID.getValue(), element);
final String firstname = this.fromApiJsonHelper.extractStringNamed(GUARANTOR_JSON_INPUT_PARAMS.FIRSTNAME.getValue(), element); final String firstname = this.fromApiJsonHelper.extractStringNamed(GuarantorJSONinputParams.FIRSTNAME.getValue(), element);
final String lastname = this.fromApiJsonHelper.extractStringNamed(GUARANTOR_JSON_INPUT_PARAMS.LASTNAME.getValue(), element); final String lastname = this.fromApiJsonHelper.extractStringNamed(GuarantorJSONinputParams.LASTNAME.getValue(), element);
final String addressLine1 = this.fromApiJsonHelper.extractStringNamed(GUARANTOR_JSON_INPUT_PARAMS.ADDRESS_LINE_1.getValue(), final String addressLine1 = this.fromApiJsonHelper.extractStringNamed(GuarantorJSONinputParams.ADDRESS_LINE_1.getValue(),
element); element);
final String addressLine2 = this.fromApiJsonHelper.extractStringNamed(GUARANTOR_JSON_INPUT_PARAMS.ADDRESS_LINE_2.getValue(), final String addressLine2 = this.fromApiJsonHelper.extractStringNamed(GuarantorJSONinputParams.ADDRESS_LINE_2.getValue(),
element); element);
final String city = this.fromApiJsonHelper.extractStringNamed(GUARANTOR_JSON_INPUT_PARAMS.CITY.getValue(), element); final String city = this.fromApiJsonHelper.extractStringNamed(GuarantorJSONinputParams.CITY.getValue(), element);
final String state = this.fromApiJsonHelper.extractStringNamed(GUARANTOR_JSON_INPUT_PARAMS.STATE.getValue(), element); final String state = this.fromApiJsonHelper.extractStringNamed(GuarantorJSONinputParams.STATE.getValue(), element);
final String zip = this.fromApiJsonHelper.extractStringNamed(GUARANTOR_JSON_INPUT_PARAMS.ZIP.getValue(), element); final String zip = this.fromApiJsonHelper.extractStringNamed(GuarantorJSONinputParams.ZIP.getValue(), element);
final String country = this.fromApiJsonHelper.extractStringNamed(GUARANTOR_JSON_INPUT_PARAMS.COUNTRY.getValue(), element); final String country = this.fromApiJsonHelper.extractStringNamed(GuarantorJSONinputParams.COUNTRY.getValue(), element);
final String mobileNumber = this.fromApiJsonHelper final String mobileNumber = this.fromApiJsonHelper
.extractStringNamed(GUARANTOR_JSON_INPUT_PARAMS.MOBILE_NUMBER.getValue(), element); .extractStringNamed(GuarantorJSONinputParams.MOBILE_NUMBER.getValue(), element);
final String housePhoneNumber = this.fromApiJsonHelper.extractStringNamed(GUARANTOR_JSON_INPUT_PARAMS.PHONE_NUMBER.getValue(), final String housePhoneNumber = this.fromApiJsonHelper.extractStringNamed(GuarantorJSONinputParams.PHONE_NUMBER.getValue(),
element); element);
final String comment = this.fromApiJsonHelper.extractStringNamed(GUARANTOR_JSON_INPUT_PARAMS.COMMENT.getValue(), element); final String comment = this.fromApiJsonHelper.extractStringNamed(GuarantorJSONinputParams.COMMENT.getValue(), element);
final LocalDate dob = this.fromApiJsonHelper.extractLocalDateNamed(GUARANTOR_JSON_INPUT_PARAMS.DATE_OF_BIRTH.getValue(), element, final LocalDate dob = this.fromApiJsonHelper.extractLocalDateNamed(GuarantorJSONinputParams.DATE_OF_BIRTH.getValue(), element,
dateFormat, locale); dateFormat, locale);
final Long savingsId = this.fromApiJsonHelper.extractLongNamed(GUARANTOR_JSON_INPUT_PARAMS.SAVINGS_ID.getValue(), element); final Long savingsId = this.fromApiJsonHelper.extractLongNamed(GuarantorJSONinputParams.SAVINGS_ID.getValue(), element);
final BigDecimal amount = this.fromApiJsonHelper.extractBigDecimalNamed(GUARANTOR_JSON_INPUT_PARAMS.AMOUNT.getValue(), element, final BigDecimal amount = this.fromApiJsonHelper.extractBigDecimalNamed(GuarantorJSONinputParams.AMOUNT.getValue(), element,
locale); locale);
return new GuarantorCommand(clientRelationshipTypeId, guarantorTypeId, entityId, firstname, lastname, addressLine1, addressLine2, return new GuarantorCommand(clientRelationshipTypeId, guarantorTypeId, entityId, firstname, lastname, addressLine1, addressLine2,
@@ -35,8 +35,8 @@ import org.apache.fineract.portfolio.account.data.AccountTransferDTO;
import org.apache.fineract.portfolio.account.domain.AccountTransferDetails; import org.apache.fineract.portfolio.account.domain.AccountTransferDetails;
import org.apache.fineract.portfolio.account.domain.AccountTransferType; import org.apache.fineract.portfolio.account.domain.AccountTransferType;
import org.apache.fineract.portfolio.account.service.AccountTransfersWritePlatformService; import org.apache.fineract.portfolio.account.service.AccountTransfersWritePlatformService;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BUSINESS_ENTITY; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEntity;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BUSINESS_EVENTS; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEvents;
import org.apache.fineract.portfolio.common.service.BusinessEventListner; import org.apache.fineract.portfolio.common.service.BusinessEventListner;
import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService; import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.loanaccount.domain.Loan; import org.apache.fineract.portfolio.loanaccount.domain.Loan;
@@ -94,17 +94,17 @@ public class GuarantorDomainServiceImpl implements GuarantorDomainService {
@PostConstruct @PostConstruct
public void addListners() { public void addListners() {
this.businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.LOAN_APPROVED, new ValidateOnBusinessEvent()); this.businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.LOAN_APPROVED, new ValidateOnBusinessEvent());
this.businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.LOAN_APPROVED, new HoldFundsOnBusinessEvent()); this.businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.LOAN_APPROVED, new HoldFundsOnBusinessEvent());
this.businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.LOAN_UNDO_APPROVAL, new UndoAllFundTransactions()); this.businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.LOAN_UNDO_APPROVAL, new UndoAllFundTransactions());
this.businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.LOAN_UNDO_DISBURSAL, this.businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.LOAN_UNDO_DISBURSAL,
new ReverseAllFundsOnBusinessEvent()); new ReverseAllFundsOnBusinessEvent());
this.businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.LOAN_ADJUST_TRANSACTION, this.businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.LOAN_ADJUST_TRANSACTION,
new AdjustFundsOnBusinessEvent()); new AdjustFundsOnBusinessEvent());
this.businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.LOAN_MAKE_REPAYMENT, this.businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.LOAN_MAKE_REPAYMENT,
new ReleaseFundsOnBusinessEvent()); new ReleaseFundsOnBusinessEvent());
this.businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.LOAN_WRITTEN_OFF, new ReleaseAllFunds()); this.businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.LOAN_WRITTEN_OFF, new ReleaseAllFunds());
this.businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.LOAN_UNDO_WRITTEN_OFF, this.businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.LOAN_UNDO_WRITTEN_OFF,
new ReverseFundsOnBusinessEvent()); new ReverseFundsOnBusinessEvent());
} }
@@ -531,11 +531,11 @@ public class GuarantorDomainServiceImpl implements GuarantorDomainService {
private class ValidateOnBusinessEvent implements BusinessEventListner { private class ValidateOnBusinessEvent implements BusinessEventListner {
@Override @Override
public void businessEventToBeExecuted(@SuppressWarnings("unused") Map<BUSINESS_ENTITY, Object> businessEventEntity) {} public void businessEventToBeExecuted(@SuppressWarnings("unused") Map<BusinessEntity, Object> businessEventEntity) {}
@Override @Override
public void businessEventWasExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Object entity = businessEventEntity.get(BUSINESS_ENTITY.LOAN); Object entity = businessEventEntity.get(BusinessEntity.LOAN);
if (entity instanceof Loan) { if (entity instanceof Loan) {
Loan loan = (Loan) entity; Loan loan = (Loan) entity;
validateGuarantorBusinessRules(loan); validateGuarantorBusinessRules(loan);
@@ -546,11 +546,11 @@ public class GuarantorDomainServiceImpl implements GuarantorDomainService {
private class HoldFundsOnBusinessEvent implements BusinessEventListner { private class HoldFundsOnBusinessEvent implements BusinessEventListner {
@Override @Override
public void businessEventToBeExecuted(@SuppressWarnings("unused") Map<BUSINESS_ENTITY, Object> businessEventEntity) {} public void businessEventToBeExecuted(@SuppressWarnings("unused") Map<BusinessEntity, Object> businessEventEntity) {}
@Override @Override
public void businessEventWasExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Object entity = businessEventEntity.get(BUSINESS_ENTITY.LOAN); Object entity = businessEventEntity.get(BusinessEntity.LOAN);
if (entity instanceof Loan) { if (entity instanceof Loan) {
Loan loan = (Loan) entity; Loan loan = (Loan) entity;
holdGuarantorFunds(loan); holdGuarantorFunds(loan);
@@ -561,11 +561,11 @@ public class GuarantorDomainServiceImpl implements GuarantorDomainService {
private class ReleaseFundsOnBusinessEvent implements BusinessEventListner { private class ReleaseFundsOnBusinessEvent implements BusinessEventListner {
@Override @Override
public void businessEventToBeExecuted(@SuppressWarnings("unused") Map<BUSINESS_ENTITY, Object> businessEventEntity) {} public void businessEventToBeExecuted(@SuppressWarnings("unused") Map<BusinessEntity, Object> businessEventEntity) {}
@Override @Override
public void businessEventWasExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Object entity = businessEventEntity.get(BUSINESS_ENTITY.LOAN_TRANSACTION); Object entity = businessEventEntity.get(BusinessEntity.LOAN_TRANSACTION);
if (entity instanceof LoanTransaction) { if (entity instanceof LoanTransaction) {
LoanTransaction loanTransaction = (LoanTransaction) entity; LoanTransaction loanTransaction = (LoanTransaction) entity;
if (releaseLoanIds.containsKey(loanTransaction.getLoan().getId())) { if (releaseLoanIds.containsKey(loanTransaction.getLoan().getId())) {
@@ -580,11 +580,11 @@ public class GuarantorDomainServiceImpl implements GuarantorDomainService {
private class ReverseFundsOnBusinessEvent implements BusinessEventListner { private class ReverseFundsOnBusinessEvent implements BusinessEventListner {
@Override @Override
public void businessEventToBeExecuted(@SuppressWarnings("unused") Map<BUSINESS_ENTITY, Object> businessEventEntity) {} public void businessEventToBeExecuted(@SuppressWarnings("unused") Map<BusinessEntity, Object> businessEventEntity) {}
@Override @Override
public void businessEventWasExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Object entity = businessEventEntity.get(BUSINESS_ENTITY.LOAN_TRANSACTION); Object entity = businessEventEntity.get(BusinessEntity.LOAN_TRANSACTION);
if (entity instanceof LoanTransaction) { if (entity instanceof LoanTransaction) {
LoanTransaction loanTransaction = (LoanTransaction) entity; LoanTransaction loanTransaction = (LoanTransaction) entity;
List<Long> reersedTransactions = new ArrayList<>(1); List<Long> reersedTransactions = new ArrayList<>(1);
@@ -597,18 +597,18 @@ public class GuarantorDomainServiceImpl implements GuarantorDomainService {
private class AdjustFundsOnBusinessEvent implements BusinessEventListner { private class AdjustFundsOnBusinessEvent implements BusinessEventListner {
@Override @Override
public void businessEventToBeExecuted(@SuppressWarnings("unused") Map<BUSINESS_ENTITY, Object> businessEventEntity) {} public void businessEventToBeExecuted(@SuppressWarnings("unused") Map<BusinessEntity, Object> businessEventEntity) {}
@Override @Override
public void businessEventWasExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Object entity = businessEventEntity.get(BUSINESS_ENTITY.LOAN_ADJUSTED_TRANSACTION); Object entity = businessEventEntity.get(BusinessEntity.LOAN_ADJUSTED_TRANSACTION);
if (entity instanceof LoanTransaction) { if (entity instanceof LoanTransaction) {
LoanTransaction loanTransaction = (LoanTransaction) entity; LoanTransaction loanTransaction = (LoanTransaction) entity;
List<Long> reersedTransactions = new ArrayList<>(1); List<Long> reersedTransactions = new ArrayList<>(1);
reersedTransactions.add(loanTransaction.getId()); reersedTransactions.add(loanTransaction.getId());
reverseTransaction(reersedTransactions); reverseTransaction(reersedTransactions);
} }
Object transactionentity = businessEventEntity.get(BUSINESS_ENTITY.LOAN_TRANSACTION); Object transactionentity = businessEventEntity.get(BusinessEntity.LOAN_TRANSACTION);
if (transactionentity != null && transactionentity instanceof LoanTransaction) { if (transactionentity != null && transactionentity instanceof LoanTransaction) {
LoanTransaction loanTransaction = (LoanTransaction) transactionentity; LoanTransaction loanTransaction = (LoanTransaction) transactionentity;
releaseGuarantorFunds(loanTransaction); releaseGuarantorFunds(loanTransaction);
@@ -619,11 +619,11 @@ public class GuarantorDomainServiceImpl implements GuarantorDomainService {
private class ReverseAllFundsOnBusinessEvent implements BusinessEventListner { private class ReverseAllFundsOnBusinessEvent implements BusinessEventListner {
@Override @Override
public void businessEventToBeExecuted(@SuppressWarnings("unused") Map<BUSINESS_ENTITY, Object> businessEventEntity) {} public void businessEventToBeExecuted(@SuppressWarnings("unused") Map<BusinessEntity, Object> businessEventEntity) {}
@Override @Override
public void businessEventWasExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Object entity = businessEventEntity.get(BUSINESS_ENTITY.LOAN); Object entity = businessEventEntity.get(BusinessEntity.LOAN);
if (entity instanceof Loan) { if (entity instanceof Loan) {
Loan loan = (Loan) entity; Loan loan = (Loan) entity;
List<Long> reersedTransactions = new ArrayList<>(1); List<Long> reersedTransactions = new ArrayList<>(1);
@@ -636,11 +636,11 @@ public class GuarantorDomainServiceImpl implements GuarantorDomainService {
private class UndoAllFundTransactions implements BusinessEventListner { private class UndoAllFundTransactions implements BusinessEventListner {
@Override @Override
public void businessEventToBeExecuted(@SuppressWarnings("unused") Map<BUSINESS_ENTITY, Object> businessEventEntity) {} public void businessEventToBeExecuted(@SuppressWarnings("unused") Map<BusinessEntity, Object> businessEventEntity) {}
@Override @Override
public void businessEventWasExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Object entity = businessEventEntity.get(BUSINESS_ENTITY.LOAN); Object entity = businessEventEntity.get(BusinessEntity.LOAN);
if (entity instanceof Loan) { if (entity instanceof Loan) {
Loan loan = (Loan) entity; Loan loan = (Loan) entity;
reverseAllFundTransaction(loan); reverseAllFundTransaction(loan);
@@ -651,11 +651,11 @@ public class GuarantorDomainServiceImpl implements GuarantorDomainService {
private class ReleaseAllFunds implements BusinessEventListner { private class ReleaseAllFunds implements BusinessEventListner {
@Override @Override
public void businessEventToBeExecuted(@SuppressWarnings("unused") Map<BUSINESS_ENTITY, Object> businessEventEntity) {} public void businessEventToBeExecuted(@SuppressWarnings("unused") Map<BusinessEntity, Object> businessEventEntity) {}
@Override @Override
public void businessEventWasExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Object entity = businessEventEntity.get(BUSINESS_ENTITY.LOAN_TRANSACTION); Object entity = businessEventEntity.get(BusinessEntity.LOAN_TRANSACTION);
if (entity instanceof LoanTransaction) { if (entity instanceof LoanTransaction) {
LoanTransaction loanTransaction = (LoanTransaction) entity; LoanTransaction loanTransaction = (LoanTransaction) entity;
releaseAllGuarantors(loanTransaction); releaseAllGuarantors(loanTransaction);
@@ -40,7 +40,7 @@ import org.apache.fineract.portfolio.client.domain.ClientRepositoryWrapper;
import org.apache.fineract.portfolio.loanaccount.domain.Loan; import org.apache.fineract.portfolio.loanaccount.domain.Loan;
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepositoryWrapper; import org.apache.fineract.portfolio.loanaccount.domain.LoanRepositoryWrapper;
import org.apache.fineract.portfolio.loanaccount.guarantor.GuarantorConstants; import org.apache.fineract.portfolio.loanaccount.guarantor.GuarantorConstants;
import org.apache.fineract.portfolio.loanaccount.guarantor.GuarantorConstants.GUARANTOR_JSON_INPUT_PARAMS; import org.apache.fineract.portfolio.loanaccount.guarantor.GuarantorConstants.GuarantorJSONinputParams;
import org.apache.fineract.portfolio.loanaccount.guarantor.command.GuarantorCommand; import org.apache.fineract.portfolio.loanaccount.guarantor.command.GuarantorCommand;
import org.apache.fineract.portfolio.loanaccount.guarantor.domain.Guarantor; import org.apache.fineract.portfolio.loanaccount.guarantor.domain.Guarantor;
import org.apache.fineract.portfolio.loanaccount.guarantor.domain.GuarantorFundStatusType; import org.apache.fineract.portfolio.loanaccount.guarantor.domain.GuarantorFundStatusType;
@@ -202,7 +202,7 @@ public class GuarantorWritePlatformServiceJpaRepositoryIImpl implements Guaranto
final Map<String, Object> changesOnly = guarantorForUpdate.update(command); final Map<String, Object> changesOnly = guarantorForUpdate.update(command);
if (changesOnly.containsKey(GUARANTOR_JSON_INPUT_PARAMS.CLIENT_RELATIONSHIP_TYPE_ID.getValue())) { if (changesOnly.containsKey(GuarantorJSONinputParams.CLIENT_RELATIONSHIP_TYPE_ID.getValue())) {
final Long clientRelationshipId = guarantorCommand.getClientRelationshipTypeId(); final Long clientRelationshipId = guarantorCommand.getClientRelationshipTypeId();
CodeValue clientRelationshipType = null; CodeValue clientRelationshipType = null;
if (clientRelationshipId != null) { if (clientRelationshipId != null) {
@@ -228,8 +228,8 @@ public class GuarantorWritePlatformServiceJpaRepositoryIImpl implements Guaranto
} }
} }
if (changesOnly.containsKey(GUARANTOR_JSON_INPUT_PARAMS.ENTITY_ID.getValue()) if (changesOnly.containsKey(GuarantorJSONinputParams.ENTITY_ID.getValue())
|| changesOnly.containsKey(GUARANTOR_JSON_INPUT_PARAMS.GUARANTOR_TYPE_ID.getValue())) { || changesOnly.containsKey(GuarantorJSONinputParams.GUARANTOR_TYPE_ID.getValue())) {
validateGuarantorBusinessRules(guarantorForUpdate); validateGuarantorBusinessRules(guarantorForUpdate);
} }
@@ -81,8 +81,8 @@ import org.apache.fineract.portfolio.client.domain.ClientRepositoryWrapper;
import org.apache.fineract.portfolio.client.exception.ClientNotActiveException; import org.apache.fineract.portfolio.client.exception.ClientNotActiveException;
import org.apache.fineract.portfolio.collateral.domain.LoanCollateral; import org.apache.fineract.portfolio.collateral.domain.LoanCollateral;
import org.apache.fineract.portfolio.collateral.service.CollateralAssembler; import org.apache.fineract.portfolio.collateral.service.CollateralAssembler;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BUSINESS_ENTITY; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEntity;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BUSINESS_EVENTS; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEvents;
import org.apache.fineract.portfolio.common.domain.PeriodFrequencyType; import org.apache.fineract.portfolio.common.domain.PeriodFrequencyType;
import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService; import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.fund.domain.Fund; import org.apache.fineract.portfolio.fund.domain.Fund;
@@ -585,8 +585,8 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
EntityTables.LOAN.getName(), StatusEnum.CREATE.getCode().longValue(), EntityTables.LOAN.getName(), StatusEnum.CREATE.getCode().longValue(),
EntityTables.LOAN.getForeignKeyColumnNameOnDatatable(), newLoanApplication.productId()); EntityTables.LOAN.getForeignKeyColumnNameOnDatatable(), newLoanApplication.productId());
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.LOAN_CREATE, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_CREATE,
constructEntityMap(BUSINESS_ENTITY.LOAN, newLoanApplication)); constructEntityMap(BusinessEntity.LOAN, newLoanApplication));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
@@ -1434,8 +1434,8 @@ public void checkForProductMixRestrictions(final Loan loan) {
this.noteRepository.save(note); this.noteRepository.save(note);
} }
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.LOAN_APPROVED, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_APPROVED,
constructEntityMap(BUSINESS_ENTITY.LOAN, loan)); constructEntityMap(BusinessEntity.LOAN, loan));
} }
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
@@ -1516,8 +1516,8 @@ public void checkForProductMixRestrictions(final Loan loan) {
final Note note = Note.loanNote(loan, noteText); final Note note = Note.loanNote(loan, noteText);
this.noteRepository.save(note); this.noteRepository.save(note);
} }
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.LOAN_UNDO_APPROVAL, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_UNDO_APPROVAL,
constructEntityMap(BUSINESS_ENTITY.LOAN, loan)); constructEntityMap(BusinessEntity.LOAN, loan));
} }
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
@@ -1591,7 +1591,7 @@ public void checkForProductMixRestrictions(final Loan loan) {
this.noteRepository.save(note); this.noteRepository.save(note);
} }
} }
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.LOAN_REJECTED, constructEntityMap(BUSINESS_ENTITY.LOAN, loan)); this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_REJECTED, constructEntityMap(BusinessEntity.LOAN, loan));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
.withEntityId(loan.getId()) // .withEntityId(loan.getId()) //
@@ -1712,8 +1712,8 @@ public void checkForProductMixRestrictions(final Loan loan) {
return user; return user;
} }
private Map<BUSINESS_ENTITY, Object> constructEntityMap(final BUSINESS_ENTITY entityEvent, Object entity) { private Map<BusinessEntity, Object> constructEntityMap(final BusinessEntity entityEvent, Object entity) {
Map<BUSINESS_ENTITY, Object> map = new HashMap<>(1); Map<BusinessEntity, Object> map = new HashMap<>(1);
map.put(entityEvent, entity); map.put(entityEvent, entity);
return map; return map;
} }
@@ -31,8 +31,8 @@ import org.apache.fineract.infrastructure.core.service.RoutingDataSource;
import org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil; import org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil;
import org.apache.fineract.infrastructure.jobs.annotation.CronTarget; import org.apache.fineract.infrastructure.jobs.annotation.CronTarget;
import org.apache.fineract.infrastructure.jobs.service.JobName; import org.apache.fineract.infrastructure.jobs.service.JobName;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BUSINESS_ENTITY; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEntity;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BUSINESS_EVENTS; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEvents;
import org.apache.fineract.portfolio.common.service.BusinessEventListner; import org.apache.fineract.portfolio.common.service.BusinessEventListner;
import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService; import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.loanaccount.domain.Loan; import org.apache.fineract.portfolio.loanaccount.domain.Loan;
@@ -69,17 +69,17 @@ public class LoanArrearsAgingServiceImpl implements LoanArrearsAgingService, Bus
@PostConstruct @PostConstruct
public void registerForNotification() { public void registerForNotification() {
this.businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.LOAN_REFUND, this); this.businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.LOAN_REFUND, this);
this.businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.LOAN_ADJUST_TRANSACTION, this); this.businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.LOAN_ADJUST_TRANSACTION, this);
this.businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.LOAN_MAKE_REPAYMENT, this); this.businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.LOAN_MAKE_REPAYMENT, this);
this.businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.LOAN_UNDO_WRITTEN_OFF, this); this.businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.LOAN_UNDO_WRITTEN_OFF, this);
this.businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.LOAN_WAIVE_INTEREST, this); this.businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.LOAN_WAIVE_INTEREST, this);
this.businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.LOAN_ADD_CHARGE, this); this.businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.LOAN_ADD_CHARGE, this);
this.businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.LOAN_WAIVE_CHARGE, this); this.businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.LOAN_WAIVE_CHARGE, this);
this.businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.LOAN_CHARGE_PAYMENT, this); this.businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.LOAN_CHARGE_PAYMENT, this);
this.businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.LOAN_APPLY_OVERDUE_CHARGE, this); this.businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.LOAN_APPLY_OVERDUE_CHARGE, this);
this.businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.LOAN_DISBURSAL, new DisbursementEventListner()); this.businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.LOAN_DISBURSAL, new DisbursementEventListner());
this.businessEventNotifierService.addBusinessEventPostListners(BUSINESS_EVENTS.LOAN_FORECLOSURE, this); this.businessEventNotifierService.addBusinessEventPostListners(BusinessEvents.LOAN_FORECLOSURE, this);
} }
@Transactional @Transactional
@@ -461,18 +461,18 @@ public class LoanArrearsAgingServiceImpl implements LoanArrearsAgingService, Bus
@SuppressWarnings("unused") @SuppressWarnings("unused")
@Override @Override
public void businessEventToBeExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventToBeExecuted(Map<BusinessEntity, Object> businessEventEntity) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
@Override @Override
public void businessEventWasExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Loan loan = null; Loan loan = null;
Object loanEntity = businessEventEntity.get(BUSINESS_ENTITY.LOAN); Object loanEntity = businessEventEntity.get(BusinessEntity.LOAN);
Object loanTransactionEntity = businessEventEntity.get(BUSINESS_ENTITY.LOAN_TRANSACTION); Object loanTransactionEntity = businessEventEntity.get(BusinessEntity.LOAN_TRANSACTION);
Object loanAdjustTransactionEntity = businessEventEntity.get(BUSINESS_ENTITY.LOAN_ADJUSTED_TRANSACTION); Object loanAdjustTransactionEntity = businessEventEntity.get(BusinessEntity.LOAN_ADJUSTED_TRANSACTION);
Object loanChargeEntity = businessEventEntity.get(BUSINESS_ENTITY.LOAN_CHARGE); Object loanChargeEntity = businessEventEntity.get(BusinessEntity.LOAN_CHARGE);
if (loanEntity != null) { if (loanEntity != null) {
loan = (Loan) loanEntity; loan = (Loan) loanEntity;
} else if (loanTransactionEntity != null) { } else if (loanTransactionEntity != null) {
@@ -497,14 +497,14 @@ public class LoanArrearsAgingServiceImpl implements LoanArrearsAgingService, Bus
@SuppressWarnings("unused") @SuppressWarnings("unused")
@Override @Override
public void businessEventToBeExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventToBeExecuted(Map<BusinessEntity, Object> businessEventEntity) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
@Override @Override
public void businessEventWasExecuted(Map<BUSINESS_ENTITY, Object> businessEventEntity) { public void businessEventWasExecuted(Map<BusinessEntity, Object> businessEventEntity) {
Object loanEntity = businessEventEntity.get(BUSINESS_ENTITY.LOAN); Object loanEntity = businessEventEntity.get(BusinessEntity.LOAN);
if (loanEntity != null) { if (loanEntity != null) {
Loan loan = (Loan) loanEntity; Loan loan = (Loan) loanEntity;
updateLoanArrearsAgeingDetails(loan); updateLoanArrearsAgeingDetails(loan);
@@ -332,7 +332,7 @@ public class LoanAssembler {
if (loanOfficerId != null) { if (loanOfficerId != null) {
staff = this.staffRepository.findById(loanOfficerId) staff = this.staffRepository.findById(loanOfficerId)
.orElseThrow(() -> new StaffNotFoundException(loanOfficerId)); .orElseThrow(() -> new StaffNotFoundException(loanOfficerId));
if (staff.isNotLoanOfficer()) { throw new StaffRoleException(loanOfficerId, StaffRoleException.STAFF_ROLE.LOAN_OFFICER); } if (staff.isNotLoanOfficer()) { throw new StaffRoleException(loanOfficerId, StaffRoleException.StaffRole.LOAN_OFFICER); }
} }
return staff; return staff;
} }
@@ -99,13 +99,13 @@ import org.apache.fineract.portfolio.charge.domain.ChargeRepositoryWrapper;
import org.apache.fineract.portfolio.charge.exception.ChargeCannotBeUpdatedException; import org.apache.fineract.portfolio.charge.exception.ChargeCannotBeUpdatedException;
import org.apache.fineract.portfolio.charge.exception.LoanChargeCannotBeAddedException; import org.apache.fineract.portfolio.charge.exception.LoanChargeCannotBeAddedException;
import org.apache.fineract.portfolio.charge.exception.LoanChargeCannotBeDeletedException; import org.apache.fineract.portfolio.charge.exception.LoanChargeCannotBeDeletedException;
import org.apache.fineract.portfolio.charge.exception.LoanChargeCannotBeDeletedException.LOAN_CHARGE_CANNOT_BE_DELETED_REASON; import org.apache.fineract.portfolio.charge.exception.LoanChargeCannotBeDeletedException.LoanChargeCannotBeDeletedReason;
import org.apache.fineract.portfolio.charge.exception.LoanChargeCannotBePayedException; import org.apache.fineract.portfolio.charge.exception.LoanChargeCannotBePayedException;
import org.apache.fineract.portfolio.charge.exception.LoanChargeCannotBePayedException.LOAN_CHARGE_CANNOT_BE_PAYED_REASON; import org.apache.fineract.portfolio.charge.exception.LoanChargeCannotBePayedException.LoanChargeCannotBePayedReason;
import org.apache.fineract.portfolio.charge.exception.LoanChargeCannotBeUpdatedException; import org.apache.fineract.portfolio.charge.exception.LoanChargeCannotBeUpdatedException;
import org.apache.fineract.portfolio.charge.exception.LoanChargeCannotBeUpdatedException.LOAN_CHARGE_CANNOT_BE_UPDATED_REASON; import org.apache.fineract.portfolio.charge.exception.LoanChargeCannotBeUpdatedException.LoanChargeCannotBeUpdatedReason;
import org.apache.fineract.portfolio.charge.exception.LoanChargeCannotBeWaivedException; import org.apache.fineract.portfolio.charge.exception.LoanChargeCannotBeWaivedException;
import org.apache.fineract.portfolio.charge.exception.LoanChargeCannotBeWaivedException.LOAN_CHARGE_CANNOT_BE_WAIVED_REASON; import org.apache.fineract.portfolio.charge.exception.LoanChargeCannotBeWaivedException.LoanChargeCannotBeWaivedReason;
import org.apache.fineract.portfolio.charge.exception.LoanChargeNotFoundException; import org.apache.fineract.portfolio.charge.exception.LoanChargeNotFoundException;
import org.apache.fineract.portfolio.client.domain.Client; import org.apache.fineract.portfolio.client.domain.Client;
import org.apache.fineract.portfolio.client.exception.ClientNotActiveException; import org.apache.fineract.portfolio.client.exception.ClientNotActiveException;
@@ -113,8 +113,8 @@ import org.apache.fineract.portfolio.collectionsheet.command.CollectionSheetBulk
import org.apache.fineract.portfolio.collectionsheet.command.CollectionSheetBulkRepaymentCommand; import org.apache.fineract.portfolio.collectionsheet.command.CollectionSheetBulkRepaymentCommand;
import org.apache.fineract.portfolio.collectionsheet.command.SingleDisbursalCommand; import org.apache.fineract.portfolio.collectionsheet.command.SingleDisbursalCommand;
import org.apache.fineract.portfolio.collectionsheet.command.SingleRepaymentCommand; import org.apache.fineract.portfolio.collectionsheet.command.SingleRepaymentCommand;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BUSINESS_ENTITY; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEntity;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BUSINESS_EVENTS; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEvents;
import org.apache.fineract.portfolio.common.domain.PeriodFrequencyType; import org.apache.fineract.portfolio.common.domain.PeriodFrequencyType;
import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService; import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.group.domain.Group; import org.apache.fineract.portfolio.group.domain.Group;
@@ -387,8 +387,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
scheduleGeneratorDTO.isSkipRepaymentOnFirstDayofMonth(), scheduleGeneratorDTO.getNumberOfdays()); scheduleGeneratorDTO.isSkipRepaymentOnFirstDayofMonth(), scheduleGeneratorDTO.getNumberOfdays());
} }
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BUSINESS_EVENTS.LOAN_DISBURSAL, this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_DISBURSAL,
constructEntityMap(BUSINESS_ENTITY.LOAN, loan)); constructEntityMap(BusinessEntity.LOAN, loan));
final List<Long> existingTransactionIds = new ArrayList<>(); final List<Long> existingTransactionIds = new ArrayList<>();
final List<Long> existingReversedTransactionIds = new ArrayList<>(); final List<Long> existingReversedTransactionIds = new ArrayList<>();
@@ -518,8 +518,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
updateRecurringCalendarDatesForInterestRecalculation(loan); updateRecurringCalendarDatesForInterestRecalculation(loan);
this.loanAccountDomainService.recalculateAccruals(loan); this.loanAccountDomainService.recalculateAccruals(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.LOAN_DISBURSAL, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_DISBURSAL,
constructEntityMap(BUSINESS_ENTITY.LOAN, loan)); constructEntityMap(BusinessEntity.LOAN, loan));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
.withEntityId(loan.getId()) // .withEntityId(loan.getId()) //
@@ -668,8 +668,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
syncExpectedDateWithActualDisbursementDate(loan, actualDisbursementDate); syncExpectedDateWithActualDisbursementDate(loan, actualDisbursementDate);
} }
checkClientOrGroupActive(loan); checkClientOrGroupActive(loan);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BUSINESS_EVENTS.LOAN_DISBURSAL, this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_DISBURSAL,
constructEntityMap(BUSINESS_ENTITY.LOAN, loan)); constructEntityMap(BusinessEntity.LOAN, loan));
final List<Long> existingTransactionIds = new ArrayList<>(); final List<Long> existingTransactionIds = new ArrayList<>();
final List<Long> existingReversedTransactionIds = new ArrayList<>(); final List<Long> existingReversedTransactionIds = new ArrayList<>();
@@ -759,8 +759,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
} }
updateRecurringCalendarDatesForInterestRecalculation(loan); updateRecurringCalendarDatesForInterestRecalculation(loan);
this.loanAccountDomainService.recalculateAccruals(loan); this.loanAccountDomainService.recalculateAccruals(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.LOAN_DISBURSAL, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_DISBURSAL,
constructEntityMap(BUSINESS_ENTITY.LOAN, loan)); constructEntityMap(BusinessEntity.LOAN, loan));
} }
return changes; return changes;
@@ -801,8 +801,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final AppUser currentUser = getAppUserIfPresent(); final AppUser currentUser = getAppUserIfPresent();
final Loan loan = this.loanAssembler.assembleFrom(loanId); final Loan loan = this.loanAssembler.assembleFrom(loanId);
checkClientOrGroupActive(loan); checkClientOrGroupActive(loan);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BUSINESS_EVENTS.LOAN_UNDO_DISBURSAL, this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_UNDO_DISBURSAL,
constructEntityMap(BUSINESS_ENTITY.LOAN, loan)); constructEntityMap(BusinessEntity.LOAN, loan));
removeLoanCycle(loan); removeLoanCycle(loan);
final List<Long> existingTransactionIds = new ArrayList<>(); final List<Long> existingTransactionIds = new ArrayList<>();
final List<Long> existingReversedTransactionIds = new ArrayList<>(); final List<Long> existingReversedTransactionIds = new ArrayList<>();
@@ -832,8 +832,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final Map<String, Object> accountingBridgeData = loan.deriveAccountingBridgeData(applicationCurrency.toData(), final Map<String, Object> accountingBridgeData = loan.deriveAccountingBridgeData(applicationCurrency.toData(),
existingTransactionIds, existingReversedTransactionIds, isAccountTransfer); existingTransactionIds, existingReversedTransactionIds, isAccountTransfer);
this.journalEntryWritePlatformService.createJournalEntriesForLoan(accountingBridgeData); this.journalEntryWritePlatformService.createJournalEntriesForLoan(accountingBridgeData);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.LOAN_UNDO_DISBURSAL, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_UNDO_DISBURSAL,
constructEntityMap(BUSINESS_ENTITY.LOAN, loan)); constructEntityMap(BusinessEntity.LOAN, loan));
} }
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
@@ -983,8 +983,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
checkClientOrGroupActive(loan); checkClientOrGroupActive(loan);
final LoanTransaction transactionToAdjust = this.loanTransactionRepository.findById(transactionId) final LoanTransaction transactionToAdjust = this.loanTransactionRepository.findById(transactionId)
.orElseThrow(() -> new LoanTransactionNotFoundException(transactionId)); .orElseThrow(() -> new LoanTransactionNotFoundException(transactionId));
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BUSINESS_EVENTS.LOAN_ADJUST_TRANSACTION, this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_ADJUST_TRANSACTION,
constructEntityMap(BUSINESS_ENTITY.LOAN_ADJUSTED_TRANSACTION, transactionToAdjust)); constructEntityMap(BusinessEntity.LOAN_ADJUSTED_TRANSACTION, transactionToAdjust));
if (this.accountTransfersReadPlatformService.isAccountTransfer(transactionId, PortfolioAccountType.LOAN)) { throw new PlatformServiceUnavailableException( if (this.accountTransfersReadPlatformService.isAccountTransfer(transactionId, PortfolioAccountType.LOAN)) { throw new PlatformServiceUnavailableException(
"error.msg.loan.transfer.transaction.update.not.allowed", "Loan transaction:" + transactionId "error.msg.loan.transfer.transaction.update.not.allowed", "Loan transaction:" + transactionId
+ " update not allowed as it involves in account transfer", transactionId); } + " update not allowed as it involves in account transfer", transactionId); }
@@ -1093,11 +1093,11 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds); postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds);
this.loanAccountDomainService.recalculateAccruals(loan); this.loanAccountDomainService.recalculateAccruals(loan);
Map<BUSINESS_ENTITY, Object> entityMap = constructEntityMap(BUSINESS_ENTITY.LOAN_ADJUSTED_TRANSACTION, transactionToAdjust); Map<BusinessEntity, Object> entityMap = constructEntityMap(BusinessEntity.LOAN_ADJUSTED_TRANSACTION, transactionToAdjust);
if (newTransactionDetail.isRepayment() && newTransactionDetail.isGreaterThanZero(loan.getPrincpal().getCurrency())) { if (newTransactionDetail.isRepayment() && newTransactionDetail.isGreaterThanZero(loan.getPrincpal().getCurrency())) {
entityMap.put(BUSINESS_ENTITY.LOAN_TRANSACTION, newTransactionDetail); entityMap.put(BusinessEntity.LOAN_TRANSACTION, newTransactionDetail);
} }
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.LOAN_ADJUST_TRANSACTION, entityMap); this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_ADJUST_TRANSACTION, entityMap);
return new CommandProcessingResultBuilder() return new CommandProcessingResultBuilder()
.withCommandId(command.commandId()) .withCommandId(command.commandId())
@@ -1144,8 +1144,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
} }
final LoanTransaction waiveInterestTransaction = LoanTransaction.waiver(loan.getOffice(), loan, transactionAmountAsMoney, final LoanTransaction waiveInterestTransaction = LoanTransaction.waiver(loan.getOffice(), loan, transactionAmountAsMoney,
transactionDate, interestComponent, unrecognizedIncome, DateUtils.getLocalDateTimeOfTenant(), currentUser); transactionDate, interestComponent, unrecognizedIncome, DateUtils.getLocalDateTimeOfTenant(), currentUser);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BUSINESS_EVENTS.LOAN_WAIVE_INTEREST, this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_WAIVE_INTEREST,
constructEntityMap(BUSINESS_ENTITY.LOAN_TRANSACTION, waiveInterestTransaction)); constructEntityMap(BusinessEntity.LOAN_TRANSACTION, waiveInterestTransaction));
LocalDate recalculateFrom = null; LocalDate recalculateFrom = null;
if (loan.repaymentScheduleDetail().isInterestRecalculationEnabled()) { if (loan.repaymentScheduleDetail().isInterestRecalculationEnabled()) {
recalculateFrom = transactionDate; recalculateFrom = transactionDate;
@@ -1184,8 +1184,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds); postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds);
this.loanAccountDomainService.recalculateAccruals(loan); this.loanAccountDomainService.recalculateAccruals(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.LOAN_WAIVE_INTEREST, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_WAIVE_INTEREST,
constructEntityMap(BUSINESS_ENTITY.LOAN_TRANSACTION, waiveInterestTransaction)); constructEntityMap(BusinessEntity.LOAN_TRANSACTION, waiveInterestTransaction));
return new CommandProcessingResultBuilder() return new CommandProcessingResultBuilder()
.withCommandId(command.commandId()) .withCommandId(command.commandId())
.withEntityId(waiveInterestTransaction.getId()) .withEntityId(waiveInterestTransaction.getId())
@@ -1217,8 +1217,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
} }
checkClientOrGroupActive(loan); checkClientOrGroupActive(loan);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BUSINESS_EVENTS.LOAN_WRITTEN_OFF, this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_WRITTEN_OFF,
constructEntityMap(BUSINESS_ENTITY.LOAN, loan)); constructEntityMap(BusinessEntity.LOAN, loan));
entityDatatableChecksWritePlatformService.runTheCheckForProduct(loanId, EntityTables.LOAN.getName(), entityDatatableChecksWritePlatformService.runTheCheckForProduct(loanId, EntityTables.LOAN.getName(),
StatusEnum.WRITE_OFF.getCode().longValue(), EntityTables.LOAN.getForeignKeyColumnNameOnDatatable(), loan.productId()); StatusEnum.WRITE_OFF.getCode().longValue(), EntityTables.LOAN.getForeignKeyColumnNameOnDatatable(), loan.productId());
@@ -1254,8 +1254,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds); postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds);
this.loanAccountDomainService.recalculateAccruals(loan); this.loanAccountDomainService.recalculateAccruals(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.LOAN_WRITTEN_OFF, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_WRITTEN_OFF,
constructEntityMap(BUSINESS_ENTITY.LOAN_TRANSACTION, writeoff)); constructEntityMap(BusinessEntity.LOAN_TRANSACTION, writeoff));
return new CommandProcessingResultBuilder() return new CommandProcessingResultBuilder()
.withCommandId(command.commandId()) .withCommandId(command.commandId())
.withEntityId(writeoff.getId()) .withEntityId(writeoff.getId())
@@ -1277,8 +1277,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final Loan loan = this.loanAssembler.assembleFrom(loanId); final Loan loan = this.loanAssembler.assembleFrom(loanId);
checkClientOrGroupActive(loan); checkClientOrGroupActive(loan);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BUSINESS_EVENTS.LOAN_CLOSE, this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_CLOSE,
constructEntityMap(BUSINESS_ENTITY.LOAN, loan)); constructEntityMap(BusinessEntity.LOAN, loan));
final Map<String, Object> changes = new LinkedHashMap<>(); final Map<String, Object> changes = new LinkedHashMap<>();
changes.put("transactionDate", command.stringValueOfParameterNamed("transactionDate")); changes.put("transactionDate", command.stringValueOfParameterNamed("transactionDate"));
@@ -1319,8 +1319,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds); postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds);
} }
this.loanAccountDomainService.recalculateAccruals(loan); this.loanAccountDomainService.recalculateAccruals(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.LOAN_CLOSE, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_CLOSE,
constructEntityMap(BUSINESS_ENTITY.LOAN, loan)); constructEntityMap(BusinessEntity.LOAN, loan));
// disable all active standing instructions linked to the loan // disable all active standing instructions linked to the loan
this.loanAccountDomainService.disableStandingInstructionsLinkedToClosedLoan(loan); this.loanAccountDomainService.disableStandingInstructionsLinkedToClosedLoan(loan);
@@ -1361,8 +1361,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final Loan loan = this.loanAssembler.assembleFrom(loanId); final Loan loan = this.loanAssembler.assembleFrom(loanId);
checkClientOrGroupActive(loan); checkClientOrGroupActive(loan);
removeLoanCycle(loan); removeLoanCycle(loan);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BUSINESS_EVENTS.LOAN_CLOSE_AS_RESCHEDULE, this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_CLOSE_AS_RESCHEDULE,
constructEntityMap(BUSINESS_ENTITY.LOAN, loan)); constructEntityMap(BusinessEntity.LOAN, loan));
final Map<String, Object> changes = new LinkedHashMap<>(); final Map<String, Object> changes = new LinkedHashMap<>();
changes.put("transactionDate", command.stringValueOfParameterNamed("transactionDate")); changes.put("transactionDate", command.stringValueOfParameterNamed("transactionDate"));
@@ -1379,8 +1379,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final Note note = Note.loanNote(loan, noteText); final Note note = Note.loanNote(loan, noteText);
this.noteRepository.save(note); this.noteRepository.save(note);
} }
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.LOAN_CLOSE_AS_RESCHEDULE, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_CLOSE_AS_RESCHEDULE,
constructEntityMap(BUSINESS_ENTITY.LOAN, loan)); constructEntityMap(BusinessEntity.LOAN, loan));
// disable all active standing instructions linked to the loan // disable all active standing instructions linked to the loan
this.loanAccountDomainService.disableStandingInstructionsLinkedToClosedLoan(loan); this.loanAccountDomainService.disableStandingInstructionsLinkedToClosedLoan(loan);
@@ -1440,8 +1440,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
disbursementDetail.expectedDisbursementDateAsLocalDate(), null, null); disbursementDetail.expectedDisbursementDateAsLocalDate(), null, null);
loanTrancheDisbursementCharge = new LoanTrancheDisbursementCharge(loanCharge, disbursementDetail); loanTrancheDisbursementCharge = new LoanTrancheDisbursementCharge(loanCharge, disbursementDetail);
loanCharge.updateLoanTrancheDisbursementCharge(loanTrancheDisbursementCharge); loanCharge.updateLoanTrancheDisbursementCharge(loanTrancheDisbursementCharge);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BUSINESS_EVENTS.LOAN_ADD_CHARGE, this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_ADD_CHARGE,
constructEntityMap(BUSINESS_ENTITY.LOAN_CHARGE, loanCharge)); constructEntityMap(BusinessEntity.LOAN_CHARGE, loanCharge));
validateAddLoanCharge(loan, chargeDefinition, loanCharge); validateAddLoanCharge(loan, chargeDefinition, loanCharge);
addCharge(loan, chargeDefinition, loanCharge); addCharge(loan, chargeDefinition, loanCharge);
isAppliedOnBackDate = true; isAppliedOnBackDate = true;
@@ -1453,8 +1453,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
loan.addTrancheLoanCharge(chargeDefinition); loan.addTrancheLoanCharge(chargeDefinition);
} else { } else {
loanCharge = LoanCharge.createNewFromJson(loan, chargeDefinition, command); loanCharge = LoanCharge.createNewFromJson(loan, chargeDefinition, command);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BUSINESS_EVENTS.LOAN_ADD_CHARGE, this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_ADD_CHARGE,
constructEntityMap(BUSINESS_ENTITY.LOAN_CHARGE, loanCharge)); constructEntityMap(BusinessEntity.LOAN_CHARGE, loanCharge));
validateAddLoanCharge(loan, chargeDefinition, loanCharge); validateAddLoanCharge(loan, chargeDefinition, loanCharge);
isAppliedOnBackDate = addCharge(loan, chargeDefinition, loanCharge); isAppliedOnBackDate = addCharge(loan, chargeDefinition, loanCharge);
@@ -1493,8 +1493,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
&& loan.isFeeCompoundingEnabledForInterestRecalculation()) { && loan.isFeeCompoundingEnabledForInterestRecalculation()) {
this.loanAccountDomainService.recalculateAccruals(loan); this.loanAccountDomainService.recalculateAccruals(loan);
} }
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.LOAN_ADD_CHARGE, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_ADD_CHARGE,
constructEntityMap(BUSINESS_ENTITY.LOAN_CHARGE, loanCharge)); constructEntityMap(BusinessEntity.LOAN_CHARGE, loanCharge));
return new CommandProcessingResultBuilder() return new CommandProcessingResultBuilder()
.withCommandId(command.commandId()) .withCommandId(command.commandId())
.withEntityId(loanCharge.getId()) .withEntityId(loanCharge.getId())
@@ -1609,16 +1609,16 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
// Charges may be edited only when the loan associated with them are // Charges may be edited only when the loan associated with them are
// yet to be approved (are in submitted and pending status) // yet to be approved (are in submitted and pending status)
if (!loan.status().isSubmittedAndPendingApproval()) { throw new LoanChargeCannotBeUpdatedException( if (!loan.status().isSubmittedAndPendingApproval()) { throw new LoanChargeCannotBeUpdatedException(
LOAN_CHARGE_CANNOT_BE_UPDATED_REASON.LOAN_NOT_IN_SUBMITTED_AND_PENDING_APPROVAL_STAGE, loanCharge.getId()); } LoanChargeCannotBeUpdatedReason.LOAN_NOT_IN_SUBMITTED_AND_PENDING_APPROVAL_STAGE, loanCharge.getId()); }
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BUSINESS_EVENTS.LOAN_UPDATE_CHARGE, this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_UPDATE_CHARGE,
constructEntityMap(BUSINESS_ENTITY.LOAN_CHARGE, loanCharge)); constructEntityMap(BusinessEntity.LOAN_CHARGE, loanCharge));
final Map<String, Object> changes = loan.updateLoanCharge(loanCharge, command); final Map<String, Object> changes = loan.updateLoanCharge(loanCharge, command);
saveLoanWithDataIntegrityViolationChecks(loan); saveLoanWithDataIntegrityViolationChecks(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.LOAN_UPDATE_CHARGE, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_UPDATE_CHARGE,
constructEntityMap(BUSINESS_ENTITY.LOAN_CHARGE, loanCharge)); constructEntityMap(BusinessEntity.LOAN_CHARGE, loanCharge));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
.withEntityId(loanChargeId) // .withEntityId(loanChargeId) //
@@ -1643,16 +1643,16 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
// Charges may be waived only when the loan associated with them are // Charges may be waived only when the loan associated with them are
// active // active
if (!loan.status().isActive()) { throw new LoanChargeCannotBeWaivedException(LOAN_CHARGE_CANNOT_BE_WAIVED_REASON.LOAN_INACTIVE, if (!loan.status().isActive()) { throw new LoanChargeCannotBeWaivedException(LoanChargeCannotBeWaivedReason.LOAN_INACTIVE,
loanCharge.getId()); } loanCharge.getId()); }
// validate loan charge is not already paid or waived // validate loan charge is not already paid or waived
if (loanCharge.isWaived()) { if (loanCharge.isWaived()) {
throw new LoanChargeCannotBeWaivedException(LOAN_CHARGE_CANNOT_BE_WAIVED_REASON.ALREADY_WAIVED, loanCharge.getId()); throw new LoanChargeCannotBeWaivedException(LoanChargeCannotBeWaivedReason.ALREADY_WAIVED, loanCharge.getId());
} else if (loanCharge.isPaid()) { throw new LoanChargeCannotBeWaivedException(LOAN_CHARGE_CANNOT_BE_WAIVED_REASON.ALREADY_PAID, } else if (loanCharge.isPaid()) { throw new LoanChargeCannotBeWaivedException(LoanChargeCannotBeWaivedReason.ALREADY_PAID,
loanCharge.getId()); } loanCharge.getId()); }
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BUSINESS_EVENTS.LOAN_WAIVE_CHARGE, this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_WAIVE_CHARGE,
constructEntityMap(BUSINESS_ENTITY.LOAN_CHARGE, loanCharge)); constructEntityMap(BusinessEntity.LOAN_CHARGE, loanCharge));
Integer loanInstallmentNumber = null; Integer loanInstallmentNumber = null;
if (loanCharge.isInstalmentFee()) { if (loanCharge.isInstalmentFee()) {
LoanInstallmentCharge chargePerInstallment = null; LoanInstallmentCharge chargePerInstallment = null;
@@ -1669,9 +1669,9 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
chargePerInstallment = loanCharge.getUnpaidInstallmentLoanCharge(); chargePerInstallment = loanCharge.getUnpaidInstallmentLoanCharge();
} }
if (chargePerInstallment.isWaived()) { if (chargePerInstallment.isWaived()) {
throw new LoanChargeCannotBePayedException(LOAN_CHARGE_CANNOT_BE_PAYED_REASON.ALREADY_WAIVED, loanCharge.getId()); throw new LoanChargeCannotBePayedException(LoanChargeCannotBePayedReason.ALREADY_WAIVED, loanCharge.getId());
} else if (chargePerInstallment.isPaid()) { throw new LoanChargeCannotBePayedException( } else if (chargePerInstallment.isPaid()) { throw new LoanChargeCannotBePayedException(
LOAN_CHARGE_CANNOT_BE_PAYED_REASON.ALREADY_PAID, loanCharge.getId()); } LoanChargeCannotBePayedReason.ALREADY_PAID, loanCharge.getId()); }
loanInstallmentNumber = chargePerInstallment.getRepaymentInstallment().getInstallmentNumber(); loanInstallmentNumber = chargePerInstallment.getRepaymentInstallment().getInstallmentNumber();
} }
@@ -1700,8 +1700,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds); postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.LOAN_WAIVE_CHARGE, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_WAIVE_CHARGE,
constructEntityMap(BUSINESS_ENTITY.LOAN_CHARGE, loanCharge)); constructEntityMap(BusinessEntity.LOAN_CHARGE, loanCharge));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
@@ -1725,14 +1725,14 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
// Charges may be deleted only when the loan associated with them are // Charges may be deleted only when the loan associated with them are
// yet to be approved (are in submitted and pending status) // yet to be approved (are in submitted and pending status)
if (!loan.status().isSubmittedAndPendingApproval()) { throw new LoanChargeCannotBeDeletedException( if (!loan.status().isSubmittedAndPendingApproval()) { throw new LoanChargeCannotBeDeletedException(
LOAN_CHARGE_CANNOT_BE_DELETED_REASON.LOAN_NOT_IN_SUBMITTED_AND_PENDING_APPROVAL_STAGE, loanCharge.getId()); } LoanChargeCannotBeDeletedReason.LOAN_NOT_IN_SUBMITTED_AND_PENDING_APPROVAL_STAGE, loanCharge.getId()); }
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BUSINESS_EVENTS.LOAN_DELETE_CHARGE, this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_DELETE_CHARGE,
constructEntityMap(BUSINESS_ENTITY.LOAN_CHARGE, loanCharge)); constructEntityMap(BusinessEntity.LOAN_CHARGE, loanCharge));
loan.removeLoanCharge(loanCharge); loan.removeLoanCharge(loanCharge);
saveLoanWithDataIntegrityViolationChecks(loan); saveLoanWithDataIntegrityViolationChecks(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.LOAN_DELETE_CHARGE, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_DELETE_CHARGE,
constructEntityMap(BUSINESS_ENTITY.LOAN_CHARGE, loanCharge)); constructEntityMap(BusinessEntity.LOAN_CHARGE, loanCharge));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
.withEntityId(loanChargeId) // .withEntityId(loanChargeId) //
@@ -1758,17 +1758,17 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
// Charges may be waived only when the loan associated with them are // Charges may be waived only when the loan associated with them are
// active // active
if (!loan.status().isActive()) { throw new LoanChargeCannotBePayedException(LOAN_CHARGE_CANNOT_BE_PAYED_REASON.LOAN_INACTIVE, if (!loan.status().isActive()) { throw new LoanChargeCannotBePayedException(LoanChargeCannotBePayedReason.LOAN_INACTIVE,
loanCharge.getId()); } loanCharge.getId()); }
// validate loan charge is not already paid or waived // validate loan charge is not already paid or waived
if (loanCharge.isWaived()) { if (loanCharge.isWaived()) {
throw new LoanChargeCannotBePayedException(LOAN_CHARGE_CANNOT_BE_PAYED_REASON.ALREADY_WAIVED, loanCharge.getId()); throw new LoanChargeCannotBePayedException(LoanChargeCannotBePayedReason.ALREADY_WAIVED, loanCharge.getId());
} else if (loanCharge.isPaid()) { throw new LoanChargeCannotBePayedException(LOAN_CHARGE_CANNOT_BE_PAYED_REASON.ALREADY_PAID, } else if (loanCharge.isPaid()) { throw new LoanChargeCannotBePayedException(LoanChargeCannotBePayedReason.ALREADY_PAID,
loanCharge.getId()); } loanCharge.getId()); }
if (!loanCharge.getChargePaymentMode().isPaymentModeAccountTransfer()) { throw new LoanChargeCannotBePayedException( if (!loanCharge.getChargePaymentMode().isPaymentModeAccountTransfer()) { throw new LoanChargeCannotBePayedException(
LOAN_CHARGE_CANNOT_BE_PAYED_REASON.CHARGE_NOT_ACCOUNT_TRANSFER, loanCharge.getId()); } LoanChargeCannotBePayedReason.CHARGE_NOT_ACCOUNT_TRANSFER, loanCharge.getId()); }
final LocalDate transactionDate = command.localDateValueOfParameterNamed("transactionDate"); final LocalDate transactionDate = command.localDateValueOfParameterNamed("transactionDate");
@@ -1789,9 +1789,9 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
chargePerInstallment = loanCharge.getUnpaidInstallmentLoanCharge(); chargePerInstallment = loanCharge.getUnpaidInstallmentLoanCharge();
} }
if (chargePerInstallment.isWaived()) { if (chargePerInstallment.isWaived()) {
throw new LoanChargeCannotBePayedException(LOAN_CHARGE_CANNOT_BE_PAYED_REASON.ALREADY_WAIVED, loanCharge.getId()); throw new LoanChargeCannotBePayedException(LoanChargeCannotBePayedReason.ALREADY_WAIVED, loanCharge.getId());
} else if (chargePerInstallment.isPaid()) { throw new LoanChargeCannotBePayedException( } else if (chargePerInstallment.isPaid()) { throw new LoanChargeCannotBePayedException(
LOAN_CHARGE_CANNOT_BE_PAYED_REASON.ALREADY_PAID, loanCharge.getId()); } LoanChargeCannotBePayedReason.ALREADY_PAID, loanCharge.getId()); }
loanInstallmentNumber = chargePerInstallment.getRepaymentInstallment().getInstallmentNumber(); loanInstallmentNumber = chargePerInstallment.getRepaymentInstallment().getInstallmentNumber();
amount = chargePerInstallment.getAmountOutstanding(); amount = chargePerInstallment.getAmountOutstanding();
} }
@@ -1935,8 +1935,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
checkClientOrGroupActive(loan); checkClientOrGroupActive(loan);
validateTransactionsForTransfer(loan, transferDate); validateTransactionsForTransfer(loan, transferDate);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BUSINESS_EVENTS.LOAN_INITIATE_TRANSFER, this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_INITIATE_TRANSFER,
constructEntityMap(BUSINESS_ENTITY.LOAN, loan)); constructEntityMap(BusinessEntity.LOAN, loan));
final List<Long> existingTransactionIds = new ArrayList<>(loan.findExistingTransactionIds()); final List<Long> existingTransactionIds = new ArrayList<>(loan.findExistingTransactionIds());
final List<Long> existingReversedTransactionIds = new ArrayList<>(loan.findExistingReversedTransactionIds()); final List<Long> existingReversedTransactionIds = new ArrayList<>(loan.findExistingReversedTransactionIds());
@@ -1950,8 +1950,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
saveLoanWithDataIntegrityViolationChecks(loan); saveLoanWithDataIntegrityViolationChecks(loan);
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds); postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.LOAN_INITIATE_TRANSFER, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_INITIATE_TRANSFER,
constructEntityMap(BUSINESS_ENTITY.LOAN, loan)); constructEntityMap(BusinessEntity.LOAN, loan));
return newTransferTransaction; return newTransferTransaction;
} }
@@ -1961,8 +1961,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final Staff loanOfficer) { final Staff loanOfficer) {
AppUser currentUser = getAppUserIfPresent(); AppUser currentUser = getAppUserIfPresent();
this.loanAssembler.setHelpers(loan) ; this.loanAssembler.setHelpers(loan) ;
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BUSINESS_EVENTS.LOAN_ACCEPT_TRANSFER, this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_ACCEPT_TRANSFER,
constructEntityMap(BUSINESS_ENTITY.LOAN, loan)); constructEntityMap(BusinessEntity.LOAN, loan));
final List<Long> existingTransactionIds = new ArrayList<>(loan.findExistingTransactionIds()); final List<Long> existingTransactionIds = new ArrayList<>(loan.findExistingTransactionIds());
final List<Long> existingReversedTransactionIds = new ArrayList<>(loan.findExistingReversedTransactionIds()); final List<Long> existingReversedTransactionIds = new ArrayList<>(loan.findExistingReversedTransactionIds());
@@ -1982,8 +1982,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
saveLoanWithDataIntegrityViolationChecks(loan); saveLoanWithDataIntegrityViolationChecks(loan);
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds); postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.LOAN_ACCEPT_TRANSFER, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_ACCEPT_TRANSFER,
constructEntityMap(BUSINESS_ENTITY.LOAN, loan)); constructEntityMap(BusinessEntity.LOAN, loan));
return newTransferAcceptanceTransaction; return newTransferAcceptanceTransaction;
} }
@@ -1993,8 +1993,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
public LoanTransaction withdrawLoanTransfer(final Loan loan, final LocalDate transferDate) { public LoanTransaction withdrawLoanTransfer(final Loan loan, final LocalDate transferDate) {
AppUser currentUser = getAppUserIfPresent(); AppUser currentUser = getAppUserIfPresent();
this.loanAssembler.setHelpers(loan); this.loanAssembler.setHelpers(loan);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BUSINESS_EVENTS.LOAN_WITHDRAW_TRANSFER, this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_WITHDRAW_TRANSFER,
constructEntityMap(BUSINESS_ENTITY.LOAN, loan)); constructEntityMap(BusinessEntity.LOAN, loan));
final List<Long> existingTransactionIds = new ArrayList<>(loan.findExistingTransactionIds()); final List<Long> existingTransactionIds = new ArrayList<>(loan.findExistingTransactionIds());
final List<Long> existingReversedTransactionIds = new ArrayList<>(loan.findExistingReversedTransactionIds()); final List<Long> existingReversedTransactionIds = new ArrayList<>(loan.findExistingReversedTransactionIds());
@@ -2008,8 +2008,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
saveLoanWithDataIntegrityViolationChecks(loan); saveLoanWithDataIntegrityViolationChecks(loan);
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds); postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.LOAN_WITHDRAW_TRANSFER, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_WITHDRAW_TRANSFER,
constructEntityMap(BUSINESS_ENTITY.LOAN, loan)); constructEntityMap(BusinessEntity.LOAN, loan));
return newTransferAcceptanceTransaction; return newTransferAcceptanceTransaction;
} }
@@ -2018,12 +2018,12 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
@Override @Override
public void rejectLoanTransfer(final Loan loan) { public void rejectLoanTransfer(final Loan loan) {
this.loanAssembler.setHelpers(loan); this.loanAssembler.setHelpers(loan);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BUSINESS_EVENTS.LOAN_REJECT_TRANSFER, this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_REJECT_TRANSFER,
constructEntityMap(BUSINESS_ENTITY.LOAN, loan)); constructEntityMap(BusinessEntity.LOAN, loan));
loan.setLoanStatus(LoanStatus.TRANSFER_ON_HOLD.getValue()); loan.setLoanStatus(LoanStatus.TRANSFER_ON_HOLD.getValue());
saveLoanWithDataIntegrityViolationChecks(loan); saveLoanWithDataIntegrityViolationChecks(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.LOAN_REJECT_TRANSFER, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_REJECT_TRANSFER,
constructEntityMap(BUSINESS_ENTITY.LOAN, loan)); constructEntityMap(BusinessEntity.LOAN, loan));
} }
@Transactional @Transactional
@@ -2041,15 +2041,15 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final Loan loan = this.loanAssembler.assembleFrom(loanId); final Loan loan = this.loanAssembler.assembleFrom(loanId);
checkClientOrGroupActive(loan); checkClientOrGroupActive(loan);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BUSINESS_EVENTS.LOAN_REASSIGN_OFFICER, this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_REASSIGN_OFFICER,
constructEntityMap(BUSINESS_ENTITY.LOAN, loan)); constructEntityMap(BusinessEntity.LOAN, loan));
if (!loan.hasLoanOfficer(fromLoanOfficer)) { throw new LoanOfficerAssignmentException(loanId, fromLoanOfficerId); } if (!loan.hasLoanOfficer(fromLoanOfficer)) { throw new LoanOfficerAssignmentException(loanId, fromLoanOfficerId); }
loan.reassignLoanOfficer(toLoanOfficer, dateOfLoanOfficerAssignment); loan.reassignLoanOfficer(toLoanOfficer, dateOfLoanOfficerAssignment);
saveLoanWithDataIntegrityViolationChecks(loan); saveLoanWithDataIntegrityViolationChecks(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.LOAN_REASSIGN_OFFICER, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_REASSIGN_OFFICER,
constructEntityMap(BUSINESS_ENTITY.LOAN, loan)); constructEntityMap(BusinessEntity.LOAN, loan));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
@@ -2079,16 +2079,16 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
for (final String loanIdString : loanIds) { for (final String loanIdString : loanIds) {
final Long loanId = Long.valueOf(loanIdString); final Long loanId = Long.valueOf(loanIdString);
final Loan loan = this.loanAssembler.assembleFrom(loanId); final Loan loan = this.loanAssembler.assembleFrom(loanId);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BUSINESS_EVENTS.LOAN_REASSIGN_OFFICER, this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_REASSIGN_OFFICER,
constructEntityMap(BUSINESS_ENTITY.LOAN, loan)); constructEntityMap(BusinessEntity.LOAN, loan));
checkClientOrGroupActive(loan); checkClientOrGroupActive(loan);
if (!loan.hasLoanOfficer(fromLoanOfficer)) { throw new LoanOfficerAssignmentException(loanId, fromLoanOfficerId); } if (!loan.hasLoanOfficer(fromLoanOfficer)) { throw new LoanOfficerAssignmentException(loanId, fromLoanOfficerId); }
loan.reassignLoanOfficer(toLoanOfficer, dateOfLoanOfficerAssignment); loan.reassignLoanOfficer(toLoanOfficer, dateOfLoanOfficerAssignment);
saveLoanWithDataIntegrityViolationChecks(loan); saveLoanWithDataIntegrityViolationChecks(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.LOAN_REASSIGN_OFFICER, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_REASSIGN_OFFICER,
constructEntityMap(BUSINESS_ENTITY.LOAN, loan)); constructEntityMap(BusinessEntity.LOAN, loan));
} }
this.loanRepositoryWrapper.flush(); this.loanRepositoryWrapper.flush();
@@ -2111,14 +2111,14 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
checkClientOrGroupActive(loan); checkClientOrGroupActive(loan);
if (loan.getLoanOfficer() == null) { throw new LoanOfficerUnassignmentException(loanId); } if (loan.getLoanOfficer() == null) { throw new LoanOfficerUnassignmentException(loanId); }
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BUSINESS_EVENTS.LOAN_REMOVE_OFFICER, this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_REMOVE_OFFICER,
constructEntityMap(BUSINESS_ENTITY.LOAN, loan)); constructEntityMap(BusinessEntity.LOAN, loan));
loan.removeLoanOfficer(dateOfLoanOfficerunAssigned); loan.removeLoanOfficer(dateOfLoanOfficerunAssigned);
saveLoanWithDataIntegrityViolationChecks(loan); saveLoanWithDataIntegrityViolationChecks(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.LOAN_REMOVE_OFFICER, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_REMOVE_OFFICER,
constructEntityMap(BUSINESS_ENTITY.LOAN, loan)); constructEntityMap(BusinessEntity.LOAN, loan));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
@@ -2477,8 +2477,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
&& loan.isFeeCompoundingEnabledForInterestRecalculation()) { && loan.isFeeCompoundingEnabledForInterestRecalculation()) {
this.loanAccountDomainService.recalculateAccruals(loan); this.loanAccountDomainService.recalculateAccruals(loan);
} }
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.LOAN_APPLY_OVERDUE_CHARGE, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_APPLY_OVERDUE_CHARGE,
constructEntityMap(BUSINESS_ENTITY.LOAN, loan)); constructEntityMap(BusinessEntity.LOAN, loan));
} }
} }
@@ -2557,8 +2557,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
LocalDate recalculateFrom = DateUtils.getLocalDateOfTenant(); LocalDate recalculateFrom = DateUtils.getLocalDateOfTenant();
if (loan != null) { if (loan != null) {
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BUSINESS_EVENTS.LOAN_APPLY_OVERDUE_CHARGE, this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_APPLY_OVERDUE_CHARGE,
constructEntityMap(BUSINESS_ENTITY.LOAN, loan)); constructEntityMap(BusinessEntity.LOAN, loan));
for (Map.Entry<Integer, LocalDate> entry : scheduleDates.entrySet()) { for (Map.Entry<Integer, LocalDate> entry : scheduleDates.entrySet()) {
final LoanCharge loanCharge = LoanCharge.createNewFromJson(loan, chargeDefinition, command, entry.getValue()); final LoanCharge loanCharge = LoanCharge.createNewFromJson(loan, chargeDefinition, command, entry.getValue());
@@ -2597,8 +2597,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
+ " update not allowed as loan status is not written off", loanId); } + " update not allowed as loan status is not written off", loanId); }
LocalDate recalculateFrom = null; LocalDate recalculateFrom = null;
LoanTransaction writeOffTransaction = loan.findWriteOffTransaction(); LoanTransaction writeOffTransaction = loan.findWriteOffTransaction();
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BUSINESS_EVENTS.LOAN_UNDO_WRITTEN_OFF, this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_UNDO_WRITTEN_OFF,
constructEntityMap(BUSINESS_ENTITY.LOAN_TRANSACTION, writeOffTransaction)); constructEntityMap(BusinessEntity.LOAN_TRANSACTION, writeOffTransaction));
ScheduleGeneratorDTO scheduleGeneratorDTO = this.loanUtilService.buildScheduleGeneratorDTO(loan, recalculateFrom); ScheduleGeneratorDTO scheduleGeneratorDTO = this.loanUtilService.buildScheduleGeneratorDTO(loan, recalculateFrom);
@@ -2615,8 +2615,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds); postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds);
this.loanAccountDomainService.recalculateAccruals(loan); this.loanAccountDomainService.recalculateAccruals(loan);
if (writeOffTransaction != null) { if (writeOffTransaction != null) {
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.LOAN_UNDO_WRITTEN_OFF, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_UNDO_WRITTEN_OFF,
constructEntityMap(BUSINESS_ENTITY.LOAN_TRANSACTION, writeOffTransaction)); constructEntityMap(BusinessEntity.LOAN_TRANSACTION, writeOffTransaction));
} }
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withOfficeId(loan.getOfficeId()) // .withOfficeId(loan.getOfficeId()) //
@@ -2783,17 +2783,17 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
// Charges may be waived only when the loan associated with them are // Charges may be waived only when the loan associated with them are
// active // active
if (!loan.status().isActive()) { throw new LoanChargeCannotBePayedException(LOAN_CHARGE_CANNOT_BE_PAYED_REASON.LOAN_INACTIVE, if (!loan.status().isActive()) { throw new LoanChargeCannotBePayedException(LoanChargeCannotBePayedReason.LOAN_INACTIVE,
loanCharge.getId()); } loanCharge.getId()); }
// validate loan charge is not already paid or waived // validate loan charge is not already paid or waived
if (loanCharge.isWaived()) { if (loanCharge.isWaived()) {
throw new LoanChargeCannotBePayedException(LOAN_CHARGE_CANNOT_BE_PAYED_REASON.ALREADY_WAIVED, loanCharge.getId()); throw new LoanChargeCannotBePayedException(LoanChargeCannotBePayedReason.ALREADY_WAIVED, loanCharge.getId());
} else if (loanCharge.isPaid()) { throw new LoanChargeCannotBePayedException(LOAN_CHARGE_CANNOT_BE_PAYED_REASON.ALREADY_PAID, } else if (loanCharge.isPaid()) { throw new LoanChargeCannotBePayedException(LoanChargeCannotBePayedReason.ALREADY_PAID,
loanCharge.getId()); } loanCharge.getId()); }
if (!loanCharge.getChargePaymentMode().isPaymentModeAccountTransfer()) { throw new LoanChargeCannotBePayedException( if (!loanCharge.getChargePaymentMode().isPaymentModeAccountTransfer()) { throw new LoanChargeCannotBePayedException(
LOAN_CHARGE_CANNOT_BE_PAYED_REASON.CHARGE_NOT_ACCOUNT_TRANSFER, loanCharge.getId()); } LoanChargeCannotBePayedReason.CHARGE_NOT_ACCOUNT_TRANSFER, loanCharge.getId()); }
final LocalDate transactionDate = command.localDateValueOfParameterNamed("transactionDate"); final LocalDate transactionDate = command.localDateValueOfParameterNamed("transactionDate");
@@ -2814,9 +2814,9 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
chargePerInstallment = loanCharge.getUnpaidInstallmentLoanCharge(); chargePerInstallment = loanCharge.getUnpaidInstallmentLoanCharge();
} }
if (chargePerInstallment.isWaived()) { if (chargePerInstallment.isWaived()) {
throw new LoanChargeCannotBePayedException(LOAN_CHARGE_CANNOT_BE_PAYED_REASON.ALREADY_WAIVED, loanCharge.getId()); throw new LoanChargeCannotBePayedException(LoanChargeCannotBePayedReason.ALREADY_WAIVED, loanCharge.getId());
} else if (chargePerInstallment.isPaid()) { throw new LoanChargeCannotBePayedException( } else if (chargePerInstallment.isPaid()) { throw new LoanChargeCannotBePayedException(
LOAN_CHARGE_CANNOT_BE_PAYED_REASON.ALREADY_PAID, loanCharge.getId()); } LoanChargeCannotBePayedReason.ALREADY_PAID, loanCharge.getId()); }
loanInstallmentNumber = chargePerInstallment.getRepaymentInstallment().getInstallmentNumber(); loanInstallmentNumber = chargePerInstallment.getRepaymentInstallment().getInstallmentNumber();
amount = chargePerInstallment.getAmountOutstanding(); amount = chargePerInstallment.getAmountOutstanding();
} }
@@ -2845,8 +2845,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
Loan loan = this.loanAssembler.assembleFrom(loanId); Loan loan = this.loanAssembler.assembleFrom(loanId);
LocalDate recalculateFrom = loan.fetchInterestRecalculateFromDate(); LocalDate recalculateFrom = loan.fetchInterestRecalculateFromDate();
AppUser currentUser = getAppUserIfPresent(); AppUser currentUser = getAppUserIfPresent();
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BUSINESS_EVENTS.LOAN_INTEREST_RECALCULATION, this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_INTEREST_RECALCULATION,
constructEntityMap(BUSINESS_ENTITY.LOAN, loan)); constructEntityMap(BusinessEntity.LOAN, loan));
final List<Long> existingTransactionIds = new ArrayList<>(); final List<Long> existingTransactionIds = new ArrayList<>();
final List<Long> existingReversedTransactionIds = new ArrayList<>(); final List<Long> existingReversedTransactionIds = new ArrayList<>();
@@ -2868,8 +2868,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
} }
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds); postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds);
this.loanAccountDomainService.recalculateAccruals(loan); this.loanAccountDomainService.recalculateAccruals(loan);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.LOAN_INTEREST_RECALCULATION, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_INTEREST_RECALCULATION,
constructEntityMap(BUSINESS_ENTITY.LOAN, loan)); constructEntityMap(BusinessEntity.LOAN, loan));
} }
@Override @Override
@@ -2975,8 +2975,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
return user; return user;
} }
private Map<BUSINESS_ENTITY, Object> constructEntityMap(final BUSINESS_ENTITY entityEvent, Object entity) { private Map<BusinessEntity, Object> constructEntityMap(final BusinessEntity entityEvent, Object entity) {
Map<BUSINESS_ENTITY, Object> map = new HashMap<>(1); Map<BusinessEntity, Object> map = new HashMap<>(1);
map.put(entityEvent, entity); map.put(entityEvent, entity);
return map; return map;
} }
@@ -2990,8 +2990,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final LocalDate recalculateFromDate = loan.getLastRepaymentDate(); final LocalDate recalculateFromDate = loan.getLastRepaymentDate();
validateIsMultiDisbursalLoanAndDisbursedMoreThanOneTranche(loan); validateIsMultiDisbursalLoanAndDisbursedMoreThanOneTranche(loan);
checkClientOrGroupActive(loan); checkClientOrGroupActive(loan);
this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BUSINESS_EVENTS.LOAN_UNDO_LASTDISBURSAL, this.businessEventNotifierService.notifyBusinessEventToBeExecuted(BusinessEvents.LOAN_UNDO_LASTDISBURSAL,
constructEntityMap(BUSINESS_ENTITY.LOAN, loan)); constructEntityMap(BusinessEntity.LOAN, loan));
final MonetaryCurrency currency = loan.getCurrency(); final MonetaryCurrency currency = loan.getCurrency();
final ApplicationCurrency applicationCurrency = this.applicationCurrencyRepository.findOneWithNotFoundDetection(currency); final ApplicationCurrency applicationCurrency = this.applicationCurrencyRepository.findOneWithNotFoundDetection(currency);
@@ -3016,8 +3016,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final Map<String, Object> accountingBridgeData = loan.deriveAccountingBridgeData(applicationCurrency.toData(), final Map<String, Object> accountingBridgeData = loan.deriveAccountingBridgeData(applicationCurrency.toData(),
existingTransactionIds, existingReversedTransactionIds, isAccountTransfer); existingTransactionIds, existingReversedTransactionIds, isAccountTransfer);
this.journalEntryWritePlatformService.createJournalEntriesForLoan(accountingBridgeData); this.journalEntryWritePlatformService.createJournalEntriesForLoan(accountingBridgeData);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.LOAN_UNDO_LASTDISBURSAL, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_UNDO_LASTDISBURSAL,
constructEntityMap(BUSINESS_ENTITY.LOAN, loan)); constructEntityMap(BusinessEntity.LOAN, loan));
} }
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
@@ -33,7 +33,7 @@ import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.accounting.common.AccountingConstants.LOAN_PRODUCT_ACCOUNTING_PARAMS; import org.apache.fineract.accounting.common.AccountingConstants.LoanProductAccountingParams;
import org.apache.fineract.accounting.common.AccountingRuleType; import org.apache.fineract.accounting.common.AccountingRuleType;
import org.apache.fineract.infrastructure.core.data.ApiParameterError; import org.apache.fineract.infrastructure.core.data.ApiParameterError;
import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder; import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder;
@@ -69,16 +69,16 @@ public final class LoanProductDataValidator {
"accountingRule", "includeInBorrowerCycle", "startDate", "closeDate", "externalId", "isLinkedToFloatingInterestRates", "accountingRule", "includeInBorrowerCycle", "startDate", "closeDate", "externalId", "isLinkedToFloatingInterestRates",
"floatingRatesId", "interestRateDifferential", "minDifferentialLendingRate", "defaultDifferentialLendingRate", "floatingRatesId", "interestRateDifferential", "minDifferentialLendingRate", "defaultDifferentialLendingRate",
"maxDifferentialLendingRate", "isFloatingInterestRateCalculationAllowed", "syncExpectedWithDisbursementDate", "maxDifferentialLendingRate", "isFloatingInterestRateCalculationAllowed", "syncExpectedWithDisbursementDate",
LOAN_PRODUCT_ACCOUNTING_PARAMS.FEES_RECEIVABLE.getValue(), LOAN_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue(), LoanProductAccountingParams.FEES_RECEIVABLE.getValue(), LoanProductAccountingParams.FUND_SOURCE.getValue(),
LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue(), LoanProductAccountingParams.INCOME_FROM_FEES.getValue(), LoanProductAccountingParams.INCOME_FROM_PENALTIES.getValue(),
LOAN_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_LOANS.getValue(), LOAN_PRODUCT_ACCOUNTING_PARAMS.INTEREST_RECEIVABLE.getValue(), LoanProductAccountingParams.INTEREST_ON_LOANS.getValue(), LoanProductAccountingParams.INTEREST_RECEIVABLE.getValue(),
LOAN_PRODUCT_ACCOUNTING_PARAMS.LOAN_PORTFOLIO.getValue(), LOAN_PRODUCT_ACCOUNTING_PARAMS.OVERPAYMENT.getValue(), LoanProductAccountingParams.LOAN_PORTFOLIO.getValue(), LoanProductAccountingParams.OVERPAYMENT.getValue(),
LOAN_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(), LOAN_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue(), LoanProductAccountingParams.TRANSFERS_SUSPENSE.getValue(), LoanProductAccountingParams.LOSSES_WRITTEN_OFF.getValue(),
LOAN_PRODUCT_ACCOUNTING_PARAMS.PENALTIES_RECEIVABLE.getValue(), LoanProductAccountingParams.PENALTIES_RECEIVABLE.getValue(),
LOAN_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(), LoanProductAccountingParams.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(),
LOAN_PRODUCT_ACCOUNTING_PARAMS.FEE_INCOME_ACCOUNT_MAPPING.getValue(), LoanProductAccountingParams.FEE_INCOME_ACCOUNT_MAPPING.getValue(),
LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_RECOVERY.getValue(), LoanProductAccountingParams.INCOME_FROM_RECOVERY.getValue(),
LOAN_PRODUCT_ACCOUNTING_PARAMS.PENALTY_INCOME_ACCOUNT_MAPPING.getValue(), LoanProductConstants.useBorrowerCycleParameterName, LoanProductAccountingParams.PENALTY_INCOME_ACCOUNT_MAPPING.getValue(), LoanProductConstants.useBorrowerCycleParameterName,
LoanProductConstants.principalVariationsForBorrowerCycleParameterName, LoanProductConstants.principalVariationsForBorrowerCycleParameterName,
LoanProductConstants.interestRateVariationsForBorrowerCycleParameterName, LoanProductConstants.interestRateVariationsForBorrowerCycleParameterName,
LoanProductConstants.numberOfRepaymentVariationsForBorrowerCycleParameterName, LoanProductConstants.shortName, LoanProductConstants.numberOfRepaymentVariationsForBorrowerCycleParameterName, LoanProductConstants.shortName,
@@ -553,49 +553,49 @@ public final class LoanProductDataValidator {
if (isCashBasedAccounting(accountingRuleType) || isAccrualBasedAccounting(accountingRuleType)) { if (isCashBasedAccounting(accountingRuleType) || isAccrualBasedAccounting(accountingRuleType)) {
final Long fundAccountId = this.fromApiJsonHelper.extractLongNamed(LOAN_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue(), final Long fundAccountId = this.fromApiJsonHelper.extractLongNamed(LoanProductAccountingParams.FUND_SOURCE.getValue(),
element); element);
baseDataValidator.reset().parameter(LOAN_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue()).value(fundAccountId).notNull() baseDataValidator.reset().parameter(LoanProductAccountingParams.FUND_SOURCE.getValue()).value(fundAccountId).notNull()
.integerGreaterThanZero(); .integerGreaterThanZero();
final Long loanPortfolioAccountId = this.fromApiJsonHelper.extractLongNamed( final Long loanPortfolioAccountId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.LOAN_PORTFOLIO.getValue(), element); LoanProductAccountingParams.LOAN_PORTFOLIO.getValue(), element);
baseDataValidator.reset().parameter(LOAN_PRODUCT_ACCOUNTING_PARAMS.LOAN_PORTFOLIO.getValue()).value(loanPortfolioAccountId) baseDataValidator.reset().parameter(LoanProductAccountingParams.LOAN_PORTFOLIO.getValue()).value(loanPortfolioAccountId)
.notNull().integerGreaterThanZero(); .notNull().integerGreaterThanZero();
final Long transfersInSuspenseAccountId = this.fromApiJsonHelper.extractLongNamed( final Long transfersInSuspenseAccountId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(), element); LoanProductAccountingParams.TRANSFERS_SUSPENSE.getValue(), element);
baseDataValidator.reset().parameter(LOAN_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue()) baseDataValidator.reset().parameter(LoanProductAccountingParams.TRANSFERS_SUSPENSE.getValue())
.value(transfersInSuspenseAccountId).notNull().integerGreaterThanZero(); .value(transfersInSuspenseAccountId).notNull().integerGreaterThanZero();
final Long incomeFromInterestId = this.fromApiJsonHelper.extractLongNamed( final Long incomeFromInterestId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_LOANS.getValue(), element); LoanProductAccountingParams.INTEREST_ON_LOANS.getValue(), element);
baseDataValidator.reset().parameter(LOAN_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_LOANS.getValue()).value(incomeFromInterestId) baseDataValidator.reset().parameter(LoanProductAccountingParams.INTEREST_ON_LOANS.getValue()).value(incomeFromInterestId)
.notNull().integerGreaterThanZero(); .notNull().integerGreaterThanZero();
final Long incomeFromFeeId = this.fromApiJsonHelper.extractLongNamed( final Long incomeFromFeeId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), element); LoanProductAccountingParams.INCOME_FROM_FEES.getValue(), element);
baseDataValidator.reset().parameter(LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue()).value(incomeFromFeeId) baseDataValidator.reset().parameter(LoanProductAccountingParams.INCOME_FROM_FEES.getValue()).value(incomeFromFeeId)
.notNull().integerGreaterThanZero(); .notNull().integerGreaterThanZero();
final Long incomeFromPenaltyId = this.fromApiJsonHelper.extractLongNamed( final Long incomeFromPenaltyId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue(), element); LoanProductAccountingParams.INCOME_FROM_PENALTIES.getValue(), element);
baseDataValidator.reset().parameter(LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue()).value(incomeFromPenaltyId) baseDataValidator.reset().parameter(LoanProductAccountingParams.INCOME_FROM_PENALTIES.getValue()).value(incomeFromPenaltyId)
.notNull().integerGreaterThanZero(); .notNull().integerGreaterThanZero();
final Long incomeFromRecoveryAccountId = this.fromApiJsonHelper.extractLongNamed( final Long incomeFromRecoveryAccountId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_RECOVERY.getValue(), element); LoanProductAccountingParams.INCOME_FROM_RECOVERY.getValue(), element);
baseDataValidator.reset().parameter(LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_RECOVERY.getValue()) baseDataValidator.reset().parameter(LoanProductAccountingParams.INCOME_FROM_RECOVERY.getValue())
.value(incomeFromRecoveryAccountId).notNull().integerGreaterThanZero(); .value(incomeFromRecoveryAccountId).notNull().integerGreaterThanZero();
final Long writeOffAccountId = this.fromApiJsonHelper.extractLongNamed( final Long writeOffAccountId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue(), element); LoanProductAccountingParams.LOSSES_WRITTEN_OFF.getValue(), element);
baseDataValidator.reset().parameter(LOAN_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue()).value(writeOffAccountId) baseDataValidator.reset().parameter(LoanProductAccountingParams.LOSSES_WRITTEN_OFF.getValue()).value(writeOffAccountId)
.notNull().integerGreaterThanZero(); .notNull().integerGreaterThanZero();
final Long overpaymentAccountId = this.fromApiJsonHelper.extractLongNamed( final Long overpaymentAccountId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.OVERPAYMENT.getValue(), element); LoanProductAccountingParams.OVERPAYMENT.getValue(), element);
baseDataValidator.reset().parameter(LOAN_PRODUCT_ACCOUNTING_PARAMS.OVERPAYMENT.getValue()).value(overpaymentAccountId) baseDataValidator.reset().parameter(LoanProductAccountingParams.OVERPAYMENT.getValue()).value(overpaymentAccountId)
.notNull().integerGreaterThanZero(); .notNull().integerGreaterThanZero();
validatePaymentChannelFundSourceMappings(baseDataValidator, element); validatePaymentChannelFundSourceMappings(baseDataValidator, element);
@@ -606,18 +606,18 @@ public final class LoanProductDataValidator {
if (isAccrualBasedAccounting(accountingRuleType)) { if (isAccrualBasedAccounting(accountingRuleType)) {
final Long receivableInterestAccountId = this.fromApiJsonHelper.extractLongNamed( final Long receivableInterestAccountId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.INTEREST_RECEIVABLE.getValue(), element); LoanProductAccountingParams.INTEREST_RECEIVABLE.getValue(), element);
baseDataValidator.reset().parameter(LOAN_PRODUCT_ACCOUNTING_PARAMS.INTEREST_RECEIVABLE.getValue()) baseDataValidator.reset().parameter(LoanProductAccountingParams.INTEREST_RECEIVABLE.getValue())
.value(receivableInterestAccountId).notNull().integerGreaterThanZero(); .value(receivableInterestAccountId).notNull().integerGreaterThanZero();
final Long receivableFeeAccountId = this.fromApiJsonHelper.extractLongNamed( final Long receivableFeeAccountId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.FEES_RECEIVABLE.getValue(), element); LoanProductAccountingParams.FEES_RECEIVABLE.getValue(), element);
baseDataValidator.reset().parameter(LOAN_PRODUCT_ACCOUNTING_PARAMS.FEES_RECEIVABLE.getValue()).value(receivableFeeAccountId) baseDataValidator.reset().parameter(LoanProductAccountingParams.FEES_RECEIVABLE.getValue()).value(receivableFeeAccountId)
.notNull().integerGreaterThanZero(); .notNull().integerGreaterThanZero();
final Long receivablePenaltyAccountId = this.fromApiJsonHelper.extractLongNamed( final Long receivablePenaltyAccountId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.PENALTIES_RECEIVABLE.getValue(), element); LoanProductAccountingParams.PENALTIES_RECEIVABLE.getValue(), element);
baseDataValidator.reset().parameter(LOAN_PRODUCT_ACCOUNTING_PARAMS.PENALTIES_RECEIVABLE.getValue()) baseDataValidator.reset().parameter(LoanProductAccountingParams.PENALTIES_RECEIVABLE.getValue())
.value(receivablePenaltyAccountId).notNull().integerGreaterThanZero(); .value(receivablePenaltyAccountId).notNull().integerGreaterThanZero();
} }
@@ -1408,63 +1408,63 @@ public final class LoanProductDataValidator {
final Integer accountingRuleType = this.fromApiJsonHelper.extractIntegerNamed("accountingRule", element, Locale.getDefault()); final Integer accountingRuleType = this.fromApiJsonHelper.extractIntegerNamed("accountingRule", element, Locale.getDefault());
baseDataValidator.reset().parameter("accountingRule").value(accountingRuleType).ignoreIfNull().inMinMaxRange(1, 4); baseDataValidator.reset().parameter("accountingRule").value(accountingRuleType).ignoreIfNull().inMinMaxRange(1, 4);
final Long fundAccountId = this.fromApiJsonHelper.extractLongNamed(LOAN_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue(), element); final Long fundAccountId = this.fromApiJsonHelper.extractLongNamed(LoanProductAccountingParams.FUND_SOURCE.getValue(), element);
baseDataValidator.reset().parameter(LOAN_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue()).value(fundAccountId).ignoreIfNull() baseDataValidator.reset().parameter(LoanProductAccountingParams.FUND_SOURCE.getValue()).value(fundAccountId).ignoreIfNull()
.integerGreaterThanZero(); .integerGreaterThanZero();
final Long loanPortfolioAccountId = this.fromApiJsonHelper.extractLongNamed( final Long loanPortfolioAccountId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.LOAN_PORTFOLIO.getValue(), element); LoanProductAccountingParams.LOAN_PORTFOLIO.getValue(), element);
baseDataValidator.reset().parameter(LOAN_PRODUCT_ACCOUNTING_PARAMS.LOAN_PORTFOLIO.getValue()).value(loanPortfolioAccountId) baseDataValidator.reset().parameter(LoanProductAccountingParams.LOAN_PORTFOLIO.getValue()).value(loanPortfolioAccountId)
.ignoreIfNull().integerGreaterThanZero(); .ignoreIfNull().integerGreaterThanZero();
final Long transfersInSuspenseAccountId = this.fromApiJsonHelper.extractLongNamed( final Long transfersInSuspenseAccountId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(), element); LoanProductAccountingParams.TRANSFERS_SUSPENSE.getValue(), element);
baseDataValidator.reset().parameter(LOAN_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue()) baseDataValidator.reset().parameter(LoanProductAccountingParams.TRANSFERS_SUSPENSE.getValue())
.value(transfersInSuspenseAccountId).ignoreIfNull().integerGreaterThanZero(); .value(transfersInSuspenseAccountId).ignoreIfNull().integerGreaterThanZero();
final Long incomeFromInterestId = this.fromApiJsonHelper.extractLongNamed( final Long incomeFromInterestId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_LOANS.getValue(), element); LoanProductAccountingParams.INTEREST_ON_LOANS.getValue(), element);
baseDataValidator.reset().parameter(LOAN_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_LOANS.getValue()).value(incomeFromInterestId) baseDataValidator.reset().parameter(LoanProductAccountingParams.INTEREST_ON_LOANS.getValue()).value(incomeFromInterestId)
.ignoreIfNull().integerGreaterThanZero(); .ignoreIfNull().integerGreaterThanZero();
final Long incomeFromFeeId = this.fromApiJsonHelper.extractLongNamed(LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), final Long incomeFromFeeId = this.fromApiJsonHelper.extractLongNamed(LoanProductAccountingParams.INCOME_FROM_FEES.getValue(),
element); element);
baseDataValidator.reset().parameter(LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue()).value(incomeFromFeeId) baseDataValidator.reset().parameter(LoanProductAccountingParams.INCOME_FROM_FEES.getValue()).value(incomeFromFeeId)
.ignoreIfNull().integerGreaterThanZero(); .ignoreIfNull().integerGreaterThanZero();
final Long incomeFromPenaltyId = this.fromApiJsonHelper.extractLongNamed( final Long incomeFromPenaltyId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue(), element); LoanProductAccountingParams.INCOME_FROM_PENALTIES.getValue(), element);
baseDataValidator.reset().parameter(LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue()).value(incomeFromPenaltyId) baseDataValidator.reset().parameter(LoanProductAccountingParams.INCOME_FROM_PENALTIES.getValue()).value(incomeFromPenaltyId)
.ignoreIfNull().integerGreaterThanZero(); .ignoreIfNull().integerGreaterThanZero();
final Long incomeFromRecoveryAccountId = this.fromApiJsonHelper.extractLongNamed( final Long incomeFromRecoveryAccountId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_RECOVERY.getValue(), element); LoanProductAccountingParams.INCOME_FROM_RECOVERY.getValue(), element);
baseDataValidator.reset().parameter(LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_RECOVERY.getValue()) baseDataValidator.reset().parameter(LoanProductAccountingParams.INCOME_FROM_RECOVERY.getValue())
.value(incomeFromRecoveryAccountId).ignoreIfNull().integerGreaterThanZero(); .value(incomeFromRecoveryAccountId).ignoreIfNull().integerGreaterThanZero();
final Long writeOffAccountId = this.fromApiJsonHelper.extractLongNamed( final Long writeOffAccountId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue(), element); LoanProductAccountingParams.LOSSES_WRITTEN_OFF.getValue(), element);
baseDataValidator.reset().parameter(LOAN_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue()).value(writeOffAccountId) baseDataValidator.reset().parameter(LoanProductAccountingParams.LOSSES_WRITTEN_OFF.getValue()).value(writeOffAccountId)
.ignoreIfNull().integerGreaterThanZero(); .ignoreIfNull().integerGreaterThanZero();
final Long overpaymentAccountId = this.fromApiJsonHelper.extractLongNamed(LOAN_PRODUCT_ACCOUNTING_PARAMS.OVERPAYMENT.getValue(), final Long overpaymentAccountId = this.fromApiJsonHelper.extractLongNamed(LoanProductAccountingParams.OVERPAYMENT.getValue(),
element); element);
baseDataValidator.reset().parameter(LOAN_PRODUCT_ACCOUNTING_PARAMS.OVERPAYMENT.getValue()).value(overpaymentAccountId) baseDataValidator.reset().parameter(LoanProductAccountingParams.OVERPAYMENT.getValue()).value(overpaymentAccountId)
.ignoreIfNull().integerGreaterThanZero(); .ignoreIfNull().integerGreaterThanZero();
final Long receivableInterestAccountId = this.fromApiJsonHelper.extractLongNamed( final Long receivableInterestAccountId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.INTEREST_RECEIVABLE.getValue(), element); LoanProductAccountingParams.INTEREST_RECEIVABLE.getValue(), element);
baseDataValidator.reset().parameter(LOAN_PRODUCT_ACCOUNTING_PARAMS.INTEREST_RECEIVABLE.getValue()) baseDataValidator.reset().parameter(LoanProductAccountingParams.INTEREST_RECEIVABLE.getValue())
.value(receivableInterestAccountId).ignoreIfNull().integerGreaterThanZero(); .value(receivableInterestAccountId).ignoreIfNull().integerGreaterThanZero();
final Long receivableFeeAccountId = this.fromApiJsonHelper.extractLongNamed( final Long receivableFeeAccountId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.FEES_RECEIVABLE.getValue(), element); LoanProductAccountingParams.FEES_RECEIVABLE.getValue(), element);
baseDataValidator.reset().parameter(LOAN_PRODUCT_ACCOUNTING_PARAMS.FEES_RECEIVABLE.getValue()).value(receivableFeeAccountId) baseDataValidator.reset().parameter(LoanProductAccountingParams.FEES_RECEIVABLE.getValue()).value(receivableFeeAccountId)
.ignoreIfNull().integerGreaterThanZero(); .ignoreIfNull().integerGreaterThanZero();
final Long receivablePenaltyAccountId = this.fromApiJsonHelper.extractLongNamed( final Long receivablePenaltyAccountId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.PENALTIES_RECEIVABLE.getValue(), element); LoanProductAccountingParams.PENALTIES_RECEIVABLE.getValue(), element);
baseDataValidator.reset().parameter(LOAN_PRODUCT_ACCOUNTING_PARAMS.PENALTIES_RECEIVABLE.getValue()) baseDataValidator.reset().parameter(LoanProductAccountingParams.PENALTIES_RECEIVABLE.getValue())
.value(receivablePenaltyAccountId).ignoreIfNull().integerGreaterThanZero(); .value(receivablePenaltyAccountId).ignoreIfNull().integerGreaterThanZero();
validatePaymentChannelFundSourceMappings(baseDataValidator, element); validatePaymentChannelFundSourceMappings(baseDataValidator, element);
@@ -1503,29 +1503,29 @@ public final class LoanProductDataValidator {
* Validation for advanced accounting options * Validation for advanced accounting options
*/ */
private void validatePaymentChannelFundSourceMappings(final DataValidatorBuilder baseDataValidator, final JsonElement element) { private void validatePaymentChannelFundSourceMappings(final DataValidatorBuilder baseDataValidator, final JsonElement element) {
if (this.fromApiJsonHelper.parameterExists(LOAN_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(), element)) { if (this.fromApiJsonHelper.parameterExists(LoanProductAccountingParams.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(), element)) {
final JsonArray paymentChannelMappingArray = this.fromApiJsonHelper.extractJsonArrayNamed( final JsonArray paymentChannelMappingArray = this.fromApiJsonHelper.extractJsonArrayNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(), element); LoanProductAccountingParams.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(), element);
if (paymentChannelMappingArray != null && paymentChannelMappingArray.size() > 0) { if (paymentChannelMappingArray != null && paymentChannelMappingArray.size() > 0) {
int i = 0; int i = 0;
do { do {
final JsonObject jsonObject = paymentChannelMappingArray.get(i).getAsJsonObject(); final JsonObject jsonObject = paymentChannelMappingArray.get(i).getAsJsonObject();
final Long paymentTypeId = this.fromApiJsonHelper.extractLongNamed( final Long paymentTypeId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_TYPE.getValue(), jsonObject); LoanProductAccountingParams.PAYMENT_TYPE.getValue(), jsonObject);
final Long paymentSpecificFundAccountId = this.fromApiJsonHelper.extractLongNamed( final Long paymentSpecificFundAccountId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue(), jsonObject); LoanProductAccountingParams.FUND_SOURCE.getValue(), jsonObject);
baseDataValidator baseDataValidator
.reset() .reset()
.parameter( .parameter(
LOAN_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue() + "[" + i + "]." LoanProductAccountingParams.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue() + "[" + i + "]."
+ LOAN_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_TYPE.getValue()).value(paymentTypeId).notNull() + LoanProductAccountingParams.PAYMENT_TYPE.getValue()).value(paymentTypeId).notNull()
.integerGreaterThanZero(); .integerGreaterThanZero();
baseDataValidator baseDataValidator
.reset() .reset()
.parameter( .parameter(
LOAN_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue() + "[" + i + "]." LoanProductAccountingParams.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue() + "[" + i + "]."
+ LOAN_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue()).value(paymentSpecificFundAccountId) + LoanProductAccountingParams.FUND_SOURCE.getValue()).value(paymentSpecificFundAccountId)
.notNull().integerGreaterThanZero(); .notNull().integerGreaterThanZero();
i++; i++;
} while (i < paymentChannelMappingArray.size()); } while (i < paymentChannelMappingArray.size());
@@ -1543,9 +1543,9 @@ public final class LoanProductDataValidator {
final boolean isPenalty) { final boolean isPenalty) {
String parameterName; String parameterName;
if (isPenalty) { if (isPenalty) {
parameterName = LOAN_PRODUCT_ACCOUNTING_PARAMS.PENALTY_INCOME_ACCOUNT_MAPPING.getValue(); parameterName = LoanProductAccountingParams.PENALTY_INCOME_ACCOUNT_MAPPING.getValue();
} else { } else {
parameterName = LOAN_PRODUCT_ACCOUNTING_PARAMS.FEE_INCOME_ACCOUNT_MAPPING.getValue(); parameterName = LoanProductAccountingParams.FEE_INCOME_ACCOUNT_MAPPING.getValue();
} }
if (this.fromApiJsonHelper.parameterExists(parameterName, element)) { if (this.fromApiJsonHelper.parameterExists(parameterName, element)) {
@@ -1554,15 +1554,15 @@ public final class LoanProductDataValidator {
int i = 0; int i = 0;
do { do {
final JsonObject jsonObject = chargeToIncomeAccountMappingArray.get(i).getAsJsonObject(); final JsonObject jsonObject = chargeToIncomeAccountMappingArray.get(i).getAsJsonObject();
final Long chargeId = this.fromApiJsonHelper.extractLongNamed(LOAN_PRODUCT_ACCOUNTING_PARAMS.CHARGE_ID.getValue(), final Long chargeId = this.fromApiJsonHelper.extractLongNamed(LoanProductAccountingParams.CHARGE_ID.getValue(),
jsonObject); jsonObject);
final Long incomeAccountId = this.fromApiJsonHelper.extractLongNamed( final Long incomeAccountId = this.fromApiJsonHelper.extractLongNamed(
LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_ACCOUNT_ID.getValue(), jsonObject); LoanProductAccountingParams.INCOME_ACCOUNT_ID.getValue(), jsonObject);
baseDataValidator.reset() baseDataValidator.reset()
.parameter(parameterName + "[" + i + "]." + LOAN_PRODUCT_ACCOUNTING_PARAMS.CHARGE_ID.getValue()) .parameter(parameterName + "[" + i + "]." + LoanProductAccountingParams.CHARGE_ID.getValue())
.value(chargeId).notNull().integerGreaterThanZero(); .value(chargeId).notNull().integerGreaterThanZero();
baseDataValidator.reset() baseDataValidator.reset()
.parameter(parameterName + "[" + i + "]." + LOAN_PRODUCT_ACCOUNTING_PARAMS.INCOME_ACCOUNT_ID.getValue()) .parameter(parameterName + "[" + i + "]." + LoanProductAccountingParams.INCOME_ACCOUNT_ID.getValue())
.value(incomeAccountId).notNull().integerGreaterThanZero(); .value(incomeAccountId).notNull().integerGreaterThanZero();
i++; i++;
} while (i < chargeToIncomeAccountMappingArray.size()); } while (i < chargeToIncomeAccountMappingArray.size());
@@ -37,8 +37,8 @@ import org.apache.fineract.infrastructure.security.service.PlatformSecurityConte
import org.apache.fineract.portfolio.charge.domain.Charge; import org.apache.fineract.portfolio.charge.domain.Charge;
import org.apache.fineract.portfolio.charge.domain.ChargeRepositoryWrapper; import org.apache.fineract.portfolio.charge.domain.ChargeRepositoryWrapper;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BUSINESS_ENTITY; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEntity;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BUSINESS_EVENTS; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEvents;
import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService; import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.floatingrates.domain.FloatingRate; import org.apache.fineract.portfolio.floatingrates.domain.FloatingRate;
import org.apache.fineract.portfolio.floatingrates.domain.FloatingRateRepositoryWrapper; import org.apache.fineract.portfolio.floatingrates.domain.FloatingRateRepositoryWrapper;
@@ -151,11 +151,11 @@ public class LoanProductWritePlatformServiceJpaRepositoryImpl implements LoanPro
FineractEntityAccessType.OFFICE_ACCESS_TO_LOAN_PRODUCTS, FineractEntityAccessType.OFFICE_ACCESS_TO_LOAN_PRODUCTS,
loanproduct.getId()); loanproduct.getId());
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.LOAN_PRODUCT_CREATE, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_PRODUCT_CREATE,
constructEntityMap(BUSINESS_ENTITY.LOAN_PRODUCT, loanproduct)); constructEntityMap(BusinessEntity.LOAN_PRODUCT, loanproduct));
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.LOAN_PRODUCT_CREATE, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.LOAN_PRODUCT_CREATE,
constructEntityMap(BUSINESS_ENTITY.LOAN_PRODUCT, loanproduct)); constructEntityMap(BusinessEntity.LOAN_PRODUCT, loanproduct));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
@@ -380,8 +380,8 @@ public class LoanProductWritePlatformServiceJpaRepositoryImpl implements LoanPro
logger.error("Error occured.", dve); logger.error("Error occured.", dve);
} }
private Map<BusinessEventNotificationConstants.BUSINESS_ENTITY, Object> constructEntityMap(final BusinessEventNotificationConstants.BUSINESS_ENTITY entityEvent, Object entity) { private Map<BusinessEventNotificationConstants.BusinessEntity, Object> constructEntityMap(final BusinessEventNotificationConstants.BusinessEntity entityEvent, Object entity) {
Map<BusinessEventNotificationConstants.BUSINESS_ENTITY, Object> map = new HashMap<>(1); Map<BusinessEventNotificationConstants.BusinessEntity, Object> map = new HashMap<>(1);
map.put(entityEvent, entity); map.put(entityEvent, entity);
return map; return map;
} }
@@ -21,7 +21,7 @@ package org.apache.fineract.portfolio.savings;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import org.apache.fineract.accounting.common.AccountingConstants.SAVINGS_PRODUCT_ACCOUNTING_PARAMS; import org.apache.fineract.accounting.common.AccountingConstants.SavingProductAccountingParams;
public class DepositsApiConstants { public class DepositsApiConstants {
@@ -207,14 +207,14 @@ public class DepositsApiConstants {
digitsAfterDecimalParamName, inMultiplesOfParamName, nominalAnnualInterestRateParamName, digitsAfterDecimalParamName, inMultiplesOfParamName, nominalAnnualInterestRateParamName,
interestCompoundingPeriodTypeParamName, interestPostingPeriodTypeParamName, interestCalculationTypeParamName, interestCompoundingPeriodTypeParamName, interestPostingPeriodTypeParamName, interestCalculationTypeParamName,
interestCalculationDaysInYearTypeParamName, lockinPeriodFrequencyParamName, lockinPeriodFrequencyTypeParamName, interestCalculationDaysInYearTypeParamName, lockinPeriodFrequencyParamName, lockinPeriodFrequencyTypeParamName,
accountingRuleParamName, chargesParamName, SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), accountingRuleParamName, chargesParamName, SavingProductAccountingParams.INCOME_FROM_FEES.getValue(),
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue(), SavingProductAccountingParams.INCOME_FROM_PENALTIES.getValue(),
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_SAVINGS.getValue(), SavingProductAccountingParams.INTEREST_ON_SAVINGS.getValue(),
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(), SavingProductAccountingParams.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(),
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_CONTROL.getValue(), SAVINGS_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(), SavingProductAccountingParams.SAVINGS_CONTROL.getValue(), SavingProductAccountingParams.TRANSFERS_SUSPENSE.getValue(),
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_REFERENCE.getValue(), SavingProductAccountingParams.SAVINGS_REFERENCE.getValue(),
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.FEE_INCOME_ACCOUNT_MAPPING.getValue(), SavingProductAccountingParams.FEE_INCOME_ACCOUNT_MAPPING.getValue(),
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.PENALTY_INCOME_ACCOUNT_MAPPING.getValue(), chartsParamName, SavingProductAccountingParams.PENALTY_INCOME_ACCOUNT_MAPPING.getValue(), chartsParamName,
SavingsApiConstants.withHoldTaxParamName, SavingsApiConstants.taxGroupIdParamName)); SavingsApiConstants.withHoldTaxParamName, SavingsApiConstants.taxGroupIdParamName));
private static final Set<String> PRECLOSURE_REQUEST_DATA_PARAMETERS = new HashSet<>(Arrays.asList(preClosurePenalApplicableParamName, private static final Set<String> PRECLOSURE_REQUEST_DATA_PARAMETERS = new HashSet<>(Arrays.asList(preClosurePenalApplicableParamName,
@@ -71,7 +71,7 @@ import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.accounting.common.AccountingConstants.SAVINGS_PRODUCT_ACCOUNTING_PARAMS; import org.apache.fineract.accounting.common.AccountingConstants.SavingProductAccountingParams;
import org.apache.fineract.accounting.common.AccountingRuleType; import org.apache.fineract.accounting.common.AccountingRuleType;
import org.apache.fineract.infrastructure.core.data.ApiParameterError; import org.apache.fineract.infrastructure.core.data.ApiParameterError;
import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder; import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder;
@@ -301,33 +301,33 @@ public class DepositProductDataValidator {
if (isCashBasedAccounting(accountingRuleType)) { if (isCashBasedAccounting(accountingRuleType)) {
final Long savingsControlAccountId = fromApiJsonHelper.extractLongNamed( final Long savingsControlAccountId = fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_CONTROL.getValue(), element); SavingProductAccountingParams.SAVINGS_CONTROL.getValue(), element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_CONTROL.getValue()) baseDataValidator.reset().parameter(SavingProductAccountingParams.SAVINGS_CONTROL.getValue())
.value(savingsControlAccountId).notNull().integerGreaterThanZero(); .value(savingsControlAccountId).notNull().integerGreaterThanZero();
final Long savingsReferenceAccountId = fromApiJsonHelper.extractLongNamed( final Long savingsReferenceAccountId = fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_REFERENCE.getValue(), element); SavingProductAccountingParams.SAVINGS_REFERENCE.getValue(), element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_REFERENCE.getValue()) baseDataValidator.reset().parameter(SavingProductAccountingParams.SAVINGS_REFERENCE.getValue())
.value(savingsReferenceAccountId).notNull().integerGreaterThanZero(); .value(savingsReferenceAccountId).notNull().integerGreaterThanZero();
final Long transfersInSuspenseAccountId = fromApiJsonHelper.extractLongNamed( final Long transfersInSuspenseAccountId = fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(), element); SavingProductAccountingParams.TRANSFERS_SUSPENSE.getValue(), element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue()) baseDataValidator.reset().parameter(SavingProductAccountingParams.TRANSFERS_SUSPENSE.getValue())
.value(transfersInSuspenseAccountId).notNull().integerGreaterThanZero(); .value(transfersInSuspenseAccountId).notNull().integerGreaterThanZero();
final Long interestOnSavingsAccountId = fromApiJsonHelper.extractLongNamed( final Long interestOnSavingsAccountId = fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_SAVINGS.getValue(), element); SavingProductAccountingParams.INTEREST_ON_SAVINGS.getValue(), element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_SAVINGS.getValue()) baseDataValidator.reset().parameter(SavingProductAccountingParams.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 = fromApiJsonHelper.extractLongNamed(SavingProductAccountingParams.INCOME_FROM_FEES.getValue(),
element); element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue()).value(incomeFromFeeId) baseDataValidator.reset().parameter(SavingProductAccountingParams.INCOME_FROM_FEES.getValue()).value(incomeFromFeeId)
.notNull().integerGreaterThanZero(); .notNull().integerGreaterThanZero();
final Long incomeFromPenaltyId = fromApiJsonHelper.extractLongNamed( final Long incomeFromPenaltyId = fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue(), element); SavingProductAccountingParams.INCOME_FROM_PENALTIES.getValue(), element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue()) baseDataValidator.reset().parameter(SavingProductAccountingParams.INCOME_FROM_PENALTIES.getValue())
.value(incomeFromPenaltyId).notNull().integerGreaterThanZero(); .value(incomeFromPenaltyId).notNull().integerGreaterThanZero();
validatePaymentChannelFundSourceMappings(fromApiJsonHelper, baseDataValidator, element); validatePaymentChannelFundSourceMappings(fromApiJsonHelper, baseDataValidator, element);
@@ -510,33 +510,33 @@ public class DepositProductDataValidator {
} }
final Long savingsControlAccountId = fromApiJsonHelper.extractLongNamed( final Long savingsControlAccountId = fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_CONTROL.getValue(), element); SavingProductAccountingParams.SAVINGS_CONTROL.getValue(), element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_CONTROL.getValue()).value(savingsControlAccountId) baseDataValidator.reset().parameter(SavingProductAccountingParams.SAVINGS_CONTROL.getValue()).value(savingsControlAccountId)
.ignoreIfNull().integerGreaterThanZero(); .ignoreIfNull().integerGreaterThanZero();
final Long savingsReferenceAccountId = fromApiJsonHelper.extractLongNamed( final Long savingsReferenceAccountId = fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_REFERENCE.getValue(), element); SavingProductAccountingParams.SAVINGS_REFERENCE.getValue(), element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_REFERENCE.getValue()) baseDataValidator.reset().parameter(SavingProductAccountingParams.SAVINGS_REFERENCE.getValue())
.value(savingsReferenceAccountId).ignoreIfNull().integerGreaterThanZero(); .value(savingsReferenceAccountId).ignoreIfNull().integerGreaterThanZero();
final Long transfersInSuspenseAccountId = fromApiJsonHelper.extractLongNamed( final Long transfersInSuspenseAccountId = fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(), element); SavingProductAccountingParams.TRANSFERS_SUSPENSE.getValue(), element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue()) baseDataValidator.reset().parameter(SavingProductAccountingParams.TRANSFERS_SUSPENSE.getValue())
.value(transfersInSuspenseAccountId).ignoreIfNull().integerGreaterThanZero(); .value(transfersInSuspenseAccountId).ignoreIfNull().integerGreaterThanZero();
final Long interestOnSavingsAccountId = fromApiJsonHelper.extractLongNamed( final Long interestOnSavingsAccountId = fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_SAVINGS.getValue(), element); SavingProductAccountingParams.INTEREST_ON_SAVINGS.getValue(), element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_SAVINGS.getValue()) baseDataValidator.reset().parameter(SavingProductAccountingParams.INTEREST_ON_SAVINGS.getValue())
.value(interestOnSavingsAccountId).ignoreIfNull().integerGreaterThanZero(); .value(interestOnSavingsAccountId).ignoreIfNull().integerGreaterThanZero();
final Long incomeFromFeeId = fromApiJsonHelper.extractLongNamed(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), final Long incomeFromFeeId = fromApiJsonHelper.extractLongNamed(SavingProductAccountingParams.INCOME_FROM_FEES.getValue(),
element); element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue()).value(incomeFromFeeId) baseDataValidator.reset().parameter(SavingProductAccountingParams.INCOME_FROM_FEES.getValue()).value(incomeFromFeeId)
.ignoreIfNull().integerGreaterThanZero(); .ignoreIfNull().integerGreaterThanZero();
final Long incomeFromPenaltyId = fromApiJsonHelper.extractLongNamed( final Long incomeFromPenaltyId = fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue(), element); SavingProductAccountingParams.INCOME_FROM_PENALTIES.getValue(), element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue()).value(incomeFromPenaltyId) baseDataValidator.reset().parameter(SavingProductAccountingParams.INCOME_FROM_PENALTIES.getValue()).value(incomeFromPenaltyId)
.ignoreIfNull().integerGreaterThanZero(); .ignoreIfNull().integerGreaterThanZero();
validatePaymentChannelFundSourceMappings(fromApiJsonHelper, baseDataValidator, element); validatePaymentChannelFundSourceMappings(fromApiJsonHelper, baseDataValidator, element);
@@ -615,27 +615,27 @@ public class DepositProductDataValidator {
*/ */
private void validatePaymentChannelFundSourceMappings(final FromJsonHelper fromApiJsonHelper, private void validatePaymentChannelFundSourceMappings(final FromJsonHelper fromApiJsonHelper,
final DataValidatorBuilder baseDataValidator, final JsonElement element) { final DataValidatorBuilder baseDataValidator, final JsonElement element) {
if (fromApiJsonHelper.parameterExists(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(), element)) { if (fromApiJsonHelper.parameterExists(SavingProductAccountingParams.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(), element)) {
final JsonArray paymentChannelMappingArray = fromApiJsonHelper.extractJsonArrayNamed( final JsonArray paymentChannelMappingArray = fromApiJsonHelper.extractJsonArrayNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(), element); SavingProductAccountingParams.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(), element);
if (paymentChannelMappingArray != null && paymentChannelMappingArray.size() > 0) { if (paymentChannelMappingArray != null && paymentChannelMappingArray.size() > 0) {
int i = 0; int i = 0;
do { do {
final JsonObject jsonObject = paymentChannelMappingArray.get(i).getAsJsonObject(); final JsonObject jsonObject = paymentChannelMappingArray.get(i).getAsJsonObject();
final Long paymentTypeId = jsonObject.get(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_TYPE.getValue()).getAsLong(); final Long paymentTypeId = jsonObject.get(SavingProductAccountingParams.PAYMENT_TYPE.getValue()).getAsLong();
final Long paymentSpecificFundAccountId = jsonObject.get(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue()) final Long paymentSpecificFundAccountId = jsonObject.get(SavingProductAccountingParams.FUND_SOURCE.getValue())
.getAsLong(); .getAsLong();
baseDataValidator baseDataValidator
.reset() .reset()
.parameter( .parameter(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue() + "[" + i + "]." SavingProductAccountingParams.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue() + "[" + i + "]."
+ SAVINGS_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_TYPE.toString()).value(paymentTypeId).notNull() + SavingProductAccountingParams.PAYMENT_TYPE.toString()).value(paymentTypeId).notNull()
.integerGreaterThanZero(); .integerGreaterThanZero();
baseDataValidator baseDataValidator
.reset() .reset()
.parameter( .parameter(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue() + "[" + i + "]." SavingProductAccountingParams.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue() + "[" + i + "]."
+ SAVINGS_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue()).value(paymentSpecificFundAccountId) + SavingProductAccountingParams.FUND_SOURCE.getValue()).value(paymentSpecificFundAccountId)
.notNull().integerGreaterThanZero(); .notNull().integerGreaterThanZero();
i++; i++;
} while (i < paymentChannelMappingArray.size()); } while (i < paymentChannelMappingArray.size());
@@ -654,9 +654,9 @@ public class DepositProductDataValidator {
final DataValidatorBuilder baseDataValidator, final JsonElement element, final boolean isPenalty) { final DataValidatorBuilder baseDataValidator, final JsonElement element, final boolean isPenalty) {
String parameterName; String parameterName;
if (isPenalty) { if (isPenalty) {
parameterName = SAVINGS_PRODUCT_ACCOUNTING_PARAMS.PENALTY_INCOME_ACCOUNT_MAPPING.getValue(); parameterName = SavingProductAccountingParams.PENALTY_INCOME_ACCOUNT_MAPPING.getValue();
} else { } else {
parameterName = SAVINGS_PRODUCT_ACCOUNTING_PARAMS.FEE_INCOME_ACCOUNT_MAPPING.getValue(); parameterName = SavingProductAccountingParams.FEE_INCOME_ACCOUNT_MAPPING.getValue();
} }
if (fromApiJsonHelper.parameterExists(parameterName, element)) { if (fromApiJsonHelper.parameterExists(parameterName, element)) {
@@ -665,15 +665,15 @@ public class DepositProductDataValidator {
int i = 0; int i = 0;
do { do {
final JsonObject jsonObject = chargeToIncomeAccountMappingArray.get(i).getAsJsonObject(); final JsonObject jsonObject = chargeToIncomeAccountMappingArray.get(i).getAsJsonObject();
final Long chargeId = fromApiJsonHelper.extractLongNamed(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.CHARGE_ID.getValue(), final Long chargeId = fromApiJsonHelper.extractLongNamed(SavingProductAccountingParams.CHARGE_ID.getValue(),
jsonObject); jsonObject);
final Long incomeAccountId = fromApiJsonHelper.extractLongNamed( final Long incomeAccountId = fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_ACCOUNT_ID.getValue(), jsonObject); SavingProductAccountingParams.INCOME_ACCOUNT_ID.getValue(), jsonObject);
baseDataValidator.reset() baseDataValidator.reset()
.parameter(parameterName + "[" + i + "]." + SAVINGS_PRODUCT_ACCOUNTING_PARAMS.CHARGE_ID.getValue()) .parameter(parameterName + "[" + i + "]." + SavingProductAccountingParams.CHARGE_ID.getValue())
.value(chargeId).notNull().integerGreaterThanZero(); .value(chargeId).notNull().integerGreaterThanZero();
baseDataValidator.reset() baseDataValidator.reset()
.parameter(parameterName + "[" + i + "]." + SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_ACCOUNT_ID.getValue()) .parameter(parameterName + "[" + i + "]." + SavingProductAccountingParams.INCOME_ACCOUNT_ID.getValue())
.value(incomeAccountId).notNull().integerGreaterThanZero(); .value(incomeAccountId).notNull().integerGreaterThanZero();
i++; i++;
} while (i < chargeToIncomeAccountMappingArray.size()); } while (i < chargeToIncomeAccountMappingArray.size());
@@ -62,7 +62,7 @@ import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.accounting.common.AccountingConstants.SAVINGS_PRODUCT_ACCOUNTING_PARAMS; import org.apache.fineract.accounting.common.AccountingConstants.SavingProductAccountingParams;
import org.apache.fineract.accounting.common.AccountingRuleType; import org.apache.fineract.accounting.common.AccountingRuleType;
import org.apache.fineract.infrastructure.core.data.ApiParameterError; import org.apache.fineract.infrastructure.core.data.ApiParameterError;
import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder; import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder;
@@ -93,19 +93,19 @@ public class SavingsProductDataValidator {
lockinPeriodFrequencyTypeParamName, SavingsApiConstants.withdrawalFeeAmountParamName, lockinPeriodFrequencyTypeParamName, SavingsApiConstants.withdrawalFeeAmountParamName,
SavingsApiConstants.withdrawalFeeTypeParamName, withdrawalFeeForTransfersParamName, SavingsApiConstants.withdrawalFeeTypeParamName, withdrawalFeeForTransfersParamName,
feeAmountParamName, feeOnMonthDayParamName, SavingsApiConstants.accountingRuleParamName, feeAmountParamName, feeOnMonthDayParamName, SavingsApiConstants.accountingRuleParamName,
SavingsApiConstants.chargesParamName, SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), SavingsApiConstants.chargesParamName, SavingProductAccountingParams.INCOME_FROM_FEES.getValue(),
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue(), SavingProductAccountingParams.INCOME_FROM_PENALTIES.getValue(),
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_SAVINGS.getValue(), SavingProductAccountingParams.INTEREST_ON_SAVINGS.getValue(),
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(), SavingProductAccountingParams.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(),
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_CONTROL.getValue(), SavingProductAccountingParams.SAVINGS_CONTROL.getValue(),
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(), SavingProductAccountingParams.TRANSFERS_SUSPENSE.getValue(),
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_REFERENCE.getValue(), SavingProductAccountingParams.SAVINGS_REFERENCE.getValue(),
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.FEE_INCOME_ACCOUNT_MAPPING.getValue(), SavingProductAccountingParams.FEE_INCOME_ACCOUNT_MAPPING.getValue(),
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.PENALTY_INCOME_ACCOUNT_MAPPING.getValue(), SavingProductAccountingParams.PENALTY_INCOME_ACCOUNT_MAPPING.getValue(),
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), SavingProductAccountingParams.OVERDRAFT_PORTFOLIO_CONTROL.getValue(),
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue(), SavingProductAccountingParams.LOSSES_WRITTEN_OFF.getValue(),
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_INTEREST.getValue(), SavingProductAccountingParams.INCOME_FROM_INTEREST.getValue(),
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.ESCHEAT_LIABILITY.getValue(), isDormancyTrackingActiveParamName, SavingProductAccountingParams.ESCHEAT_LIABILITY.getValue(), isDormancyTrackingActiveParamName,
daysToDormancyParamName, daysToInactiveParamName, daysToEscheatParamName, allowOverdraftParamName, daysToDormancyParamName, daysToInactiveParamName, daysToEscheatParamName, allowOverdraftParamName,
overdraftLimitParamName, nominalAnnualInterestRateOverdraftParamName, overdraftLimitParamName, nominalAnnualInterestRateOverdraftParamName,
minOverdraftForInterestCalculationParamName, SavingsApiConstants.minRequiredBalanceParamName, minOverdraftForInterestCalculationParamName, SavingsApiConstants.minRequiredBalanceParamName,
@@ -297,54 +297,54 @@ public class SavingsProductDataValidator {
if (isCashBasedAccounting(accountingRuleType)) { if (isCashBasedAccounting(accountingRuleType)) {
final Long savingsControlAccountId = this.fromApiJsonHelper.extractLongNamed( final Long savingsControlAccountId = this.fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_CONTROL.getValue(), element); SavingProductAccountingParams.SAVINGS_CONTROL.getValue(), element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_CONTROL.getValue()) baseDataValidator.reset().parameter(SavingProductAccountingParams.SAVINGS_CONTROL.getValue())
.value(savingsControlAccountId).notNull().integerGreaterThanZero(); .value(savingsControlAccountId).notNull().integerGreaterThanZero();
final Long savingsReferenceAccountId = this.fromApiJsonHelper.extractLongNamed( final Long savingsReferenceAccountId = this.fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_REFERENCE.getValue(), element); SavingProductAccountingParams.SAVINGS_REFERENCE.getValue(), element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_REFERENCE.getValue()) baseDataValidator.reset().parameter(SavingProductAccountingParams.SAVINGS_REFERENCE.getValue())
.value(savingsReferenceAccountId).notNull().integerGreaterThanZero(); .value(savingsReferenceAccountId).notNull().integerGreaterThanZero();
final Long transfersInSuspenseAccountId = this.fromApiJsonHelper.extractLongNamed( final Long transfersInSuspenseAccountId = this.fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(), element); SavingProductAccountingParams.TRANSFERS_SUSPENSE.getValue(), element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue()) baseDataValidator.reset().parameter(SavingProductAccountingParams.TRANSFERS_SUSPENSE.getValue())
.value(transfersInSuspenseAccountId).notNull().integerGreaterThanZero(); .value(transfersInSuspenseAccountId).notNull().integerGreaterThanZero();
final Long interestOnSavingsAccountId = this.fromApiJsonHelper.extractLongNamed( final Long interestOnSavingsAccountId = this.fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_SAVINGS.getValue(), element); SavingProductAccountingParams.INTEREST_ON_SAVINGS.getValue(), element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_SAVINGS.getValue()) baseDataValidator.reset().parameter(SavingProductAccountingParams.INTEREST_ON_SAVINGS.getValue())
.value(interestOnSavingsAccountId).notNull().integerGreaterThanZero(); .value(interestOnSavingsAccountId).notNull().integerGreaterThanZero();
final Long incomeFromFeeId = this.fromApiJsonHelper.extractLongNamed( final Long incomeFromFeeId = this.fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), element); SavingProductAccountingParams.INCOME_FROM_FEES.getValue(), element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue()).value(incomeFromFeeId) baseDataValidator.reset().parameter(SavingProductAccountingParams.INCOME_FROM_FEES.getValue()).value(incomeFromFeeId)
.notNull().integerGreaterThanZero(); .notNull().integerGreaterThanZero();
final Long incomeFromPenaltyId = this.fromApiJsonHelper.extractLongNamed( final Long incomeFromPenaltyId = this.fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue(), element); SavingProductAccountingParams.INCOME_FROM_PENALTIES.getValue(), element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue()) baseDataValidator.reset().parameter(SavingProductAccountingParams.INCOME_FROM_PENALTIES.getValue())
.value(incomeFromPenaltyId).notNull().integerGreaterThanZero(); .value(incomeFromPenaltyId).notNull().integerGreaterThanZero();
final Long overdraftControlAccountId = this.fromApiJsonHelper.extractLongNamed( final Long overdraftControlAccountId = this.fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), element); SavingProductAccountingParams.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.OVERDRAFT_PORTFOLIO_CONTROL.getValue()) baseDataValidator.reset().parameter(SavingProductAccountingParams.OVERDRAFT_PORTFOLIO_CONTROL.getValue())
.value(overdraftControlAccountId).notNull().integerGreaterThanZero(); .value(overdraftControlAccountId).notNull().integerGreaterThanZero();
final Long incomeFromInterest = this.fromApiJsonHelper.extractLongNamed( final Long incomeFromInterest = this.fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_INTEREST.getValue(), element); SavingProductAccountingParams.INCOME_FROM_INTEREST.getValue(), element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_INTEREST.getValue()) baseDataValidator.reset().parameter(SavingProductAccountingParams.INCOME_FROM_INTEREST.getValue())
.value(incomeFromInterest).notNull().integerGreaterThanZero(); .value(incomeFromInterest).notNull().integerGreaterThanZero();
final Long writtenoff = this.fromApiJsonHelper.extractLongNamed( final Long writtenoff = this.fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue(), element); SavingProductAccountingParams.LOSSES_WRITTEN_OFF.getValue(), element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue()).value(writtenoff) baseDataValidator.reset().parameter(SavingProductAccountingParams.LOSSES_WRITTEN_OFF.getValue()).value(writtenoff)
.notNull().integerGreaterThanZero(); .notNull().integerGreaterThanZero();
if(null != isDormancyActive && isDormancyActive){ if(null != isDormancyActive && isDormancyActive){
final Long escheatLiabilityAccountId = this.fromApiJsonHelper.extractLongNamed( final Long escheatLiabilityAccountId = this.fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.ESCHEAT_LIABILITY.getValue(), element); SavingProductAccountingParams.ESCHEAT_LIABILITY.getValue(), element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.ESCHEAT_LIABILITY.getValue()) baseDataValidator.reset().parameter(SavingProductAccountingParams.ESCHEAT_LIABILITY.getValue())
.value(escheatLiabilityAccountId).notNull().integerGreaterThanZero(); .value(escheatLiabilityAccountId).notNull().integerGreaterThanZero();
} }
@@ -473,48 +473,48 @@ public class SavingsProductDataValidator {
} }
final Long savingsControlAccountId = this.fromApiJsonHelper.extractLongNamed( final Long savingsControlAccountId = this.fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_CONTROL.getValue(), element); SavingProductAccountingParams.SAVINGS_CONTROL.getValue(), element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_CONTROL.getValue()).value(savingsControlAccountId) baseDataValidator.reset().parameter(SavingProductAccountingParams.SAVINGS_CONTROL.getValue()).value(savingsControlAccountId)
.ignoreIfNull().integerGreaterThanZero(); .ignoreIfNull().integerGreaterThanZero();
final Long savingsReferenceAccountId = this.fromApiJsonHelper.extractLongNamed( final Long savingsReferenceAccountId = this.fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_REFERENCE.getValue(), element); SavingProductAccountingParams.SAVINGS_REFERENCE.getValue(), element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.SAVINGS_REFERENCE.getValue()) baseDataValidator.reset().parameter(SavingProductAccountingParams.SAVINGS_REFERENCE.getValue())
.value(savingsReferenceAccountId).ignoreIfNull().integerGreaterThanZero(); .value(savingsReferenceAccountId).ignoreIfNull().integerGreaterThanZero();
final Long transfersInSuspenseAccountId = this.fromApiJsonHelper.extractLongNamed( final Long transfersInSuspenseAccountId = this.fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue(), element); SavingProductAccountingParams.TRANSFERS_SUSPENSE.getValue(), element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.TRANSFERS_SUSPENSE.getValue()) baseDataValidator.reset().parameter(SavingProductAccountingParams.TRANSFERS_SUSPENSE.getValue())
.value(transfersInSuspenseAccountId).ignoreIfNull().integerGreaterThanZero(); .value(transfersInSuspenseAccountId).ignoreIfNull().integerGreaterThanZero();
final Long interestOnSavingsAccountId = this.fromApiJsonHelper.extractLongNamed( final Long interestOnSavingsAccountId = this.fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_SAVINGS.getValue(), element); SavingProductAccountingParams.INTEREST_ON_SAVINGS.getValue(), element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INTEREST_ON_SAVINGS.getValue()) baseDataValidator.reset().parameter(SavingProductAccountingParams.INTEREST_ON_SAVINGS.getValue())
.value(interestOnSavingsAccountId).ignoreIfNull().integerGreaterThanZero(); .value(interestOnSavingsAccountId).ignoreIfNull().integerGreaterThanZero();
final Long incomeFromFeeId = this.fromApiJsonHelper.extractLongNamed(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), final Long incomeFromFeeId = this.fromApiJsonHelper.extractLongNamed(SavingProductAccountingParams.INCOME_FROM_FEES.getValue(),
element); element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue()).value(incomeFromFeeId) baseDataValidator.reset().parameter(SavingProductAccountingParams.INCOME_FROM_FEES.getValue()).value(incomeFromFeeId)
.ignoreIfNull().integerGreaterThanZero(); .ignoreIfNull().integerGreaterThanZero();
final Long incomeFromPenaltyId = this.fromApiJsonHelper.extractLongNamed( final Long incomeFromPenaltyId = this.fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue(), element); SavingProductAccountingParams.INCOME_FROM_PENALTIES.getValue(), element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue()).value(incomeFromPenaltyId) baseDataValidator.reset().parameter(SavingProductAccountingParams.INCOME_FROM_PENALTIES.getValue()).value(incomeFromPenaltyId)
.ignoreIfNull().integerGreaterThanZero(); .ignoreIfNull().integerGreaterThanZero();
final Long overdraftAccountId = this.fromApiJsonHelper.extractLongNamed( final Long overdraftAccountId = this.fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), element); SavingProductAccountingParams.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.OVERDRAFT_PORTFOLIO_CONTROL.getValue()) baseDataValidator.reset().parameter(SavingProductAccountingParams.OVERDRAFT_PORTFOLIO_CONTROL.getValue())
.value(overdraftAccountId).ignoreIfNull().integerGreaterThanZero(); .value(overdraftAccountId).ignoreIfNull().integerGreaterThanZero();
final Long incomeFromInterest = this.fromApiJsonHelper.extractLongNamed( final Long incomeFromInterest = this.fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_INTEREST.getValue(), element); SavingProductAccountingParams.INCOME_FROM_INTEREST.getValue(), element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_INTEREST.getValue()).value(incomeFromInterest) baseDataValidator.reset().parameter(SavingProductAccountingParams.INCOME_FROM_INTEREST.getValue()).value(incomeFromInterest)
.ignoreIfNull().integerGreaterThanZero(); .ignoreIfNull().integerGreaterThanZero();
final Long writtenoff = this.fromApiJsonHelper.extractLongNamed(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue(), final Long writtenoff = this.fromApiJsonHelper.extractLongNamed(SavingProductAccountingParams.LOSSES_WRITTEN_OFF.getValue(),
element); element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue()).value(writtenoff) baseDataValidator.reset().parameter(SavingProductAccountingParams.LOSSES_WRITTEN_OFF.getValue()).value(writtenoff)
.ignoreIfNull().integerGreaterThanZero(); .ignoreIfNull().integerGreaterThanZero();
//dormancy //dormancy
@@ -545,10 +545,10 @@ public class SavingsProductDataValidator {
baseDataValidator.reset().parameter(daysToEscheatParamName).value(daysToEsc).longGreaterThanNumber(daysToDor); baseDataValidator.reset().parameter(daysToEscheatParamName).value(daysToEsc).longGreaterThanNumber(daysToDor);
} }
if(this.fromApiJsonHelper.parameterExists(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.ESCHEAT_LIABILITY.getValue(), element)){ if(this.fromApiJsonHelper.parameterExists(SavingProductAccountingParams.ESCHEAT_LIABILITY.getValue(), element)){
final Long escheatLiabilityAccountId = this.fromApiJsonHelper.extractLongNamed( final Long escheatLiabilityAccountId = this.fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.ESCHEAT_LIABILITY.getValue(), element); SavingProductAccountingParams.ESCHEAT_LIABILITY.getValue(), element);
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.ESCHEAT_LIABILITY.getValue()) baseDataValidator.reset().parameter(SavingProductAccountingParams.ESCHEAT_LIABILITY.getValue())
.value(escheatLiabilityAccountId).notNull().integerGreaterThanZero(); .value(escheatLiabilityAccountId).notNull().integerGreaterThanZero();
} }
} }
@@ -581,28 +581,28 @@ public class SavingsProductDataValidator {
* Validation for advanced accounting options * Validation for advanced accounting options
*/ */
private void validatePaymentChannelFundSourceMappings(final DataValidatorBuilder baseDataValidator, final JsonElement element) { private void validatePaymentChannelFundSourceMappings(final DataValidatorBuilder baseDataValidator, final JsonElement element) {
if (this.fromApiJsonHelper.parameterExists(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(), if (this.fromApiJsonHelper.parameterExists(SavingProductAccountingParams.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(),
element)) { element)) {
final JsonArray paymentChannelMappingArray = this.fromApiJsonHelper.extractJsonArrayNamed( final JsonArray paymentChannelMappingArray = this.fromApiJsonHelper.extractJsonArrayNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(), element); SavingProductAccountingParams.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(), element);
if (paymentChannelMappingArray != null && paymentChannelMappingArray.size() > 0) { if (paymentChannelMappingArray != null && paymentChannelMappingArray.size() > 0) {
int i = 0; int i = 0;
do { do {
final JsonObject jsonObject = paymentChannelMappingArray.get(i).getAsJsonObject(); final JsonObject jsonObject = paymentChannelMappingArray.get(i).getAsJsonObject();
final Long paymentTypeId = jsonObject.get(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_TYPE.getValue()).getAsLong(); final Long paymentTypeId = jsonObject.get(SavingProductAccountingParams.PAYMENT_TYPE.getValue()).getAsLong();
final Long paymentSpecificFundAccountId = jsonObject.get(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue()) final Long paymentSpecificFundAccountId = jsonObject.get(SavingProductAccountingParams.FUND_SOURCE.getValue())
.getAsLong(); .getAsLong();
baseDataValidator baseDataValidator
.reset() .reset()
.parameter( .parameter(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue() + "[" + i + "]." SavingProductAccountingParams.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue() + "[" + i + "]."
+ SAVINGS_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_TYPE.toString()).value(paymentTypeId).notNull() + SavingProductAccountingParams.PAYMENT_TYPE.toString()).value(paymentTypeId).notNull()
.integerGreaterThanZero(); .integerGreaterThanZero();
baseDataValidator baseDataValidator
.reset() .reset()
.parameter( .parameter(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue() + "[" + i + "]." SavingProductAccountingParams.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue() + "[" + i + "]."
+ SAVINGS_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue()).value(paymentSpecificFundAccountId) + SavingProductAccountingParams.FUND_SOURCE.getValue()).value(paymentSpecificFundAccountId)
.notNull().integerGreaterThanZero(); .notNull().integerGreaterThanZero();
i++; i++;
} while (i < paymentChannelMappingArray.size()); } while (i < paymentChannelMappingArray.size());
@@ -620,9 +620,9 @@ public class SavingsProductDataValidator {
final boolean isPenalty) { final boolean isPenalty) {
String parameterName; String parameterName;
if (isPenalty) { if (isPenalty) {
parameterName = SAVINGS_PRODUCT_ACCOUNTING_PARAMS.PENALTY_INCOME_ACCOUNT_MAPPING.getValue(); parameterName = SavingProductAccountingParams.PENALTY_INCOME_ACCOUNT_MAPPING.getValue();
} else { } else {
parameterName = SAVINGS_PRODUCT_ACCOUNTING_PARAMS.FEE_INCOME_ACCOUNT_MAPPING.getValue(); parameterName = SavingProductAccountingParams.FEE_INCOME_ACCOUNT_MAPPING.getValue();
} }
if (this.fromApiJsonHelper.parameterExists(parameterName, element)) { if (this.fromApiJsonHelper.parameterExists(parameterName, element)) {
@@ -631,15 +631,15 @@ public class SavingsProductDataValidator {
int i = 0; int i = 0;
do { do {
final JsonObject jsonObject = chargeToIncomeAccountMappingArray.get(i).getAsJsonObject(); final JsonObject jsonObject = chargeToIncomeAccountMappingArray.get(i).getAsJsonObject();
final Long chargeId = this.fromApiJsonHelper.extractLongNamed(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.CHARGE_ID.getValue(), final Long chargeId = this.fromApiJsonHelper.extractLongNamed(SavingProductAccountingParams.CHARGE_ID.getValue(),
jsonObject); jsonObject);
final Long incomeAccountId = this.fromApiJsonHelper.extractLongNamed( final Long incomeAccountId = this.fromApiJsonHelper.extractLongNamed(
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_ACCOUNT_ID.getValue(), jsonObject); SavingProductAccountingParams.INCOME_ACCOUNT_ID.getValue(), jsonObject);
baseDataValidator.reset() baseDataValidator.reset()
.parameter(parameterName + "[" + i + "]." + SAVINGS_PRODUCT_ACCOUNTING_PARAMS.CHARGE_ID.getValue()) .parameter(parameterName + "[" + i + "]." + SavingProductAccountingParams.CHARGE_ID.getValue())
.value(chargeId).notNull().integerGreaterThanZero(); .value(chargeId).notNull().integerGreaterThanZero();
baseDataValidator.reset() baseDataValidator.reset()
.parameter(parameterName + "[" + i + "]." + SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_ACCOUNT_ID.getValue()) .parameter(parameterName + "[" + i + "]." + SavingProductAccountingParams.INCOME_ACCOUNT_ID.getValue())
.value(incomeAccountId).notNull().integerGreaterThanZero(); .value(incomeAccountId).notNull().integerGreaterThanZero();
i++; i++;
} while (i < chargeToIncomeAccountMappingArray.size()); } while (i < chargeToIncomeAccountMappingArray.size());
@@ -33,8 +33,8 @@ import org.apache.fineract.infrastructure.security.service.PlatformSecurityConte
import org.apache.fineract.organisation.monetary.domain.ApplicationCurrency; import org.apache.fineract.organisation.monetary.domain.ApplicationCurrency;
import org.apache.fineract.organisation.monetary.domain.ApplicationCurrencyRepositoryWrapper; import org.apache.fineract.organisation.monetary.domain.ApplicationCurrencyRepositoryWrapper;
import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency; import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BUSINESS_ENTITY; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEntity;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BUSINESS_EVENTS; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEvents;
import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService; import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.paymentdetail.domain.PaymentDetail; import org.apache.fineract.portfolio.paymentdetail.domain.PaymentDetail;
import org.apache.fineract.portfolio.savings.SavingsAccountTransactionType; import org.apache.fineract.portfolio.savings.SavingsAccountTransactionType;
@@ -121,8 +121,8 @@ public class SavingsAccountDomainServiceJpa implements SavingsAccountDomainServi
this.savingsAccountRepository.save(account); this.savingsAccountRepository.save(account);
postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds, transactionBooleanValues.isAccountTransfer()); postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds, transactionBooleanValues.isAccountTransfer());
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.SAVINGS_WITHDRAWAL, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.SAVINGS_WITHDRAWAL,
constructEntityMap(BUSINESS_ENTITY.SAVINGS_TRANSACTION, withdrawal)); constructEntityMap(BusinessEntity.SAVINGS_TRANSACTION, withdrawal));
return withdrawal; return withdrawal;
} }
@@ -182,8 +182,8 @@ public class SavingsAccountDomainServiceJpa implements SavingsAccountDomainServi
this.savingsAccountRepository.saveAndFlush(account); this.savingsAccountRepository.saveAndFlush(account);
postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds, isAccountTransfer); postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds, isAccountTransfer);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.SAVINGS_DEPOSIT, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.SAVINGS_DEPOSIT,
constructEntityMap(BUSINESS_ENTITY.SAVINGS_TRANSACTION, deposit)); constructEntityMap(BusinessEntity.SAVINGS_TRANSACTION, deposit));
return deposit; return deposit;
} }
@@ -230,8 +230,8 @@ public class SavingsAccountDomainServiceJpa implements SavingsAccountDomainServi
postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds, isAccountTransfer); postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds, isAccountTransfer);
} }
private Map<BUSINESS_ENTITY, Object> constructEntityMap(final BUSINESS_ENTITY entityEvent, Object entity) { private Map<BusinessEntity, Object> constructEntityMap(final BusinessEntity entityEvent, Object entity) {
Map<BUSINESS_ENTITY, Object> map = new HashMap<>(1); Map<BusinessEntity, Object> map = new HashMap<>(1);
map.put(entityEvent, entity); map.put(entityEvent, entity);
return map; return map;
} }
@@ -23,7 +23,7 @@ import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainR
public class PostInterestAsOnDateException extends AbstractPlatformDomainRuleException{ public class PostInterestAsOnDateException extends AbstractPlatformDomainRuleException{
public static enum PostInterestAsOnException_TYPE { public static enum PostInterestAsOnExceptionType {
FUTURE_DATE, VALID_DATE, ACTIVATION_DATE, LAST_TRANSACTION_DATE; FUTURE_DATE, VALID_DATE, ACTIVATION_DATE, LAST_TRANSACTION_DATE;
public String errorMessage() { public String errorMessage() {
if (name().toString().equalsIgnoreCase("FUTURE_DATE")) { if (name().toString().equalsIgnoreCase("FUTURE_DATE")) {
@@ -53,7 +53,7 @@ public class PostInterestAsOnDateException extends AbstractPlatformDomainRuleExc
} }
public PostInterestAsOnDateException(final PostInterestAsOnException_TYPE reason) { public PostInterestAsOnDateException(final PostInterestAsOnExceptionType reason) {
super(reason.errorCode(), reason.errorMessage()); super(reason.errorCode(), reason.errorMessage());
} }
@@ -65,8 +65,8 @@ import org.apache.fineract.portfolio.client.domain.Client;
import org.apache.fineract.portfolio.client.domain.ClientRepositoryWrapper; import org.apache.fineract.portfolio.client.domain.ClientRepositoryWrapper;
import org.apache.fineract.portfolio.client.exception.ClientNotActiveException; import org.apache.fineract.portfolio.client.exception.ClientNotActiveException;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BUSINESS_ENTITY; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEntity;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BUSINESS_EVENTS; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEvents;
import org.apache.fineract.portfolio.common.domain.PeriodFrequencyType; import org.apache.fineract.portfolio.common.domain.PeriodFrequencyType;
import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService; import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.group.domain.Group; import org.apache.fineract.portfolio.group.domain.Group;
@@ -232,11 +232,11 @@ public class DepositApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
} }
final Long savingsId = account.getId(); final Long savingsId = account.getId();
this.businessEventNotifierService.notifyBusinessEventWasExecuted( BUSINESS_EVENTS.FIXED_DEPOSIT_ACCOUNT_CREATE, this.businessEventNotifierService.notifyBusinessEventWasExecuted( BusinessEvents.FIXED_DEPOSIT_ACCOUNT_CREATE,
constructEntityMap(BUSINESS_ENTITY.DEPOSIT_ACCOUNT, account)); constructEntityMap(BusinessEntity.DEPOSIT_ACCOUNT, account));
this.businessEventNotifierService.notifyBusinessEventWasExecuted( BUSINESS_EVENTS.FIXED_DEPOSIT_ACCOUNT_CREATE, this.businessEventNotifierService.notifyBusinessEventWasExecuted( BusinessEvents.FIXED_DEPOSIT_ACCOUNT_CREATE,
constructEntityMap(BUSINESS_ENTITY.DEPOSIT_ACCOUNT, account)); constructEntityMap(BusinessEntity.DEPOSIT_ACCOUNT, account));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
@@ -295,11 +295,11 @@ public class DepositApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
financialYearBeginningMonth); financialYearBeginningMonth);
account.validateApplicableInterestRate(); account.validateApplicableInterestRate();
this.savingAccountRepository.save(account); this.savingAccountRepository.save(account);
this.businessEventNotifierService.notifyBusinessEventWasExecuted( BUSINESS_EVENTS.RECURRING_DEPOSIT_ACCOUNT_CREATE, this.businessEventNotifierService.notifyBusinessEventWasExecuted( BusinessEvents.RECURRING_DEPOSIT_ACCOUNT_CREATE,
constructEntityMap(BUSINESS_ENTITY.DEPOSIT_ACCOUNT, account)); constructEntityMap(BusinessEntity.DEPOSIT_ACCOUNT, account));
this.businessEventNotifierService.notifyBusinessEventWasExecuted( BUSINESS_EVENTS.RECURRING_DEPOSIT_ACCOUNT_CREATE, this.businessEventNotifierService.notifyBusinessEventWasExecuted( BusinessEvents.RECURRING_DEPOSIT_ACCOUNT_CREATE,
constructEntityMap(BUSINESS_ENTITY.DEPOSIT_ACCOUNT, account)); constructEntityMap(BusinessEntity.DEPOSIT_ACCOUNT, account));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
@@ -786,8 +786,8 @@ public class DepositApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
} }
} }
private Map<BusinessEventNotificationConstants.BUSINESS_ENTITY, Object> constructEntityMap(final BUSINESS_ENTITY entityEvent, Object entity) { private Map<BusinessEventNotificationConstants.BusinessEntity, Object> constructEntityMap(final BusinessEntity entityEvent, Object entity) {
Map<BusinessEventNotificationConstants.BUSINESS_ENTITY, Object> map = new HashMap<>(1); Map<BusinessEventNotificationConstants.BusinessEntity, Object> map = new HashMap<>(1);
map.put(entityEvent, entity); map.put(entityEvent, entity);
return map; return map;
} }
@@ -76,8 +76,8 @@ import org.apache.fineract.portfolio.charge.domain.ChargeRepositoryWrapper;
import org.apache.fineract.portfolio.charge.domain.ChargeTimeType; import org.apache.fineract.portfolio.charge.domain.ChargeTimeType;
import org.apache.fineract.portfolio.client.domain.Client; import org.apache.fineract.portfolio.client.domain.Client;
import org.apache.fineract.portfolio.client.exception.ClientNotActiveException; import org.apache.fineract.portfolio.client.exception.ClientNotActiveException;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BUSINESS_ENTITY; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEntity;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BUSINESS_EVENTS; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEvents;
import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService; import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.group.domain.Group; import org.apache.fineract.portfolio.group.domain.Group;
import org.apache.fineract.portfolio.group.exception.GroupNotActiveException; import org.apache.fineract.portfolio.group.exception.GroupNotActiveException;
@@ -106,7 +106,7 @@ import org.apache.fineract.portfolio.savings.domain.SavingsAccountStatusType;
import org.apache.fineract.portfolio.savings.domain.SavingsAccountTransaction; import org.apache.fineract.portfolio.savings.domain.SavingsAccountTransaction;
import org.apache.fineract.portfolio.savings.domain.SavingsAccountTransactionRepository; import org.apache.fineract.portfolio.savings.domain.SavingsAccountTransactionRepository;
import org.apache.fineract.portfolio.savings.exception.PostInterestAsOnDateException; import org.apache.fineract.portfolio.savings.exception.PostInterestAsOnDateException;
import org.apache.fineract.portfolio.savings.exception.PostInterestAsOnDateException.PostInterestAsOnException_TYPE; import org.apache.fineract.portfolio.savings.exception.PostInterestAsOnDateException.PostInterestAsOnExceptionType;
import org.apache.fineract.portfolio.savings.exception.PostInterestClosingDateException; import org.apache.fineract.portfolio.savings.exception.PostInterestClosingDateException;
import org.apache.fineract.portfolio.savings.exception.SavingsAccountClosingNotAllowedException; import org.apache.fineract.portfolio.savings.exception.SavingsAccountClosingNotAllowedException;
import org.apache.fineract.portfolio.savings.exception.SavingsAccountTransactionNotFoundException; import org.apache.fineract.portfolio.savings.exception.SavingsAccountTransactionNotFoundException;
@@ -256,8 +256,8 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
} }
postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds); postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.SAVINGS_ACTIVATE, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.SAVINGS_ACTIVATE,
constructEntityMap(BUSINESS_ENTITY.SAVING, account)); constructEntityMap(BusinessEntity.SAVING, account));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withEntityId(savingsId) // .withEntityId(savingsId) //
@@ -508,23 +508,23 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
if (transactionDate == null) { if (transactionDate == null) {
throw new PostInterestAsOnDateException(PostInterestAsOnException_TYPE.VALID_DATE); } throw new PostInterestAsOnDateException(PostInterestAsOnExceptionType.VALID_DATE); }
if (transactionDate.isBefore(account.accountSubmittedOrActivationDate())) { throw new PostInterestAsOnDateException( if (transactionDate.isBefore(account.accountSubmittedOrActivationDate())) { throw new PostInterestAsOnDateException(
PostInterestAsOnException_TYPE.ACTIVATION_DATE); } PostInterestAsOnExceptionType.ACTIVATION_DATE); }
List<SavingsAccountTransaction> savingTransactions = account.getTransactions(); List<SavingsAccountTransaction> savingTransactions = account.getTransactions();
for (SavingsAccountTransaction savingTransaction : savingTransactions) { for (SavingsAccountTransaction savingTransaction : savingTransactions) {
if (transactionDate.toDate().before(savingTransaction if (transactionDate.toDate().before(savingTransaction
.getDateOf())) { throw new PostInterestAsOnDateException(PostInterestAsOnException_TYPE.LAST_TRANSACTION_DATE); } .getDateOf())) { throw new PostInterestAsOnDateException(PostInterestAsOnExceptionType.LAST_TRANSACTION_DATE); }
} }
LocalDate today = DateUtils.getLocalDateOfTenant(); LocalDate today = DateUtils.getLocalDateOfTenant();
if (transactionDate.isAfter(today)) { throw new PostInterestAsOnDateException(PostInterestAsOnException_TYPE.FUTURE_DATE); } if (transactionDate.isAfter(today)) { throw new PostInterestAsOnDateException(PostInterestAsOnExceptionType.FUTURE_DATE); }
} }
postInterest(account, postInterestAs, transactionDate); postInterest(account, postInterestAs, transactionDate);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.SAVINGS_POST_INTEREST, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.SAVINGS_POST_INTEREST,
constructEntityMap(BUSINESS_ENTITY.SAVING, account)); constructEntityMap(BusinessEntity.SAVING, account));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withEntityId(savingsId) // .withEntityId(savingsId) //
.withOfficeId(account.officeId()) // .withOfficeId(account.officeId()) //
@@ -851,8 +851,8 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
} }
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.SAVINGS_CLOSE, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.SAVINGS_CLOSE,
constructEntityMap(BUSINESS_ENTITY.SAVING, account)); constructEntityMap(BusinessEntity.SAVING, account));
// disable all standing orders linked to the savings account // disable all standing orders linked to the savings account
this.disableStandingInstructionsLinkedToClosedSavings(account); this.disableStandingInstructionsLinkedToClosedSavings(account);
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
@@ -1510,8 +1510,8 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
} }
} }
private Map<BUSINESS_ENTITY, Object> constructEntityMap(final BUSINESS_ENTITY entityEvent, Object entity) { private Map<BusinessEntity, Object> constructEntityMap(final BusinessEntity entityEvent, Object entity) {
Map<BUSINESS_ENTITY, Object> map = new HashMap<>(1); Map<BusinessEntity, Object> map = new HashMap<>(1);
map.put(entityEvent, entity); map.put(entityEvent, entity);
return map; return map;
} }
@@ -58,8 +58,8 @@ import org.apache.fineract.portfolio.client.domain.AccountNumberGenerator;
import org.apache.fineract.portfolio.client.domain.Client; import org.apache.fineract.portfolio.client.domain.Client;
import org.apache.fineract.portfolio.client.domain.ClientRepositoryWrapper; import org.apache.fineract.portfolio.client.domain.ClientRepositoryWrapper;
import org.apache.fineract.portfolio.client.exception.ClientNotActiveException; import org.apache.fineract.portfolio.client.exception.ClientNotActiveException;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BUSINESS_ENTITY; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEntity;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BUSINESS_EVENTS; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEvents;
import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService; import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.group.domain.Group; import org.apache.fineract.portfolio.group.domain.Group;
import org.apache.fineract.portfolio.group.domain.GroupRepository; import org.apache.fineract.portfolio.group.domain.GroupRepository;
@@ -307,8 +307,8 @@ public class SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
EntityTables.SAVING.getName(), StatusEnum.CREATE.getCode().longValue(), EntityTables.SAVING.getName(), StatusEnum.CREATE.getCode().longValue(),
EntityTables.SAVING.getForeignKeyColumnNameOnDatatable(), account.productId()); EntityTables.SAVING.getForeignKeyColumnNameOnDatatable(), account.productId());
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.SAVINGS_CREATE, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.SAVINGS_CREATE,
constructEntityMap(BUSINESS_ENTITY.SAVING, account)); constructEntityMap(BusinessEntity.SAVING, account));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
@@ -533,8 +533,8 @@ public class SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
} }
} }
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.SAVINGS_APPROVE, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.SAVINGS_APPROVE,
constructEntityMap(BUSINESS_ENTITY.SAVING, savingsAccount)); constructEntityMap(BusinessEntity.SAVING, savingsAccount));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
@@ -656,8 +656,8 @@ public class SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
this.noteRepository.save(note); this.noteRepository.save(note);
} }
} }
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.SAVINGS_REJECT, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.SAVINGS_REJECT,
constructEntityMap(BUSINESS_ENTITY.SAVING, savingsAccount)); constructEntityMap(BusinessEntity.SAVING, savingsAccount));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
.withEntityId(savingsId) // .withEntityId(savingsId) //
@@ -754,8 +754,8 @@ public class SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
} }
private Map<BUSINESS_ENTITY, Object> constructEntityMap(final BUSINESS_ENTITY entityEvent, Object entity) { private Map<BusinessEntity, Object> constructEntityMap(final BusinessEntity entityEvent, Object entity) {
Map<BUSINESS_ENTITY, Object> map = new HashMap<>(1); Map<BusinessEntity, Object> map = new HashMap<>(1);
map.put(entityEvent, entity); map.put(entityEvent, entity);
return map; return map;
} }
@@ -23,19 +23,19 @@ import java.util.Set;
public class SearchConstants { public class SearchConstants {
public static enum SEARCH_RESPONSE_PARAMETERS { public static enum SearchResponseParameters {
ENTITY_ID("entityId"), ENTITY_ACCOUNT_NO("entityAccountNo"), ENTITY_EXTERNAL_ID("entityExternalId"), ENTITY_NAME("entityName"), ENTITY_TYPE( ENTITY_ID("entityId"), ENTITY_ACCOUNT_NO("entityAccountNo"), ENTITY_EXTERNAL_ID("entityExternalId"), ENTITY_NAME("entityName"), ENTITY_TYPE(
"entityType"), PARENT_ID("parentId"), PARENT_NAME("parentName"),ENTITY_MOBILE_NO("entityMobileNo"), ENTITY_STATUS("entityStatus"); "entityType"), PARENT_ID("parentId"), PARENT_NAME("parentName"),ENTITY_MOBILE_NO("entityMobileNo"), ENTITY_STATUS("entityStatus");
private final String value; private final String value;
private SEARCH_RESPONSE_PARAMETERS(final String value) { private SearchResponseParameters(final String value) {
this.value = value; this.value = value;
} }
private static final Set<String> values = new HashSet<>(); private static final Set<String> values = new HashSet<>();
static { static {
for (final SEARCH_RESPONSE_PARAMETERS param : SEARCH_RESPONSE_PARAMETERS.values()) { for (final SearchResponseParameters param : SearchResponseParameters.values()) {
values.add(param.value); values.add(param.value);
} }
} }
@@ -54,18 +54,18 @@ public class SearchConstants {
} }
} }
public static enum SEARCH_SUPPORTED_PARAMETERS { public static enum SearchSupportedParameters {
QUERY("query"), RESOURCE("resource"),EXACTMATCH("exactMatch"); QUERY("query"), RESOURCE("resource"),EXACTMATCH("exactMatch");
private final String value; private final String value;
private SEARCH_SUPPORTED_PARAMETERS(final String value) { private SearchSupportedParameters(final String value) {
this.value = value; this.value = value;
} }
private static final Set<String> values = new HashSet<>(); private static final Set<String> values = new HashSet<>();
static { static {
for (final SEARCH_SUPPORTED_PARAMETERS param : SEARCH_SUPPORTED_PARAMETERS.values()) { for (final SearchSupportedParameters param : SearchSupportedParameters.values()) {
values.add(param.value); values.add(param.value);
} }
} }
@@ -84,18 +84,18 @@ public class SearchConstants {
} }
} }
public static enum SEARCH_SUPPORTED_RESOURCES { public static enum SearchSupportedResources {
CLIENTS("clients"), GROUPS("groups"), LOANS("loans"), SAVINGS("savings"), SHARES("shares"), CLIENTIDENTIFIERS("clientIdentifiers"); CLIENTS("clients"), GROUPS("groups"), LOANS("loans"), SAVINGS("savings"), SHARES("shares"), CLIENTIDENTIFIERS("clientIdentifiers");
private final String value; private final String value;
private SEARCH_SUPPORTED_RESOURCES(final String value) { private SearchSupportedResources(final String value) {
this.value = value; this.value = value;
} }
private static final Set<String> values = new HashSet<>(); private static final Set<String> values = new HashSet<>();
static { static {
for (final SEARCH_SUPPORTED_RESOURCES param : SEARCH_SUPPORTED_RESOURCES.values()) { for (final SearchSupportedResources param : SearchSupportedResources.values()) {
values.add(param.value); values.add(param.value);
} }
} }
@@ -114,18 +114,18 @@ public class SearchConstants {
} }
} }
public static enum SEARCH_LOAN_DATE { public static enum SearchLoanDate {
APPROVAL_DATE("approvalDate"), CREATED_DATE("createdDate"), DISBURSAL_DATE("disbursalDate"); APPROVAL_DATE("approvalDate"), CREATED_DATE("createdDate"), DISBURSAL_DATE("disbursalDate");
private final String value; private final String value;
private SEARCH_LOAN_DATE(final String value) { private SearchLoanDate(final String value) {
this.value = value; this.value = value;
} }
private static final Set<String> values = new HashSet<>(); private static final Set<String> values = new HashSet<>();
static { static {
for (final SEARCH_LOAN_DATE param : SEARCH_LOAN_DATE.values()) { for (final SearchLoanDate param : SearchLoanDate.values()) {
values.add(param.value); values.add(param.value);
} }
} }
@@ -42,7 +42,7 @@ import javax.ws.rs.core.UriInfo;
import org.apache.fineract.infrastructure.core.api.ApiRequestParameterHelper; import org.apache.fineract.infrastructure.core.api.ApiRequestParameterHelper;
import org.apache.fineract.infrastructure.core.serialization.ApiRequestJsonSerializationSettings; import org.apache.fineract.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
import org.apache.fineract.infrastructure.core.serialization.ToApiJsonSerializer; import org.apache.fineract.infrastructure.core.serialization.ToApiJsonSerializer;
import org.apache.fineract.portfolio.search.SearchConstants.SEARCH_RESPONSE_PARAMETERS; import org.apache.fineract.portfolio.search.SearchConstants.SearchResponseParameters;
import org.apache.fineract.portfolio.search.data.AdHocQueryDataValidator; import org.apache.fineract.portfolio.search.data.AdHocQueryDataValidator;
import org.apache.fineract.portfolio.search.data.AdHocQuerySearchConditions; import org.apache.fineract.portfolio.search.data.AdHocQuerySearchConditions;
import org.apache.fineract.portfolio.search.data.AdHocSearchQueryData; import org.apache.fineract.portfolio.search.data.AdHocSearchQueryData;
@@ -62,7 +62,7 @@ import org.springframework.stereotype.Component;
}) })
public class SearchApiResource { public class SearchApiResource {
private final Set<String> searchResponseParameters = SEARCH_RESPONSE_PARAMETERS.getAllValues(); private final Set<String> searchResponseParameters = SearchResponseParameters.getAllValues();
private final SearchReadPlatformService searchReadPlatformService; private final SearchReadPlatformService searchReadPlatformService;
private final ToApiJsonSerializer<Object> toApiJsonSerializer; private final ToApiJsonSerializer<Object> toApiJsonSerializer;
@@ -18,7 +18,7 @@
*/ */
package org.apache.fineract.portfolio.search.data; package org.apache.fineract.portfolio.search.data;
import org.apache.fineract.portfolio.search.SearchConstants.SEARCH_SUPPORTED_RESOURCES; import org.apache.fineract.portfolio.search.SearchConstants.SearchSupportedResources;
public class SearchConditions { public class SearchConditions {
@@ -37,17 +37,17 @@ public class SearchConditions {
this.searchResource = searchResource; this.searchResource = searchResource;
this.exactMatch=exactMatch; this.exactMatch=exactMatch;
this.clientSearch = (null == searchResource || searchResource.toLowerCase().contains( this.clientSearch = (null == searchResource || searchResource.toLowerCase().contains(
SEARCH_SUPPORTED_RESOURCES.CLIENTS.name().toLowerCase())) ? true : false; SearchSupportedResources.CLIENTS.name().toLowerCase())) ? true : false;
this.groupSearch = (null == searchResource || searchResource.toLowerCase().contains( this.groupSearch = (null == searchResource || searchResource.toLowerCase().contains(
SEARCH_SUPPORTED_RESOURCES.GROUPS.name().toLowerCase())) ? true : false; SearchSupportedResources.GROUPS.name().toLowerCase())) ? true : false;
this.loanSeach = (null == searchResource || searchResource.toLowerCase().contains( this.loanSeach = (null == searchResource || searchResource.toLowerCase().contains(
SEARCH_SUPPORTED_RESOURCES.LOANS.name().toLowerCase())) ? true : false; SearchSupportedResources.LOANS.name().toLowerCase())) ? true : false;
this.savingSeach = (null == searchResource || searchResource.toLowerCase().contains( this.savingSeach = (null == searchResource || searchResource.toLowerCase().contains(
SEARCH_SUPPORTED_RESOURCES.SAVINGS.name().toLowerCase())) ? true : false; SearchSupportedResources.SAVINGS.name().toLowerCase())) ? true : false;
this.shareSeach = (null == searchResource || searchResource.toLowerCase().contains( this.shareSeach = (null == searchResource || searchResource.toLowerCase().contains(
SEARCH_SUPPORTED_RESOURCES.SHARES.name().toLowerCase())) ? true : false; SearchSupportedResources.SHARES.name().toLowerCase())) ? true : false;
this.clientIdentifierSearch = (null == searchResource || searchResource.toLowerCase().contains( this.clientIdentifierSearch = (null == searchResource || searchResource.toLowerCase().contains(
SEARCH_SUPPORTED_RESOURCES.CLIENTIDENTIFIERS.name().toLowerCase())) ? true : false; SearchSupportedResources.CLIENTIDENTIFIERS.name().toLowerCase())) ? true : false;
} }
public SearchConditions(final String searchQueryParam, final String searchResource, final Boolean clientSearch, public SearchConditions(final String searchQueryParam, final String searchResource, final Boolean clientSearch,
@@ -243,17 +243,17 @@ public class SearchReadPlatformServiceImpl implements SearchReadPlatformService
} }
if (StringUtils.isNotBlank(searchConditions.getLoanDateOption())) { if (StringUtils.isNotBlank(searchConditions.getLoanDateOption())) {
if (searchConditions.getLoanDateOption().equals(SearchConstants.SEARCH_LOAN_DATE.APPROVAL_DATE.getValue())) { if (searchConditions.getLoanDateOption().equals(SearchConstants.SearchLoanDate.APPROVAL_DATE.getValue())) {
checkAndUpdateWhereClause(sql); checkAndUpdateWhereClause(sql);
params.addValue("loanFromDate", searchConditions.getLoanFromDate().toDate()); params.addValue("loanFromDate", searchConditions.getLoanFromDate().toDate());
params.addValue("loanToDate", searchConditions.getLoanToDate().toDate()); params.addValue("loanToDate", searchConditions.getLoanToDate().toDate());
sql.append(" ( ml.approvedon_date between :loanFromDate and :loanToDate ) "); sql.append(" ( ml.approvedon_date between :loanFromDate and :loanToDate ) ");
} else if (searchConditions.getLoanDateOption().equals(SearchConstants.SEARCH_LOAN_DATE.CREATED_DATE.getValue())) { } else if (searchConditions.getLoanDateOption().equals(SearchConstants.SearchLoanDate.CREATED_DATE.getValue())) {
checkAndUpdateWhereClause(sql); checkAndUpdateWhereClause(sql);
params.addValue("loanFromDate", searchConditions.getLoanFromDate().toDate()); params.addValue("loanFromDate", searchConditions.getLoanFromDate().toDate());
params.addValue("loanToDate", searchConditions.getLoanToDate().toDate()); params.addValue("loanToDate", searchConditions.getLoanToDate().toDate());
sql.append(" ( ml.submittedon_date between :loanFromDate and :loanToDate ) "); sql.append(" ( ml.submittedon_date between :loanFromDate and :loanToDate ) ");
} else if (searchConditions.getLoanDateOption().equals(SearchConstants.SEARCH_LOAN_DATE.DISBURSAL_DATE.getValue())) { } else if (searchConditions.getLoanDateOption().equals(SearchConstants.SearchLoanDate.DISBURSAL_DATE.getValue())) {
checkAndUpdateWhereClause(sql); checkAndUpdateWhereClause(sql);
params.addValue("loanFromDate", searchConditions.getLoanFromDate().toDate()); params.addValue("loanFromDate", searchConditions.getLoanFromDate().toDate());
params.addValue("loanToDate", searchConditions.getLoanToDate().toDate()); params.addValue("loanToDate", searchConditions.getLoanToDate().toDate());
@@ -43,8 +43,8 @@ import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency;
import org.apache.fineract.portfolio.accounts.constants.ShareAccountApiConstants; import org.apache.fineract.portfolio.accounts.constants.ShareAccountApiConstants;
import org.apache.fineract.portfolio.client.domain.AccountNumberGenerator; import org.apache.fineract.portfolio.client.domain.AccountNumberGenerator;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BUSINESS_ENTITY; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEntity;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BUSINESS_EVENTS; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEvents;
import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService; import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.note.domain.Note; import org.apache.fineract.portfolio.note.domain.Note;
import org.apache.fineract.portfolio.note.domain.NoteRepository; import org.apache.fineract.portfolio.note.domain.NoteRepository;
@@ -108,8 +108,8 @@ public class ShareAccountWritePlatformServiceJpaRepositoryImpl implements ShareA
journalEntryWritePlatformService.createJournalEntriesForShares(populateJournalEntries(account, journalEntryWritePlatformService.createJournalEntriesForShares(populateJournalEntries(account,
account.getPendingForApprovalSharePurchaseTransactions())); account.getPendingForApprovalSharePurchaseTransactions()));
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.SHARE_ACCOUNT_CREATE, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.SHARE_ACCOUNT_CREATE,
constructEntityMap(BUSINESS_ENTITY.SHARE_ACCOUNT, account)); constructEntityMap(BusinessEntity.SHARE_ACCOUNT, account));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(jsonCommand.commandId()) // .withCommandId(jsonCommand.commandId()) //
@@ -284,8 +284,8 @@ public class ShareAccountWritePlatformServiceJpaRepositoryImpl implements ShareA
this.journalEntryWritePlatformService.createJournalEntriesForShares(populateJournalEntries(account, journalTransactions)); this.journalEntryWritePlatformService.createJournalEntriesForShares(populateJournalEntries(account, journalTransactions));
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.SHARE_ACCOUNT_APPROVE, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.SHARE_ACCOUNT_APPROVE,
constructEntityMap(BUSINESS_ENTITY.SHARE_ACCOUNT, account)); constructEntityMap(BusinessEntity.SHARE_ACCOUNT, account));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(jsonCommand.commandId()) // .withCommandId(jsonCommand.commandId()) //
@@ -531,8 +531,8 @@ public class ShareAccountWritePlatformServiceJpaRepositoryImpl implements ShareA
"Unknown data integrity issue with resource."); "Unknown data integrity issue with resource.");
} }
private Map<BusinessEventNotificationConstants.BUSINESS_ENTITY, Object> constructEntityMap(final BusinessEventNotificationConstants.BUSINESS_ENTITY entityEvent, Object entity) { private Map<BusinessEventNotificationConstants.BusinessEntity, Object> constructEntityMap(final BusinessEventNotificationConstants.BusinessEntity entityEvent, Object entity) {
Map<BusinessEventNotificationConstants.BUSINESS_ENTITY, Object> map = new HashMap<>(1); Map<BusinessEventNotificationConstants.BusinessEntity, Object> map = new HashMap<>(1);
map.put(entityEvent, entity); map.put(entityEvent, entity);
return map; return map;
} }
@@ -82,10 +82,10 @@ public class ShareProductDataSerializer {
ShareProductApiConstants.minimumactiveperiodfordividends_paramname, ShareProductApiConstants.minimumactiveperiodfordividends_paramname,
ShareProductApiConstants.minimumactiveperiodfrequencytype_paramname, ShareProductApiConstants.minimumactiveperiodfrequencytype_paramname,
ShareProductApiConstants.sharecapital_paramname, ShareProductApiConstants.accountingRuleParamName, ShareProductApiConstants.sharecapital_paramname, ShareProductApiConstants.accountingRuleParamName,
AccountingConstants.SHARES_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), AccountingConstants.SharesProductAccountingParams.INCOME_FROM_FEES.getValue(),
AccountingConstants.SHARES_PRODUCT_ACCOUNTING_PARAMS.SHARES_EQUITY.getValue(), AccountingConstants.SharesProductAccountingParams.SHARES_EQUITY.getValue(),
AccountingConstants.SHARES_PRODUCT_ACCOUNTING_PARAMS.SHARES_REFERENCE.getValue(), AccountingConstants.SharesProductAccountingParams.SHARES_REFERENCE.getValue(),
AccountingConstants.SHARES_PRODUCT_ACCOUNTING_PARAMS.SHARES_SUSPENSE.getValue())); AccountingConstants.SharesProductAccountingParams.SHARES_SUSPENSE.getValue()));
private static final Set<String> supportedParametersForDivident = new HashSet<>(Arrays.asList( private static final Set<String> supportedParametersForDivident = new HashSet<>(Arrays.asList(
ShareProductApiConstants.locale_paramname, ShareProductApiConstants.dateFormatParamName, ShareProductApiConstants.locale_paramname, ShareProductApiConstants.dateFormatParamName,
@@ -31,8 +31,8 @@ import org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuild
import org.apache.fineract.infrastructure.core.exception.PlatformDataIntegrityException; import org.apache.fineract.infrastructure.core.exception.PlatformDataIntegrityException;
import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper; import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BUSINESS_ENTITY; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEntity;
import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BUSINESS_EVENTS; import org.apache.fineract.portfolio.common.BusinessEventNotificationConstants.BusinessEvents;
import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService; import org.apache.fineract.portfolio.common.service.BusinessEventNotifierService;
import org.apache.fineract.portfolio.shareproducts.constants.ShareProductApiConstants; import org.apache.fineract.portfolio.shareproducts.constants.ShareProductApiConstants;
import org.apache.fineract.portfolio.shareproducts.domain.ShareProduct; import org.apache.fineract.portfolio.shareproducts.domain.ShareProduct;
@@ -146,8 +146,8 @@ public class ShareProductWritePlatformServiceJpaRepositoryImpl implements ShareP
this.shareProductDividentPayOutDetailsRepository.save(dividendPayOutDetails); this.shareProductDividentPayOutDetailsRepository.save(dividendPayOutDetails);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BUSINESS_EVENTS.SHARE_PRODUCT_DIVIDENDS_CREATE, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.SHARE_PRODUCT_DIVIDENDS_CREATE,
constructEntityMap(BUSINESS_ENTITY.SHARE_PRODUCT, productId)); constructEntityMap(BusinessEntity.SHARE_PRODUCT, productId));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(jsonCommand.commandId()) // .withCommandId(jsonCommand.commandId()) //
@@ -213,8 +213,8 @@ public class ShareProductWritePlatformServiceJpaRepositoryImpl implements ShareP
"Unknown data integrity issue with resource."); "Unknown data integrity issue with resource.");
} }
private Map<BusinessEventNotificationConstants.BUSINESS_ENTITY, Object> constructEntityMap(final BusinessEventNotificationConstants.BUSINESS_ENTITY entityEvent, Object entity) { private Map<BusinessEventNotificationConstants.BusinessEntity, Object> constructEntityMap(final BusinessEventNotificationConstants.BusinessEntity entityEvent, Object entity) {
Map<BusinessEventNotificationConstants.BUSINESS_ENTITY, Object> map = new HashMap<>(1); Map<BusinessEventNotificationConstants.BusinessEntity, Object> map = new HashMap<>(1);
map.put(entityEvent, entity); map.put(entityEvent, entity);
return map; return map;
} }

Some files were not shown because too many files have changed in this diff Show More