formatting source code

This commit is contained in:
Vishwas Babu A J
2014-09-14 10:36:06 -07:00
parent 3e5db84702
commit 4b9f6f3042
53 changed files with 291 additions and 270 deletions
@@ -72,7 +72,7 @@ public enum DepositAccountOnClosureType {
public boolean isInvalid() {
return this.value.equals(DepositAccountOnClosureType.INVALID.getValue());
}
public static Object[] integerValues() {
final List<Integer> values = new ArrayList<>();
for (final DepositAccountOnClosureType enumType : values()) {
@@ -8,15 +8,12 @@ package org.mifosplatform.portfolio.savings;
import java.util.ArrayList;
import java.util.List;
/**
* An enumeration of supported calendar periods used in savings.
*/
public enum PreClosurePenalInterestOnType {
INVALID(0, "preClosurePenalInterestOnType.invalid"),
WHOLE_TERM(1, "preClosurePenalInterestOnType.wholeTerm"), //
INVALID(0, "preClosurePenalInterestOnType.invalid"), WHOLE_TERM(1, "preClosurePenalInterestOnType.wholeTerm"), //
TILL_PREMATURE_WITHDRAWAL(2, "preClosurePenalInterestOnType.tillPrematureWithdrawal"); //
private final Integer value;
private final String code;
@@ -48,7 +45,7 @@ public enum PreClosurePenalInterestOnType {
}
return penalInterestType;
}
public static Object[] integerValues() {
final List<Integer> values = new ArrayList<>();
for (final PreClosurePenalInterestOnType enumType : values()) {
@@ -59,15 +56,15 @@ public enum PreClosurePenalInterestOnType {
return values.toArray();
}
public boolean isInvalid(){
public boolean isInvalid() {
return this.value.equals(PreClosurePenalInterestOnType.INVALID.value);
}
public boolean isWholeTerm() {
return this.value.equals(PreClosurePenalInterestOnType.WHOLE_TERM.getValue());
}
public boolean isTillPrematureWithdrawal() {
return this.value.equals(PreClosurePenalInterestOnType.TILL_PREMATURE_WITHDRAWAL.getValue());
}
@@ -8,15 +8,12 @@ package org.mifosplatform.portfolio.savings;
import java.util.ArrayList;
import java.util.List;
/**
* An enumeration of supported calendar periods used in savings.
*/
public enum RecurringDepositType {
INVALID(0, "recurringDepositType.invalid"),
VOLUNTARY(1, "recurringDepositType.voluntary"), //
INVALID(0, "recurringDepositType.invalid"), VOLUNTARY(1, "recurringDepositType.voluntary"), //
MANDATORY(2, "recurringDepositType.mandatory"); //
private final Integer value;
private final String code;
@@ -48,7 +45,7 @@ public enum RecurringDepositType {
}
return rdType;
}
public static Object[] integerValues() {
final List<Integer> values = new ArrayList<>();
for (final RecurringDepositType enumType : values()) {
@@ -59,8 +56,8 @@ public enum RecurringDepositType {
return values.toArray();
}
public boolean isInvalid(){
public boolean isInvalid() {
return this.value.equals(RecurringDepositType.INVALID.value);
}
}
@@ -173,8 +173,8 @@ public class SavingsApiConstants {
"interestCalculationDaysInYearTypeOptions", "lockinPeriodFrequencyTypeOptions", "withdrawalFeeTypeOptions"));
public static final Set<String> SAVINGS_ACCOUNT_REQUEST_DATA_PARAMETERS = new HashSet<>(Arrays.asList(localeParamName,
dateFormatParamName, monthDayFormatParamName, staffIdParamName, accountNoParamName, externalIdParamName, clientIdParamName, groupIdParamName,
productIdParamName, fieldOfficerIdParamName, submittedOnDateParamName, nominalAnnualInterestRateParamName,
dateFormatParamName, monthDayFormatParamName, staffIdParamName, accountNoParamName, externalIdParamName, clientIdParamName,
groupIdParamName, productIdParamName, fieldOfficerIdParamName, submittedOnDateParamName, nominalAnnualInterestRateParamName,
interestCompoundingPeriodTypeParamName, interestPostingPeriodTypeParamName, interestCalculationTypeParamName,
interestCalculationDaysInYearTypeParamName, minRequiredOpeningBalanceParamName, lockinPeriodFrequencyParamName,
lockinPeriodFrequencyTypeParamName,
@@ -188,8 +188,8 @@ public class SavingsApiConstants {
* parameters to match those of request parameters.
*/
public static final Set<String> SAVINGS_ACCOUNT_RESPONSE_DATA_PARAMETERS = new HashSet<>(Arrays.asList(idParamName, accountNoParamName,
externalIdParamName, statusParamName, activatedOnDateParamName,staffIdParamName, clientIdParamName, "clientName", groupIdParamName, "groupName",
"savingsProductId", "savingsProductName", "currency", nominalAnnualInterestRateParamName,
externalIdParamName, statusParamName, activatedOnDateParamName, staffIdParamName, clientIdParamName, "clientName",
groupIdParamName, "groupName", "savingsProductId", "savingsProductName", "currency", nominalAnnualInterestRateParamName,
interestCompoundingPeriodTypeParamName, interestCalculationTypeParamName, interestCalculationDaysInYearTypeParamName,
minRequiredOpeningBalanceParamName, lockinPeriodFrequencyParamName, lockinPeriodFrequencyTypeParamName,
withdrawalFeeAmountParamName, withdrawalFeeTypeParamName, withdrawalFeeForTransfersParamName, feeAmountParamName,
@@ -58,7 +58,7 @@ public enum SavingsPeriodFrequencyType {
public boolean isInvalid() {
return this.value.equals(SavingsPeriodFrequencyType.INVALID.value);
}
public static Object[] integerValues() {
final List<Integer> values = new ArrayList<>();
for (final SavingsPeriodFrequencyType enumType : values()) {
@@ -17,8 +17,7 @@ public enum SavingsPostingInterestPeriodType {
INVALID(0, "savingsPostingInterestPeriodType.invalid"), //
MONTHLY(4, "savingsPostingInterestPeriodType.monthly"), //
QUATERLY(5, "savingsPostingInterestPeriodType.quarterly"), //
BIANNUAL(6, "savingsPostingInterestPeriodType.biannual"),
ANNUAL(7, "savingsPostingInterestPeriodType.annual");
BIANNUAL(6, "savingsPostingInterestPeriodType.biannual"), ANNUAL(7, "savingsPostingInterestPeriodType.annual");
private final Integer value;
private final String code;
@@ -174,7 +174,8 @@ public class FixedDepositAccountsApiResource {
}
private FixedDepositAccountData populateTemplateAndAssociations(final Long accountId, final FixedDepositAccountData savingsAccount,
final boolean staffInSelectedOfficeOnly, final String chargeStatus, final UriInfo uriInfo, final Set<String> mandatoryResponseParameters) {
final boolean staffInSelectedOfficeOnly, final String chargeStatus, final UriInfo uriInfo,
final Set<String> mandatoryResponseParameters) {
Collection<SavingsAccountTransactionData> transactions = null;
Collection<SavingsAccountChargeData> charges = null;
@@ -85,7 +85,7 @@ public class RecurringDepositAccountTransactionsApiResource {
this.context.authenticatedUser().validateHasReadPermission(DepositsApiConstants.RECURRING_DEPOSIT_ACCOUNT_RESOURCE_NAME);
/***
* Check @Param commandParam value for deposit or withdrawal
* Check @Param commandParam value for deposit or withdrawal
*/
if (!(is(commandParam, "deposit") || is(commandParam, "withdrawal"))) { throw new UnrecognizedQueryParamException("command",
commandParam, new Object[] { "deposit", "withdrawal" }); }
@@ -181,7 +181,8 @@ public class RecurringDepositAccountTransactionsApiResource {
final CommandWrapper commandRequest = builder.undoRecurringAccountTransaction(recurringDepositAccountId, transactionId).build();
result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
} else if (is(commandParam, DepositsApiConstants.COMMAND_ADJUST_TRANSACTION)) {
final CommandWrapper commandRequest = builder.adjustRecurringAccountTransaction(recurringDepositAccountId, transactionId).build();
final CommandWrapper commandRequest = builder.adjustRecurringAccountTransaction(recurringDepositAccountId, transactionId)
.build();
result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
}
@@ -82,7 +82,8 @@ public class SavingsAccountTransactionsApiResource {
// FIXME - KW - for now just send back generic default information for
// both deposit/withdrawal templates
SavingsAccountTransactionData savingsAccount = this.savingsAccountReadPlatformService.retrieveDepositTransactionTemplate(savingsId, DepositAccountType.SAVINGS_DEPOSIT);
SavingsAccountTransactionData savingsAccount = this.savingsAccountReadPlatformService.retrieveDepositTransactionTemplate(savingsId,
DepositAccountType.SAVINGS_DEPOSIT);
final Collection<CodeValueData> paymentTypeOptions = this.codeValueReadPlatformService
.retrieveCodeValuesByCode(PaymentDetailConstants.paymentTypeCodeName);
savingsAccount = SavingsAccountTransactionData.templateOnTop(savingsAccount, paymentTypeOptions);
@@ -248,21 +248,21 @@ public class SavingsAccountsApiResource {
} else if (is(commandParam, "close")) {
final CommandWrapper commandRequest = builder.closeSavingsAccountApplication(accountId).build();
result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
}else if (is(commandParam, "assignFieldOfficer")) {
final CommandWrapper commandRequest = builder.assignFieldOfficer(accountId).build();
} else if (is(commandParam, "assignFieldOfficer")) {
final CommandWrapper commandRequest = builder.assignFieldOfficer(accountId).build();
result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
return this.toApiJsonSerializer.serialize(result);
} else if (is(commandParam, "unassignFieldOfficer")) {
final CommandWrapper commandRequest = builder.unassignFieldOfficer(accountId).build();
final CommandWrapper commandRequest = builder.unassignFieldOfficer(accountId).build();
result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
return this.toApiJsonSerializer.serialize(result);
}
if (result == null) {
//
throw new UnrecognizedQueryParamException("command", commandParam, new Object[] { "reject", "withdrawnByApplicant", "approve",
"undoapproval", "activate", "calculateInterest", "postInterest", "close" ,"assignFieldOfficer" ,"unassignFieldOfficer"});
throw new UnrecognizedQueryParamException("command", commandParam,
new Object[] { "reject", "withdrawnByApplicant", "approve", "undoapproval", "activate", "calculateInterest",
"postInterest", "close", "assignFieldOfficer", "unassignFieldOfficer" });
}
return this.toApiJsonSerializer.serialize(result);
@@ -527,8 +527,10 @@ public class DepositAccountDataValidator {
private void validateRecurringDetailForSubmit(final JsonElement element, final DataValidatorBuilder baseDataValidator) {
final BigDecimal mandatoryRecommendedDepositAmount = fromApiJsonHelper.extractBigDecimalWithLocaleNamed(mandatoryRecommendedDepositAmountParamName, element);
baseDataValidator.reset().parameter(mandatoryRecommendedDepositAmountParamName).value(mandatoryRecommendedDepositAmount).notNull().positiveAmount();
final BigDecimal mandatoryRecommendedDepositAmount = fromApiJsonHelper.extractBigDecimalWithLocaleNamed(
mandatoryRecommendedDepositAmountParamName, element);
baseDataValidator.reset().parameter(mandatoryRecommendedDepositAmountParamName).value(mandatoryRecommendedDepositAmount).notNull()
.positiveAmount();
if (this.fromApiJsonHelper.parameterExists(isMandatoryDepositParamName, element)) {
final Boolean isMandatoryDeposit = this.fromApiJsonHelper.extractBooleanNamed(isMandatoryDepositParamName, element);
@@ -66,8 +66,8 @@ public class DepositAccountTransactionDataValidator {
DepositsApiConstants.DEPOSIT_ACCOUNT_TRANSACTION_REQUEST_DATA_PARAMETERS);
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
.resource(depositAccountType.resourceName());
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource(depositAccountType
.resourceName());
final JsonElement element = command.parsedJson();
@@ -80,8 +80,8 @@ public class DepositAccountTransactionDataValidator {
// Validate all string payment detail fields for max length
final Integer paymentTypeId = this.fromApiJsonHelper.extractIntegerWithLocaleNamed(paymentTypeIdParamName, element);
baseDataValidator.reset().parameter(paymentTypeIdParamName).value(paymentTypeId).ignoreIfNull().integerGreaterThanZero();
final Set<String> paymentDetailParameters = new HashSet<>(Arrays.asList(transactionAccountNumberParamName,
checkNumberParamName, routingCodeParamName, receiptNumberParamName, bankNumberParamName));
final Set<String> paymentDetailParameters = new HashSet<>(Arrays.asList(transactionAccountNumberParamName, checkNumberParamName,
routingCodeParamName, receiptNumberParamName, bankNumberParamName));
for (final String paymentDetailParameterName : paymentDetailParameters) {
final String paymentDetailParameterValue = this.fromApiJsonHelper.extractStringNamed(paymentDetailParameterName, element);
baseDataValidator.reset().parameter(paymentDetailParameterName).value(paymentDetailParameterValue).ignoreIfNull()
@@ -158,8 +158,12 @@ public class DepositAccountTransactionDataValidator {
final DepositAccountOnClosureType accountOnClosureType = DepositAccountOnClosureType.fromInt(onAccountClosureId);
if (accountOnClosureType.isTransferToSavings()) {
final Long toSavingsAccountId = this.fromApiJsonHelper.extractLongNamed(toSavingsAccountIdParamName, element);
baseDataValidator.reset().parameter(toSavingsAccountIdParamName).value(toSavingsAccountId)
.cantBeBlankWhenParameterProvidedIs(onAccountClosureIdParamName, DepositAccountOnClosureType.fromInt(onAccountClosureId).getCode());
baseDataValidator
.reset()
.parameter(toSavingsAccountIdParamName)
.value(toSavingsAccountId)
.cantBeBlankWhenParameterProvidedIs(onAccountClosureIdParamName,
DepositAccountOnClosureType.fromInt(onAccountClosureId).getCode());
} else if (accountOnClosureType.isReinvest() && isPreMatureClose) {
baseDataValidator.reset().parameter(onAccountClosureIdParamName).value(onAccountClosureId)
.failWithCode("reinvest.not.allowed", "Re-Invest is not supported for account pre mature close");
@@ -169,8 +173,8 @@ public class DepositAccountTransactionDataValidator {
// Validate all string payment detail fields for max length
final Integer paymentTypeId = this.fromApiJsonHelper.extractIntegerWithLocaleNamed(paymentTypeIdParamName, element);
baseDataValidator.reset().parameter(paymentTypeIdParamName).value(paymentTypeId).ignoreIfNull().integerGreaterThanZero();
final Set<String> paymentDetailParameters = new HashSet<>(Arrays.asList(transactionAccountNumberParamName,
checkNumberParamName, routingCodeParamName, receiptNumberParamName, bankNumberParamName));
final Set<String> paymentDetailParameters = new HashSet<>(Arrays.asList(transactionAccountNumberParamName, checkNumberParamName,
routingCodeParamName, receiptNumberParamName, bankNumberParamName));
for (final String paymentDetailParameterName : paymentDetailParameters) {
final String paymentDetailParameterValue = this.fromApiJsonHelper.extractStringNamed(paymentDetailParameterName, element);
baseDataValidator.reset().parameter(paymentDetailParameterName).value(paymentDetailParameterValue).ignoreIfNull()
@@ -390,6 +390,7 @@ public class SavingsAccountDataValidator {
}
}
public void validateForAssignFieldOfficer(final String json) {
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
@@ -414,8 +415,8 @@ public class SavingsAccountDataValidator {
}
public void validateForUnAssignFieldOfficer(final String json) {
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
public void validateForUnAssignFieldOfficer(final String json) {
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
@@ -435,6 +436,5 @@ public class SavingsAccountDataValidator {
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
}
}
}
@@ -30,8 +30,10 @@ public class SavingsAccountTransactionDTO {
this.createdDate = createdDate;
this.savingsAccountId = null;
}
/** This constructor is used for bulk deposit transactions
/**
* This constructor is used for bulk deposit transactions
*
* @param formatter
* @param transactionDate
* @param transactionAmount
@@ -49,8 +51,6 @@ public class SavingsAccountTransactionDTO {
this.savingsAccountId = savingsAccountId;
}
public DateTimeFormatter getFormatter() {
return this.formatter;
}
@@ -70,9 +70,9 @@ public class SavingsAccountTransactionDTO {
public Date getCreatedDate() {
return this.createdDate;
}
public Long getSavingsAccountId() {
return this.savingsAccountId;
}
}
@@ -87,7 +87,8 @@ public class SavingsAccountTransactionData {
this.paymentTypeOptions = paymentTypeOptions;
}
public static SavingsAccountTransactionData withWithDrawalTransactionDetails(final SavingsAccountTransactionData savingsAccountTransactionData) {
public static SavingsAccountTransactionData withWithDrawalTransactionDetails(
final SavingsAccountTransactionData savingsAccountTransactionData) {
final LocalDate currentDate = DateUtils.getLocalDateOfTenant();
final SavingsAccountTransactionEnumData transactionType = SavingsEnumerations
@@ -72,7 +72,7 @@ public class SavingsAccountTransactionDataValidator {
final BigDecimal transactionAmount = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(transactionAmountParamName, element);
baseDataValidator.reset().parameter(transactionAmountParamName).value(transactionAmount).notNull().positiveAmount();
validatePaymentTypeDetails(baseDataValidator, element);
throwExceptionIfValidationWarningsExist(dataValidationErrors);
@@ -64,7 +64,7 @@ public class DepositRecurringDetail {
actualChanges.put(allowWithdrawalParamName, newValue);
this.allowWithdrawal = newValue;
}
if (command.isChangeInBooleanParameterNamed(adjustAdvanceTowardsFuturePaymentsParamName, this.adjustAdvanceTowardsFuturePayments)) {
final boolean newValue = command.booleanObjectValueOfParameterNamed(adjustAdvanceTowardsFuturePaymentsParamName);
actualChanges.put(adjustAdvanceTowardsFuturePaymentsParamName, newValue);
@@ -73,15 +73,15 @@ public class DepositRecurringDetail {
return actualChanges;
}
public boolean isMandatoryDeposit() {
return this.isMandatoryDeposit;
}
public boolean allowWithdrawal() {
return this.allowWithdrawal;
}
public boolean adjustAdvanceTowardsFuturePayments() {
return this.adjustAdvanceTowardsFuturePayments;
}
@@ -8,7 +8,7 @@ package org.mifosplatform.portfolio.savings.domain;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
public interface FixedDepositAccountRepository extends JpaRepository<FixedDepositAccount, Long>, JpaSpecificationExecutor<FixedDepositAccount> {
public interface FixedDepositAccountRepository extends JpaRepository<FixedDepositAccount, Long>,
JpaSpecificationExecutor<FixedDepositAccount> {
}
@@ -75,7 +75,8 @@ public class FixedDepositProduct extends SavingsProduct {
final SavingsPostingInterestPeriodType interestPostingPeriodType, final SavingsInterestCalculationType interestCalculationType,
final SavingsInterestCalculationDaysInYearType interestCalculationDaysInYearType, final Integer lockinPeriodFrequency,
final SavingsPeriodFrequencyType lockinPeriodFrequencyType, final AccountingRuleType accountingRuleType,
final Set<Charge> charges, final DepositProductTermAndPreClosure productTermAndPreClosure, final Set<InterestRateChart> charts, BigDecimal minBalanceForInterestCalculation) {
final Set<Charge> charges, final DepositProductTermAndPreClosure productTermAndPreClosure, final Set<InterestRateChart> charts,
BigDecimal minBalanceForInterestCalculation) {
final BigDecimal minRequiredOpeningBalance = null;
final boolean withdrawalFeeApplicableForTransfer = false;
@@ -8,6 +8,7 @@ package org.mifosplatform.portfolio.savings.domain;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
public interface FixedDepositProductRepository extends JpaRepository<FixedDepositProduct, Long>, JpaSpecificationExecutor<FixedDepositProduct> {
public interface FixedDepositProductRepository extends JpaRepository<FixedDepositProduct, Long>,
JpaSpecificationExecutor<FixedDepositProduct> {
}
@@ -8,6 +8,7 @@ package org.mifosplatform.portfolio.savings.domain;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
public interface RecurringDepositAccountRepository extends JpaRepository<RecurringDepositAccount, Long>, JpaSpecificationExecutor<RecurringDepositAccount> {
public interface RecurringDepositAccountRepository extends JpaRepository<RecurringDepositAccount, Long>,
JpaSpecificationExecutor<RecurringDepositAccount> {
}
@@ -8,6 +8,7 @@ package org.mifosplatform.portfolio.savings.domain;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
public interface RecurringDepositProductRepository extends JpaRepository<RecurringDepositProduct, Long>, JpaSpecificationExecutor<RecurringDepositProduct> {
public interface RecurringDepositProductRepository extends JpaRepository<RecurringDepositProduct, Long>,
JpaSpecificationExecutor<RecurringDepositProduct> {
//
}
@@ -160,7 +160,7 @@ public class RecurringDepositScheduleInstallment extends AbstractAuditableCustom
public LocalDate dueDate() {
return (this.dueDate == null) ? null : new LocalDate(this.dueDate);
}
public Money payInstallment(final LocalDate transactionDate, final Money transactionAmountRemaining) {
final MonetaryCurrency currency = transactionAmountRemaining.getCurrency();
@@ -183,18 +183,18 @@ public class RecurringDepositScheduleInstallment extends AbstractAuditableCustom
return depositAmountPortionOfTransaction;
}
private void checkIfInstallmentObligationsAreMet(final LocalDate transactionDate, final MonetaryCurrency currency) {
this.obligationsMet = getTotalOutstanding(currency).isZero();
if (this.obligationsMet) {
this.obligationsMetOnDate = transactionDate.toDate();
}
}
public Money getTotalOutstanding(final MonetaryCurrency currency) {
return getDepositAmountOutstanding(currency);
}
private void trackAdvanceAndLateTotalsForInstallment(final LocalDate transactionDate, final MonetaryCurrency currency,
final Money amountPaidInInstallment) {
if (isInAdvance(transactionDate)) {
@@ -203,7 +203,7 @@ public class RecurringDepositScheduleInstallment extends AbstractAuditableCustom
this.totalPaidLate = asMoney(this.totalPaidLate, currency).plus(amountPaidInInstallment).getAmount();
}
}
private boolean isInAdvance(final LocalDate transactionDate) {
return transactionDate.isBefore(dueDate());
}
@@ -211,12 +211,12 @@ public class RecurringDepositScheduleInstallment extends AbstractAuditableCustom
private boolean isLatePayment(final LocalDate transactionDate) {
return transactionDate.isAfter(dueDate());
}
private Money asMoney(final BigDecimal decimal, final MonetaryCurrency currency) {
return Money.of(currency, decimal);
}
public void resetDerivedFields(){
public void resetDerivedFields() {
this.depositAmountCompleted = null;
this.totalPaidInAdvance = null;
this.totalPaidLate = null;
@@ -246,7 +246,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
@Column(name = "min_required_balance", scale = 6, precision = 19, nullable = true)
private BigDecimal minRequiredBalance;
@Temporal(TemporalType.DATE)
@Column(name = "start_interest_calculation_date")
protected Date startInterestCalculationDate;
@@ -472,21 +472,21 @@ public class SavingsAccount extends AbstractPersistable<Long> {
return postingTransation;
}
//Determine the last transaction for given day
protected SavingsAccountTransaction findLastTransaction(final LocalDate date) {
SavingsAccountTransaction savingsTransaction = null;
// Determine the last transaction for given day
protected SavingsAccountTransaction findLastTransaction(final LocalDate date) {
for (final SavingsAccountTransaction transaction : this.transactions) {
if (transaction.isNotReversed() && transaction.occursOn(date)) {
savingsTransaction = transaction;
break;
}
}
SavingsAccountTransaction savingsTransaction = null;
return savingsTransaction;
}
for (final SavingsAccountTransaction transaction : this.transactions) {
if (transaction.isNotReversed() && transaction.occursOn(date)) {
savingsTransaction = transaction;
break;
}
}
return savingsTransaction;
}
/**
* All interest calculation based on END-OF-DAY-BALANCE.
@@ -529,42 +529,34 @@ public class SavingsAccount extends AbstractPersistable<Long> {
final SavingsInterestCalculationDaysInYearType daysInYearType = SavingsInterestCalculationDaysInYearType
.fromInt(this.interestCalculationDaysInYearType);
final List<LocalDateInterval> postingPeriodIntervals = this.savingsHelper.determineInterestPostingPeriods(getStartInterestCalculationDate(),
upToInterestCalculationDate, postingPeriodType);
final List<LocalDateInterval> postingPeriodIntervals = this.savingsHelper.determineInterestPostingPeriods(
getStartInterestCalculationDate(), upToInterestCalculationDate, postingPeriodType);
final List<PostingPeriod> allPostingPeriods = new ArrayList<>();
Money periodStartingBalance;
if (this.startInterestCalculationDate != null) {
LocalDate startInterestCalculationDate = new LocalDate(
this.startInterestCalculationDate);
final SavingsAccountTransaction transaction = findLastTransaction(startInterestCalculationDate);
if (transaction == null) {
final String defaultUserMessage = "No transactions were found on the specified date "
+ getStartInterestCalculationDate().toString()
+ " for account number "
+ this.accountNumber.toString()
+ " and resource id "
+ getId();
Money periodStartingBalance;
if (this.startInterestCalculationDate != null) {
LocalDate startInterestCalculationDate = new LocalDate(this.startInterestCalculationDate);
final SavingsAccountTransaction transaction = findLastTransaction(startInterestCalculationDate);
final ApiParameterError error = ApiParameterError
.parameterError(
"error.msg.savingsaccount.transaction.incorrect.start.interest.calculation.date",
defaultUserMessage, "transactionDate",
getStartInterestCalculationDate().toString());
if (transaction == null) {
final String defaultUserMessage = "No transactions were found on the specified date "
+ getStartInterestCalculationDate().toString() + " for account number " + this.accountNumber.toString()
+ " and resource id " + getId();
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
dataValidationErrors.add(error);
final ApiParameterError error = ApiParameterError.parameterError(
"error.msg.savingsaccount.transaction.incorrect.start.interest.calculation.date", defaultUserMessage,
"transactionDate", getStartInterestCalculationDate().toString());
throw new PlatformApiDataValidationException(
dataValidationErrors);
}
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
dataValidationErrors.add(error);
periodStartingBalance = transaction
.getRunningBalance(this.currency);
} else
periodStartingBalance = Money.zero(this.currency);
throw new PlatformApiDataValidationException(dataValidationErrors);
}
periodStartingBalance = transaction.getRunningBalance(this.currency);
} else
periodStartingBalance = Money.zero(this.currency);
final SavingsInterestCalculationType interestCalculationType = SavingsInterestCalculationType.fromInt(this.interestCalculationType);
final BigDecimal interestRateAsFraction = getEffectiveInterestRateAsFraction(mc, upToInterestCalculationDate);
@@ -749,18 +741,17 @@ public class SavingsAccount extends AbstractPersistable<Long> {
}
return activationLocalDate;
}
//startInterestCalculationDate is set during migration so that there is no
//interference with interest posting of previous system
public LocalDate getStartInterestCalculationDate() {
LocalDate startInterestCalculationLocalDate = null;
if (this.startInterestCalculationDate != null) {
startInterestCalculationLocalDate = new LocalDate(
this.startInterestCalculationDate);
} else
startInterestCalculationLocalDate = getActivationLocalDate();
return startInterestCalculationLocalDate;
}
// startInterestCalculationDate is set during migration so that there is no
// interference with interest posting of previous system
public LocalDate getStartInterestCalculationDate() {
LocalDate startInterestCalculationLocalDate = null;
if (this.startInterestCalculationDate != null) {
startInterestCalculationLocalDate = new LocalDate(this.startInterestCalculationDate);
} else
startInterestCalculationLocalDate = getActivationLocalDate();
return startInterestCalculationLocalDate;
}
public SavingsAccountTransaction withdraw(final SavingsAccountTransactionDTO transactionDTO, final boolean applyWithdrawFee) {
@@ -104,7 +104,7 @@ public class SavingsAccountCharge extends AbstractPersistable<Long> {
@Column(name = "is_active", nullable = false)
private boolean status = true;
@Temporal(TemporalType.DATE)
@Column(name = "inactivated_on_date")
private Date inactivationDate;
@@ -28,7 +28,8 @@ public interface SavingsAccountRepository extends JpaRepository<SavingsAccount,
@Query("from SavingsAccount sa where sa.client.id is null and sa.group.id = :groupId")
List<SavingsAccount> findByGroupId(@Param("groupId") Long groupId);
@Query("from SavingsAccount sa where sa.id = :accountId and sa.depositType = :depositAccountTypeId")
SavingsAccount findByIdAndDepositAccountType(@Param("accountId") Long accountId, @Param("depositAccountTypeId") Integer depositAccountTypeId);
SavingsAccount findByIdAndDepositAccountType(@Param("accountId") Long accountId,
@Param("depositAccountTypeId") Integer depositAccountTypeId);
}
@@ -37,7 +37,7 @@ public class SavingsAccountRepositoryWrapper {
if (account == null) { throw new SavingsAccountNotFoundException(savingsId); }
return account;
}
public SavingsAccount findOneWithNotFoundDetection(final Long savingsId, final DepositAccountType depositAccountType) {
final SavingsAccount account = this.repository.findByIdAndDepositAccountType(savingsId, depositAccountType.getValue());
if (account == null) { throw new SavingsAccountNotFoundException(savingsId); }
@@ -18,10 +18,8 @@ public enum SavingsAccountStatusType {
TRANSFER_ON_HOLD(304, "savingsAccountStatusType.transfer.on.hold"), //
WITHDRAWN_BY_APPLICANT(400, "savingsAccountStatusType.withdrawn.by.applicant"), //
REJECTED(500, "savingsAccountStatusType.rejected"), //
CLOSED(600, "savingsAccountStatusType.closed"),
PRE_MATURE_CLOSURE(700, "savingsAccountStatusType.pre.mature.closure"),
MATURED(800, "savingsAccountStatusType.matured");
CLOSED(600, "savingsAccountStatusType.closed"), PRE_MATURE_CLOSURE(700, "savingsAccountStatusType.pre.mature.closure"), MATURED(800,
"savingsAccountStatusType.matured");
private final Integer value;
private final String code;
@@ -100,7 +98,7 @@ public enum SavingsAccountStatusType {
public boolean isActive() {
return this.value.equals(SavingsAccountStatusType.ACTIVE.getValue());
}
public boolean isActiveOrAwaitingApprovalOrDisbursal() {
return isApproved() || isSubmittedAndPendingApproval() || isActive();
}
@@ -120,11 +118,11 @@ public enum SavingsAccountStatusType {
public boolean isUnderTransfer() {
return isTransferInProgress() || isTransferOnHold();
}
public boolean isMatured() {
return this.value.equals(SavingsAccountStatusType.MATURED.getValue());
}
public boolean isPreMatureClosure() {
return this.value.equals(SavingsAccountStatusType.PRE_MATURE_CLOSURE.getValue());
}
@@ -216,9 +216,9 @@ public final class SavingsAccountTransaction extends AbstractPersistable<Long> {
public Money getAmount(final MonetaryCurrency currency) {
return Money.of(currency, this.amount);
}
public Money getRunningBalance(final MonetaryCurrency currency) {
return Money.of(currency, this.runningBalance);
return Money.of(currency, this.runningBalance);
}
public boolean isDeposit() {
@@ -10,6 +10,7 @@ import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceN
public class DepositAccountInterestRateChartNotFoundException extends AbstractPlatformResourceNotFoundException {
public DepositAccountInterestRateChartNotFoundException(final Long id) {
super("error.msg.deposit.account.interest.rate.chart.id.invalid", "Deposit Account Interest rate chart with identifier " + id + " does not exist", id);
super("error.msg.deposit.account.interest.rate.chart.id.invalid", "Deposit Account Interest rate chart with identifier " + id
+ " does not exist", id);
}
}
@@ -16,7 +16,7 @@ import org.mifosplatform.portfolio.savings.service.SavingsEnumerations;
public class DepositAccountTransactionNotAllowedException extends AbstractPlatformServiceUnavailableException {
public DepositAccountTransactionNotAllowedException(final Long accountId, final String action, final DepositAccountType type) {
super("error.msg." + type.resourceName() + ".account.trasaction." + action + ".notallowed", SavingsEnumerations.depositType(type).getValue()
+ "account " + action + " transaction not allowed with account identifier " + accountId, accountId);
super("error.msg." + type.resourceName() + ".account.trasaction." + action + ".notallowed", SavingsEnumerations.depositType(type)
.getValue() + "account " + action + " transaction not allowed with account identifier " + accountId, accountId);
}
}
@@ -10,8 +10,8 @@ import org.springframework.transaction.annotation.Transactional;
@Service
public class AssignFieldOfficerSavingsAccountCommandHandler implements NewCommandSourceHandler {
private final SavingsAccountWritePlatformService savingsWritePlatformService;
private final SavingsAccountWritePlatformService savingsWritePlatformService;
@Autowired
public AssignFieldOfficerSavingsAccountCommandHandler(final SavingsAccountWritePlatformService savingAccountWritePlatformService) {
@@ -20,7 +20,8 @@ public class CalculateInterestRecurringDepositAccountCommandHandler implements N
private final DepositAccountWritePlatformService depositAccountWritePlatformService;
@Autowired
public CalculateInterestRecurringDepositAccountCommandHandler(final DepositAccountWritePlatformService depositAccountWritePlatformService) {
public CalculateInterestRecurringDepositAccountCommandHandler(
final DepositAccountWritePlatformService depositAccountWritePlatformService) {
this.depositAccountWritePlatformService = depositAccountWritePlatformService;
}
@@ -28,6 +28,7 @@ public class FixedDepositAccountApplicationApprovalUndoCommandHandler implements
@Transactional
@Override
public CommandProcessingResult processCommand(final JsonCommand command) {
return this.depositAccountWritePlatformService.undoApplicationApproval(command.entityId(), command, DepositAccountType.FIXED_DEPOSIT);
return this.depositAccountWritePlatformService.undoApplicationApproval(command.entityId(), command,
DepositAccountType.FIXED_DEPOSIT);
}
}
@@ -28,6 +28,7 @@ public class RecurringDepositAccountApplicationApprovalCommandHandler implements
@Transactional
@Override
public CommandProcessingResult processCommand(final JsonCommand command) {
return this.depositAccountWritePlatformService.approveApplication(command.entityId(), command, DepositAccountType.RECURRING_DEPOSIT);
return this.depositAccountWritePlatformService
.approveApplication(command.entityId(), command, DepositAccountType.RECURRING_DEPOSIT);
}
}
@@ -28,6 +28,7 @@ public class RecurringDepositAccountApplicationApprovalUndoCommandHandler implem
@Transactional
@Override
public CommandProcessingResult processCommand(final JsonCommand command) {
return this.depositAccountWritePlatformService.undoApplicationApproval(command.entityId(), command, DepositAccountType.RECURRING_DEPOSIT);
return this.depositAccountWritePlatformService.undoApplicationApproval(command.entityId(), command,
DepositAccountType.RECURRING_DEPOSIT);
}
}
@@ -10,8 +10,8 @@ import org.springframework.transaction.annotation.Transactional;
@Service
public class UnassignFieldOfficerSavingsAccountCommandHandler implements NewCommandSourceHandler {
private final SavingsAccountWritePlatformService savingsWritePlatformService;
private final SavingsAccountWritePlatformService savingsWritePlatformService;
@Autowired
public UnassignFieldOfficerSavingsAccountCommandHandler(final SavingsAccountWritePlatformService savingAccountWritePlatformService) {
@@ -8,14 +8,14 @@ package org.mifosplatform.portfolio.savings.service;
import org.mifosplatform.portfolio.savings.data.DepositAccountInterestRateChartData;
public interface DepositAccountInterestRateChartReadPlatformService {
DepositAccountInterestRateChartData retrieveOne(Long interestChartId);
DepositAccountInterestRateChartData retrieveOneWithSlabs(Long interestChartId);
DepositAccountInterestRateChartData retrieveWithTemplate(DepositAccountInterestRateChartData DepositAccountInterestRateChartData);
DepositAccountInterestRateChartData retrieveOneWithSlabsOnAccountId(Long accountId);
DepositAccountInterestRateChartData template();
}
@@ -17,23 +17,24 @@ import org.mifosplatform.portfolio.savings.data.SavingsAccountTransactionData;
public interface DepositAccountReadPlatformService {
Collection<DepositAccountData> retrieveAll(final DepositAccountType depositAccountType, final PaginationParameters paginationParameters);
Page<DepositAccountData> retrieveAllPaged(final DepositAccountType depositAccountType, final PaginationParameters paginationParameters);
Collection<DepositAccountData> retrieveAllForLookup(final DepositAccountType depositAccountType);
DepositAccountData retrieveOne(final DepositAccountType depositAccountType, Long accountId);
DepositAccountData retrieveOneWithClosureTemplate(final DepositAccountType depositAccountType, Long accountId);
DepositAccountData retrieveOneWithChartSlabs(final DepositAccountType depositAccountType, Long productId);
Collection<SavingsAccountTransactionData> retrieveAllTransactions(final DepositAccountType depositAccountType, Long accountId);
DepositAccountData retrieveTemplate(final DepositAccountType depositAccountType, Long clientId, Long groupId, Long productId, boolean staffInSelectedOfficeOnly);
DepositAccountData retrieveTemplate(final DepositAccountType depositAccountType, Long clientId, Long groupId, Long productId,
boolean staffInSelectedOfficeOnly);
Collection<DepositAccountData> retrieveForMaturityUpdate();
SavingsAccountTransactionData retrieveRecurringAccountDepositTransactionTemplate(final Long accountId);
Collection<AccountTransferDTO> retrieveDataForInterestTransfer();
@@ -1366,7 +1366,8 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
.transactionType(SavingsAccountTransactionType.DEPOSIT.getValue());
final PaymentDetailData paymentDetailData = null;
final AccountTransferData transfer = null;
final BigDecimal runningBalance = JdbcSupport.getBigDecimalDefaultToNullIfZero(rs, "runningBalance");;
final BigDecimal runningBalance = JdbcSupport.getBigDecimalDefaultToNullIfZero(rs, "runningBalance");
;
return SavingsAccountTransactionData.create(savingsId, transactionType, paymentDetailData, savingsId, accountNo, duedate,
currency, dueamount, runningBalance, false, transfer);
}
@@ -18,11 +18,11 @@ import org.mifosplatform.portfolio.savings.domain.SavingsAccountTransaction;
public interface DepositAccountWritePlatformService {
CommandProcessingResult activateFDAccount(Long savingsId, JsonCommand command);
CommandProcessingResult activateRDAccount(Long savingsId, JsonCommand command);
CommandProcessingResult depositToFDAccount(Long savingsId, JsonCommand command);
CommandProcessingResult depositToRDAccount(Long savingsId, JsonCommand command);
CommandProcessingResult withdrawal(Long savingsId, JsonCommand command, final DepositAccountType depositAccountType);
@@ -32,19 +32,19 @@ public interface DepositAccountWritePlatformService {
CommandProcessingResult postInterest(Long savingsId, final DepositAccountType depositAccountType);
CommandProcessingResult undoFDTransaction(Long savingsId, Long transactionId, boolean allowAccountTransferModification);
CommandProcessingResult undoRDTransaction(Long savingsId, Long transactionId, boolean allowAccountTransferModification);
CommandProcessingResult adjustFDTransaction(Long savingsId, Long transactionId, JsonCommand command);
CommandProcessingResult adjustRDTransaction(Long savingsId, Long transactionId, JsonCommand command);
CommandProcessingResult closeFDAccount(Long savingsId, JsonCommand command);
CommandProcessingResult closeRDAccount(Long savingsId, JsonCommand command);
CommandProcessingResult prematureCloseFDAccount(Long savingsId, JsonCommand command);
CommandProcessingResult prematureCloseRDAccount(Long savingsId, JsonCommand command);
SavingsAccountTransaction initiateSavingsTransfer(Long accountId, LocalDate transferDate, final DepositAccountType depositAccountType);
@@ -53,23 +53,26 @@ public interface DepositAccountWritePlatformService {
void rejectSavingsTransfer(Long accountId, final DepositAccountType depositAccountType);
SavingsAccountTransaction acceptSavingsTransfer(Long accountId, LocalDate transferDate, Office acceptedInOffice, Staff staff, final DepositAccountType depositAccountType);
SavingsAccountTransaction acceptSavingsTransfer(Long accountId, LocalDate transferDate, Office acceptedInOffice, Staff staff,
final DepositAccountType depositAccountType);
CommandProcessingResult addSavingsAccountCharge(JsonCommand command, final DepositAccountType depositAccountType);
CommandProcessingResult updateSavingsAccountCharge(JsonCommand command, final DepositAccountType depositAccountType);
CommandProcessingResult deleteSavingsAccountCharge(Long savingsAccountId, Long savingsAccountChargeId, JsonCommand command, final DepositAccountType depositAccountType);
CommandProcessingResult deleteSavingsAccountCharge(Long savingsAccountId, Long savingsAccountChargeId, JsonCommand command,
final DepositAccountType depositAccountType);
CommandProcessingResult waiveCharge(Long savingsAccountId, Long savingsAccountChargeId, final DepositAccountType depositAccountType);
CommandProcessingResult payCharge(Long savingsAccountId, Long savingsAccountChargeId, JsonCommand command, final DepositAccountType depositAccountType);
CommandProcessingResult payCharge(Long savingsAccountId, Long savingsAccountChargeId, JsonCommand command,
final DepositAccountType depositAccountType);
void applyChargeDue(final Long savingsAccountChargeId, final Long accountId, final DepositAccountType depositAccountType);
void updateMaturityDetails(final Long depositAccountId, final DepositAccountType depositAccountType);
void transferInterestToSavings() throws JobExecutionException;
SavingsAccountTransaction mandatorySavingsAccountDeposit(final SavingsAccountTransactionDTO accountTransactionDTO);
}
@@ -12,11 +12,11 @@ import org.mifosplatform.portfolio.savings.DepositAccountType;
public interface DepositApplicationProcessWritePlatformService {
CommandProcessingResult submitFDApplication(JsonCommand command);
CommandProcessingResult submitRDApplication(JsonCommand command);
CommandProcessingResult modifyFDApplication(Long accountId, JsonCommand command);
CommandProcessingResult modifyRDApplication(Long accountId, JsonCommand command);
CommandProcessingResult deleteApplication(Long accountId, DepositAccountType depositAccountType);
@@ -17,7 +17,7 @@ public interface DepositProductReadPlatformService {
Collection<DepositProductData> retrieveAllForLookup(final DepositAccountType depositAccountType);
DepositProductData retrieveOne(final DepositAccountType depositAccountType, Long productId);
DepositProductData retrieveOneWithChartSlabs(final DepositAccountType depositAccountType, Long productId);
}
@@ -15,10 +15,12 @@ public interface DepositsDropdownReadPlatformService {
Collection<EnumOptionData> retrievePreClosurePenalInterestOnTypeOptions();
/*Collection<EnumOptionData> retrieveDepositTermTypeOptions();
Collection<EnumOptionData> retrieveInMultiplesOfDepositTermTypeOptions();
Collection<EnumOptionData> retrieveDepositPeriodFrequencyOptions();*/
/*
* Collection<EnumOptionData> retrieveDepositTermTypeOptions();
*
* Collection<EnumOptionData> retrieveInMultiplesOfDepositTermTypeOptions();
*
* Collection<EnumOptionData> retrieveDepositPeriodFrequencyOptions();
*/
}
@@ -13,25 +13,27 @@ import org.springframework.stereotype.Service;
@Service
public class DepositsDropdownReadPlatformServiceImpl implements DepositsDropdownReadPlatformService {
@Override
public Collection<EnumOptionData> retrievePreClosurePenalInterestOnTypeOptions() {
return SavingsEnumerations.preClosurePenaltyInterestOnType(PreClosurePenalInterestOnType.values());
}
/*@Override
public Collection<EnumOptionData> retrieveDepositTermTypeOptions() {
return SavingsEnumerations.recurringDepositFrequencyType(SavingsPeriodFrequencyType.values());
}
@Override
public Collection<EnumOptionData> retrieveDepositPeriodFrequencyOptions() {
return SavingsEnumerations.depositPeriodFrequency(SavingsPeriodFrequencyType.values());
}
/*
* @Override public Collection<EnumOptionData>
* retrieveDepositTermTypeOptions() { return
* SavingsEnumerations.recurringDepositFrequencyType
* (SavingsPeriodFrequencyType.values()); }
*
* @Override public Collection<EnumOptionData>
* retrieveDepositPeriodFrequencyOptions() { return
* SavingsEnumerations.depositPeriodFrequency
* (SavingsPeriodFrequencyType.values()); }
*
* @Override public Collection<EnumOptionData>
* retrieveInMultiplesOfDepositTermTypeOptions() { return
* SavingsEnumerations
* .recurringDepositFrequencyType(SavingsPeriodFrequencyType.values()); }
*/
@Override
public Collection<EnumOptionData> retrieveInMultiplesOfDepositTermTypeOptions() {
return SavingsEnumerations.recurringDepositFrequencyType(SavingsPeriodFrequencyType.values());
}*/
}
@@ -45,8 +45,7 @@ public class FixedDepositProductWritePlatformServiceJpaRepositoryImpl implements
@Autowired
public FixedDepositProductWritePlatformServiceJpaRepositoryImpl(final PlatformSecurityContext context,
final FixedDepositProductRepository fixedDepositProductRepository,
final DepositProductDataValidator fromApiJsonDataValidator,
final FixedDepositProductRepository fixedDepositProductRepository, final DepositProductDataValidator fromApiJsonDataValidator,
final DepositProductAssembler depositProductAssembler,
final ProductToGLAccountMappingWritePlatformService accountMappingWritePlatformService,
final InterestRateChartAssembler chartAssembler) {
@@ -71,7 +70,8 @@ public class FixedDepositProductWritePlatformServiceJpaRepositoryImpl implements
this.fixedDepositProductRepository.save(product);
// save accounting mappings
this.accountMappingWritePlatformService.createSavingProductToGLAccountMapping(product.getId(), command, DepositAccountType.FIXED_DEPOSIT);
this.accountMappingWritePlatformService.createSavingProductToGLAccountMapping(product.getId(), command,
DepositAccountType.FIXED_DEPOSIT);
return new CommandProcessingResultBuilder() //
.withEntityId(product.getId()) //
@@ -93,12 +93,12 @@ public class FixedDepositProductWritePlatformServiceJpaRepositoryImpl implements
final FixedDepositProduct product = this.fixedDepositProductRepository.findOne(productId);
if (product == null) { throw new FixedDepositProductNotFoundException(productId); }
product.setHelpers(this.chartAssembler);
final Map<String, Object> changes = product.update(command);
if (changes.containsKey(chargesParamName)) {
final Set<Charge> savingsProductCharges = this.depositProductAssembler.assembleListOfSavingsProductCharges(command,
product.currency().getCode());
final Set<Charge> savingsProductCharges = this.depositProductAssembler.assembleListOfSavingsProductCharges(command, product
.currency().getCode());
final boolean updated = product.update(savingsProductCharges);
if (!updated) {
changes.remove(chargesParamName);
@@ -108,7 +108,8 @@ public class FixedDepositProductWritePlatformServiceJpaRepositoryImpl implements
// accounting related changes
final boolean accountingTypeChanged = changes.containsKey(accountingRuleParamName);
final Map<String, Object> accountingMappingChanges = this.accountMappingWritePlatformService
.updateSavingsProductToGLAccountMapping(product.getId(), command, accountingTypeChanged, product.getAccountingType(), DepositAccountType.FIXED_DEPOSIT);
.updateSavingsProductToGLAccountMapping(product.getId(), command, accountingTypeChanged, product.getAccountingType(),
DepositAccountType.FIXED_DEPOSIT);
changes.putAll(accountingMappingChanges);
if (!changes.isEmpty()) {
@@ -46,8 +46,7 @@ public class RecurringDepositProductWritePlatformServiceJpaRepositoryImpl implem
@Autowired
public RecurringDepositProductWritePlatformServiceJpaRepositoryImpl(final PlatformSecurityContext context,
final RecurringDepositProductRepository recurringDepositProductRepository,
final DepositProductDataValidator fromApiJsonDataValidator,
final DepositProductAssembler depositProductAssembler,
final DepositProductDataValidator fromApiJsonDataValidator, final DepositProductAssembler depositProductAssembler,
final ProductToGLAccountMappingWritePlatformService accountMappingWritePlatformService,
final InterestRateChartAssembler chartAssembler) {
this.context = context;
@@ -71,7 +70,8 @@ public class RecurringDepositProductWritePlatformServiceJpaRepositoryImpl implem
this.recurringDepositProductRepository.save(product);
// save accounting mappings
this.accountMappingWritePlatformService.createSavingProductToGLAccountMapping(product.getId(), command, DepositAccountType.RECURRING_DEPOSIT);
this.accountMappingWritePlatformService.createSavingProductToGLAccountMapping(product.getId(), command,
DepositAccountType.RECURRING_DEPOSIT);
return new CommandProcessingResultBuilder() //
.withEntityId(product.getId()) //
@@ -93,12 +93,12 @@ public class RecurringDepositProductWritePlatformServiceJpaRepositoryImpl implem
final RecurringDepositProduct product = this.recurringDepositProductRepository.findOne(productId);
if (product == null) { throw new RecurringDepositProductNotFoundException(productId); }
product.setHelpers(this.chartAssembler);
final Map<String, Object> changes = product.update(command);
if (changes.containsKey(chargesParamName)) {
final Set<Charge> savingsProductCharges = this.depositProductAssembler.assembleListOfSavingsProductCharges(command,
product.currency().getCode());
final Set<Charge> savingsProductCharges = this.depositProductAssembler.assembleListOfSavingsProductCharges(command, product
.currency().getCode());
final boolean updated = product.update(savingsProductCharges);
if (!updated) {
changes.remove(chargesParamName);
@@ -108,7 +108,8 @@ public class RecurringDepositProductWritePlatformServiceJpaRepositoryImpl implem
// accounting related changes
final boolean accountingTypeChanged = changes.containsKey(accountingRuleParamName);
final Map<String, Object> accountingMappingChanges = this.accountMappingWritePlatformService
.updateSavingsProductToGLAccountMapping(product.getId(), command, accountingTypeChanged, product.getAccountingType(), DepositAccountType.RECURRING_DEPOSIT);
.updateSavingsProductToGLAccountMapping(product.getId(), command, accountingTypeChanged, product.getAccountingType(),
DepositAccountType.RECURRING_DEPOSIT);
changes.putAll(accountingMappingChanges);
if (!changes.isEmpty()) {
@@ -149,13 +150,13 @@ public class RecurringDepositProductWritePlatformServiceJpaRepositoryImpl implem
if (realCause.getMessage().contains("sp_unq_name")) {
final String name = command.stringValueOfParameterNamed("name");
throw new PlatformDataIntegrityException("error.msg.product.savings.duplicate.name", "Recurring Deposit product with name `" + name
+ "` already exists", "name", name);
throw new PlatformDataIntegrityException("error.msg.product.savings.duplicate.name", "Recurring Deposit product with name `"
+ name + "` already exists", "name", name);
} else if (realCause.getMessage().contains("sp_unq_short_name")) {
final String shortName = command.stringValueOfParameterNamed("shortName");
throw new PlatformDataIntegrityException("error.msg.product.savings.duplicate.short.name", "Recurring Deposit product with short name `"
+ shortName + "` already exists", "shortName", shortName);
throw new PlatformDataIntegrityException("error.msg.product.savings.duplicate.short.name",
"Recurring Deposit product with short name `" + shortName + "` already exists", "shortName", shortName);
}
logAsErrorUnexpectedDataIntegrityException(dae);
@@ -18,7 +18,7 @@ public interface SavingsAccountReadPlatformService {
Page<SavingsAccountData> retrieveAll(SearchParameters searchParameters);
Collection<SavingsAccountData> retrieveAllForLookup(Long clientId);
Collection<SavingsAccountData> retrieveActiveForLookup(Long clientId, DepositAccountType depositAccountType);
SavingsAccountData retrieveOne(Long savingsId);
@@ -33,6 +33,6 @@ public interface SavingsAccountReadPlatformService {
// retrieveAccountsWithAnnualFeeDue();
SavingsAccountTransactionData retrieveSavingsTransaction(Long savingsId, Long transactionId, DepositAccountType depositAccountType);
Collection<SavingsAccountData> retrieveForLookup(Long clientId,Boolean overdraft);
Collection<SavingsAccountData> retrieveForLookup(Long clientId, Boolean overdraft);
}
@@ -55,11 +55,11 @@ public interface SavingsAccountWritePlatformService {
CommandProcessingResult waiveCharge(Long savingsAccountId, Long savingsAccountChargeId);
CommandProcessingResult payCharge(Long savingsAccountId, Long savingsAccountChargeId, JsonCommand command);
CommandProcessingResult inactivateCharge(Long savingsAccountId, Long savingsAccountChargeId);
CommandProcessingResult assignFieldOfficer(Long savingsAccountId, JsonCommand command);
CommandProcessingResult unassignFieldOfficer(Long savingsAccountId, JsonCommand command);
void applyChargeDue(final Long savingsAccountChargeId, final Long accountId);
@@ -128,8 +128,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
final ChargeRepositoryWrapper chargeRepository, final SavingsAccountChargeRepositoryWrapper savingsAccountChargeRepository,
final HolidayWritePlatformService holidayWritePlatformService,
final WorkingDaysWritePlatformService workingDaysWritePlatformService,
final SavingsAccountDataValidator fromApiJsonDeserializer,
final SavingsAccountRepositoryWrapper savingsRepository,
final SavingsAccountDataValidator fromApiJsonDeserializer, final SavingsAccountRepositoryWrapper savingsRepository,
final StaffRepositoryWrapper staffRepository) {
this.context = context;
this.savingAccountRepository = savingAccountRepository;
@@ -195,8 +194,8 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
boolean isRegularTransaction = false;
if (amountForDeposit.isGreaterThanZero()) {
boolean isAccountTransfer = false;
this.savingsAccountDomainService.handleDeposit(account, fmt, account.getActivationLocalDate(),
amountForDeposit.getAmount(), null, isAccountTransfer, isRegularTransaction);
this.savingsAccountDomainService.handleDeposit(account, fmt, account.getActivationLocalDate(), amountForDeposit.getAmount(),
null, isAccountTransfer, isRegularTransaction);
updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds);
}
account.processAccountUponActivation();
@@ -1022,10 +1021,9 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
return null;
}
@Override
public CommandProcessingResult assignFieldOfficer(Long savingsAccountId,
JsonCommand command) {
this.context.authenticatedUser();
@Override
public CommandProcessingResult assignFieldOfficer(Long savingsAccountId, JsonCommand command) {
this.context.authenticatedUser();
final Map<String, Object> actualChanges = new LinkedHashMap<>(5);
@@ -1037,7 +1035,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
final Long staffId = command.longValueOfParameterNamed(SavingsApiConstants.staffIdParamName);
if (staffId != null) {
staff = this.staffRepository.findByOfficeHierarchyWithNotFoundDetection(staffId, savingsForUpdate.office().getHierarchy());
savingsForUpdate.assignFieldOfficer(staff);
}
@@ -1052,12 +1050,11 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
.withClientId(savingsAccountId) //
.with(actualChanges) //
.build();
}
}
@Override
public CommandProcessingResult unassignFieldOfficer(Long savingsAccountId,
JsonCommand command) {
this.context.authenticatedUser();
@Override
public CommandProcessingResult unassignFieldOfficer(Long savingsAccountId, JsonCommand command) {
this.context.authenticatedUser();
final Map<String, Object> actualChanges = new LinkedHashMap<>(5);
@@ -1071,7 +1068,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
presentStaffId = presentStaff.getId();
final String staffIdParamName = SavingsApiConstants.staffIdParamName;
if (!command.isChangeInLongParameterNamed(staffIdParamName, presentStaffId)) {
savingsForUpdate.unassignFieldOfficer();
savingsForUpdate.unassignFieldOfficer();
}
this.savingsRepository.saveAndFlush(savingsForUpdate);
@@ -1084,6 +1081,6 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
.withClientId(savingsAccountId) //
.with(actualChanges) //
.build();
}
}
}
@@ -45,7 +45,8 @@ public class SavingsDropdownReadPlatformServiceImpl implements SavingsDropdownRe
@Override
public Collection<EnumOptionData> retrieveCompoundingInterestPeriodTypeOptions() {
final List<EnumOptionData> allowedOptions = Arrays.asList( //
final List<EnumOptionData> allowedOptions = Arrays.asList(
//
SavingsEnumerations.compoundingInterestPeriodType(SavingsCompoundingInterestPeriodType.DAILY), //
// SavingsEnumerations.compoundingInterestPeriodType(SavingsCompoundingInterestPeriodType.WEEKLY),
// //
@@ -26,7 +26,7 @@ import org.mifosplatform.portfolio.savings.data.SavingsAccountTransactionEnumDat
import org.mifosplatform.portfolio.savings.domain.SavingsAccountStatusType;
public class SavingsEnumerations {
public static final String INTEREST_COMPOUNDING_PERIOD_TYPE = "interestCompoundingPeriodType";
public static final String INTEREST_POSTING_PERIOD_TYPE = "interestPostingPeriodType";
public static final String INTEREST_CALCULATION_TYPE = "interestCalculationType";
@@ -39,7 +39,7 @@ public class SavingsEnumerations {
public static final String PRE_CLOSURE_PENAL_INTEREST_TYPE = "preClosurePenalInterestOnTypeId";
public static final String INTEREST_CALCULATION_DAYS_IN_YEAR = "interestCalculationDaysInYearType";
public static final String RECURRING_FREQUENCY_TYPE = "recurringFrequencyType";
public static EnumOptionData savingEnumueration(final String typeName, final int id) {
if (typeName.equals(INTEREST_COMPOUNDING_PERIOD_TYPE)) {
return compoundingInterestPeriodType(id);
@@ -57,18 +57,16 @@ public class SavingsEnumerations {
return depositPeriodFrequency(id);
} else if (typeName.equals(LOCKIN_PERIOD_FREQUNCY_TYPE)) {
return lockinPeriodFrequencyType(id);
} else if (typeName.equals(ACCOUNTING_RULE_TYPE)) {
} else if (typeName.equals(ACCOUNTING_RULE_TYPE)) {
return AccountingEnumerations.accountingRuleType(id);
} else if (typeName.equals(PRE_CLOSURE_PENAL_INTEREST_TYPE)) {
return preClosurePenaltyInterestOnType(id);
} else if (typeName.equals(INTEREST_CALCULATION_DAYS_IN_YEAR)) {
} else if (typeName.equals(INTEREST_CALCULATION_DAYS_IN_YEAR)) {
return interestCalculationDaysInYearType(id);
} else if (typeName.equals(RECURRING_FREQUENCY_TYPE)) {
return depositPeriodFrequency(id);
}
} else if (typeName.equals(RECURRING_FREQUENCY_TYPE)) { return depositPeriodFrequency(id); }
return null;
}
public static EnumOptionData lockinPeriodFrequencyType(final int id) {
return lockinPeriodFrequencyType(SavingsPeriodFrequencyType.fromInt(id));
}
@@ -211,7 +209,8 @@ public class SavingsEnumerations {
case WITHDRAWN_BY_APPLICANT:
optionData = new SavingsAccountStatusEnumData(SavingsAccountStatusType.WITHDRAWN_BY_APPLICANT.getValue().longValue(),
SavingsAccountStatusType.WITHDRAWN_BY_APPLICANT.getCode(), "Withdrawn by applicant", submittedAndPendingApproval,
isApproved, isRejected, isWithdrawnByApplicant, isActive, isClosed, isPrematureClosed, isTransferInProgress, isTransferOnHold);
isApproved, isRejected, isWithdrawnByApplicant, isActive, isClosed, isPrematureClosed, isTransferInProgress,
isTransferOnHold);
break;
case APPROVED:
optionData = new SavingsAccountStatusEnumData(SavingsAccountStatusType.APPROVED.getValue().longValue(),
@@ -231,22 +230,24 @@ public class SavingsEnumerations {
case TRANSFER_IN_PROGRESS:
optionData = new SavingsAccountStatusEnumData(SavingsAccountStatusType.TRANSFER_IN_PROGRESS.getValue().longValue(),
SavingsAccountStatusType.TRANSFER_IN_PROGRESS.getCode(), "Transfer in progress", submittedAndPendingApproval,
isApproved, isRejected, isWithdrawnByApplicant, isActive, isClosed, isPrematureClosed, isTransferInProgress, isTransferOnHold);
isApproved, isRejected, isWithdrawnByApplicant, isActive, isClosed, isPrematureClosed, isTransferInProgress,
isTransferOnHold);
break;
case TRANSFER_ON_HOLD:
optionData = new SavingsAccountStatusEnumData(SavingsAccountStatusType.TRANSFER_IN_PROGRESS.getValue().longValue(),
SavingsAccountStatusType.TRANSFER_ON_HOLD.getCode(), "Transfer in progress", submittedAndPendingApproval,
isApproved, isRejected, isWithdrawnByApplicant, isActive, isClosed, isPrematureClosed, isTransferInProgress, isTransferOnHold);
isApproved, isRejected, isWithdrawnByApplicant, isActive, isClosed, isPrematureClosed, isTransferInProgress,
isTransferOnHold);
break;
case PRE_MATURE_CLOSURE:
optionData = new SavingsAccountStatusEnumData(SavingsAccountStatusType.PRE_MATURE_CLOSURE.getValue().longValue(),
SavingsAccountStatusType.PRE_MATURE_CLOSURE.getCode(), "Premature Closed", submittedAndPendingApproval,
isApproved, isRejected, isWithdrawnByApplicant, isActive, isClosed, isPrematureClosed, isTransferInProgress, isTransferOnHold);
SavingsAccountStatusType.PRE_MATURE_CLOSURE.getCode(), "Premature Closed", submittedAndPendingApproval, isApproved,
isRejected, isWithdrawnByApplicant, isActive, isClosed, isPrematureClosed, isTransferInProgress, isTransferOnHold);
break;
case MATURED:
optionData = new SavingsAccountStatusEnumData(SavingsAccountStatusType.MATURED.getValue().longValue(),
SavingsAccountStatusType.MATURED.getCode(), "Matured", submittedAndPendingApproval,
isApproved, isRejected, isWithdrawnByApplicant, isActive, isClosed, isPrematureClosed, isTransferInProgress, isTransferOnHold);
SavingsAccountStatusType.MATURED.getCode(), "Matured", submittedAndPendingApproval, isApproved, isRejected,
isWithdrawnByApplicant, isActive, isClosed, isPrematureClosed, isTransferInProgress, isTransferOnHold);
break;
default:
break;
@@ -622,16 +623,20 @@ public class SavingsEnumerations {
case INVALID:
break;
case SAVINGS_DEPOSIT:
optionData = new EnumOptionData(DepositAccountType.SAVINGS_DEPOSIT.getValue().longValue(), DepositAccountType.SAVINGS_DEPOSIT.getCode(), "Savings");
optionData = new EnumOptionData(DepositAccountType.SAVINGS_DEPOSIT.getValue().longValue(),
DepositAccountType.SAVINGS_DEPOSIT.getCode(), "Savings");
break;
case FIXED_DEPOSIT:
optionData = new EnumOptionData(DepositAccountType.FIXED_DEPOSIT.getValue().longValue(), DepositAccountType.FIXED_DEPOSIT.getCode(), "Fixed Deposit");
optionData = new EnumOptionData(DepositAccountType.FIXED_DEPOSIT.getValue().longValue(),
DepositAccountType.FIXED_DEPOSIT.getCode(), "Fixed Deposit");
break;
case RECURRING_DEPOSIT:
optionData = new EnumOptionData(DepositAccountType.RECURRING_DEPOSIT.getValue().longValue(), DepositAccountType.RECURRING_DEPOSIT.getCode(), "Recurring Deposit");
optionData = new EnumOptionData(DepositAccountType.RECURRING_DEPOSIT.getValue().longValue(),
DepositAccountType.RECURRING_DEPOSIT.getCode(), "Recurring Deposit");
break;
case CURRENT_DEPOSIT:
optionData = new EnumOptionData(DepositAccountType.CURRENT_DEPOSIT.getValue().longValue(), DepositAccountType.CURRENT_DEPOSIT.getCode(), "Current Deposit");
optionData = new EnumOptionData(DepositAccountType.CURRENT_DEPOSIT.getValue().longValue(),
DepositAccountType.CURRENT_DEPOSIT.getCode(), "Current Deposit");
break;
}
return optionData;
@@ -646,7 +651,7 @@ public class SavingsEnumerations {
}
return optionDatas;
}
public static EnumOptionData depositPeriodFrequency(final int id) {
return depositPeriodFrequency(SavingsPeriodFrequencyType.fromInt(id));
}
@@ -687,7 +692,7 @@ public class SavingsEnumerations {
}
return optionDatas;
}
public static EnumOptionData depositAccountOnClosureType(final int id) {
return depositAccountOnClosureType(DepositAccountOnClosureType.fromInt(id));
}
@@ -699,13 +704,16 @@ public class SavingsEnumerations {
case INVALID:
break;
case WITHDRAW_DEPOSIT:
optionData = new EnumOptionData(DepositAccountOnClosureType.WITHDRAW_DEPOSIT.getValue().longValue(), DepositAccountOnClosureType.WITHDRAW_DEPOSIT.getCode(), "Withdraw Deposit");
optionData = new EnumOptionData(DepositAccountOnClosureType.WITHDRAW_DEPOSIT.getValue().longValue(),
DepositAccountOnClosureType.WITHDRAW_DEPOSIT.getCode(), "Withdraw Deposit");
break;
case TRANSFER_TO_SAVINGS:
optionData = new EnumOptionData(DepositAccountOnClosureType.TRANSFER_TO_SAVINGS.getValue().longValue(), DepositAccountOnClosureType.TRANSFER_TO_SAVINGS.getCode(), "Transfer to Savings");
optionData = new EnumOptionData(DepositAccountOnClosureType.TRANSFER_TO_SAVINGS.getValue().longValue(),
DepositAccountOnClosureType.TRANSFER_TO_SAVINGS.getCode(), "Transfer to Savings");
break;
case REINVEST:
optionData = new EnumOptionData(DepositAccountOnClosureType.REINVEST.getValue().longValue(), DepositAccountOnClosureType.REINVEST.getCode(), "Re-Invest");
optionData = new EnumOptionData(DepositAccountOnClosureType.REINVEST.getValue().longValue(),
DepositAccountOnClosureType.REINVEST.getCode(), "Re-Invest");
break;
}
return optionData;
@@ -94,7 +94,8 @@ public class SavingsProductWritePlatformServiceJpaRepositoryImpl implements Savi
this.savingProductRepository.save(product);
// save accounting mappings
this.accountMappingWritePlatformService.createSavingProductToGLAccountMapping(product.getId(), command, DepositAccountType.SAVINGS_DEPOSIT);
this.accountMappingWritePlatformService.createSavingProductToGLAccountMapping(product.getId(), command,
DepositAccountType.SAVINGS_DEPOSIT);
return new CommandProcessingResultBuilder() //
.withEntityId(product.getId()) //
@@ -130,7 +131,8 @@ public class SavingsProductWritePlatformServiceJpaRepositoryImpl implements Savi
// accounting related changes
final boolean accountingTypeChanged = changes.containsKey(accountingRuleParamName);
final Map<String, Object> accountingMappingChanges = this.accountMappingWritePlatformService
.updateSavingsProductToGLAccountMapping(product.getId(), command, accountingTypeChanged, product.getAccountingType(), DepositAccountType.SAVINGS_DEPOSIT);
.updateSavingsProductToGLAccountMapping(product.getId(), command, accountingTypeChanged, product.getAccountingType(),
DepositAccountType.SAVINGS_DEPOSIT);
changes.putAll(accountingMappingChanges);
if (!changes.isEmpty()) {