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
@@ -8,16 +8,13 @@ package org.mifosplatform.portfolio.savings;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
* An enumeration of supported calendar periods used in savings. * An enumeration of supported calendar periods used in savings.
*/ */
public enum PreClosurePenalInterestOnType { public enum PreClosurePenalInterestOnType {
INVALID(0, "preClosurePenalInterestOnType.invalid"), INVALID(0, "preClosurePenalInterestOnType.invalid"), WHOLE_TERM(1, "preClosurePenalInterestOnType.wholeTerm"), //
WHOLE_TERM(1, "preClosurePenalInterestOnType.wholeTerm"), //
TILL_PREMATURE_WITHDRAWAL(2, "preClosurePenalInterestOnType.tillPrematureWithdrawal"); // TILL_PREMATURE_WITHDRAWAL(2, "preClosurePenalInterestOnType.tillPrematureWithdrawal"); //
private final Integer value; private final Integer value;
private final String code; private final String code;
@@ -60,7 +57,7 @@ public enum PreClosurePenalInterestOnType {
return values.toArray(); return values.toArray();
} }
public boolean isInvalid(){ public boolean isInvalid() {
return this.value.equals(PreClosurePenalInterestOnType.INVALID.value); return this.value.equals(PreClosurePenalInterestOnType.INVALID.value);
} }
@@ -8,16 +8,13 @@ package org.mifosplatform.portfolio.savings;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
* An enumeration of supported calendar periods used in savings. * An enumeration of supported calendar periods used in savings.
*/ */
public enum RecurringDepositType { public enum RecurringDepositType {
INVALID(0, "recurringDepositType.invalid"), INVALID(0, "recurringDepositType.invalid"), VOLUNTARY(1, "recurringDepositType.voluntary"), //
VOLUNTARY(1, "recurringDepositType.voluntary"), //
MANDATORY(2, "recurringDepositType.mandatory"); // MANDATORY(2, "recurringDepositType.mandatory"); //
private final Integer value; private final Integer value;
private final String code; private final String code;
@@ -60,7 +57,7 @@ public enum RecurringDepositType {
return values.toArray(); return values.toArray();
} }
public boolean isInvalid(){ public boolean isInvalid() {
return this.value.equals(RecurringDepositType.INVALID.value); return this.value.equals(RecurringDepositType.INVALID.value);
} }
} }
@@ -173,8 +173,8 @@ public class SavingsApiConstants {
"interestCalculationDaysInYearTypeOptions", "lockinPeriodFrequencyTypeOptions", "withdrawalFeeTypeOptions")); "interestCalculationDaysInYearTypeOptions", "lockinPeriodFrequencyTypeOptions", "withdrawalFeeTypeOptions"));
public static final Set<String> SAVINGS_ACCOUNT_REQUEST_DATA_PARAMETERS = new HashSet<>(Arrays.asList(localeParamName, public static final Set<String> SAVINGS_ACCOUNT_REQUEST_DATA_PARAMETERS = new HashSet<>(Arrays.asList(localeParamName,
dateFormatParamName, monthDayFormatParamName, staffIdParamName, accountNoParamName, externalIdParamName, clientIdParamName, groupIdParamName, dateFormatParamName, monthDayFormatParamName, staffIdParamName, accountNoParamName, externalIdParamName, clientIdParamName,
productIdParamName, fieldOfficerIdParamName, submittedOnDateParamName, nominalAnnualInterestRateParamName, groupIdParamName, productIdParamName, fieldOfficerIdParamName, submittedOnDateParamName, nominalAnnualInterestRateParamName,
interestCompoundingPeriodTypeParamName, interestPostingPeriodTypeParamName, interestCalculationTypeParamName, interestCompoundingPeriodTypeParamName, interestPostingPeriodTypeParamName, interestCalculationTypeParamName,
interestCalculationDaysInYearTypeParamName, minRequiredOpeningBalanceParamName, lockinPeriodFrequencyParamName, interestCalculationDaysInYearTypeParamName, minRequiredOpeningBalanceParamName, lockinPeriodFrequencyParamName,
lockinPeriodFrequencyTypeParamName, lockinPeriodFrequencyTypeParamName,
@@ -188,8 +188,8 @@ public class SavingsApiConstants {
* parameters to match those of request parameters. * parameters to match those of request parameters.
*/ */
public static final Set<String> SAVINGS_ACCOUNT_RESPONSE_DATA_PARAMETERS = new HashSet<>(Arrays.asList(idParamName, accountNoParamName, public static final Set<String> SAVINGS_ACCOUNT_RESPONSE_DATA_PARAMETERS = new HashSet<>(Arrays.asList(idParamName, accountNoParamName,
externalIdParamName, statusParamName, activatedOnDateParamName,staffIdParamName, clientIdParamName, "clientName", groupIdParamName, "groupName", externalIdParamName, statusParamName, activatedOnDateParamName, staffIdParamName, clientIdParamName, "clientName",
"savingsProductId", "savingsProductName", "currency", nominalAnnualInterestRateParamName, groupIdParamName, "groupName", "savingsProductId", "savingsProductName", "currency", nominalAnnualInterestRateParamName,
interestCompoundingPeriodTypeParamName, interestCalculationTypeParamName, interestCalculationDaysInYearTypeParamName, interestCompoundingPeriodTypeParamName, interestCalculationTypeParamName, interestCalculationDaysInYearTypeParamName,
minRequiredOpeningBalanceParamName, lockinPeriodFrequencyParamName, lockinPeriodFrequencyTypeParamName, minRequiredOpeningBalanceParamName, lockinPeriodFrequencyParamName, lockinPeriodFrequencyTypeParamName,
withdrawalFeeAmountParamName, withdrawalFeeTypeParamName, withdrawalFeeForTransfersParamName, feeAmountParamName, withdrawalFeeAmountParamName, withdrawalFeeTypeParamName, withdrawalFeeForTransfersParamName, feeAmountParamName,
@@ -17,8 +17,7 @@ public enum SavingsPostingInterestPeriodType {
INVALID(0, "savingsPostingInterestPeriodType.invalid"), // INVALID(0, "savingsPostingInterestPeriodType.invalid"), //
MONTHLY(4, "savingsPostingInterestPeriodType.monthly"), // MONTHLY(4, "savingsPostingInterestPeriodType.monthly"), //
QUATERLY(5, "savingsPostingInterestPeriodType.quarterly"), // QUATERLY(5, "savingsPostingInterestPeriodType.quarterly"), //
BIANNUAL(6, "savingsPostingInterestPeriodType.biannual"), BIANNUAL(6, "savingsPostingInterestPeriodType.biannual"), ANNUAL(7, "savingsPostingInterestPeriodType.annual");
ANNUAL(7, "savingsPostingInterestPeriodType.annual");
private final Integer value; private final Integer value;
private final String code; private final String code;
@@ -174,7 +174,8 @@ public class FixedDepositAccountsApiResource {
} }
private FixedDepositAccountData populateTemplateAndAssociations(final Long accountId, final FixedDepositAccountData savingsAccount, 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<SavingsAccountTransactionData> transactions = null;
Collection<SavingsAccountChargeData> charges = null; Collection<SavingsAccountChargeData> charges = null;
@@ -181,7 +181,8 @@ public class RecurringDepositAccountTransactionsApiResource {
final CommandWrapper commandRequest = builder.undoRecurringAccountTransaction(recurringDepositAccountId, transactionId).build(); final CommandWrapper commandRequest = builder.undoRecurringAccountTransaction(recurringDepositAccountId, transactionId).build();
result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
} else if (is(commandParam, DepositsApiConstants.COMMAND_ADJUST_TRANSACTION)) { } 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); result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
} }
@@ -82,7 +82,8 @@ public class SavingsAccountTransactionsApiResource {
// FIXME - KW - for now just send back generic default information for // FIXME - KW - for now just send back generic default information for
// both deposit/withdrawal templates // 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 final Collection<CodeValueData> paymentTypeOptions = this.codeValueReadPlatformService
.retrieveCodeValuesByCode(PaymentDetailConstants.paymentTypeCodeName); .retrieveCodeValuesByCode(PaymentDetailConstants.paymentTypeCodeName);
savingsAccount = SavingsAccountTransactionData.templateOnTop(savingsAccount, paymentTypeOptions); savingsAccount = SavingsAccountTransactionData.templateOnTop(savingsAccount, paymentTypeOptions);
@@ -248,21 +248,21 @@ public class SavingsAccountsApiResource {
} else if (is(commandParam, "close")) { } else if (is(commandParam, "close")) {
final CommandWrapper commandRequest = builder.closeSavingsAccountApplication(accountId).build(); final CommandWrapper commandRequest = builder.closeSavingsAccountApplication(accountId).build();
result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
}else if (is(commandParam, "assignFieldOfficer")) { } else if (is(commandParam, "assignFieldOfficer")) {
final CommandWrapper commandRequest = builder.assignFieldOfficer(accountId).build(); final CommandWrapper commandRequest = builder.assignFieldOfficer(accountId).build();
result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
return this.toApiJsonSerializer.serialize(result); return this.toApiJsonSerializer.serialize(result);
} else if (is(commandParam, "unassignFieldOfficer")) { } else if (is(commandParam, "unassignFieldOfficer")) {
final CommandWrapper commandRequest = builder.unassignFieldOfficer(accountId).build(); final CommandWrapper commandRequest = builder.unassignFieldOfficer(accountId).build();
result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
return this.toApiJsonSerializer.serialize(result); return this.toApiJsonSerializer.serialize(result);
} }
if (result == null) { if (result == null) {
// //
throw new UnrecognizedQueryParamException("command", commandParam, new Object[] { "reject", "withdrawnByApplicant", "approve", throw new UnrecognizedQueryParamException("command", commandParam,
"undoapproval", "activate", "calculateInterest", "postInterest", "close" ,"assignFieldOfficer" ,"unassignFieldOfficer"}); new Object[] { "reject", "withdrawnByApplicant", "approve", "undoapproval", "activate", "calculateInterest",
"postInterest", "close", "assignFieldOfficer", "unassignFieldOfficer" });
} }
return this.toApiJsonSerializer.serialize(result); return this.toApiJsonSerializer.serialize(result);
@@ -527,8 +527,10 @@ public class DepositAccountDataValidator {
private void validateRecurringDetailForSubmit(final JsonElement element, final DataValidatorBuilder baseDataValidator) { private void validateRecurringDetailForSubmit(final JsonElement element, final DataValidatorBuilder baseDataValidator) {
final BigDecimal mandatoryRecommendedDepositAmount = fromApiJsonHelper.extractBigDecimalWithLocaleNamed(mandatoryRecommendedDepositAmountParamName, element); final BigDecimal mandatoryRecommendedDepositAmount = fromApiJsonHelper.extractBigDecimalWithLocaleNamed(
baseDataValidator.reset().parameter(mandatoryRecommendedDepositAmountParamName).value(mandatoryRecommendedDepositAmount).notNull().positiveAmount(); mandatoryRecommendedDepositAmountParamName, element);
baseDataValidator.reset().parameter(mandatoryRecommendedDepositAmountParamName).value(mandatoryRecommendedDepositAmount).notNull()
.positiveAmount();
if (this.fromApiJsonHelper.parameterExists(isMandatoryDepositParamName, element)) { if (this.fromApiJsonHelper.parameterExists(isMandatoryDepositParamName, element)) {
final Boolean isMandatoryDeposit = this.fromApiJsonHelper.extractBooleanNamed(isMandatoryDepositParamName, element); final Boolean isMandatoryDeposit = this.fromApiJsonHelper.extractBooleanNamed(isMandatoryDepositParamName, element);
@@ -66,8 +66,8 @@ public class DepositAccountTransactionDataValidator {
DepositsApiConstants.DEPOSIT_ACCOUNT_TRANSACTION_REQUEST_DATA_PARAMETERS); DepositsApiConstants.DEPOSIT_ACCOUNT_TRANSACTION_REQUEST_DATA_PARAMETERS);
final List<ApiParameterError> dataValidationErrors = new ArrayList<>(); final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors) final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource(depositAccountType
.resource(depositAccountType.resourceName()); .resourceName());
final JsonElement element = command.parsedJson(); final JsonElement element = command.parsedJson();
@@ -80,8 +80,8 @@ public class DepositAccountTransactionDataValidator {
// Validate all string payment detail fields for max length // Validate all string payment detail fields for max length
final Integer paymentTypeId = this.fromApiJsonHelper.extractIntegerWithLocaleNamed(paymentTypeIdParamName, element); final Integer paymentTypeId = this.fromApiJsonHelper.extractIntegerWithLocaleNamed(paymentTypeIdParamName, element);
baseDataValidator.reset().parameter(paymentTypeIdParamName).value(paymentTypeId).ignoreIfNull().integerGreaterThanZero(); baseDataValidator.reset().parameter(paymentTypeIdParamName).value(paymentTypeId).ignoreIfNull().integerGreaterThanZero();
final Set<String> paymentDetailParameters = new HashSet<>(Arrays.asList(transactionAccountNumberParamName, final Set<String> paymentDetailParameters = new HashSet<>(Arrays.asList(transactionAccountNumberParamName, checkNumberParamName,
checkNumberParamName, routingCodeParamName, receiptNumberParamName, bankNumberParamName)); routingCodeParamName, receiptNumberParamName, bankNumberParamName));
for (final String paymentDetailParameterName : paymentDetailParameters) { for (final String paymentDetailParameterName : paymentDetailParameters) {
final String paymentDetailParameterValue = this.fromApiJsonHelper.extractStringNamed(paymentDetailParameterName, element); final String paymentDetailParameterValue = this.fromApiJsonHelper.extractStringNamed(paymentDetailParameterName, element);
baseDataValidator.reset().parameter(paymentDetailParameterName).value(paymentDetailParameterValue).ignoreIfNull() baseDataValidator.reset().parameter(paymentDetailParameterName).value(paymentDetailParameterValue).ignoreIfNull()
@@ -158,8 +158,12 @@ public class DepositAccountTransactionDataValidator {
final DepositAccountOnClosureType accountOnClosureType = DepositAccountOnClosureType.fromInt(onAccountClosureId); final DepositAccountOnClosureType accountOnClosureType = DepositAccountOnClosureType.fromInt(onAccountClosureId);
if (accountOnClosureType.isTransferToSavings()) { if (accountOnClosureType.isTransferToSavings()) {
final Long toSavingsAccountId = this.fromApiJsonHelper.extractLongNamed(toSavingsAccountIdParamName, element); final Long toSavingsAccountId = this.fromApiJsonHelper.extractLongNamed(toSavingsAccountIdParamName, element);
baseDataValidator.reset().parameter(toSavingsAccountIdParamName).value(toSavingsAccountId) baseDataValidator
.cantBeBlankWhenParameterProvidedIs(onAccountClosureIdParamName, DepositAccountOnClosureType.fromInt(onAccountClosureId).getCode()); .reset()
.parameter(toSavingsAccountIdParamName)
.value(toSavingsAccountId)
.cantBeBlankWhenParameterProvidedIs(onAccountClosureIdParamName,
DepositAccountOnClosureType.fromInt(onAccountClosureId).getCode());
} else if (accountOnClosureType.isReinvest() && isPreMatureClose) { } else if (accountOnClosureType.isReinvest() && isPreMatureClose) {
baseDataValidator.reset().parameter(onAccountClosureIdParamName).value(onAccountClosureId) baseDataValidator.reset().parameter(onAccountClosureIdParamName).value(onAccountClosureId)
.failWithCode("reinvest.not.allowed", "Re-Invest is not supported for account pre mature close"); .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 // Validate all string payment detail fields for max length
final Integer paymentTypeId = this.fromApiJsonHelper.extractIntegerWithLocaleNamed(paymentTypeIdParamName, element); final Integer paymentTypeId = this.fromApiJsonHelper.extractIntegerWithLocaleNamed(paymentTypeIdParamName, element);
baseDataValidator.reset().parameter(paymentTypeIdParamName).value(paymentTypeId).ignoreIfNull().integerGreaterThanZero(); baseDataValidator.reset().parameter(paymentTypeIdParamName).value(paymentTypeId).ignoreIfNull().integerGreaterThanZero();
final Set<String> paymentDetailParameters = new HashSet<>(Arrays.asList(transactionAccountNumberParamName, final Set<String> paymentDetailParameters = new HashSet<>(Arrays.asList(transactionAccountNumberParamName, checkNumberParamName,
checkNumberParamName, routingCodeParamName, receiptNumberParamName, bankNumberParamName)); routingCodeParamName, receiptNumberParamName, bankNumberParamName));
for (final String paymentDetailParameterName : paymentDetailParameters) { for (final String paymentDetailParameterName : paymentDetailParameters) {
final String paymentDetailParameterValue = this.fromApiJsonHelper.extractStringNamed(paymentDetailParameterName, element); final String paymentDetailParameterValue = this.fromApiJsonHelper.extractStringNamed(paymentDetailParameterName, element);
baseDataValidator.reset().parameter(paymentDetailParameterName).value(paymentDetailParameterValue).ignoreIfNull() baseDataValidator.reset().parameter(paymentDetailParameterName).value(paymentDetailParameterValue).ignoreIfNull()
@@ -390,6 +390,7 @@ public class SavingsAccountDataValidator {
} }
} }
public void validateForAssignFieldOfficer(final String json) { public void validateForAssignFieldOfficer(final String json) {
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); } if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
@@ -414,8 +415,8 @@ public class SavingsAccountDataValidator {
} }
public void validateForUnAssignFieldOfficer(final String json) { public void validateForUnAssignFieldOfficer(final String json) {
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();
@@ -435,6 +436,5 @@ public class SavingsAccountDataValidator {
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); } if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
}
}
} }
@@ -31,7 +31,9 @@ public class SavingsAccountTransactionDTO {
this.savingsAccountId = null; this.savingsAccountId = null;
} }
/** This constructor is used for bulk deposit transactions /**
* This constructor is used for bulk deposit transactions
*
* @param formatter * @param formatter
* @param transactionDate * @param transactionDate
* @param transactionAmount * @param transactionAmount
@@ -49,8 +51,6 @@ public class SavingsAccountTransactionDTO {
this.savingsAccountId = savingsAccountId; this.savingsAccountId = savingsAccountId;
} }
public DateTimeFormatter getFormatter() { public DateTimeFormatter getFormatter() {
return this.formatter; return this.formatter;
} }
@@ -87,7 +87,8 @@ public class SavingsAccountTransactionData {
this.paymentTypeOptions = paymentTypeOptions; this.paymentTypeOptions = paymentTypeOptions;
} }
public static SavingsAccountTransactionData withWithDrawalTransactionDetails(final SavingsAccountTransactionData savingsAccountTransactionData) { public static SavingsAccountTransactionData withWithDrawalTransactionDetails(
final SavingsAccountTransactionData savingsAccountTransactionData) {
final LocalDate currentDate = DateUtils.getLocalDateOfTenant(); final LocalDate currentDate = DateUtils.getLocalDateOfTenant();
final SavingsAccountTransactionEnumData transactionType = SavingsEnumerations final SavingsAccountTransactionEnumData transactionType = SavingsEnumerations
@@ -8,7 +8,7 @@ package org.mifosplatform.portfolio.savings.domain;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 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 SavingsPostingInterestPeriodType interestPostingPeriodType, final SavingsInterestCalculationType interestCalculationType,
final SavingsInterestCalculationDaysInYearType interestCalculationDaysInYearType, final Integer lockinPeriodFrequency, final SavingsInterestCalculationDaysInYearType interestCalculationDaysInYearType, final Integer lockinPeriodFrequency,
final SavingsPeriodFrequencyType lockinPeriodFrequencyType, final AccountingRuleType accountingRuleType, 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 BigDecimal minRequiredOpeningBalance = null;
final boolean withdrawalFeeApplicableForTransfer = false; 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.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 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.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 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.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 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> {
// //
} }
@@ -216,7 +216,7 @@ public class RecurringDepositScheduleInstallment extends AbstractAuditableCustom
return Money.of(currency, decimal); return Money.of(currency, decimal);
} }
public void resetDerivedFields(){ public void resetDerivedFields() {
this.depositAmountCompleted = null; this.depositAmountCompleted = null;
this.totalPaidInAdvance = null; this.totalPaidInAdvance = null;
this.totalPaidLate = null; this.totalPaidLate = null;
@@ -473,20 +473,20 @@ public class SavingsAccount extends AbstractPersistable<Long> {
return postingTransation; return postingTransation;
} }
//Determine the last transaction for given day // Determine the last transaction for given day
protected SavingsAccountTransaction findLastTransaction(final LocalDate date) { protected SavingsAccountTransaction findLastTransaction(final LocalDate date) {
SavingsAccountTransaction savingsTransaction = null; SavingsAccountTransaction savingsTransaction = null;
for (final SavingsAccountTransaction transaction : this.transactions) { for (final SavingsAccountTransaction transaction : this.transactions) {
if (transaction.isNotReversed() && transaction.occursOn(date)) { if (transaction.isNotReversed() && transaction.occursOn(date)) {
savingsTransaction = transaction; savingsTransaction = transaction;
break; break;
} }
} }
return savingsTransaction; return savingsTransaction;
} }
/** /**
* All interest calculation based on END-OF-DAY-BALANCE. * All interest calculation based on END-OF-DAY-BALANCE.
@@ -529,42 +529,34 @@ public class SavingsAccount extends AbstractPersistable<Long> {
final SavingsInterestCalculationDaysInYearType daysInYearType = SavingsInterestCalculationDaysInYearType final SavingsInterestCalculationDaysInYearType daysInYearType = SavingsInterestCalculationDaysInYearType
.fromInt(this.interestCalculationDaysInYearType); .fromInt(this.interestCalculationDaysInYearType);
final List<LocalDateInterval> postingPeriodIntervals = this.savingsHelper.determineInterestPostingPeriods(getStartInterestCalculationDate(), final List<LocalDateInterval> postingPeriodIntervals = this.savingsHelper.determineInterestPostingPeriods(
upToInterestCalculationDate, postingPeriodType); getStartInterestCalculationDate(), upToInterestCalculationDate, postingPeriodType);
final List<PostingPeriod> allPostingPeriods = new ArrayList<>(); final List<PostingPeriod> allPostingPeriods = new ArrayList<>();
Money periodStartingBalance; Money periodStartingBalance;
if (this.startInterestCalculationDate != null) { if (this.startInterestCalculationDate != null) {
LocalDate startInterestCalculationDate = new LocalDate( LocalDate startInterestCalculationDate = new LocalDate(this.startInterestCalculationDate);
this.startInterestCalculationDate); final SavingsAccountTransaction transaction = findLastTransaction(startInterestCalculationDate);
final SavingsAccountTransaction transaction = findLastTransaction(startInterestCalculationDate);
if (transaction == null) { if (transaction == null) {
final String defaultUserMessage = "No transactions were found on the specified date " final String defaultUserMessage = "No transactions were found on the specified date "
+ getStartInterestCalculationDate().toString() + getStartInterestCalculationDate().toString() + " for account number " + this.accountNumber.toString()
+ " for account number " + " and resource id " + getId();
+ this.accountNumber.toString()
+ " and resource id "
+ getId();
final ApiParameterError error = ApiParameterError final ApiParameterError error = ApiParameterError.parameterError(
.parameterError( "error.msg.savingsaccount.transaction.incorrect.start.interest.calculation.date", defaultUserMessage,
"error.msg.savingsaccount.transaction.incorrect.start.interest.calculation.date", "transactionDate", getStartInterestCalculationDate().toString());
defaultUserMessage, "transactionDate",
getStartInterestCalculationDate().toString());
final List<ApiParameterError> dataValidationErrors = new ArrayList<>(); final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
dataValidationErrors.add(error); dataValidationErrors.add(error);
throw new PlatformApiDataValidationException( throw new PlatformApiDataValidationException(dataValidationErrors);
dataValidationErrors); }
}
periodStartingBalance = transaction periodStartingBalance = transaction.getRunningBalance(this.currency);
.getRunningBalance(this.currency); } else
} else periodStartingBalance = Money.zero(this.currency);
periodStartingBalance = Money.zero(this.currency);
final SavingsInterestCalculationType interestCalculationType = SavingsInterestCalculationType.fromInt(this.interestCalculationType); final SavingsInterestCalculationType interestCalculationType = SavingsInterestCalculationType.fromInt(this.interestCalculationType);
final BigDecimal interestRateAsFraction = getEffectiveInterestRateAsFraction(mc, upToInterestCalculationDate); final BigDecimal interestRateAsFraction = getEffectiveInterestRateAsFraction(mc, upToInterestCalculationDate);
@@ -750,17 +742,16 @@ public class SavingsAccount extends AbstractPersistable<Long> {
return activationLocalDate; return activationLocalDate;
} }
//startInterestCalculationDate is set during migration so that there is no // startInterestCalculationDate is set during migration so that there is no
//interference with interest posting of previous system // interference with interest posting of previous system
public LocalDate getStartInterestCalculationDate() { public LocalDate getStartInterestCalculationDate() {
LocalDate startInterestCalculationLocalDate = null; LocalDate startInterestCalculationLocalDate = null;
if (this.startInterestCalculationDate != null) { if (this.startInterestCalculationDate != null) {
startInterestCalculationLocalDate = new LocalDate( startInterestCalculationLocalDate = new LocalDate(this.startInterestCalculationDate);
this.startInterestCalculationDate); } else
} else startInterestCalculationLocalDate = getActivationLocalDate();
startInterestCalculationLocalDate = getActivationLocalDate(); return startInterestCalculationLocalDate;
return startInterestCalculationLocalDate; }
}
public SavingsAccountTransaction withdraw(final SavingsAccountTransactionDTO transactionDTO, final boolean applyWithdrawFee) { public SavingsAccountTransaction withdraw(final SavingsAccountTransactionDTO transactionDTO, final boolean applyWithdrawFee) {
@@ -30,5 +30,6 @@ public interface SavingsAccountRepository extends JpaRepository<SavingsAccount,
List<SavingsAccount> findByGroupId(@Param("groupId") Long groupId); List<SavingsAccount> findByGroupId(@Param("groupId") Long groupId);
@Query("from SavingsAccount sa where sa.id = :accountId and sa.depositType = :depositAccountTypeId") @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);
} }
@@ -18,10 +18,8 @@ public enum SavingsAccountStatusType {
TRANSFER_ON_HOLD(304, "savingsAccountStatusType.transfer.on.hold"), // TRANSFER_ON_HOLD(304, "savingsAccountStatusType.transfer.on.hold"), //
WITHDRAWN_BY_APPLICANT(400, "savingsAccountStatusType.withdrawn.by.applicant"), // WITHDRAWN_BY_APPLICANT(400, "savingsAccountStatusType.withdrawn.by.applicant"), //
REJECTED(500, "savingsAccountStatusType.rejected"), // REJECTED(500, "savingsAccountStatusType.rejected"), //
CLOSED(600, "savingsAccountStatusType.closed"), CLOSED(600, "savingsAccountStatusType.closed"), PRE_MATURE_CLOSURE(700, "savingsAccountStatusType.pre.mature.closure"), MATURED(800,
PRE_MATURE_CLOSURE(700, "savingsAccountStatusType.pre.mature.closure"), "savingsAccountStatusType.matured");
MATURED(800, "savingsAccountStatusType.matured");
private final Integer value; private final Integer value;
private final String code; private final String code;
@@ -218,7 +218,7 @@ public final class SavingsAccountTransaction extends AbstractPersistable<Long> {
} }
public Money getRunningBalance(final MonetaryCurrency currency) { public Money getRunningBalance(final MonetaryCurrency currency) {
return Money.of(currency, this.runningBalance); return Money.of(currency, this.runningBalance);
} }
public boolean isDeposit() { public boolean isDeposit() {
@@ -10,6 +10,7 @@ import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceN
public class DepositAccountInterestRateChartNotFoundException extends AbstractPlatformResourceNotFoundException { public class DepositAccountInterestRateChartNotFoundException extends AbstractPlatformResourceNotFoundException {
public DepositAccountInterestRateChartNotFoundException(final Long id) { 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 class DepositAccountTransactionNotAllowedException extends AbstractPlatformServiceUnavailableException {
public DepositAccountTransactionNotAllowedException(final Long accountId, final String action, final DepositAccountType type) { public DepositAccountTransactionNotAllowedException(final Long accountId, final String action, final DepositAccountType type) {
super("error.msg." + type.resourceName() + ".account.trasaction." + action + ".notallowed", SavingsEnumerations.depositType(type).getValue() super("error.msg." + type.resourceName() + ".account.trasaction." + action + ".notallowed", SavingsEnumerations.depositType(type)
+ "account " + action + " transaction not allowed with account identifier " + accountId, accountId); .getValue() + "account " + action + " transaction not allowed with account identifier " + accountId, accountId);
} }
} }
@@ -11,7 +11,7 @@ import org.springframework.transaction.annotation.Transactional;
@Service @Service
public class AssignFieldOfficerSavingsAccountCommandHandler implements NewCommandSourceHandler { public class AssignFieldOfficerSavingsAccountCommandHandler implements NewCommandSourceHandler {
private final SavingsAccountWritePlatformService savingsWritePlatformService; private final SavingsAccountWritePlatformService savingsWritePlatformService;
@Autowired @Autowired
public AssignFieldOfficerSavingsAccountCommandHandler(final SavingsAccountWritePlatformService savingAccountWritePlatformService) { public AssignFieldOfficerSavingsAccountCommandHandler(final SavingsAccountWritePlatformService savingAccountWritePlatformService) {
@@ -20,7 +20,8 @@ public class CalculateInterestRecurringDepositAccountCommandHandler implements N
private final DepositAccountWritePlatformService depositAccountWritePlatformService; private final DepositAccountWritePlatformService depositAccountWritePlatformService;
@Autowired @Autowired
public CalculateInterestRecurringDepositAccountCommandHandler(final DepositAccountWritePlatformService depositAccountWritePlatformService) { public CalculateInterestRecurringDepositAccountCommandHandler(
final DepositAccountWritePlatformService depositAccountWritePlatformService) {
this.depositAccountWritePlatformService = depositAccountWritePlatformService; this.depositAccountWritePlatformService = depositAccountWritePlatformService;
} }
@@ -28,6 +28,7 @@ public class FixedDepositAccountApplicationApprovalUndoCommandHandler implements
@Transactional @Transactional
@Override @Override
public CommandProcessingResult processCommand(final JsonCommand command) { 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 @Transactional
@Override @Override
public CommandProcessingResult processCommand(final JsonCommand command) { 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 @Transactional
@Override @Override
public CommandProcessingResult processCommand(final JsonCommand command) { 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);
} }
} }
@@ -11,7 +11,7 @@ import org.springframework.transaction.annotation.Transactional;
@Service @Service
public class UnassignFieldOfficerSavingsAccountCommandHandler implements NewCommandSourceHandler { public class UnassignFieldOfficerSavingsAccountCommandHandler implements NewCommandSourceHandler {
private final SavingsAccountWritePlatformService savingsWritePlatformService; private final SavingsAccountWritePlatformService savingsWritePlatformService;
@Autowired @Autowired
public UnassignFieldOfficerSavingsAccountCommandHandler(final SavingsAccountWritePlatformService savingAccountWritePlatformService) { public UnassignFieldOfficerSavingsAccountCommandHandler(final SavingsAccountWritePlatformService savingAccountWritePlatformService) {
@@ -30,7 +30,8 @@ public interface DepositAccountReadPlatformService {
Collection<SavingsAccountTransactionData> retrieveAllTransactions(final DepositAccountType depositAccountType, Long accountId); 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(); Collection<DepositAccountData> retrieveForMaturityUpdate();
@@ -1366,7 +1366,8 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
.transactionType(SavingsAccountTransactionType.DEPOSIT.getValue()); .transactionType(SavingsAccountTransactionType.DEPOSIT.getValue());
final PaymentDetailData paymentDetailData = null; final PaymentDetailData paymentDetailData = null;
final AccountTransferData transfer = 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, return SavingsAccountTransactionData.create(savingsId, transactionType, paymentDetailData, savingsId, accountNo, duedate,
currency, dueamount, runningBalance, false, transfer); currency, dueamount, runningBalance, false, transfer);
} }
@@ -53,17 +53,20 @@ public interface DepositAccountWritePlatformService {
void rejectSavingsTransfer(Long accountId, final DepositAccountType depositAccountType); 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 addSavingsAccountCharge(JsonCommand command, final DepositAccountType depositAccountType);
CommandProcessingResult updateSavingsAccountCharge(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 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 applyChargeDue(final Long savingsAccountChargeId, final Long accountId, final DepositAccountType depositAccountType);
@@ -15,10 +15,12 @@ public interface DepositsDropdownReadPlatformService {
Collection<EnumOptionData> retrievePreClosurePenalInterestOnTypeOptions(); Collection<EnumOptionData> retrievePreClosurePenalInterestOnTypeOptions();
/*Collection<EnumOptionData> retrieveDepositTermTypeOptions(); /*
* Collection<EnumOptionData> retrieveDepositTermTypeOptions();
Collection<EnumOptionData> retrieveInMultiplesOfDepositTermTypeOptions(); *
* Collection<EnumOptionData> retrieveInMultiplesOfDepositTermTypeOptions();
Collection<EnumOptionData> retrieveDepositPeriodFrequencyOptions();*/ *
* Collection<EnumOptionData> retrieveDepositPeriodFrequencyOptions();
*/
} }
@@ -19,19 +19,21 @@ public class DepositsDropdownReadPlatformServiceImpl implements DepositsDropdown
return SavingsEnumerations.preClosurePenaltyInterestOnType(PreClosurePenalInterestOnType.values()); return SavingsEnumerations.preClosurePenaltyInterestOnType(PreClosurePenalInterestOnType.values());
} }
/*@Override /*
public Collection<EnumOptionData> retrieveDepositTermTypeOptions() { * @Override public Collection<EnumOptionData>
return SavingsEnumerations.recurringDepositFrequencyType(SavingsPeriodFrequencyType.values()); * retrieveDepositTermTypeOptions() { return
} * SavingsEnumerations.recurringDepositFrequencyType
* (SavingsPeriodFrequencyType.values()); }
@Override *
public Collection<EnumOptionData> retrieveDepositPeriodFrequencyOptions() { * @Override public Collection<EnumOptionData>
return SavingsEnumerations.depositPeriodFrequency(SavingsPeriodFrequencyType.values()); * retrieveDepositPeriodFrequencyOptions() { return
} * SavingsEnumerations.depositPeriodFrequency
* (SavingsPeriodFrequencyType.values()); }
@Override *
public Collection<EnumOptionData> retrieveInMultiplesOfDepositTermTypeOptions() { * @Override public Collection<EnumOptionData>
return SavingsEnumerations.recurringDepositFrequencyType(SavingsPeriodFrequencyType.values()); * retrieveInMultiplesOfDepositTermTypeOptions() { return
}*/ * SavingsEnumerations
* .recurringDepositFrequencyType(SavingsPeriodFrequencyType.values()); }
*/
} }
@@ -45,8 +45,7 @@ public class FixedDepositProductWritePlatformServiceJpaRepositoryImpl implements
@Autowired @Autowired
public FixedDepositProductWritePlatformServiceJpaRepositoryImpl(final PlatformSecurityContext context, public FixedDepositProductWritePlatformServiceJpaRepositoryImpl(final PlatformSecurityContext context,
final FixedDepositProductRepository fixedDepositProductRepository, final FixedDepositProductRepository fixedDepositProductRepository, final DepositProductDataValidator fromApiJsonDataValidator,
final DepositProductDataValidator fromApiJsonDataValidator,
final DepositProductAssembler depositProductAssembler, final DepositProductAssembler depositProductAssembler,
final ProductToGLAccountMappingWritePlatformService accountMappingWritePlatformService, final ProductToGLAccountMappingWritePlatformService accountMappingWritePlatformService,
final InterestRateChartAssembler chartAssembler) { final InterestRateChartAssembler chartAssembler) {
@@ -71,7 +70,8 @@ public class FixedDepositProductWritePlatformServiceJpaRepositoryImpl implements
this.fixedDepositProductRepository.save(product); this.fixedDepositProductRepository.save(product);
// save accounting mappings // save accounting mappings
this.accountMappingWritePlatformService.createSavingProductToGLAccountMapping(product.getId(), command, DepositAccountType.FIXED_DEPOSIT); this.accountMappingWritePlatformService.createSavingProductToGLAccountMapping(product.getId(), command,
DepositAccountType.FIXED_DEPOSIT);
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withEntityId(product.getId()) // .withEntityId(product.getId()) //
@@ -97,8 +97,8 @@ public class FixedDepositProductWritePlatformServiceJpaRepositoryImpl implements
final Map<String, Object> changes = product.update(command); final Map<String, Object> changes = product.update(command);
if (changes.containsKey(chargesParamName)) { if (changes.containsKey(chargesParamName)) {
final Set<Charge> savingsProductCharges = this.depositProductAssembler.assembleListOfSavingsProductCharges(command, final Set<Charge> savingsProductCharges = this.depositProductAssembler.assembleListOfSavingsProductCharges(command, product
product.currency().getCode()); .currency().getCode());
final boolean updated = product.update(savingsProductCharges); final boolean updated = product.update(savingsProductCharges);
if (!updated) { if (!updated) {
changes.remove(chargesParamName); changes.remove(chargesParamName);
@@ -108,7 +108,8 @@ public class FixedDepositProductWritePlatformServiceJpaRepositoryImpl implements
// accounting related changes // accounting related changes
final boolean accountingTypeChanged = changes.containsKey(accountingRuleParamName); final boolean accountingTypeChanged = changes.containsKey(accountingRuleParamName);
final Map<String, Object> accountingMappingChanges = this.accountMappingWritePlatformService 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); changes.putAll(accountingMappingChanges);
if (!changes.isEmpty()) { if (!changes.isEmpty()) {
@@ -46,8 +46,7 @@ public class RecurringDepositProductWritePlatformServiceJpaRepositoryImpl implem
@Autowired @Autowired
public RecurringDepositProductWritePlatformServiceJpaRepositoryImpl(final PlatformSecurityContext context, public RecurringDepositProductWritePlatformServiceJpaRepositoryImpl(final PlatformSecurityContext context,
final RecurringDepositProductRepository recurringDepositProductRepository, final RecurringDepositProductRepository recurringDepositProductRepository,
final DepositProductDataValidator fromApiJsonDataValidator, final DepositProductDataValidator fromApiJsonDataValidator, final DepositProductAssembler depositProductAssembler,
final DepositProductAssembler depositProductAssembler,
final ProductToGLAccountMappingWritePlatformService accountMappingWritePlatformService, final ProductToGLAccountMappingWritePlatformService accountMappingWritePlatformService,
final InterestRateChartAssembler chartAssembler) { final InterestRateChartAssembler chartAssembler) {
this.context = context; this.context = context;
@@ -71,7 +70,8 @@ public class RecurringDepositProductWritePlatformServiceJpaRepositoryImpl implem
this.recurringDepositProductRepository.save(product); this.recurringDepositProductRepository.save(product);
// save accounting mappings // save accounting mappings
this.accountMappingWritePlatformService.createSavingProductToGLAccountMapping(product.getId(), command, DepositAccountType.RECURRING_DEPOSIT); this.accountMappingWritePlatformService.createSavingProductToGLAccountMapping(product.getId(), command,
DepositAccountType.RECURRING_DEPOSIT);
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withEntityId(product.getId()) // .withEntityId(product.getId()) //
@@ -97,8 +97,8 @@ public class RecurringDepositProductWritePlatformServiceJpaRepositoryImpl implem
final Map<String, Object> changes = product.update(command); final Map<String, Object> changes = product.update(command);
if (changes.containsKey(chargesParamName)) { if (changes.containsKey(chargesParamName)) {
final Set<Charge> savingsProductCharges = this.depositProductAssembler.assembleListOfSavingsProductCharges(command, final Set<Charge> savingsProductCharges = this.depositProductAssembler.assembleListOfSavingsProductCharges(command, product
product.currency().getCode()); .currency().getCode());
final boolean updated = product.update(savingsProductCharges); final boolean updated = product.update(savingsProductCharges);
if (!updated) { if (!updated) {
changes.remove(chargesParamName); changes.remove(chargesParamName);
@@ -108,7 +108,8 @@ public class RecurringDepositProductWritePlatformServiceJpaRepositoryImpl implem
// accounting related changes // accounting related changes
final boolean accountingTypeChanged = changes.containsKey(accountingRuleParamName); final boolean accountingTypeChanged = changes.containsKey(accountingRuleParamName);
final Map<String, Object> accountingMappingChanges = this.accountMappingWritePlatformService 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); changes.putAll(accountingMappingChanges);
if (!changes.isEmpty()) { if (!changes.isEmpty()) {
@@ -149,13 +150,13 @@ public class RecurringDepositProductWritePlatformServiceJpaRepositoryImpl implem
if (realCause.getMessage().contains("sp_unq_name")) { if (realCause.getMessage().contains("sp_unq_name")) {
final String name = command.stringValueOfParameterNamed("name"); final String name = command.stringValueOfParameterNamed("name");
throw new PlatformDataIntegrityException("error.msg.product.savings.duplicate.name", "Recurring Deposit product with name `" + name throw new PlatformDataIntegrityException("error.msg.product.savings.duplicate.name", "Recurring Deposit product with name `"
+ "` already exists", "name", name); + name + "` already exists", "name", name);
} else if (realCause.getMessage().contains("sp_unq_short_name")) { } else if (realCause.getMessage().contains("sp_unq_short_name")) {
final String shortName = command.stringValueOfParameterNamed("shortName"); final String shortName = command.stringValueOfParameterNamed("shortName");
throw new PlatformDataIntegrityException("error.msg.product.savings.duplicate.short.name", "Recurring Deposit product with short name `" throw new PlatformDataIntegrityException("error.msg.product.savings.duplicate.short.name",
+ shortName + "` already exists", "shortName", shortName); "Recurring Deposit product with short name `" + shortName + "` already exists", "shortName", shortName);
} }
logAsErrorUnexpectedDataIntegrityException(dae); logAsErrorUnexpectedDataIntegrityException(dae);
@@ -34,5 +34,5 @@ public interface SavingsAccountReadPlatformService {
SavingsAccountTransactionData retrieveSavingsTransaction(Long savingsId, Long transactionId, DepositAccountType depositAccountType); SavingsAccountTransactionData retrieveSavingsTransaction(Long savingsId, Long transactionId, DepositAccountType depositAccountType);
Collection<SavingsAccountData> retrieveForLookup(Long clientId,Boolean overdraft); Collection<SavingsAccountData> retrieveForLookup(Long clientId, Boolean overdraft);
} }
@@ -128,8 +128,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
final ChargeRepositoryWrapper chargeRepository, final SavingsAccountChargeRepositoryWrapper savingsAccountChargeRepository, final ChargeRepositoryWrapper chargeRepository, final SavingsAccountChargeRepositoryWrapper savingsAccountChargeRepository,
final HolidayWritePlatformService holidayWritePlatformService, final HolidayWritePlatformService holidayWritePlatformService,
final WorkingDaysWritePlatformService workingDaysWritePlatformService, final WorkingDaysWritePlatformService workingDaysWritePlatformService,
final SavingsAccountDataValidator fromApiJsonDeserializer, final SavingsAccountDataValidator fromApiJsonDeserializer, final SavingsAccountRepositoryWrapper savingsRepository,
final SavingsAccountRepositoryWrapper savingsRepository,
final StaffRepositoryWrapper staffRepository) { final StaffRepositoryWrapper staffRepository) {
this.context = context; this.context = context;
this.savingAccountRepository = savingAccountRepository; this.savingAccountRepository = savingAccountRepository;
@@ -195,8 +194,8 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
boolean isRegularTransaction = false; boolean isRegularTransaction = false;
if (amountForDeposit.isGreaterThanZero()) { if (amountForDeposit.isGreaterThanZero()) {
boolean isAccountTransfer = false; boolean isAccountTransfer = false;
this.savingsAccountDomainService.handleDeposit(account, fmt, account.getActivationLocalDate(), this.savingsAccountDomainService.handleDeposit(account, fmt, account.getActivationLocalDate(), amountForDeposit.getAmount(),
amountForDeposit.getAmount(), null, isAccountTransfer, isRegularTransaction); null, isAccountTransfer, isRegularTransaction);
updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds); updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds);
} }
account.processAccountUponActivation(); account.processAccountUponActivation();
@@ -1022,10 +1021,9 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
return null; return null;
} }
@Override @Override
public CommandProcessingResult assignFieldOfficer(Long savingsAccountId, public CommandProcessingResult assignFieldOfficer(Long savingsAccountId, JsonCommand command) {
JsonCommand command) { this.context.authenticatedUser();
this.context.authenticatedUser();
final Map<String, Object> actualChanges = new LinkedHashMap<>(5); final Map<String, Object> actualChanges = new LinkedHashMap<>(5);
@@ -1052,12 +1050,11 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
.withClientId(savingsAccountId) // .withClientId(savingsAccountId) //
.with(actualChanges) // .with(actualChanges) //
.build(); .build();
} }
@Override @Override
public CommandProcessingResult unassignFieldOfficer(Long savingsAccountId, public CommandProcessingResult unassignFieldOfficer(Long savingsAccountId, JsonCommand command) {
JsonCommand command) { this.context.authenticatedUser();
this.context.authenticatedUser();
final Map<String, Object> actualChanges = new LinkedHashMap<>(5); final Map<String, Object> actualChanges = new LinkedHashMap<>(5);
@@ -1071,7 +1068,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
presentStaffId = presentStaff.getId(); presentStaffId = presentStaff.getId();
final String staffIdParamName = SavingsApiConstants.staffIdParamName; final String staffIdParamName = SavingsApiConstants.staffIdParamName;
if (!command.isChangeInLongParameterNamed(staffIdParamName, presentStaffId)) { if (!command.isChangeInLongParameterNamed(staffIdParamName, presentStaffId)) {
savingsForUpdate.unassignFieldOfficer(); savingsForUpdate.unassignFieldOfficer();
} }
this.savingsRepository.saveAndFlush(savingsForUpdate); this.savingsRepository.saveAndFlush(savingsForUpdate);
@@ -1084,6 +1081,6 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
.withClientId(savingsAccountId) // .withClientId(savingsAccountId) //
.with(actualChanges) // .with(actualChanges) //
.build(); .build();
} }
} }
@@ -45,7 +45,8 @@ public class SavingsDropdownReadPlatformServiceImpl implements SavingsDropdownRe
@Override @Override
public Collection<EnumOptionData> retrieveCompoundingInterestPeriodTypeOptions() { public Collection<EnumOptionData> retrieveCompoundingInterestPeriodTypeOptions() {
final List<EnumOptionData> allowedOptions = Arrays.asList( // final List<EnumOptionData> allowedOptions = Arrays.asList(
//
SavingsEnumerations.compoundingInterestPeriodType(SavingsCompoundingInterestPeriodType.DAILY), // SavingsEnumerations.compoundingInterestPeriodType(SavingsCompoundingInterestPeriodType.DAILY), //
// SavingsEnumerations.compoundingInterestPeriodType(SavingsCompoundingInterestPeriodType.WEEKLY), // SavingsEnumerations.compoundingInterestPeriodType(SavingsCompoundingInterestPeriodType.WEEKLY),
// // // //
@@ -63,9 +63,7 @@ public class SavingsEnumerations {
return preClosurePenaltyInterestOnType(id); return preClosurePenaltyInterestOnType(id);
} else if (typeName.equals(INTEREST_CALCULATION_DAYS_IN_YEAR)) { } else if (typeName.equals(INTEREST_CALCULATION_DAYS_IN_YEAR)) {
return interestCalculationDaysInYearType(id); return interestCalculationDaysInYearType(id);
} else if (typeName.equals(RECURRING_FREQUENCY_TYPE)) { } else if (typeName.equals(RECURRING_FREQUENCY_TYPE)) { return depositPeriodFrequency(id); }
return depositPeriodFrequency(id);
}
return null; return null;
} }
@@ -211,7 +209,8 @@ public class SavingsEnumerations {
case WITHDRAWN_BY_APPLICANT: case WITHDRAWN_BY_APPLICANT:
optionData = new SavingsAccountStatusEnumData(SavingsAccountStatusType.WITHDRAWN_BY_APPLICANT.getValue().longValue(), optionData = new SavingsAccountStatusEnumData(SavingsAccountStatusType.WITHDRAWN_BY_APPLICANT.getValue().longValue(),
SavingsAccountStatusType.WITHDRAWN_BY_APPLICANT.getCode(), "Withdrawn by applicant", submittedAndPendingApproval, 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; break;
case APPROVED: case APPROVED:
optionData = new SavingsAccountStatusEnumData(SavingsAccountStatusType.APPROVED.getValue().longValue(), optionData = new SavingsAccountStatusEnumData(SavingsAccountStatusType.APPROVED.getValue().longValue(),
@@ -231,22 +230,24 @@ public class SavingsEnumerations {
case TRANSFER_IN_PROGRESS: case TRANSFER_IN_PROGRESS:
optionData = new SavingsAccountStatusEnumData(SavingsAccountStatusType.TRANSFER_IN_PROGRESS.getValue().longValue(), optionData = new SavingsAccountStatusEnumData(SavingsAccountStatusType.TRANSFER_IN_PROGRESS.getValue().longValue(),
SavingsAccountStatusType.TRANSFER_IN_PROGRESS.getCode(), "Transfer in progress", submittedAndPendingApproval, 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; break;
case TRANSFER_ON_HOLD: case TRANSFER_ON_HOLD:
optionData = new SavingsAccountStatusEnumData(SavingsAccountStatusType.TRANSFER_IN_PROGRESS.getValue().longValue(), optionData = new SavingsAccountStatusEnumData(SavingsAccountStatusType.TRANSFER_IN_PROGRESS.getValue().longValue(),
SavingsAccountStatusType.TRANSFER_ON_HOLD.getCode(), "Transfer in progress", submittedAndPendingApproval, 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; break;
case PRE_MATURE_CLOSURE: case PRE_MATURE_CLOSURE:
optionData = new SavingsAccountStatusEnumData(SavingsAccountStatusType.PRE_MATURE_CLOSURE.getValue().longValue(), optionData = new SavingsAccountStatusEnumData(SavingsAccountStatusType.PRE_MATURE_CLOSURE.getValue().longValue(),
SavingsAccountStatusType.PRE_MATURE_CLOSURE.getCode(), "Premature Closed", submittedAndPendingApproval, SavingsAccountStatusType.PRE_MATURE_CLOSURE.getCode(), "Premature Closed", submittedAndPendingApproval, isApproved,
isApproved, isRejected, isWithdrawnByApplicant, isActive, isClosed, isPrematureClosed, isTransferInProgress, isTransferOnHold); isRejected, isWithdrawnByApplicant, isActive, isClosed, isPrematureClosed, isTransferInProgress, isTransferOnHold);
break; break;
case MATURED: case MATURED:
optionData = new SavingsAccountStatusEnumData(SavingsAccountStatusType.MATURED.getValue().longValue(), optionData = new SavingsAccountStatusEnumData(SavingsAccountStatusType.MATURED.getValue().longValue(),
SavingsAccountStatusType.MATURED.getCode(), "Matured", submittedAndPendingApproval, SavingsAccountStatusType.MATURED.getCode(), "Matured", submittedAndPendingApproval, isApproved, isRejected,
isApproved, isRejected, isWithdrawnByApplicant, isActive, isClosed, isPrematureClosed, isTransferInProgress, isTransferOnHold); isWithdrawnByApplicant, isActive, isClosed, isPrematureClosed, isTransferInProgress, isTransferOnHold);
break; break;
default: default:
break; break;
@@ -622,16 +623,20 @@ public class SavingsEnumerations {
case INVALID: case INVALID:
break; break;
case SAVINGS_DEPOSIT: 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; break;
case FIXED_DEPOSIT: 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; break;
case RECURRING_DEPOSIT: 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; break;
case CURRENT_DEPOSIT: 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; break;
} }
return optionData; return optionData;
@@ -699,13 +704,16 @@ public class SavingsEnumerations {
case INVALID: case INVALID:
break; break;
case WITHDRAW_DEPOSIT: 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; break;
case TRANSFER_TO_SAVINGS: 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; break;
case REINVEST: 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; break;
} }
return optionData; return optionData;
@@ -94,7 +94,8 @@ public class SavingsProductWritePlatformServiceJpaRepositoryImpl implements Savi
this.savingProductRepository.save(product); this.savingProductRepository.save(product);
// save accounting mappings // save accounting mappings
this.accountMappingWritePlatformService.createSavingProductToGLAccountMapping(product.getId(), command, DepositAccountType.SAVINGS_DEPOSIT); this.accountMappingWritePlatformService.createSavingProductToGLAccountMapping(product.getId(), command,
DepositAccountType.SAVINGS_DEPOSIT);
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withEntityId(product.getId()) // .withEntityId(product.getId()) //
@@ -130,7 +131,8 @@ public class SavingsProductWritePlatformServiceJpaRepositoryImpl implements Savi
// accounting related changes // accounting related changes
final boolean accountingTypeChanged = changes.containsKey(accountingRuleParamName); final boolean accountingTypeChanged = changes.containsKey(accountingRuleParamName);
final Map<String, Object> accountingMappingChanges = this.accountMappingWritePlatformService 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); changes.putAll(accountingMappingChanges);
if (!changes.isEmpty()) { if (!changes.isEmpty()) {