Merge pull request #920 from ashok-conflux/CONFLUX-39-CR

Added support to mandatory savings
This commit is contained in:
Vishwas Babu A J
2014-05-28 11:45:07 +05:30
138 changed files with 4478 additions and 2438 deletions
@@ -0,0 +1,71 @@
INSERT INTO `c_configuration` (`name`, `value`, `enabled`) VALUES ('age_limit_for_senior_citizen', 65, 1);
INSERT INTO `c_configuration` (`name`, `value`, `enabled`) VALUES ('age_limit_for_children', 15, 1);
ALTER TABLE `m_interest_rate_slab`
ADD COLUMN `interest_rate_for_female` DECIMAL(19,6) NULL AFTER `annual_interest_rate`,
ADD COLUMN `interest_rate_for_children` DECIMAL(19,6) NULL AFTER `interest_rate_for_female`,
ADD COLUMN `interest_rate_for_senior_citizen` DECIMAL(19,6) NULL AFTER `interest_rate_for_children`;
ALTER TABLE `m_savings_account_interest_rate_slab`
ADD COLUMN `interest_rate_for_female` DECIMAL(19,6) NULL AFTER `annual_interest_rate`,
ADD COLUMN `interest_rate_for_children` DECIMAL(19,6) NULL AFTER `interest_rate_for_female`,
ADD COLUMN `interest_rate_for_senior_citizen` DECIMAL(19,6) NULL AFTER `interest_rate_for_children`;
ALTER TABLE `m_deposit_account_recurring_detail`
CHANGE COLUMN `recurring_deposit_amount` `mandatory_recommended_deposit_amount` DECIMAL(19,6) NULL DEFAULT NULL,
ADD COLUMN `is_mandatory` TINYINT NOT NULL DEFAULT '0',
ADD COLUMN `allow_withdrawal` TINYINT NOT NULL DEFAULT '0',
ADD COLUMN `adjust_advance_towards_future_payments` TINYINT NOT NULL DEFAULT '1',
ADD COLUMN `is_calendar_inherited` TINYINT NOT NULL DEFAULT '0',
ADD COLUMN `total_overdue_amount` DECIMAL(19,6) NULL DEFAULT NULL,
ADD COLUMN `no_of_overdue_installments` INT(11) NULL DEFAULT NULL,
DROP COLUMN `recurring_deposit_type_enum`,
DROP COLUMN `recurring_deposit_frequency`,
DROP COLUMN `recurring_deposit_frequency_type_enum`;
ALTER TABLE `m_deposit_product_term_and_preclosure`
DROP COLUMN `interest_free_period_applicable`,
DROP COLUMN `interest_free_from_period`,
DROP COLUMN `interest_free_to_period`,
DROP COLUMN `interest_free_period_frequency_enum`;
ALTER TABLE `m_deposit_product_recurring_detail`
ADD COLUMN `is_mandatory` TINYINT(1) NOT NULL DEFAULT '1',
ADD COLUMN `allow_withdrawal` TINYINT(1) NOT NULL DEFAULT '0',
ADD COLUMN `adjust_advance_towards_future_payments` TINYINT(1) NOT NULL DEFAULT '1',
DROP COLUMN `recurring_deposit_type_enum`,
DROP COLUMN `recurring_deposit_frequency`,
DROP COLUMN `recurring_deposit_frequency_type_enum`;
ALTER TABLE `m_deposit_account_term_and_preclosure`
DROP COLUMN `interest_free_period_applicable`,
DROP COLUMN `interest_free_from_period`,
DROP COLUMN `interest_free_to_period`,
DROP COLUMN `interest_free_period_frequency_enum`;
CREATE TABLE `m_mandatory_savings_schedule` (
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
`savings_account_id` BIGINT(20) NOT NULL,
`fromdate` DATE NULL DEFAULT NULL,
`duedate` DATE NOT NULL,
`installment` SMALLINT(5) NOT NULL,
`deposit_amount` DECIMAL(19,6) NULL DEFAULT NULL,
`deposit_amount_completed_derived` DECIMAL(19,6) NULL DEFAULT NULL,
`total_paid_in_advance_derived` DECIMAL(19,6) NULL DEFAULT NULL,
`total_paid_late_derived` DECIMAL(19,6) NULL DEFAULT NULL,
`completed_derived` BIT(1) NOT NULL,
`obligations_met_on_date` DATE NULL DEFAULT NULL,
`createdby_id` BIGINT(20) NULL DEFAULT NULL,
`created_date` DATETIME NULL DEFAULT NULL,
`lastmodified_date` DATETIME NULL DEFAULT NULL,
`lastmodifiedby_id` BIGINT(20) NULL DEFAULT NULL,
PRIMARY KEY (`id`),
INDEX `FKMSS0000000001` (`savings_account_id`),
CONSTRAINT `FKMSS0000000001` FOREIGN KEY (`savings_account_id`) REFERENCES `m_savings_account` (`id`)
);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('organisation', 'READ_RECURRINGDEPOSITPRODUCT', 'RECURRINGDEPOSITPRODUCT', 'READ', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('organisation', 'READ_FIXEDDEPOSITPRODUCT', 'FIXEDDEPOSITPRODUCT', 'READ', 0);
@@ -5,7 +5,6 @@
*/
package org.mifosplatform.commands.domain;
import org.mifosplatform.portfolio.savings.DepositAccountType;
public class CommandWrapper {
@@ -28,8 +27,6 @@ public class CommandWrapper {
@SuppressWarnings("unused")
private Long templateId;
private Long interestRatechartId;
private DepositAccountType depositAccountType;
public static CommandWrapper wrap(final String actionName, final String entityName, final Long resourceId, final Long subresourceId) {
return new CommandWrapper(null, actionName, entityName, resourceId, subresourceId, null, null);
@@ -68,8 +65,7 @@ public class CommandWrapper {
public CommandWrapper(final Long officeId, final Long groupId, final Long clientId, final Long loanId, final Long savingsId,
final String actionName, final String entityName, final Long entityId, final Long subentityId, final String href,
final String json, final String transactionId, final Long productId, final Long templateId, Long interestRatechartId,
DepositAccountType depositAccountType) {
final String json, final String transactionId, final Long productId, final Long templateId) {
this.commandId = null;
this.officeId = officeId;
@@ -87,8 +83,6 @@ public class CommandWrapper {
this.transactionId = transactionId;
this.productId = productId;
this.templateId = templateId;
this.interestRatechartId = interestRatechartId;
this.depositAccountType = depositAccountType;
}
private CommandWrapper(final Long commandId, final String actionName, final String entityName, final Long resourceId,
@@ -720,10 +714,6 @@ public class CommandWrapper {
return this.entityName.equalsIgnoreCase("CACHE");
}
public Long interestRatechartId() {
return this.interestRatechartId;
}
// Begin - Deposit product
public boolean isFixedDepositProductResource() {
return this.entityName.equalsIgnoreCase("FIXEDDEPOSITPRODUCT");
@@ -737,53 +727,101 @@ public class CommandWrapper {
// Begin - Deposit accounts
public boolean isDepositAccountResource() {
return this.entityName.equalsIgnoreCase("FIXEDDEPOSITACCOUNT") || this.entityName.equalsIgnoreCase("RECURRINGDEPOSITACCOUNT");
return isFixedDepositAccountResource() || isRecurringDepositAccountResource();
}
public boolean isRejectionOfDepositAccountApplication() {
return this.actionName.equalsIgnoreCase("REJECT") && isDepositAccountResource();
public boolean isFixedDepositAccountResource() {
return this.entityName.equalsIgnoreCase("FIXEDDEPOSITACCOUNT");
}
public boolean isWithdrawFromDepositAccountApplicationByApplicant() {
return this.actionName.equalsIgnoreCase("WITHDRAW") && isDepositAccountResource();
public boolean isRecurringDepositAccountResource() {
return this.entityName.equalsIgnoreCase("RECURRINGDEPOSITACCOUNT");
}
public boolean isApprovalOfDepositAccountApplication() {
return this.actionName.equalsIgnoreCase("APPROVE") && isDepositAccountResource();
public boolean isFixedDepositAccountCreate() {
return isCreate() && isFixedDepositAccountResource();
}
public boolean isRecurringDepositAccountCreate() {
return isCreate() && isRecurringDepositAccountResource();
}
public boolean isFixedDepositAccountUpdate() {
return isUpdate() && isFixedDepositAccountResource();
}
public boolean isRecurringDepositAccountUpdate() {
return isUpdate() && isRecurringDepositAccountResource();
}
public boolean isFixedDepositAccountDelete() {
return isDelete() && isFixedDepositAccountResource();
}
public boolean isRecurringDepositAccountDelete() {
return isDelete() && isRecurringDepositAccountResource();
}
public boolean isRejectionOfFixedDepositAccountApplication() {
return this.actionName.equalsIgnoreCase("REJECT") && isFixedDepositAccountResource();
}
public boolean isRejectionOfRecurringDepositAccountApplication() {
return this.actionName.equalsIgnoreCase("REJECT") && isRecurringDepositAccountResource();
}
public boolean isWithdrawFixedDepositAccountApplicationByApplicant() {
return this.actionName.equalsIgnoreCase("WITHDRAW") && isFixedDepositAccountResource();
}
public boolean isWithdrawRecurringDepositAccountApplicationByApplicant() {
return this.actionName.equalsIgnoreCase("WITHDRAW") && isRecurringDepositAccountResource();
}
public boolean isApprovalOfFixedDepositAccountApplication() {
return this.actionName.equalsIgnoreCase("APPROVE") && isFixedDepositAccountResource();
}
public boolean isApprovalOfRecurringDepositAccountApplication() {
return this.actionName.equalsIgnoreCase("APPROVE") && isRecurringDepositAccountResource();
}
public boolean isUndoApprovalOfDepositAccountApplication() {
return this.actionName.equalsIgnoreCase("APPROVALUNDO") && isDepositAccountResource();
public boolean isUndoApprovalOfFixedDepositAccountApplication() {
return this.actionName.equalsIgnoreCase("APPROVALUNDO") && isFixedDepositAccountResource();
}
public boolean isUndoApprovalOfRecurringDepositAccountApplication() {
return this.actionName.equalsIgnoreCase("APPROVALUNDO") && isRecurringDepositAccountResource();
}
//Account transaction actions
public boolean isDepositAccountDeposit() {
return this.actionName.equalsIgnoreCase("DEPOSIT") && isDepositAccountResource();
public boolean isDeposit() {
return this.actionName.equalsIgnoreCase("DEPOSIT");
}
public boolean isDepositAccountWithdrawal() {
return this.actionName.equalsIgnoreCase("WITHDRAWAL") && isDepositAccountResource();
public boolean isWithdrawal() {
return this.actionName.equalsIgnoreCase("WITHDRAWAL");
}
public boolean isDepositAccountActivation() {
return this.actionName.equalsIgnoreCase("ACTIVATE") && isDepositAccountResource();
public boolean isActivation() {
return this.actionName.equalsIgnoreCase("ACTIVATE");
}
public boolean isDepositAccountInterestCalculation() {
return this.actionName.equalsIgnoreCase("CALCULATEINTEREST") && isDepositAccountResource();
public boolean isInterestCalculation() {
return this.actionName.equalsIgnoreCase("CALCULATEINTEREST");
}
public boolean isDepositAccountInterestPosting() {
return this.actionName.equalsIgnoreCase("POSTINTEREST") && isDepositAccountResource();
public boolean isInterestPosting() {
return this.actionName.equalsIgnoreCase("POSTINTEREST");
}
public boolean isDepositAccountUndoTransaction() {
return this.actionName.equalsIgnoreCase("UNDOTRANSACTION") && isDepositAccountResource();
public boolean isUndoTransaction() {
return this.actionName.equalsIgnoreCase("UNDOTRANSACTION");
}
public boolean isAdjustDeopsitAccountTransaction() {
return this.actionName.equalsIgnoreCase("ADJUSTTRANSACTION") && isDepositAccountResource();
public boolean isAdjustTransaction() {
return this.actionName.equalsIgnoreCase("ADJUSTTRANSACTION");
}
public boolean isDepositAccountClose() {
@@ -795,8 +833,4 @@ public class CommandWrapper {
}
// End - Deposit accounts
public DepositAccountType depositAccountType(){
return this.depositAccountType;
}
}
@@ -6,7 +6,6 @@
package org.mifosplatform.commands.service;
import org.mifosplatform.commands.domain.CommandWrapper;
import org.mifosplatform.portfolio.savings.DepositAccountType;
public class CommandWrapperBuilder {
@@ -24,13 +23,11 @@ public class CommandWrapperBuilder {
private String transactionId;
private Long productId;
private Long templateId;
private Long interestRatechartId;
private DepositAccountType depositAccountType;
public CommandWrapper build() {
return new CommandWrapper(this.officeId, this.groupId, this.clientId, this.loanId, this.savingsId, this.actionName,
this.entityName, this.entityId, this.subentityId, this.href, this.json, this.transactionId, this.productId,
this.templateId, this.interestRatechartId, this.depositAccountType);
this.templateId);
}
public CommandWrapperBuilder withLoanId(final Long withLoanId) {
@@ -1185,7 +1182,7 @@ public class CommandWrapperBuilder {
this.actionName = "CREATE";
this.entityName = "CHARTSLAB";
this.entityId = null;
this.interestRatechartId = chartId;
this.subentityId = chartId; //refer to chart id
this.href = "/interestratechart/" + chartId + "/chartdetails/template";
return this;
}
@@ -1194,7 +1191,7 @@ public class CommandWrapperBuilder {
this.actionName = "UPDATE";
this.entityName = "CHARTSLAB";
this.entityId = chartSlabId;
this.interestRatechartId = chartId;
this.subentityId = chartId;//refers parent chart
this.href = "/interestratechart/" + chartId + "/chartdetails/" + chartSlabId;
return this;
}
@@ -1203,7 +1200,7 @@ public class CommandWrapperBuilder {
this.actionName = "DELETE";
this.entityName = "CHARTSLAB";
this.entityId = chartSlabId;
this.interestRatechartId = chartId;
this.subentityId = chartId;//refers parent chart
this.href = "/interestratechart/" + chartId + "/chartdetails/" + chartSlabId;
return this;
}
@@ -1698,7 +1695,6 @@ public class CommandWrapperBuilder {
this.actionName = "CREATE";
this.entityName = "FIXEDDEPOSITACCOUNT";
this.entityId = null;
this.depositAccountType = DepositAccountType.FIXED_DEPOSIT;
this.href = "/fixeddepositaccounts/template";
return this;
}
@@ -1707,7 +1703,6 @@ public class CommandWrapperBuilder {
this.actionName = "UPDATE";
this.entityName = "FIXEDDEPOSITACCOUNT";
this.entityId = accountId;
this.depositAccountType = DepositAccountType.FIXED_DEPOSIT;
this.href = "/fixeddepositaccounts/" + accountId;
return this;
}
@@ -1716,7 +1711,6 @@ public class CommandWrapperBuilder {
this.actionName = "DELETE";
this.entityName = "FIXEDDEPOSITACCOUNT";
this.entityId = accountId;
this.depositAccountType = DepositAccountType.FIXED_DEPOSIT;
this.href = "/fixeddepositaccounts/" + accountId;
return this;
}
@@ -1726,7 +1720,6 @@ public class CommandWrapperBuilder {
this.entityName = "FIXEDDEPOSITACCOUNT";
this.entityId = accountId;
this.savingsId = accountId;
this.depositAccountType = DepositAccountType.FIXED_DEPOSIT;
this.href = "/fixeddepositaccounts/" + accountId + "?command=reject";
return this;
}
@@ -1736,7 +1729,6 @@ public class CommandWrapperBuilder {
this.entityName = "FIXEDDEPOSITACCOUNT";
this.entityId = accountId;
this.savingsId = accountId;
this.depositAccountType = DepositAccountType.FIXED_DEPOSIT;
this.href = "/fixeddepositaccounts/" + accountId + "?command=withdrawnByApplicant";
return this;
}
@@ -1746,7 +1738,6 @@ public class CommandWrapperBuilder {
this.entityName = "FIXEDDEPOSITACCOUNT";
this.entityId = accountId;
this.savingsId = accountId;
this.depositAccountType = DepositAccountType.FIXED_DEPOSIT;
this.href = "/fixeddepositaccounts/" + accountId + "?command=approve";
return this;
}
@@ -1756,7 +1747,6 @@ public class CommandWrapperBuilder {
this.entityName = "FIXEDDEPOSITACCOUNT";
this.entityId = accountId;
this.savingsId = accountId;
this.depositAccountType = DepositAccountType.FIXED_DEPOSIT;
this.href = "/fixeddepositaccounts/" + accountId + "?command=undoapproval";
return this;
}
@@ -1766,7 +1756,6 @@ public class CommandWrapperBuilder {
this.entityName = "FIXEDDEPOSITACCOUNT";
this.savingsId = accountId;
this.entityId = accountId;
this.depositAccountType = DepositAccountType.FIXED_DEPOSIT;
this.href = "/fixeddepositaccounts/" + accountId + "?command=activate";
return this;
}
@@ -1776,7 +1765,6 @@ public class CommandWrapperBuilder {
this.entityName = "FIXEDDEPOSITACCOUNT";
this.entityId = accountId;
this.savingsId = accountId;
this.depositAccountType = DepositAccountType.FIXED_DEPOSIT;
this.href = "/fixeddepositaccounts/" + accountId + "?command=close";
return this;
}
@@ -1786,7 +1774,6 @@ public class CommandWrapperBuilder {
this.entityName = "FIXEDDEPOSITACCOUNT";
this.entityId = accountId;
this.savingsId = accountId;
this.depositAccountType = DepositAccountType.FIXED_DEPOSIT;
this.href = "/fixeddepositaccounts/" + accountId + "?command=prematureClose";
return this;
}
@@ -1796,7 +1783,6 @@ public class CommandWrapperBuilder {
this.entityName = "FIXEDDEPOSITACCOUNT";
this.savingsId = accountId;
this.entityId = accountId;
this.depositAccountType = DepositAccountType.FIXED_DEPOSIT;
this.href = "/fixeddepositaccounts/" + accountId + "?command=calculateInterest";
return this;
}
@@ -1806,7 +1792,6 @@ public class CommandWrapperBuilder {
this.entityName = "FIXEDDEPOSITACCOUNT";
this.savingsId = accountId;
this.entityId = accountId;
this.depositAccountType = DepositAccountType.FIXED_DEPOSIT;
this.href = "/fixeddepositaccounts/" + accountId + "?command=postInterest";
return this;
}
@@ -1815,7 +1800,6 @@ public class CommandWrapperBuilder {
this.actionName = "DEPOSIT";
this.entityName = "FIXEDDEPOSITACCOUNT";
this.savingsId = accountId;
this.depositAccountType = DepositAccountType.FIXED_DEPOSIT;
this.entityId = accountId;
this.href = "/fixeddepositaccounts/" + accountId + "/transactions?command=deposit";
return this;
@@ -1825,7 +1809,6 @@ public class CommandWrapperBuilder {
this.actionName = "WITHDRAWAL";
this.entityName = "FIXEDDEPOSITACCOUNT";
this.savingsId = accountId;
this.depositAccountType = DepositAccountType.FIXED_DEPOSIT;
this.entityId = accountId;
this.href = "/fixeddepositaccounts/" + accountId + "/transactions?command=withdrawal";
return this;
@@ -1835,7 +1818,6 @@ public class CommandWrapperBuilder {
this.actionName = "CREATE";
this.entityName = "RECURRINGDEPOSITACCOUNT";
this.entityId = null;
this.depositAccountType = DepositAccountType.RECURRING_DEPOSIT;
this.href = "/recurringdepositaccounts/template";
return this;
}
@@ -1844,7 +1826,6 @@ public class CommandWrapperBuilder {
this.actionName = "UPDATE";
this.entityName = "RECURRINGDEPOSITACCOUNT";
this.entityId = accountId;
this.depositAccountType = DepositAccountType.RECURRING_DEPOSIT;
this.href = "/recurringdepositaccounts/" + accountId;
return this;
}
@@ -1853,7 +1834,6 @@ public class CommandWrapperBuilder {
this.actionName = "DEPOSIT";
this.entityName = "RECURRINGDEPOSITACCOUNT";
this.savingsId = accountId;
this.depositAccountType = DepositAccountType.RECURRING_DEPOSIT;
this.entityId = accountId;
this.href = "/recurringdepositaccounts/" + accountId + "/transactions?command=deposit";
return this;
@@ -1863,7 +1843,6 @@ public class CommandWrapperBuilder {
this.actionName = "WITHDRAWAL";
this.entityName = "RECURRINGDEPOSITACCOUNT";
this.savingsId = accountId;
this.depositAccountType = DepositAccountType.RECURRING_DEPOSIT;
this.entityId = accountId;
this.href = "/recurringdepositaccounts/" + accountId + "/transactions?command=withdrawal";
return this;
@@ -1874,7 +1853,6 @@ public class CommandWrapperBuilder {
this.entityName = "RECURRINGDEPOSITACCOUNT";
this.savingsId = accountId;
this.entityId = accountId;
this.depositAccountType = DepositAccountType.RECURRING_DEPOSIT;
this.subentityId = transactionId;
this.transactionId = transactionId.toString();
this.href = "/recurringdepositaccounts/" + accountId + "/transactions/" + transactionId + "?command=modify";
@@ -1886,7 +1864,6 @@ public class CommandWrapperBuilder {
this.entityName = "RECURRINGDEPOSITACCOUNT";
this.savingsId = accountId;
this.entityId = accountId;
this.depositAccountType = DepositAccountType.RECURRING_DEPOSIT;
this.subentityId = transactionId;
this.transactionId = transactionId.toString();
this.href = "/recurringdepositaccounts/" + accountId + "/transactions/" + transactionId + "?command=undo";
@@ -1897,7 +1874,6 @@ public class CommandWrapperBuilder {
this.actionName = "DELETE";
this.entityName = "RECURRINGDEPOSITACCOUNT";
this.entityId = accountId;
this.depositAccountType = DepositAccountType.RECURRING_DEPOSIT;
this.href = "/recurringdepositaccounts/" + accountId;
return this;
}
@@ -1907,7 +1883,6 @@ public class CommandWrapperBuilder {
this.entityName = "RECURRINGDEPOSITACCOUNT";
this.entityId = accountId;
this.savingsId = accountId;
this.depositAccountType = DepositAccountType.RECURRING_DEPOSIT;
this.href = "/recurringdepositaccounts/" + accountId + "?command=reject";
return this;
}
@@ -1917,7 +1892,6 @@ public class CommandWrapperBuilder {
this.entityName = "RECURRINGDEPOSITACCOUNT";
this.entityId = accountId;
this.savingsId = accountId;
this.depositAccountType = DepositAccountType.RECURRING_DEPOSIT;
this.href = "/recurringdepositaccounts/" + accountId + "?command=withdrawnByApplicant";
return this;
}
@@ -1927,7 +1901,6 @@ public class CommandWrapperBuilder {
this.entityName = "RECURRINGDEPOSITACCOUNT";
this.entityId = accountId;
this.savingsId = accountId;
this.depositAccountType = DepositAccountType.RECURRING_DEPOSIT;
this.href = "/recurringdepositaccounts/" + accountId + "?command=approve";
return this;
}
@@ -1937,7 +1910,6 @@ public class CommandWrapperBuilder {
this.entityName = "RECURRINGDEPOSITACCOUNT";
this.entityId = accountId;
this.savingsId = accountId;
this.depositAccountType = DepositAccountType.RECURRING_DEPOSIT;
this.href = "/recurringdepositaccounts/" + accountId + "?command=undoapproval";
return this;
}
@@ -1947,7 +1919,6 @@ public class CommandWrapperBuilder {
this.entityName = "RECURRINGDEPOSITACCOUNT";
this.savingsId = accountId;
this.entityId = accountId;
this.depositAccountType = DepositAccountType.RECURRING_DEPOSIT;
this.href = "/recurringdepositaccounts/" + accountId + "?command=activate";
return this;
}
@@ -1957,7 +1928,6 @@ public class CommandWrapperBuilder {
this.entityName = "RECURRINGDEPOSITACCOUNT";
this.entityId = accountId;
this.savingsId = accountId;
this.depositAccountType = DepositAccountType.RECURRING_DEPOSIT;
this.href = "/recurringdepositaccounts/" + accountId + "?command=close";
return this;
}
@@ -1967,7 +1937,6 @@ public class CommandWrapperBuilder {
this.entityName = "RECURRINGDEPOSITACCOUNT";
this.entityId = accountId;
this.savingsId = accountId;
this.depositAccountType = DepositAccountType.RECURRING_DEPOSIT;
this.href = "/recurringdepositaccounts/" + accountId + "?command=prematureClose";
return this;
}
@@ -1977,7 +1946,6 @@ public class CommandWrapperBuilder {
this.entityName = "RECURRINGDEPOSITACCOUNT";
this.savingsId = accountId;
this.entityId = accountId;
this.depositAccountType = DepositAccountType.RECURRING_DEPOSIT;
this.href = "/recurringdepositaccounts/" + accountId + "?command=calculateInterest";
return this;
}
@@ -1987,7 +1955,6 @@ public class CommandWrapperBuilder {
this.entityName = "RECURRINGDEPOSITACCOUNT";
this.savingsId = accountId;
this.entityId = accountId;
this.depositAccountType = DepositAccountType.RECURRING_DEPOSIT;
this.href = "/recurringdepositaccounts/" + accountId + "?command=postInterest";
return this;
}
@@ -68,8 +68,7 @@ public class PortfolioCommandSourceWritePlatformServiceImpl implements Portfolio
final JsonElement parsedCommand = this.fromApiJsonHelper.parse(json);
final JsonCommand command = JsonCommand.from(json, parsedCommand, this.fromApiJsonHelper, wrapper.getEntityName(),
wrapper.getEntityId(), wrapper.getSubentityId(), wrapper.getGroupId(), wrapper.getClientId(), wrapper.getLoanId(),
wrapper.getSavingsId(), wrapper.getTransactionId(), wrapper.getHref(), wrapper.getProductId(),
wrapper.interestRatechartId(), wrapper.depositAccountType());
wrapper.getSavingsId(), wrapper.getTransactionId(), wrapper.getHref(), wrapper.getProductId());
result = this.processAndLogCommandService.processAndLogCommand(wrapper, command, isApprovedByChecker);
} catch (final RollbackTransactionAsCommandIsNotApprovedByCheckerException e) {
@@ -503,43 +503,87 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
} else {
throw new UnsupportedCommandException(wrapper.commandName());
}
} else if (wrapper.isDepositAccountResource()) {
} else if (wrapper.isFixedDepositAccountResource()) {
if (wrapper.isCreate()) {
handler = this.applicationContext
.getBean("depositAccountApplicationSubmittalCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isUpdate()) {
handler = this.applicationContext.getBean("depositAccountApplicationModificationCommandHandler",
handler = this.applicationContext.getBean("fixedDepositAccountApplicationSubmittalCommandHandler",
NewCommandSourceHandler.class);
}else if (wrapper.isUpdate()) {
handler = this.applicationContext.getBean("fixedDepositAccountApplicationModificationCommandHandler",
NewCommandSourceHandler.class);
} else if (wrapper.isDelete()) {
handler = this.applicationContext.getBean("depositAccountApplicationDeletionCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isRejectionOfDepositAccountApplication()) {
handler = this.applicationContext.getBean("depositAccountApplicationRejectedCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isWithdrawFromDepositAccountApplicationByApplicant()) {
handler = this.applicationContext.getBean("depositAccountApplicationWithdrawnByApplicantCommandHandler",
handler = this.applicationContext.getBean("fixedDepositAccountApplicationDeletionCommandHandler",
NewCommandSourceHandler.class);
} else if (wrapper.isApprovalOfDepositAccountApplication()) {
handler = this.applicationContext.getBean("depositAccountApplicationApprovalCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isUndoApprovalOfDepositAccountApplication()) {
handler = this.applicationContext.getBean("depositAccountApplicationApprovalUndoCommandHandler",
} else if (wrapper.isRejectionOfFixedDepositAccountApplication()) {
handler = this.applicationContext.getBean("fixedDepositAccountApplicationRejectedCommandHandler",
NewCommandSourceHandler.class);
} else if (wrapper.isDepositAccountDeposit()) {
handler = this.applicationContext.getBean("depositAccountDepositCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isDepositAccountWithdrawal()) {
handler = this.applicationContext.getBean("withdrawDepositAccountCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isDepositAccountActivation()) {
handler = this.applicationContext.getBean("activateDepositAccountCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isDepositAccountInterestCalculation()) {
handler = this.applicationContext.getBean("calculateInterestDepositAccountCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isDepositAccountInterestPosting()) {
handler = this.applicationContext.getBean("postInterestDepositAccountCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isDepositAccountUndoTransaction()) {
handler = this.applicationContext.getBean("undoTransactionDepositAccountCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isAdjustDeopsitAccountTransaction()) {
handler = this.applicationContext.getBean("depositTransactionAdjustmentCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isWithdrawFixedDepositAccountApplicationByApplicant()) {
handler = this.applicationContext.getBean("fixedDepositAccountApplicationWithdrawnByApplicantCommandHandler",
NewCommandSourceHandler.class);
} else if (wrapper.isApprovalOfFixedDepositAccountApplication()) {
handler = this.applicationContext.getBean("fixedDepositAccountApplicationApprovalCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isUndoApprovalOfFixedDepositAccountApplication()) {
handler = this.applicationContext.getBean("fixedDepositAccountApplicationApprovalUndoCommandHandler",
NewCommandSourceHandler.class);
} else if (wrapper.isDeposit()) {
handler = this.applicationContext.getBean("fixedDepositAccountDepositCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isWithdrawal()) {
handler = this.applicationContext.getBean("withdrawalFixedDepositAccountCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isActivation()) {
handler = this.applicationContext.getBean("activateFixedDepositAccountCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isInterestCalculation()) {
handler = this.applicationContext.getBean("calculateInterestFixedDepositAccountCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isInterestPosting()) {
handler = this.applicationContext.getBean("postInterestFixedDepositAccountCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isUndoTransaction()) {
handler = this.applicationContext.getBean("undoTransactionFixedDepositAccountCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isAdjustTransaction()) {
handler = this.applicationContext.getBean("fixedDepositTransactionAdjustmentCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isDepositAccountClose()) {
handler = this.applicationContext.getBean("closeDepositAccountCommandHandler", NewCommandSourceHandler.class);
handler = this.applicationContext.getBean("closeFixedDepositAccountCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isDepositAccountPrematureClose()) {
handler = this.applicationContext.getBean("prematureCloseDepositAccountCommandHandler", NewCommandSourceHandler.class);
handler = this.applicationContext.getBean("prematureCloseFixedDepositAccountCommandHandler", NewCommandSourceHandler.class);
} else {
throw new UnsupportedCommandException(wrapper.commandName());
}
} else if (wrapper.isRecurringDepositAccountResource()) {
if (wrapper.isCreate()) {
handler = this.applicationContext.getBean("recurringDepositAccountApplicationSubmittalCommandHandler",
NewCommandSourceHandler.class);
}else if (wrapper.isUpdate()) {
handler = this.applicationContext.getBean("recurringDepositAccountApplicationModificationCommandHandler",
NewCommandSourceHandler.class);
} else if (wrapper.isDelete()) {
handler = this.applicationContext.getBean("recurringDepositAccountApplicationDeletionCommandHandler",
NewCommandSourceHandler.class);
} else if (wrapper.isRejectionOfRecurringDepositAccountApplication()) {
handler = this.applicationContext.getBean("recurringDepositAccountApplicationRejectedCommandHandler",
NewCommandSourceHandler.class);
} else if (wrapper.isWithdrawRecurringDepositAccountApplicationByApplicant()) {
handler = this.applicationContext.getBean("recurringDepositAccountApplicationWithdrawnByApplicantCommandHandler",
NewCommandSourceHandler.class);
} else if (wrapper.isApprovalOfRecurringDepositAccountApplication()) {
handler = this.applicationContext.getBean("recurringDepositAccountApplicationApprovalCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isUndoApprovalOfRecurringDepositAccountApplication()) {
handler = this.applicationContext.getBean("recurringDepositAccountApplicationApprovalUndoCommandHandler",
NewCommandSourceHandler.class);
} else if (wrapper.isDeposit()) {
handler = this.applicationContext.getBean("recurringDepositAccountDepositCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isWithdrawal()) {
handler = this.applicationContext.getBean("withdrawalRecurringDepositAccountCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isActivation()) {
handler = this.applicationContext.getBean("activateRecurringDepositAccountCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isInterestCalculation()) {
handler = this.applicationContext.getBean("calculateInterestRecurringDepositAccountCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isInterestPosting()) {
handler = this.applicationContext.getBean("postInterestRecurringDepositAccountCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isUndoTransaction()) {
handler = this.applicationContext.getBean("undoTransactionRecurringDepositAccountCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isAdjustTransaction()) {
handler = this.applicationContext.getBean("recurringDepositTransactionAdjustmentCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isDepositAccountClose()) {
handler = this.applicationContext.getBean("closeRecurringDepositAccountCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isDepositAccountPrematureClose()) {
handler = this.applicationContext.getBean("prematureCloseRecurringDepositAccountCommandHandler", NewCommandSourceHandler.class);
} else {
throw new UnsupportedCommandException(wrapper.commandName());
}
@@ -34,4 +34,8 @@ public interface ConfigurationDomainService {
Long retrievePasswordLiveTime();
Long retrieveGraceOnPenaltyPostingPeriod();
Long ageLimitForSeniorCitizen();
Long ageLimitForChildren();
}
@@ -135,4 +135,19 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService
final GlobalConfigurationProperty property = this.globalConfigurationRepository.findOneByNameWithNotFoundDetection(propertyName);
return property.getValue();
}
@Override
public Long ageLimitForSeniorCitizen() {
final String propertyName = "age_limit_for_senior_citizen";
final GlobalConfigurationProperty property = this.globalConfigurationRepository.findOneByNameWithNotFoundDetection(propertyName);
return property.getValue();
}
@Override
public Long ageLimitForChildren() {
final String propertyName = "age_limit_for_children";
final GlobalConfigurationProperty property = this.globalConfigurationRepository.findOneByNameWithNotFoundDetection(propertyName);
return property.getValue();
}
}
@@ -21,7 +21,6 @@ import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper;
import org.mifosplatform.infrastructure.security.domain.BasicPasswordEncodablePlatformUser;
import org.mifosplatform.infrastructure.security.domain.PlatformUser;
import org.mifosplatform.infrastructure.security.service.PlatformPasswordEncoder;
import org.mifosplatform.portfolio.savings.DepositAccountType;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
@@ -49,35 +48,28 @@ public final class JsonCommand {
private final String transactionId;
private final String url;
private final Long productId;
private final Long interestRateChartId;
private final DepositAccountType depositAccountType;
public static JsonCommand from(final String jsonCommand, final JsonElement parsedCommand, final FromJsonHelper fromApiJsonHelper,
final String entityName, final Long resourceId, final Long subresourceId, final Long groupId, final Long clientId,
final Long loanId, final Long savingsId, final String transactionId, final String url, final Long productId,
final Long interestRateChartId, final DepositAccountType depositAccountType) {
final Long loanId, final Long savingsId, final String transactionId, final String url, final Long productId) {
return new JsonCommand(null, jsonCommand, parsedCommand, fromApiJsonHelper, entityName, resourceId, subresourceId, groupId,
clientId, loanId, savingsId, transactionId, url, productId, interestRateChartId, depositAccountType);
clientId, loanId, savingsId, transactionId, url, productId);
}
public static JsonCommand fromExistingCommand(final Long commandId, final String jsonCommand, final JsonElement parsedCommand,
final FromJsonHelper fromApiJsonHelper, final String entityName, final Long resourceId, final Long subresourceId,
final String url, final Long productId) {
final Long interestRateChartId = null;
final DepositAccountType depositAccountType = null;
return new JsonCommand(commandId, jsonCommand, parsedCommand, fromApiJsonHelper, entityName, resourceId, subresourceId, null, null,
null, null, null, url, productId, interestRateChartId, depositAccountType);
null, null, null, url, productId);
}
public static JsonCommand fromExistingCommand(final Long commandId, final String jsonCommand, final JsonElement parsedCommand,
final FromJsonHelper fromApiJsonHelper, final String entityName, final Long resourceId, final Long subresourceId,
final Long groupId, final Long clientId, final Long loanId, final Long savingsId, final String transactionId, final String url,
final Long productId) {
final Long interestRateChartId = null;
final DepositAccountType depositAccountType = null;
return new JsonCommand(commandId, jsonCommand, parsedCommand, fromApiJsonHelper, entityName, resourceId, subresourceId, groupId,
clientId, loanId, savingsId, transactionId, url, productId, interestRateChartId, depositAccountType);
clientId, loanId, savingsId, transactionId, url, productId);
}
@@ -85,13 +77,13 @@ public final class JsonCommand {
final String jsonCommand = command.fromApiJsonHelper.toJson(parsedCommand);
return new JsonCommand(command.commandId, jsonCommand, parsedCommand, command.fromApiJsonHelper, command.entityName,
command.resourceId, command.subresourceId, command.groupId, command.clientId, command.loanId, command.savingsId,
command.transactionId, command.url, command.productId, command.interestRateChartId, command.depositAccountType);
command.transactionId, command.url, command.productId);
}
public JsonCommand(final Long commandId, final String jsonCommand, final JsonElement parsedCommand,
final FromJsonHelper fromApiJsonHelper, final String entityName, final Long resourceId, final Long subresourceId,
final Long groupId, final Long clientId, final Long loanId, final Long savingsId, final String transactionId, final String url,
final Long productId, final Long interestRateChartId, final DepositAccountType depositAccountType) {
final Long productId) {
this.commandId = commandId;
this.jsonCommand = jsonCommand;
@@ -107,8 +99,6 @@ public final class JsonCommand {
this.transactionId = transactionId;
this.url = url;
this.productId = productId;
this.interestRateChartId = interestRateChartId;
this.depositAccountType = depositAccountType;
}
public String json() {
@@ -503,12 +493,5 @@ public final class JsonCommand {
public void checkForUnsupportedParameters(final Type typeOfMap, final String json, final Set<String> requestDataParameters) {
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, requestDataParameters);
}
public Long interestRateChartId() {
return this.interestRateChartId;
}
public DepositAccountType depositAccounttype() {
return this.depositAccountType;
}
}
@@ -32,14 +32,15 @@ public class AccountTransferDTO {
private final String noteText;
private final String txnExternalId;
private final Loan loan;
private final SavingsAccount savingsAccount;
private final SavingsAccount toSavingsAccount;
private final SavingsAccount fromSavingsAccount;
public AccountTransferDTO(final LocalDate transactionDate, final BigDecimal transactionAmount,
final PortfolioAccountType fromAccountType, final PortfolioAccountType toAccountType, final Long fromAccountId,
final Long toAccountId, final String description, final Locale locale, final DateTimeFormatter fmt,
final PaymentDetail paymentDetail, final Integer fromTransferType, final Integer toTransferType, final Long chargeId,
Integer loanInstallmentNumber, Integer transferType, final AccountTransferDetails accountTransferDetails,
final String noteText, final String txnExternalId, final Loan loan, SavingsAccount savingsAccount) {
final String noteText, final String txnExternalId, final Loan loan, SavingsAccount toSavingsAccount, final SavingsAccount fromSavingsAccount) {
this.transactionDate = transactionDate;
this.transactionAmount = transactionAmount;
this.fromAccountType = fromAccountType;
@@ -59,7 +60,8 @@ public class AccountTransferDTO {
this.noteText = noteText;
this.txnExternalId = txnExternalId;
this.loan = loan;
this.savingsAccount = savingsAccount;
this.toSavingsAccount = toSavingsAccount;
this.fromSavingsAccount = fromSavingsAccount;
}
public LocalDate getTransactionDate() {
@@ -138,8 +140,12 @@ public class AccountTransferDTO {
return this.loan;
}
public SavingsAccount getSavingsAccount() {
return this.savingsAccount;
public SavingsAccount getToSavingsAccount() {
return this.toSavingsAccount;
}
public SavingsAccount getFromSavingsAccount() {
return this.fromSavingsAccount;
}
}
@@ -13,17 +13,14 @@ import org.springframework.data.jpa.domain.AbstractPersistable;
@Table(name = "m_portfolio_account_associations")
public class AccountAssociations extends AbstractPersistable<Long> {
@SuppressWarnings("unused")
@ManyToOne
@JoinColumn(name = "loan_account_id", nullable = true)
private Loan loanAccount;
@SuppressWarnings("unused")
@ManyToOne
@JoinColumn(name = "savings_account_id", nullable = true)
private SavingsAccount savingsAccount;
@SuppressWarnings("unused")
@ManyToOne
@JoinColumn(name = "linked_loan_account_id", nullable = true)
private Loan linkedLoanAccount;
@@ -86,6 +86,10 @@ public class AccountTransferEnumerations {
optionData = new EnumOptionData(AccountTransferType.CHARGE_PAYMENT.getValue().longValue(),
AccountTransferType.CHARGE_PAYMENT.getCode(), "Charge Payment");
break;
case INTEREST_TRANSFER:
optionData = new EnumOptionData(AccountTransferType.INTEREST_TRANSFER.getValue().longValue(),
AccountTransferType.INTEREST_TRANSFER.getCode(), "Interest Transfer");
break;
}
}
return optionData;
@@ -274,11 +274,15 @@ public class AccountTransfersWritePlatformServiceImpl implements AccountTransfer
SavingsAccount fromSavingsAccount = null;
SavingsAccount toSavingsAccount = null;
if (accountTransferDetails == null) {
fromSavingsAccount = this.savingsAccountAssembler.assembleFrom(accountTransferDTO.getFromAccountId());
if (accountTransferDTO.getSavingsAccount() == null) {
if (accountTransferDTO.getFromSavingsAccount() == null) {
fromSavingsAccount = this.savingsAccountAssembler.assembleFrom(accountTransferDTO.getFromAccountId());
}else{
fromSavingsAccount = accountTransferDTO.getFromSavingsAccount();
}
if (accountTransferDTO.getToSavingsAccount() == null) {
toSavingsAccount = this.savingsAccountAssembler.assembleFrom(accountTransferDTO.getToAccountId());
} else {
toSavingsAccount = accountTransferDTO.getSavingsAccount();
toSavingsAccount = accountTransferDTO.getToSavingsAccount();
}
} else {
fromSavingsAccount = accountTransferDetails.fromSavingsAccount();
@@ -42,6 +42,7 @@ import org.mifosplatform.portfolio.account.exception.StandingInstructionNotFound
import org.mifosplatform.portfolio.common.domain.PeriodFrequencyType;
import org.mifosplatform.portfolio.loanaccount.loanschedule.domain.DefaultScheduledDateGenerator;
import org.mifosplatform.portfolio.loanaccount.loanschedule.domain.ScheduledDateGenerator;
import org.mifosplatform.portfolio.savings.domain.SavingsAccount;
import org.mifosplatform.portfolio.savings.exception.InsufficientAccountBalanceException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -213,11 +214,12 @@ public class StandingInstructionWritePlatformServiceImpl implements StandingInst
if (isDueForTransfer && transactionAmount != null && transactionAmount.compareTo(BigDecimal.ZERO) > 0) {
final AccountTransferDetails accountTransferDetails = this.accountTransferDetailRepository.findOne(data.accountDetailId());
final SavingsAccount fromSavingsAccount = null;
accountTransferDetails.accountTransferStandingInstruction().updateLatsRunDate(transactionDate.toDate());
AccountTransferDTO accountTransferDTO = new AccountTransferDTO(transactionDate, transactionAmount, data.fromAccountType(),
data.toAccountType(), data.fromAccount().accountId(), data.toAccount().accountId(), data.name()
+ " Standing instruction trasfer ", null, null, null, null, data.toTransferType(), null, null, data
.transferType().getValue(), accountTransferDetails, null, null, null, null);
.transferType().getValue(), accountTransferDetails, null, null, null, null, fromSavingsAccount);
transferAmount(sb, accountTransferDTO, data.getId());
}
}
@@ -236,6 +236,9 @@ public class CalendarsApiResource {
case LOANS:
resourceDetails.withLoanId(entityId);
break;
case SAVINGS:
resourceDetails.withSavingsId(entityId);
break;
case INVALID:
break;
}
@@ -326,4 +326,12 @@ public class CalendarData {
compareDate); }
return false;
}
public Integer interval(){
return this.interval;
}
public EnumOptionData frequencyType(){
return this.frequency;
}
}
@@ -128,6 +128,23 @@ public class Calendar extends AbstractAuditableCustom<AppUser, Long> {
this.secondReminder = secondReminder;
}
public static Calendar createRepeatingCalendar(final String title, final LocalDate startDate, final Integer typeId,
final CalendarFrequencyType frequencyType, final Integer interval, final Integer repeatsOnDay) {
final String description = null;
final String location = null;
final LocalDate endDate = null;
final Integer duration = null;
final boolean repeating = true;
final Integer remindById = null;
final Integer firstReminder = null;
final Integer secondReminder = null;
final String recurrence = constructRecurrence(frequencyType, interval, repeatsOnDay);
return new Calendar(title, description, location, startDate, endDate, duration, typeId, repeating, recurrence, remindById,
firstReminder, secondReminder);
}
public static Calendar fromJson(final JsonCommand command) {
// final Long entityId = command.getSupportedEntityId();
@@ -301,6 +318,25 @@ public class Calendar extends AbstractAuditableCustom<AppUser, Long> {
return actualChanges;
}
@SuppressWarnings("null")
public Map<String, Object> updateRepeatingCalendar(final LocalDate calendarStartDate, final CalendarFrequencyType frequencyType, final Integer interval, final Integer repeatsOnDay){
final Map<String, Object> actualChanges = new LinkedHashMap<String, Object>(9);
if(calendarStartDate != null & this.startDate != null){
if(!calendarStartDate.equals(this.getStartDateLocalDate())){
actualChanges.put("startDate", calendarStartDate);
this.startDate = calendarStartDate.toDate();
}
}
final String newRecurrence = Calendar.constructRecurrence(frequencyType, interval, repeatsOnDay);
if (!StringUtils.isBlank(this.recurrence) && !newRecurrence.equalsIgnoreCase(this.recurrence)) {
actualChanges.put("recurrence", newRecurrence);
this.recurrence = newRecurrence;
}
return actualChanges;
}
public String getTitle() {
return this.title;
@@ -419,29 +455,38 @@ public class Calendar extends AbstractAuditableCustom<AppUser, Long> {
}
if (repeating) {
final StringBuilder recurrenceBuilder = new StringBuilder(200);
final Integer frequency = command.integerValueOfParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.FREQUENCY.getValue());
final CalendarFrequencyType frequencyType = CalendarFrequencyType.fromInt(frequency);
recurrenceBuilder.append("FREQ=");
recurrenceBuilder.append(frequencyType.toString().toUpperCase());
final Integer interval = command.integerValueOfParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.INTERVAL.getValue());
if (interval > 1) {
recurrenceBuilder.append(";INTERVAL=");
recurrenceBuilder.append(interval);
}
Integer repeatsOnDay = null;
if (frequencyType.isWeekly()) {
final Integer repeatsOnDay = command.integerValueOfParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.REPEATS_ON_DAY.getValue());
final CalendarWeekDaysType weekDays = CalendarWeekDaysType.fromInt(repeatsOnDay);
if (!weekDays.isInvalid()) {
recurrenceBuilder.append(";BYDAY=");
recurrenceBuilder.append(weekDays.toString().toUpperCase());
}
repeatsOnDay = command.integerValueOfParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.REPEATS_ON_DAY.getValue());
}
return recurrenceBuilder.toString();
return constructRecurrence(frequencyType, interval, repeatsOnDay);
}
return "";
}
private static String constructRecurrence(final CalendarFrequencyType frequencyType, final Integer interval, final Integer repeatsOnDay) {
final StringBuilder recurrenceBuilder = new StringBuilder(200);
recurrenceBuilder.append("FREQ=");
recurrenceBuilder.append(frequencyType.toString().toUpperCase());
if (interval > 1) {
recurrenceBuilder.append(";INTERVAL=");
recurrenceBuilder.append(interval);
}
if (frequencyType.isWeekly()) {
final CalendarWeekDaysType weekDays = CalendarWeekDaysType.fromInt(repeatsOnDay);
if (!weekDays.isInvalid()) {
recurrenceBuilder.append(";BYDAY=");
recurrenceBuilder.append(weekDays.toString().toUpperCase());
}
}
return recurrenceBuilder.toString();
}
public boolean isValidRecurringDate(final LocalDate compareDate) {
if (isBetweenStartAndEndDate(compareDate)) { return CalendarUtils.isValidRedurringDate(getRecurrence(), getStartDateLocalDate(),
@@ -11,7 +11,7 @@ import java.util.Map;
public enum CalendarEntityType {
INVALID(0, "calendarEntityType.invalid"), CLIENTS(1, "calendarEntityType.clients"), GROUPS(2, "calendarEntityType.groups"), LOANS(3,
"calendarEntityType.loans"), CENTERS(4, "calendarEntityType.centers");
"calendarEntityType.loans"), CENTERS(4, "calendarEntityType.centers"), SAVINGS(5, "calendarEntityType.savings");
private final Integer value;
private final String code;
@@ -126,5 +126,17 @@ public enum CalendarEntityType {
public static CalendarEntityType getEntityType(String entityType) {
return entityNameToEnumMap.get(entityType.toLowerCase());
}
public static boolean isSavings(final Integer value) {
return CalendarEntityType.SAVINGS.value.equals(value) ? true : false;
}
public static boolean isSavings(final String name) {
return CalendarEntityType.SAVINGS.name().equalsIgnoreCase(name) ? true : false;
}
public boolean isSavings() {
return this.value.equals(CalendarEntityType.SAVINGS.getValue());
}
}
@@ -8,6 +8,7 @@ package org.mifosplatform.portfolio.calendar.domain;
import java.util.HashMap;
import java.util.Map;
import org.mifosplatform.portfolio.common.domain.PeriodFrequencyType;
import org.springframework.util.StringUtils;
public enum CalendarFrequencyType {
@@ -84,4 +85,44 @@ public enum CalendarFrequencyType {
public boolean isInvalid() {
return this.value.equals(CalendarFrequencyType.INVALID.value);
}
/** To convert from period frequency type tp calendar frequency type.
* This method requires code refactoring.
* @param periodFrequencyType
* @return
*/
public static CalendarFrequencyType from(final PeriodFrequencyType periodFrequencyType) {
switch (periodFrequencyType) {
case DAYS:
return CalendarFrequencyType.DAILY;
case WEEKS:
return CalendarFrequencyType.WEEKLY;
case MONTHS:
return CalendarFrequencyType.MONTHLY;
case YEARS:
return CalendarFrequencyType.YEARLY;
default:
return CalendarFrequencyType.INVALID;
}
}
/** To convert from period frequency type tp calendar frequency type.
* This method requires code refactoring.
* @param frequencyType
* @return
*/
public static PeriodFrequencyType from(final CalendarFrequencyType frequencyType) {
switch (frequencyType) {
case DAILY:
return PeriodFrequencyType.DAYS;
case WEEKLY:
return PeriodFrequencyType.WEEKS;
case MONTHLY:
return PeriodFrequencyType.MONTHS;
case YEARLY:
return PeriodFrequencyType.YEARS;
default:
return PeriodFrequencyType.INVALID;
}
}
}
@@ -5,6 +5,7 @@
*/
package org.mifosplatform.portfolio.calendar.domain;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
@@ -17,7 +18,7 @@ import org.springframework.data.jpa.domain.AbstractPersistable;
@Table(name = "m_calendar_instance")
public class CalendarInstance extends AbstractPersistable<Long> {
@ManyToOne
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "calendar_id", nullable = false)
private Calendar calendar;
@@ -37,7 +38,7 @@ public class CalendarInstance extends AbstractPersistable<Long> {
}
public static CalendarInstance fromJson(final Calendar calendar, final Long entityId, final Integer entityTypeId) {
public static CalendarInstance from(final Calendar calendar, final Long entityId, final Integer entityTypeId) {
return new CalendarInstance(calendar, entityId, entityTypeId);
}
@@ -8,17 +8,28 @@ package org.mifosplatform.portfolio.calendar.domain;
import java.util.Collection;
import java.util.List;
import org.mifosplatform.portfolio.group.domain.Group;
import org.mifosplatform.portfolio.loanaccount.domain.Loan;
import org.mifosplatform.portfolio.savings.domain.SavingsAccount;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import ch.qos.logback.core.net.server.Client;
public interface CalendarInstanceRepository extends JpaRepository<CalendarInstance, Long>, JpaSpecificationExecutor<CalendarInstance> {
CalendarInstance findByCalendarIdAndEntityIdAndEntityTypeId(Long calendarId, Long entityId, Integer entityTypeId);
Collection<CalendarInstance> findByEntityIdAndEntityTypeId(Long entityId, Integer entityTypeId);
/**
* @param entityId : Id of {@link Client}, {@link Group}, {@link Loan} or {@link SavingsAccount}.
* @param entityTypeId: {@link CalendarEntityType}
* @param calendarTypeId: {@link CalendarType}
* @return
*/
CalendarInstance findByEntityIdAndEntityTypeIdAndCalendarTypeId(Long entityId, Integer entityTypeId, Integer calendarTypeId);
@Query("from CalendarInstance ci where ci.entityId = :loanId and ci.entityTypeId = :entityTypeId")
@@ -138,7 +138,7 @@ public class CalendarWritePlatformServiceJpaRepositoryImpl implements CalendarWr
this.calendarRepository.save(newCalendar);
final CalendarInstance newCalendarInstance = CalendarInstance.fromJson(newCalendar, entityId, entityTypeId);
final CalendarInstance newCalendarInstance = CalendarInstance.from(newCalendar, entityId, entityTypeId);
this.calendarInstanceRepository.save(newCalendarInstance);
return new CommandProcessingResultBuilder() //
@@ -65,11 +65,9 @@ final public class ClientData implements Comparable<ClientData> {
// template
private final Collection<OfficeData> officeOptions;
private final Collection<StaffData> staffOptions;
@SuppressWarnings("unused")
private final Collection<CodeValueData> closureReasons;
private final Collection<SavingsProductData> savingProductOptions;
private final Collection<SavingsAccountData> savingAccountOptions;
@SuppressWarnings("unused")
private final Collection<CodeValueData> genderOptions;
public static ClientData template(final Long officeId, final LocalDate joinedDate, final Collection<OfficeData> officeOptions,
@@ -87,7 +85,7 @@ final public class ClientData implements Comparable<ClientData> {
clientData.transferToOfficeId, clientData.transferToOfficeName, clientData.id, clientData.firstname, clientData.middlename,
clientData.lastname, clientData.fullname, clientData.displayName, clientData.externalId, clientData.mobileNo,
clientData.dateOfBirth, clientData.gender, clientData.activationDate, clientData.imageId, clientData.staffId,
clientData.staffName, templateData.officeOptions, clientData.groups, templateData.staffOptions, null, null, null,
clientData.staffName, templateData.officeOptions, clientData.groups, templateData.staffOptions, templateData.closureReasons, templateData.genderOptions, clientData.timeline,
templateData.savingProductOptions, clientData.savingsProductId, clientData.savingsProductName, clientData.savingsAccountId,
clientData.savingAccountOptions);
@@ -32,6 +32,7 @@ import org.apache.commons.lang.StringUtils;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.joda.time.LocalDate;
import org.joda.time.Years;
import org.joda.time.format.DateTimeFormatter;
import org.mifosplatform.infrastructure.codes.domain.CodeValue;
import org.mifosplatform.infrastructure.core.api.JsonCommand;
@@ -45,6 +46,7 @@ import org.mifosplatform.organisation.office.domain.Office;
import org.mifosplatform.organisation.staff.domain.Staff;
import org.mifosplatform.portfolio.client.api.ClientApiConstants;
import org.mifosplatform.portfolio.group.domain.Group;
import org.mifosplatform.portfolio.interestratechart.data.ClientIncentiveAttributes;
import org.mifosplatform.portfolio.savings.domain.SavingsAccount;
import org.mifosplatform.portfolio.savings.domain.SavingsProduct;
import org.mifosplatform.useradministration.domain.AppUser;
@@ -157,6 +159,9 @@ public final class Client extends AbstractPersistable<Long> {
@JoinColumn(name = "default_savings_account", nullable = true)
private SavingsAccount savingsAccount;
@Transient
private ClientIncentiveAttributes incentiveAttributes;
public static Client createNew(final AppUser currentUser, final Office clientOffice, final Group clientParentGroup, final Staff staff,
final SavingsProduct savingsProduct, final CodeValue gender, final JsonCommand command) {
@@ -272,7 +277,7 @@ public final class Client extends AbstractPersistable<Long> {
this.savingsProduct = savingsProduct;
this.savingsAccount = savingsAccount;
if(gender != null){
if (gender != null) {
this.gender = gender;
}
if (dateOfBirth != null) {
@@ -692,4 +697,41 @@ public final class Client extends AbstractPersistable<Long> {
public void updateSavingsAccount(SavingsAccount savingsAccount) {
this.savingsAccount = savingsAccount;
}
public ClientIncentiveAttributes incentiveAttributes() {
return this.incentiveAttributes;
}
public void updateIncentiveAttributes(final Long ageLimitForChildren, final Long ageLimitForSeniorCitizen, final LocalDate compareOnDate) {
boolean isFemale = false;
boolean isChild = false;
boolean isSeniorCitizen = false;
if (this.gender != null) {
// FIXME: this needs to be handled in better way
if (this.gender.label().equalsIgnoreCase("FEMALE")) {
isFemale = true;
}
}
if (this.dateOfBirth != null) {
final LocalDate dobLacalDate = LocalDate.fromDateFields(this.dateOfBirth);
final int age = Years.yearsBetween(dobLacalDate, compareOnDate).getYears();
if (age >= ageLimitForSeniorCitizen.intValue()) {
isSeniorCitizen = true;
}
if (age <= ageLimitForChildren.intValue()) {
isChild = true;
}
}
this.incentiveAttributes = ClientIncentiveAttributes.instance(isFemale, isChild, isSeniorCitizen);
}
public CodeValue gender() {
return this.gender;
}
}
@@ -20,6 +20,7 @@ public class CollectionSheetConstants {
public static final String actualDisbursementDateParamName = "actualDisbursementDate";
public static final String bulkRepaymentTransactionsParamName = "bulkRepaymentTransactions";
public static final String bulkDisbursementTransactionsParamName = "bulkDisbursementTransactions";
public static final String bulkSavingsDueTransactionsParamName = "bulkSavingsDueTransactions";
public static final String noteParamName = "note";
public static final String calendarIdParamName = "calendarId";
@@ -29,9 +30,10 @@ public class CollectionSheetConstants {
public static final String attendanceTypeParamName = "attendanceType";
public static final String loanIdParamName = "loanId";
public static final String savingsIdParamName = "savingsId";
public static final String transactionAmountParamName = "transactionAmount";
public static final Set<String> COLLECTIONSHEET_REQUEST_DATA_PARAMETERS = new HashSet<String>(Arrays.asList(localeParamName,
dateFormatParamName, transactionDateParamName, actualDisbursementDateParamName, bulkRepaymentTransactionsParamName,
bulkDisbursementTransactionsParamName, noteParamName, calendarIdParamName, clientsAttendanceParamName));
bulkDisbursementTransactionsParamName, noteParamName, calendarIdParamName, clientsAttendanceParamName, bulkSavingsDueTransactionsParamName));
}
@@ -10,10 +10,12 @@ import static org.mifosplatform.portfolio.collectionsheet.CollectionSheetConstan
import static org.mifosplatform.portfolio.collectionsheet.CollectionSheetConstants.attendanceTypeParamName;
import static org.mifosplatform.portfolio.collectionsheet.CollectionSheetConstants.bulkDisbursementTransactionsParamName;
import static org.mifosplatform.portfolio.collectionsheet.CollectionSheetConstants.bulkRepaymentTransactionsParamName;
import static org.mifosplatform.portfolio.collectionsheet.CollectionSheetConstants.bulkSavingsDueTransactionsParamName;
import static org.mifosplatform.portfolio.collectionsheet.CollectionSheetConstants.calendarIdParamName;
import static org.mifosplatform.portfolio.collectionsheet.CollectionSheetConstants.clientIdParamName;
import static org.mifosplatform.portfolio.collectionsheet.CollectionSheetConstants.clientsAttendanceParamName;
import static org.mifosplatform.portfolio.collectionsheet.CollectionSheetConstants.loanIdParamName;
import static org.mifosplatform.portfolio.collectionsheet.CollectionSheetConstants.savingsIdParamName;
import static org.mifosplatform.portfolio.collectionsheet.CollectionSheetConstants.noteParamName;
import static org.mifosplatform.portfolio.collectionsheet.CollectionSheetConstants.transactionAmountParamName;
import static org.mifosplatform.portfolio.collectionsheet.CollectionSheetConstants.transactionDateParamName;
@@ -80,6 +82,8 @@ public class CollectionSheetTransactionDataValidator {
validateDisbursementTransactions(element, baseDataValidator);
validateRepaymentTransactions(element, baseDataValidator);
validateSavingsDueTransactions(element, baseDataValidator);
throwExceptionIfValidationWarningsExist(dataValidationErrors);
}
@@ -147,8 +151,31 @@ public class CollectionSheetTransactionDataValidator {
}
}
}
private void validateSavingsDueTransactions(final JsonElement element, final DataValidatorBuilder baseDataValidator) {
final JsonObject topLevelJsonElement = element.getAsJsonObject();
final Locale locale = this.fromApiJsonHelper.extractLocaleParameter(topLevelJsonElement);
if (element.isJsonObject()) {
if (topLevelJsonElement.has(bulkSavingsDueTransactionsParamName)
&& topLevelJsonElement.get(bulkSavingsDueTransactionsParamName).isJsonArray()) {
final JsonArray array = topLevelJsonElement.get(bulkSavingsDueTransactionsParamName).getAsJsonArray();
for (int i = 0; i < array.size(); i++) {
final JsonObject savingsTransactionElement = array.get(i).getAsJsonObject();
final Long savingsId = this.fromApiJsonHelper.extractLongNamed(savingsIdParamName, savingsTransactionElement);
final BigDecimal dueAmount = this.fromApiJsonHelper.extractBigDecimalNamed(transactionAmountParamName,
savingsTransactionElement, locale);
baseDataValidator.reset().parameter("bulktransaction" + "[" + i + "].savings.id").value(savingsId).notNull()
.integerGreaterThanZero();
baseDataValidator.reset().parameter("bulktransaction" + "[" + i + "].due.amount").value(dueAmount)
.notNull().zeroOrPositiveAmount();
}
}
}
}
private void throwExceptionIfValidationWarningsExist(final List<ApiParameterError> dataValidationErrors) {
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
}
}
}
@@ -18,21 +18,50 @@ public class JLGClientData {
private final Long clientId;
private final String clientName;
private Collection<LoanDueData> loans;
private Collection<SavingsDueData> savings;
@SuppressWarnings("unused")
private final EnumOptionData attendanceType;
public JLGClientData(final Long clientId, final String clientName, final Collection<LoanDueData> loans,
public static JLGClientData instance(final Long clientId, final String clientName, final EnumOptionData attendanceType){
final Collection<LoanDueData> loans = null;
final Collection<SavingsDueData> savings = null;
return new JLGClientData(clientId, clientName, loans, savings, attendanceType);
}
public static JLGClientData withSavings(final JLGClientData client, final Collection<SavingsDueData> savings){
final Collection<LoanDueData> loans = null;
final EnumOptionData attendanceType = null;
return new JLGClientData(client.clientId, client.clientName, loans, savings, attendanceType);
}
/*public JLGClientData(final Long clientId, final String clientName, final Collection<LoanDueData> loans,
final EnumOptionData attendanceType) {
this.clientId = clientId;
this.clientName = clientName;
this.loans = loans;
this.attendanceType = attendanceType;
}
}*/
public JLGClientData(final Long clientId, final String clientName, final EnumOptionData attendanceType) {
public static JLGClientData withAttendance(final Long clientId, final String clientName, final EnumOptionData attendanceType) {
final Collection<LoanDueData> loans = null;
final Collection<SavingsDueData> savings = null;
return new JLGClientData(clientId, clientName, loans, savings, attendanceType);
}
/**
* @param clientId
* @param clientName
* @param loans
* @param savings
* @param attendanceType
*/
private JLGClientData(Long clientId, String clientName, Collection<LoanDueData> loans, Collection<SavingsDueData> savings,
EnumOptionData attendanceType) {
this.clientId = clientId;
this.clientName = clientName;
this.loans = null;
this.loans = loans;
this.savings = savings;
this.attendanceType = attendanceType;
}
@@ -51,4 +80,24 @@ public class JLGClientData {
public void setLoans(final Collection<LoanDueData> loans) {
this.loans = loans;
}
public Collection<SavingsDueData> getSavings() {
return this.savings;
}
public void setSavings(Collection<SavingsDueData> savings) {
this.savings = savings;
}
@Override
public boolean equals(final Object obj) {
final JLGClientData clientData = (JLGClientData) obj;
return clientData.clientId.compareTo(this.clientId) == 0;
}
@Override
public int hashCode() {
return this.clientId.hashCode();
}
}
@@ -11,6 +11,7 @@ import java.util.List;
import org.joda.time.LocalDate;
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
import org.mifosplatform.portfolio.loanproduct.data.LoanProductData;
import org.mifosplatform.portfolio.savings.data.SavingsProductData;
/**
* Immutable data object for join liability group's collection sheet.
@@ -19,14 +20,27 @@ public class JLGCollectionSheetData {
private final LocalDate dueDate;
private final Collection<LoanProductData> loanProducts;
private final Collection<JLGGroupData> groups;
@SuppressWarnings("unused")
private final Collection<SavingsProductData> savingsProducts;
private final Collection<JLGGroupData> groups;
private final List<EnumOptionData> attendanceTypeOptions;
public JLGCollectionSheetData(final LocalDate date, final Collection<LoanProductData> loanProducts,
public static JLGCollectionSheetData instance(final LocalDate date, final Collection<LoanProductData> loanProducts,
final Collection<JLGGroupData> groups, final List<EnumOptionData> attendanceTypeOptions) {
this.dueDate = date;
return new JLGCollectionSheetData(date, loanProducts, null, groups, attendanceTypeOptions);
}
public static JLGCollectionSheetData withSavingsProducts(final JLGCollectionSheetData data,
final Collection<SavingsProductData> savingsProducts) {
return new JLGCollectionSheetData(data.dueDate, data.loanProducts, savingsProducts, data.groups, data.attendanceTypeOptions);
}
private JLGCollectionSheetData(LocalDate dueDate, Collection<LoanProductData> loanProducts,
Collection<SavingsProductData> savingsProducts, Collection<JLGGroupData> groups, List<EnumOptionData> attendanceTypeOptions) {
this.dueDate = dueDate;
this.loanProducts = loanProducts;
this.savingsProducts = savingsProducts;
this.groups = groups;
this.attendanceTypeOptions = attendanceTypeOptions;
}
@@ -42,4 +56,5 @@ public class JLGCollectionSheetData {
public Collection<LoanProductData> getLoanProducts() {
return this.loanProducts;
}
}
@@ -153,12 +153,12 @@ public class JLGCollectionSheetFlatData {
}
public JLGClientData getClientData() {
return new JLGClientData(this.clientId, this.clientName, this.attendanceType);
return JLGClientData.withAttendance(this.clientId, this.clientName, this.attendanceType);
}
public JLGGroupData getJLGGroupData() {
return new JLGGroupData(this.groupId, this.groupName, this.staffId, this.staffName, this.levelId, this.levelName);
return JLGGroupData.instance(this.groupId, this.groupName, this.staffId, this.staffName, this.levelId, this.levelName);
}
}
@@ -21,14 +21,24 @@ public class JLGGroupData {
private final String levelName;
private Collection<JLGClientData> clients;
public JLGGroupData(final Long groupId, final String groupName, final Long staffId, final String staffName, final Long levelId,
final String levelName) {
public static JLGGroupData instance(final Long groupId, final String groupName, final Long staffId, final String staffName, final Long levelId,
final String levelName){
return new JLGGroupData(groupId, groupName, staffId, staffName, levelId, levelName, null);
}
public static JLGGroupData withClients(final JLGGroupData group, Collection<JLGClientData> clients){
return new JLGGroupData(group.groupId, group.groupName, group.staffId, group.staffName, group.levelId, group.levelName, clients);
}
private JLGGroupData(final Long groupId, final String groupName, final Long staffId, final String staffName, final Long levelId,
final String levelName, final Collection<JLGClientData> clients) {
this.groupId = groupId;
this.groupName = groupName;
this.staffId = staffId;
this.staffName = staffName;
this.levelId = levelId;
this.levelName = levelName;
this.clients = clients;
}
public Long getGroupId() {
@@ -62,4 +72,15 @@ public class JLGGroupData {
public void setClients(final Collection<JLGClientData> clients) {
this.clients = clients;
}
@Override
public boolean equals(final Object obj) {
final JLGGroupData groupData = (JLGGroupData) obj;
return groupData.groupId.compareTo(this.groupId) == 0;
}
@Override
public int hashCode() {
return this.groupId.hashCode();
}
}
@@ -0,0 +1,55 @@
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.mifosplatform.portfolio.collectionsheet.data;
import java.math.BigDecimal;
import org.mifosplatform.organisation.monetary.data.CurrencyData;
/**
* Immutable data object for representing loan with dues (example: loan is due
* for disbursement, repayments).
*/
public class SavingsDueData {
@SuppressWarnings("unused")
private final Long savingsId;
@SuppressWarnings("unused")
private final String accountId;
@SuppressWarnings("unused")
private final Integer accountStatusId;
private final String productName;
private final Long productId;
@SuppressWarnings("unused")
private final CurrencyData currency;
@SuppressWarnings("unused")
private BigDecimal dueAmount = BigDecimal.ZERO;
public static SavingsDueData instance(final Long savingsId, final String accountId, final Integer accountStatusId,
final String productName, final Long productId, final CurrencyData currency, final BigDecimal dueAmount) {
return new SavingsDueData(savingsId, accountId, accountStatusId, productName, productId, currency, dueAmount);
}
private SavingsDueData(final Long savingsId, final String accountId, final Integer accountStatusId, final String productName,
final Long productId, final CurrencyData currency, final BigDecimal dueAmount) {
this.savingsId = savingsId;
this.accountId = accountId;
this.accountStatusId = accountStatusId;
this.productName = productName;
this.productId = productId;
this.currency = currency;
this.dueAmount = dueAmount;
}
public String productName() {
return this.productName;
}
public Long productId() {
return this.productId;
}
}
@@ -35,6 +35,7 @@ import org.mifosplatform.portfolio.collectionsheet.data.JLGCollectionSheetData;
import org.mifosplatform.portfolio.collectionsheet.data.JLGCollectionSheetFlatData;
import org.mifosplatform.portfolio.collectionsheet.data.JLGGroupData;
import org.mifosplatform.portfolio.collectionsheet.data.LoanDueData;
import org.mifosplatform.portfolio.collectionsheet.data.SavingsDueData;
import org.mifosplatform.portfolio.collectionsheet.serialization.CollectionSheetGenerateCommandFromApiJsonDeserializer;
import org.mifosplatform.portfolio.group.data.CenterData;
import org.mifosplatform.portfolio.group.data.GroupGeneralData;
@@ -43,8 +44,11 @@ import org.mifosplatform.portfolio.group.service.GroupReadPlatformService;
import org.mifosplatform.portfolio.loanproduct.data.LoanProductData;
import org.mifosplatform.portfolio.meeting.attendance.service.AttendanceDropdownReadPlatformService;
import org.mifosplatform.portfolio.meeting.attendance.service.AttendanceEnumerations;
import org.mifosplatform.portfolio.savings.data.SavingsProductData;
import org.mifosplatform.useradministration.domain.AppUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.ResultSetExtractor;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
@@ -61,6 +65,7 @@ public class CollectionSheetReadPlatformServiceImpl implements CollectionSheetRe
private final CollectionSheetGenerateCommandFromApiJsonDeserializer collectionSheetGenerateCommandFromApiJsonDeserializer;
private final CalendarRepositoryWrapper calendarRepositoryWrapper;
private final AttendanceDropdownReadPlatformService attendanceDropdownReadPlatformService;
final MandatorySavingsCollectionsheetExtractor mandatorySavingsExtractor = new MandatorySavingsCollectionsheetExtractor();
@Autowired
public CollectionSheetReadPlatformServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource,
@@ -162,7 +167,7 @@ public class CollectionSheetReadPlatformServiceImpl implements CollectionSheetRe
jlgGroupsData.add(jlgGroupData);
}
jlgCollectionSheetData = new JLGCollectionSheetData(dueDate, loanProducts, jlgGroupsData,
jlgCollectionSheetData = JLGCollectionSheetData.instance(dueDate, loanProducts, jlgGroupsData,
this.attendanceDropdownReadPlatformService.retrieveAttendanceTypeOptions());
}
@@ -296,8 +301,6 @@ public class CollectionSheetReadPlatformServiceImpl implements CollectionSheetRe
final JLGCollectionSheetFaltDataMapper mapper = new JLGCollectionSheetFaltDataMapper();
final StringBuilder sql = new StringBuilder(mapper.collectionSheetSchema(false));
// entityType should be center if it's within a center
final CalendarEntityType entityType = (group.isChildGroup()) ? CalendarEntityType.CENTERS : CalendarEntityType.GROUPS;
@@ -305,10 +308,81 @@ public class CollectionSheetReadPlatformServiceImpl implements CollectionSheetRe
.addValue("groupId", group.getId()).addValue("officeHierarchy", officeHierarchy)
.addValue("entityTypeId", entityType.getValue());
final Collection<JLGCollectionSheetFlatData> collectionSheetFlatDatas = this.namedParameterjdbcTemplate.query(sql.toString(),
namedParameters, mapper);
final Collection<JLGCollectionSheetFlatData> collectionSheetFlatDatas = this.namedParameterjdbcTemplate.query(
mapper.collectionSheetSchema(false), namedParameters, mapper);
return buildJLGCollectionSheet(transactionDate, collectionSheetFlatDatas);
// loan data for collection sheet
JLGCollectionSheetData collectionSheetData = buildJLGCollectionSheet(transactionDate, collectionSheetFlatDatas);
// mandatory savings data for collection sheet
Collection<JLGGroupData> groupsWithSavingsData = this.namedParameterjdbcTemplate.query(
mandatorySavingsExtractor.collectionSheetSchema(false), namedParameters, mandatorySavingsExtractor);
// merge savings data into loan data
mergeSavingsGroupDataIntoCollectionsheetData(groupsWithSavingsData, collectionSheetData);
collectionSheetData = JLGCollectionSheetData.withSavingsProducts(collectionSheetData,
retrieveSavingsProducts(groupsWithSavingsData));
return collectionSheetData;
}
private void mergeSavingsGroupDataIntoCollectionsheetData(final Collection<JLGGroupData> groupsWithSavingsData,
final JLGCollectionSheetData collectionSheetData) {
final List<JLGGroupData> groupsWithLoanData = (List<JLGGroupData>) collectionSheetData.getGroups();
for (JLGGroupData groupSavingsData : groupsWithSavingsData) {
if (groupsWithLoanData.contains(groupSavingsData)) {
mergeGroup(groupSavingsData, groupsWithLoanData);
} else {
groupsWithLoanData.add(groupSavingsData);
}
}
}
private void mergeGroup(final JLGGroupData groupSavingsData, final List<JLGGroupData> groupsWithLoanData) {
final int index = groupsWithLoanData.indexOf(groupSavingsData);
if (index < 0) return;
JLGGroupData groupLoanData = groupsWithLoanData.get(index);
List<JLGClientData> clientsLoanData = (List<JLGClientData>) groupLoanData.getClients();
List<JLGClientData> clientsSavingsData = (List<JLGClientData>) groupSavingsData.getClients();
for (JLGClientData clientSavingsData : clientsSavingsData) {
if (clientsLoanData.contains(clientSavingsData)) {
mergeClient(clientSavingsData, clientsLoanData);
} else {
clientsLoanData.add(clientSavingsData);
}
}
}
private void mergeClient(final JLGClientData clientSavingsData, List<JLGClientData> clientsLoanData) {
final int index = clientsLoanData.indexOf(clientSavingsData);
if (index < 0) return;
JLGClientData clientLoanData = clientsLoanData.get(index);
clientLoanData.setSavings(clientSavingsData.getSavings());
}
private Collection<SavingsProductData> retrieveSavingsProducts(Collection<JLGGroupData> groupsWithSavingsData) {
List<SavingsProductData> savingsProducts = new ArrayList<SavingsProductData>();
for (JLGGroupData groupSavingsData : groupsWithSavingsData) {
Collection<JLGClientData> clientsSavingsData = groupSavingsData.getClients();
for (JLGClientData clientSavingsData : clientsSavingsData) {
Collection<SavingsDueData> savingsDatas = clientSavingsData.getSavings();
for (SavingsDueData savingsDueData : savingsDatas) {
final SavingsProductData savingsProduct = SavingsProductData.lookup(savingsDueData.productId(),
savingsDueData.productName());
if (!savingsProducts.contains(savingsProduct)) {
savingsProducts.add(savingsProduct);
}
}
}
}
return savingsProducts;
}
@Override
@@ -337,6 +411,204 @@ public class CollectionSheetReadPlatformServiceImpl implements CollectionSheetRe
final Collection<JLGCollectionSheetFlatData> collectionSheetFlatDatas = this.namedParameterjdbcTemplate.query(sql.toString(),
namedParameters, mapper);
return buildJLGCollectionSheet(transactionDate, collectionSheetFlatDatas);
// loan data for collection sheet
JLGCollectionSheetData collectionSheetData = buildJLGCollectionSheet(transactionDate, collectionSheetFlatDatas);
// mandatory savings data for collection sheet
Collection<JLGGroupData> groupsWithSavingsData = this.namedParameterjdbcTemplate.query(
mandatorySavingsExtractor.collectionSheetSchema(true), namedParameters, mandatorySavingsExtractor);
// merge savings data into loan data
mergeSavingsGroupDataIntoCollectionsheetData(groupsWithSavingsData, collectionSheetData);
collectionSheetData = JLGCollectionSheetData.withSavingsProducts(collectionSheetData,
retrieveSavingsProducts(groupsWithSavingsData));
return collectionSheetData;
}
private static final class MandatorySavingsCollectionsheetExtractor implements ResultSetExtractor<Collection<JLGGroupData>> {
private GroupSavingsDataMapper groupSavingsDataMapper = new GroupSavingsDataMapper();
public String collectionSheetSchema(final boolean isCenterCollection) {
final StringBuffer sql = new StringBuffer(400);
sql.append("SELECT gp.display_name As groupName, ")
.append("gp.id As groupId, ")
.append("cl.display_name As clientName, ")
.append("cl.id As clientId, ")
.append("sf.id As staffId, ")
.append("sf.display_name As staffName, ")
.append("gl.id As levelId, ")
.append("gl.level_name As levelName, ")
.append("sa.id As savingsId, ")
.append("sa.account_no As accountId, ")
.append("sa.status_enum As accountStatusId, ")
.append("sp.short_name As productShortName, ")
.append("sp.id As productId, ")
.append("sa.currency_code as currencyCode, ")
.append("sa.currency_digits as currencyDigits, ")
.append("sa.currency_multiplesof as inMultiplesOf, ")
.append("rc.`name` as currencyName, ")
.append("rc.display_symbol as currencyDisplaySymbol, ")
.append("rc.internationalized_name_code as currencyNameCode, ")
.append("sum(ifnull(mss.deposit_amount,0) - ifnull(mss.deposit_amount_completed_derived,0)) as dueAmount ")
.append("FROM m_group gp ")
.append("LEFT JOIN m_office of ON of.id = gp.office_id AND of.hierarchy like :officeHierarchy ")
.append("JOIN m_group_level gl ON gl.id = gp.level_Id ")
.append("LEFT JOIN m_staff sf ON sf.id = gp.staff_id ")
.append("JOIN m_group_client gc ON gc.group_id = gp.id ")
.append("JOIN m_client cl ON cl.id = gc.client_id ")
.append("JOIN m_savings_account sa ON sa.client_id=cl.id and sa.status_enum=300 ")
.append("JOIN m_savings_product sp ON sa.product_id=sp.id ")
.append("JOIN m_deposit_account_recurring_detail dard ON sa.id = dard.savings_account_id AND dard.is_mandatory = true AND dard.is_calendar_inherited = true ")
.append("JOIN m_mandatory_savings_schedule mss ON mss.savings_account_id=sa.id AND mss.duedate <= :dueDate ")
.append("LEFT JOIN m_currency rc on rc.`code` = sa.currency_code ");
if (isCenterCollection) {
sql.append("WHERE gp.parent_id = :centerId ");
} else {
sql.append("WHERE gp.id = :groupId ");
}
sql.append("and (gp.status_enum = 300 or (gp.status_enum = 600 and gp.closedon_date >= :dueDate)) ")
.append("and (cl.status_enum = 300 or (cl.status_enum = 600 and cl.closedon_date >= :dueDate)) ")
.append("GROUP BY gp.id ,cl.id , sa.id ORDER BY gp.id , cl.id , sa.id ");
return sql.toString();
}
@Override
public Collection<JLGGroupData> extractData(ResultSet rs) throws SQLException, DataAccessException {
List<JLGGroupData> groups = new ArrayList<JLGGroupData>();
JLGGroupData group = null;
int groupIndex = 0;
boolean isEndOfRecords = false;
// move cursor to first row.
rs.next();
while (!isEndOfRecords) {
group = groupSavingsDataMapper.mapRowData(rs, groupIndex++);
groups.add(group);
isEndOfRecords = rs.isAfterLast();
}
return groups;
}
}
private static final class GroupSavingsDataMapper implements RowMapper<JLGGroupData> {
private ClientSavingsDataMapper clientSavingsDataMapper = new ClientSavingsDataMapper();
private GroupSavingsDataMapper() {}
public JLGGroupData mapRowData(ResultSet rs, int rowNum) throws SQLException {
final List<JLGClientData> clients = new ArrayList<JLGClientData>();
final JLGGroupData group = this.mapRow(rs, rowNum);
final Long previousGroupId = group.getGroupId();
// first client row of new group
JLGClientData client = clientSavingsDataMapper.mapRowData(rs, rowNum);
clients.add(client);
//if its not after last row loop
while (!rs.isAfterLast()) {
final Long groupId = JdbcSupport.getLong(rs, "groupId");
if (previousGroupId != null && groupId.compareTo(previousGroupId) != 0) {
// return for next group details
return JLGGroupData.withClients(group, clients);
}
client = clientSavingsDataMapper.mapRowData(rs, rowNum);
clients.add(client);
}
return JLGGroupData.withClients(group, clients);
}
@Override
public JLGGroupData mapRow(ResultSet rs, @SuppressWarnings("unused") int rowNum) throws SQLException {
final String groupName = rs.getString("groupName");
final Long groupId = JdbcSupport.getLong(rs, "groupId");
final Long staffId = JdbcSupport.getLong(rs, "staffId");
final String staffName = rs.getString("staffName");
final Long levelId = JdbcSupport.getLong(rs, "levelId");
final String levelName = rs.getString("levelName");
return JLGGroupData.instance(groupId, groupName, staffId, staffName, levelId, levelName);
}
}
private static final class ClientSavingsDataMapper implements RowMapper<JLGClientData> {
private SavingsDueDataMapper savingsDueDataMapper = new SavingsDueDataMapper();
private ClientSavingsDataMapper() {}
public JLGClientData mapRowData(ResultSet rs, int rowNum) throws SQLException {
List<SavingsDueData> savings = new ArrayList<SavingsDueData>();
JLGClientData client = this.mapRow(rs, rowNum);
final Long previousClientId = client.getClientId();
// first savings row of new client record
SavingsDueData saving = savingsDueDataMapper.mapRow(rs, rowNum);
savings.add(saving);
while (rs.next()) {
final Long clientId = JdbcSupport.getLong(rs, "clientId");
if (previousClientId != null && clientId.compareTo(previousClientId) != 0) {
// client id changes then return for next client data
return JLGClientData.withSavings(client, savings);
}
saving = savingsDueDataMapper.mapRow(rs, rowNum);
savings.add(saving);
}
return JLGClientData.withSavings(client, savings);
}
@Override
public JLGClientData mapRow(ResultSet rs, @SuppressWarnings("unused") int rowNum) throws SQLException {
final String clientName = rs.getString("clientName");
final Long clientId = JdbcSupport.getLong(rs, "clientId");
// final Integer attendanceTypeId = rs.getInt("attendanceTypeId");
// final EnumOptionData attendanceType =
// AttendanceEnumerations.attendanceType(attendanceTypeId);
final EnumOptionData attendanceType = null;
return JLGClientData.instance(clientId, clientName, attendanceType);
}
}
private static final class SavingsDueDataMapper implements RowMapper<SavingsDueData> {
private SavingsDueDataMapper() {}
@Override
public SavingsDueData mapRow(ResultSet rs, @SuppressWarnings("unused") int rowNum) throws SQLException {
final Long savingsId = rs.getLong("savingsId");
final String accountId = rs.getString("accountId");
final Integer accountStatusId = JdbcSupport.getInteger(rs, "accountStatusId");
final String productName = rs.getString("productShortName");
final Long productId = rs.getLong("productId");
final BigDecimal dueAmount = rs.getBigDecimal("dueAmount");
final String currencyCode = rs.getString("currencyCode");
final String currencyName = rs.getString("currencyName");
final String currencyNameCode = rs.getString("currencyNameCode");
final String currencyDisplaySymbol = rs.getString("currencyDisplaySymbol");
final Integer currencyDigits = JdbcSupport.getInteger(rs, "currencyDigits");
final Integer inMultiplesOf = JdbcSupport.getInteger(rs, "inMultiplesOf");
// currency
final CurrencyData currency = new CurrencyData(currencyCode, currencyName, currencyDigits, inMultiplesOf,
currencyDisplaySymbol, currencyNameCode);
return SavingsDueData.instance(savingsId, accountId, accountStatusId, productName, productId, currency, dueAmount);
}
}
}
@@ -5,6 +5,7 @@
*/
package org.mifosplatform.portfolio.collectionsheet.service;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
@@ -19,6 +20,9 @@ import org.mifosplatform.portfolio.collectionsheet.serialization.CollectionSheet
import org.mifosplatform.portfolio.collectionsheet.serialization.CollectionSheetBulkRepaymentCommandFromApiJsonDeserializer;
import org.mifosplatform.portfolio.loanaccount.service.LoanWritePlatformService;
import org.mifosplatform.portfolio.meeting.service.MeetingWritePlatformService;
import org.mifosplatform.portfolio.savings.data.SavingsAccountTransactionDTO;
import org.mifosplatform.portfolio.savings.domain.DepositAccountAssembler;
import org.mifosplatform.portfolio.savings.service.DepositAccountWritePlatformService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -30,18 +34,23 @@ public class CollectionSheetWritePlatformServiceJpaRepositoryImpl implements Col
private final CollectionSheetBulkDisbursalCommandFromApiJsonDeserializer bulkDisbursalCommandFromApiJsonDeserializer;
private final CollectionSheetTransactionDataValidator transactionDataValidator;
private final MeetingWritePlatformService meetingWritePlatformService;
private final DepositAccountAssembler accountAssembler;
private final DepositAccountWritePlatformService accountWritePlatformService;
@Autowired
public CollectionSheetWritePlatformServiceJpaRepositoryImpl(final LoanWritePlatformService loanWritePlatformService,
final CollectionSheetBulkRepaymentCommandFromApiJsonDeserializer bulkRepaymentCommandFromApiJsonDeserializer,
final CollectionSheetBulkDisbursalCommandFromApiJsonDeserializer bulkDisbursalCommandFromApiJsonDeserializer,
final CollectionSheetTransactionDataValidator transactionDataValidator,
final MeetingWritePlatformService meetingWritePlatformService) {
final MeetingWritePlatformService meetingWritePlatformService, final DepositAccountAssembler accountAssembler,
final DepositAccountWritePlatformService accountWritePlatformService) {
this.loanWritePlatformService = loanWritePlatformService;
this.bulkRepaymentCommandFromApiJsonDeserializer = bulkRepaymentCommandFromApiJsonDeserializer;
this.bulkDisbursalCommandFromApiJsonDeserializer = bulkDisbursalCommandFromApiJsonDeserializer;
this.transactionDataValidator = transactionDataValidator;
this.meetingWritePlatformService = meetingWritePlatformService;
this.accountAssembler = accountAssembler;
this.accountWritePlatformService = accountWritePlatformService;
}
@Override
@@ -61,6 +70,8 @@ public class CollectionSheetWritePlatformServiceJpaRepositoryImpl implements Col
changes.putAll(updateBulkReapayments(command));
changes.putAll(updateBulkDisbursals(command));
changes.putAll(updateBulkMandatorySavingsDuePayments(command));
this.meetingWritePlatformService.updateCollectionSheetAttendance(command);
@@ -86,4 +97,21 @@ public class CollectionSheetWritePlatformServiceJpaRepositoryImpl implements Col
changes.putAll(this.loanWritePlatformService.bulkLoanDisbursal(command, bulkDisbursalCommand, false));
return changes;
}
private Map<String, Object> updateBulkMandatorySavingsDuePayments(final JsonCommand command) {
final Map<String, Object> changes = new HashMap<String, Object>();
final Collection<SavingsAccountTransactionDTO> savingsTransactions = this.accountAssembler.assembleBulkMandatorySavingsAccountTransactionDTOs(command);
for (SavingsAccountTransactionDTO savingsAccountTransactionDTO : savingsTransactions) {
try {
this.accountWritePlatformService.mandatorySavingsAccountDeposit(savingsAccountTransactionDTO);
changes.put("savingsAccountId", savingsAccountTransactionDTO.getSavingsAccountId());
changes.put("transationAmount", savingsAccountTransactionDTO.getTransactionAmount());
} catch (Exception e) {
// TODO: handle exception
}
}
return changes;
}
}
@@ -5,6 +5,9 @@
*/
package org.mifosplatform.portfolio.common.domain;
import java.util.ArrayList;
import java.util.List;
public enum PeriodFrequencyType {
DAYS(0, "periodFrequencyType.days"), //
@@ -57,4 +60,19 @@ public enum PeriodFrequencyType {
public boolean isYearly() {
return this.value.equals(PeriodFrequencyType.MONTHS.getValue());
}
public boolean isInvalid() {
return this.value.equals(PeriodFrequencyType.INVALID.getValue());
}
public static Object[] integerValues() {
final List<Integer> values = new ArrayList<Integer>();
for (final PeriodFrequencyType enumType : values()) {
if (!enumType.isInvalid()) {
values.add(enumType.getValue());
}
}
return values.toArray();
}
}
@@ -29,16 +29,19 @@ public class InterestRateChartApiConstants {
public static final String descriptionParamName = "description";
public static final String fromDateParamName = "fromDate";
public static final String endDateParamName = "endDate";
public static final String savingsProductIdParamName = "savingsProductId";
public static final String savingsProductNameParamName = "savingsProductName";
public static final String productIdParamName = "productId";
public static final String productNameParamName = "productName";
// interest rate chart Slabs parameters
public static final String periodTypeParamName = "periodType";
public static final String fromPeriodParamName = "fromPeriod";
public static final String toPeriodParamName = "toPeriod";
public static final String amountRangeFromParamName = "amountRangeFrom";
public static final String amountRangeToParamName = "amountRangeTo";
public static final String annualInterestRateParamName = "annualInterestRate";
// public static final String periodTypeParamName = "periodType";
// public static final String fromPeriodParamName = "fromPeriod";
// public static final String toPeriodParamName = "toPeriod";
// public static final String amountRangeFromParamName = "amountRangeFrom";
// public static final String amountRangeToParamName = "amountRangeTo";
// public static final String annualInterestRateParamName = "annualInterestRate";
// public static final String interestRateForFemaleParamName = "interestRateForFemale";
// public static final String interestRateForChildrenParamName = "interestRateForChildren";
// public static final String interestRateForSeniorCitizenParamName = "interestRateForSeniorCitizen";
// associations
public static final String chartSlabs = "chartSlabs";
@@ -47,7 +50,7 @@ public class InterestRateChartApiConstants {
public static final String deleteParamName = "delete";
public static final Set<String> INTERESTRATE_CHART_CREATE_REQUEST_DATA_PARAMETERS = new HashSet<String>(Arrays.asList(localeParamName,
dateFormatParamName, nameParamName, descriptionParamName, fromDateParamName, endDateParamName, savingsProductIdParamName,
dateFormatParamName, nameParamName, descriptionParamName, fromDateParamName, endDateParamName, productIdParamName,
chartSlabs));
public static final Set<String> INTERESTRATE_CHART_UPDATE_REQUEST_DATA_PARAMETERS = new HashSet<String>(Arrays.asList(localeParamName,
@@ -1,74 +0,0 @@
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.mifosplatform.portfolio.interestratechart;
import java.util.ArrayList;
import java.util.List;
/**
* An enumeration of supported calendar periods used in savings.
*/
public enum InterestRateChartPeriodType {
DAYS(0, "interestChartPeriodType.days"), //
WEEKS(1, "interestChartPeriodType.weeks"), //
MONTHS(2, "interestChartPeriodType.months"), //
YEARS(3, "interestChartPeriodType.years"), //
INVALID(4, "interestChartPeriodType.invalid");
private final Integer value;
private final String code;
private InterestRateChartPeriodType(final Integer value, final String code) {
this.value = value;
this.code = code;
}
public Integer getValue() {
return this.value;
}
public String getCode() {
return this.code;
}
public static InterestRateChartPeriodType fromInt(final Integer type) {
InterestRateChartPeriodType periodType = InterestRateChartPeriodType.INVALID;
if (type != null) {
switch (type) {
case 0:
periodType = InterestRateChartPeriodType.DAYS;
break;
case 1:
periodType = InterestRateChartPeriodType.WEEKS;
break;
case 2:
periodType = InterestRateChartPeriodType.MONTHS;
break;
case 3:
periodType = InterestRateChartPeriodType.YEARS;
break;
}
}
return periodType;
}
public static Object[] integerValues() {
final List<Integer> values = new ArrayList<Integer>();
for (final InterestRateChartPeriodType enumType : values()) {
if (!enumType.isInvalid()) {
values.add(enumType.getValue());
}
}
return values.toArray();
}
public boolean isInvalid(){
return this.value.equals(InterestRateChartPeriodType.INVALID.value);
}
}
@@ -30,19 +30,25 @@ public class InterestRateChartSlabApiConstants {
public static final String amountRangeFromParamName = "amountRangeFrom";
public static final String amountRangeToParamName = "amountRangeTo";
public static final String annualInterestRateParamName = "annualInterestRate";
public static final String currencyCodeParamName = "currencyCode";
public static final String interestRateForFemaleParamName = "interestRateForFemale";
public static final String interestRateForChildrenParamName = "interestRateForChildren";
public static final String interestRateForSeniorCitizenParamName = "interestRateForSeniorCitizen";
public static final String currencyCodeParamName = "currencyCode";
// associations
public static final Set<String> INTERESTRATE_CHART_SLAB_CREATE_REQUEST_DATA_PARAMETERS = new HashSet<String>(Arrays.asList(
localeParamName, idParamName, descriptionParamName, periodTypeParamName, fromPeriodParamName, toPeriodParamName,
amountRangeFromParamName, amountRangeToParamName, annualInterestRateParamName, currencyCodeParamName));
amountRangeFromParamName, amountRangeToParamName, annualInterestRateParamName, interestRateForFemaleParamName,
interestRateForChildrenParamName, interestRateForSeniorCitizenParamName, currencyCodeParamName));
public static final Set<String> INTERESTRATE_CHART_SLAB_UPDATE_REQUEST_DATA_PARAMETERS = new HashSet<String>(Arrays.asList(
localeParamName, idParamName, descriptionParamName, periodTypeParamName, fromPeriodParamName, toPeriodParamName,
amountRangeFromParamName, amountRangeToParamName, annualInterestRateParamName, currencyCodeParamName));
amountRangeFromParamName, amountRangeToParamName, annualInterestRateParamName, interestRateForFemaleParamName,
interestRateForChildrenParamName, interestRateForSeniorCitizenParamName, currencyCodeParamName));
public static final Set<String> INTERESTRATE_CHART_SLAB_RESPONSE_DATA_PARAMETERS = new HashSet<String>(Arrays.asList(localeParamName,
idParamName, descriptionParamName, periodTypeParamName, fromPeriodParamName, toPeriodParamName, amountRangeFromParamName,
amountRangeToParamName, annualInterestRateParamName, currencyCodeParamName));
amountRangeToParamName, annualInterestRateParamName, interestRateForFemaleParamName, interestRateForChildrenParamName,
interestRateForSeniorCitizenParamName, currencyCodeParamName));
}
@@ -64,9 +64,10 @@ public class InterestRateChartSlabsApiResource {
@Path("template")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
public String template() {
// TODO: implement
return null;
public String template(@Context final UriInfo uriInfo) {
InterestRateChartSlabData chartSlab = this.interestRateChartSlabReadPlatformService.retrieveTemplate();
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
return this.toApiJsonSerializer.serialize(settings, chartSlab, INTERESTRATE_CHART_SLAB_RESPONSE_DATA_PARAMETERS);
}
@GET
@@ -6,6 +6,7 @@
package org.mifosplatform.portfolio.interestratechart.api;
import java.util.Collection;
import java.util.Set;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
@@ -23,6 +24,7 @@ import javax.ws.rs.core.UriInfo;
import org.mifosplatform.commands.domain.CommandWrapper;
import org.mifosplatform.commands.service.CommandWrapperBuilder;
import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService;
import org.mifosplatform.infrastructure.core.api.ApiParameterHelper;
import org.mifosplatform.infrastructure.core.api.ApiRequestParameterHelper;
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
import org.mifosplatform.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
@@ -94,8 +96,15 @@ public class InterestRateChartsApiResource {
public String retrieveOne(@PathParam("chartId") final Long chartId, @Context final UriInfo uriInfo) {
this.context.authenticatedUser().validateHasReadPermission(InterestRateChartApiConstants.INTERESTRATE_CHART_RESOURCE_NAME);
InterestRateChartData chartData = this.chartReadPlatformService.retrieveOneWithSlabs(chartId);
InterestRateChartData chartData = null;
final Set<String> associationParameters = ApiParameterHelper.extractAssociationsForResponseIfProvided(uriInfo.getQueryParameters());
if (!associationParameters.isEmpty() && associationParameters.contains(InterestRateChartApiConstants.chartSlabs)) {
chartData = this.chartReadPlatformService.retrieveOneWithSlabs(chartId);
}else {
chartData = this.chartReadPlatformService.retrieveOne(chartId);
}
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
if (settings.isTemplate()) {
chartData = this.chartReadPlatformService.retrieveWithTemplate(chartData);
@@ -0,0 +1,43 @@
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.mifosplatform.portfolio.interestratechart.data;
/**
* Immutable data object representing a ClientIncentiveAttributes used
* for determining interest rate applicable from Interest rate chart.
*/
public class ClientIncentiveAttributes {
private final boolean isFemale;
private final boolean isChild;
private final boolean isSeniorCitizen;
public static ClientIncentiveAttributes instance(final boolean isFemale, final boolean isChild, final boolean isSeniorCitizen) {
return new ClientIncentiveAttributes(isFemale, isChild, isSeniorCitizen);
}
private ClientIncentiveAttributes(final boolean isFemale, final boolean isChild, final boolean isSeniorCitizen) {
this.isFemale = isFemale;
this.isChild = isChild;
this.isSeniorCitizen = isSeniorCitizen;
}
public boolean isFemale(){
return this.isFemale;
}
public boolean isChild(){
return this.isChild;
}
public boolean isSeniorCitizen(){
return this.isSeniorCitizen;
}
}
@@ -22,8 +22,8 @@ public class InterestRateChartData {
private final String description;
private final LocalDate fromDate;
private final LocalDate endDate;
private final Long savingsProductId;
private final String savingsProductName;
private final Long productId;
private final String productName;
// associations
private Set<InterestRateChartSlabData> chartSlabs;
@@ -32,8 +32,9 @@ public class InterestRateChartData {
private Collection<EnumOptionData> periodTypes;
public static InterestRateChartData instance(Long id, String name, String description, LocalDate fromDate, LocalDate endDate,
Long savingsProductId, String savingsProductName, Set<InterestRateChartSlabData> chartSlabs) {
Long savingsProductId, String savingsProductName) {
Collection<EnumOptionData> periodTypes = null;
Set<InterestRateChartSlabData> chartSlabs = null;
return new InterestRateChartData(id, name, description, fromDate, endDate, savingsProductId, savingsProductName, chartSlabs,
periodTypes);
}
@@ -41,14 +42,14 @@ public class InterestRateChartData {
public static InterestRateChartData withSlabs(InterestRateChartData interestRateChartData,
Set<InterestRateChartSlabData> chartSlabs) {
return new InterestRateChartData(interestRateChartData.id, interestRateChartData.name, interestRateChartData.description,
interestRateChartData.fromDate, interestRateChartData.endDate, interestRateChartData.savingsProductId,
interestRateChartData.savingsProductName, chartSlabs, interestRateChartData.periodTypes);
interestRateChartData.fromDate, interestRateChartData.endDate, interestRateChartData.productId,
interestRateChartData.productName, chartSlabs, interestRateChartData.periodTypes);
}
public static InterestRateChartData withTemplate(InterestRateChartData interestRateChartData, Collection<EnumOptionData> periodTypes) {
return new InterestRateChartData(interestRateChartData.id, interestRateChartData.name, interestRateChartData.description,
interestRateChartData.fromDate, interestRateChartData.endDate, interestRateChartData.savingsProductId,
interestRateChartData.savingsProductName, interestRateChartData.chartSlabs, periodTypes);
interestRateChartData.fromDate, interestRateChartData.endDate, interestRateChartData.productId,
interestRateChartData.productName, interestRateChartData.chartSlabs, periodTypes);
}
public static InterestRateChartData template(Collection<EnumOptionData> periodTypes) {
@@ -73,8 +74,8 @@ public class InterestRateChartData {
this.fromDate = fromDate;
this.endDate = endDate;
this.chartSlabs = chartSlabs;
this.savingsProductId = savingsProductId;
this.savingsProductName = savingsProductName;
this.productId = savingsProductId;
this.productName = savingsProductName;
this.periodTypes = periodTypes;
}
@@ -14,7 +14,7 @@ import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApi
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.fromDateParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.idParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.nameParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.savingsProductIdParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.productIdParamName;
import java.lang.reflect.Type;
import java.util.ArrayList;
@@ -112,9 +112,9 @@ public class InterestRateChartDataValidator {
final JsonElement element = this.fromApiJsonHelper.parse(json);
if (this.fromApiJsonHelper.parameterExists(savingsProductIdParamName, element)) {
final Long savingsProductId = this.fromApiJsonHelper.extractLongNamed(savingsProductIdParamName, element);
baseDataValidator.reset().parameter(savingsProductIdParamName).value(savingsProductId).notNull().integerGreaterThanZero();
if (this.fromApiJsonHelper.parameterExists(productIdParamName, element)) {
final Long savingsProductId = this.fromApiJsonHelper.extractLongNamed(productIdParamName, element);
baseDataValidator.reset().parameter(productIdParamName).value(savingsProductId).notNull().integerGreaterThanZero();
}
if (this.fromApiJsonHelper.parameterExists(nameParamName, element)) {
@@ -24,25 +24,52 @@ public class InterestRateChartSlabData {
private final BigDecimal amountRangeFrom;
private final BigDecimal amountRangeTo;
private final BigDecimal annualInterestRate;
private final BigDecimal interestRateForFemale;
private final BigDecimal interestRateForChildren;
private final BigDecimal interestRateForSeniorCitizen;
private final CurrencyData currency;
// template
private Collection<EnumOptionData> periodTypes;
private final Collection<EnumOptionData> periodTypes;
public static InterestRateChartSlabData instance(Long id, String description, EnumOptionData periodType, Integer fromPeriod,
Integer toPeriod, BigDecimal amountRangeFrom, BigDecimal amountRangeTo, BigDecimal annualInterestRate, CurrencyData currency) {
Collection<EnumOptionData> periodTypes = null;
public static InterestRateChartSlabData instance(final Long id, final String description, final EnumOptionData periodType,
final Integer fromPeriod, final Integer toPeriod, final BigDecimal amountRangeFrom, final BigDecimal amountRangeTo,
final BigDecimal annualInterestRate, final BigDecimal interestRateForFemale, final BigDecimal interestRateForChildren,
final BigDecimal interestRateForSeniorCitizen, final CurrencyData currency) {
final Collection<EnumOptionData> periodTypes = null;
return new InterestRateChartSlabData(id, description, periodType, fromPeriod, toPeriod, amountRangeFrom, amountRangeTo,
annualInterestRate, currency, periodTypes);
}
public static InterestRateChartSlabData withTemplate(InterestRateChartSlabData chartSlab, Collection<EnumOptionData> periodTypes) {
return new InterestRateChartSlabData(chartSlab.id, chartSlab.description, chartSlab.periodType, chartSlab.fromPeriod, chartSlab.toPeriod, chartSlab.amountRangeFrom, chartSlab.amountRangeTo,
chartSlab.annualInterestRate, chartSlab.currency, periodTypes);
annualInterestRate, interestRateForFemale, interestRateForChildren, interestRateForSeniorCitizen, currency, periodTypes);
}
private InterestRateChartSlabData(Long id, String description, EnumOptionData periodType, Integer fromPeriod, Integer toPeriod,
BigDecimal amountRangeFrom, BigDecimal amountRangeTo, BigDecimal annualInterestRate, CurrencyData currency, Collection<EnumOptionData> periodTypes) {
public static InterestRateChartSlabData withTemplate(final InterestRateChartSlabData chartSlab,
final Collection<EnumOptionData> periodTypes) {
return new InterestRateChartSlabData(chartSlab.id, chartSlab.description, chartSlab.periodType, chartSlab.fromPeriod,
chartSlab.toPeriod, chartSlab.amountRangeFrom, chartSlab.amountRangeTo, chartSlab.annualInterestRate,
chartSlab.interestRateForFemale, chartSlab.interestRateForChildren, chartSlab.interestRateForSeniorCitizen,
chartSlab.currency, periodTypes);
}
public static InterestRateChartSlabData template(final Collection<EnumOptionData> periodTypes) {
final Long id = null;
final String description = null;
final EnumOptionData periodType = null;
final Integer fromPeriod = null;
final Integer toPeriod = null;
final BigDecimal amountRangeFrom = null;
final BigDecimal amountRangeTo = null;
final BigDecimal annualInterestRate = null;
final BigDecimal interestRateForFemale = null;
final BigDecimal interestRateForChildren = null;
final BigDecimal interestRateForSeniorCitizen = null;
final CurrencyData currency = null;
return new InterestRateChartSlabData(id, description, periodType, fromPeriod, toPeriod, amountRangeFrom, amountRangeTo,
annualInterestRate, interestRateForFemale, interestRateForChildren, interestRateForSeniorCitizen, currency, periodTypes);
}
private InterestRateChartSlabData(final Long id, final String description, final EnumOptionData periodType, final Integer fromPeriod,
final Integer toPeriod, final BigDecimal amountRangeFrom, final BigDecimal amountRangeTo, final BigDecimal annualInterestRate,
final BigDecimal interestRateForFemale, final BigDecimal interestRateForChildren,
final BigDecimal interestRateForSeniorCitizen, final CurrencyData currency, final Collection<EnumOptionData> periodTypes) {
this.id = id;
this.description = description;
this.periodType = periodType;
@@ -51,51 +78,59 @@ public class InterestRateChartSlabData {
this.amountRangeFrom = amountRangeFrom;
this.amountRangeTo = amountRangeTo;
this.annualInterestRate = annualInterestRate;
this.interestRateForFemale = interestRateForFemale;
this.interestRateForChildren = interestRateForChildren;
this.interestRateForSeniorCitizen = interestRateForSeniorCitizen;
this.currency = currency;
this.periodTypes = periodTypes;
}
public String description() {
return this.description;
}
public EnumOptionData periodType() {
return this.periodType;
}
public Integer fromPeriod() {
return this.fromPeriod;
}
public Integer toPeriod() {
return this.toPeriod;
}
public BigDecimal amountRangeFrom() {
return this.amountRangeFrom;
}
public BigDecimal amountRangeTo() {
return this.amountRangeTo;
}
public BigDecimal annualInterestRate() {
return this.annualInterestRate;
}
public BigDecimal interestRateForFemale() {
return this.interestRateForFemale;
}
public BigDecimal interestRateForChildren() {
return this.interestRateForChildren;
}
public BigDecimal interestRateForSeniorCitizen() {
return this.interestRateForSeniorCitizen;
}
public CurrencyData currency() {
return this.currency;
}
public Collection<EnumOptionData> periodTypes() {
return this.periodTypes;
}
}
@@ -14,6 +14,9 @@ import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSla
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.currencyCodeParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.descriptionParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.fromPeriodParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.interestRateForChildrenParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.interestRateForFemaleParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.interestRateForSeniorCitizenParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.periodTypeParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.toPeriodParamName;
@@ -30,7 +33,7 @@ import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder;
import org.mifosplatform.infrastructure.core.exception.InvalidJsonException;
import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException;
import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper;
import org.mifosplatform.portfolio.interestratechart.InterestRateChartPeriodType;
import org.mifosplatform.portfolio.common.domain.PeriodFrequencyType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -61,17 +64,16 @@ public class InterestRateChartSlabDataValidator {
final JsonElement element = this.fromApiJsonHelper.parse(json);
final JsonObject objectElement = element.getAsJsonObject();
final Locale locale = this.fromApiJsonHelper.extractLocaleParameter(objectElement);
final String currencyCode = this.fromApiJsonHelper.extractStringNamed(currencyCodeParamName, element);
baseDataValidator.reset().parameter(currencyCodeParamName).value(currencyCode).notBlank().notExceedingLengthOf(3);
validateChartSlabsCreate(element, baseDataValidator, locale);
throwExceptionIfValidationWarningsExist(dataValidationErrors);
}
public void validateChartSlabsCreate(final JsonElement element, final DataValidatorBuilder baseDataValidator, final Locale locale) {
if (this.fromApiJsonHelper.parameterExists(descriptionParamName, element)) {
final String description = this.fromApiJsonHelper.extractStringNamed(descriptionParamName, element);
@@ -80,7 +82,7 @@ public class InterestRateChartSlabDataValidator {
final Integer periodType = this.fromApiJsonHelper.extractIntegerNamed(periodTypeParamName, element, locale);
baseDataValidator.reset().parameter(periodTypeParamName).value(periodType).notNull()
.isOneOfTheseValues(InterestRateChartPeriodType.integerValues());
.isOneOfTheseValues(PeriodFrequencyType.integerValues());
Integer toPeriod = null;
@@ -117,6 +119,25 @@ public class InterestRateChartSlabDataValidator {
final BigDecimal annualInterestRate = this.fromApiJsonHelper.extractBigDecimalNamed(annualInterestRateParamName, element, locale);
baseDataValidator.reset().parameter(annualInterestRateParamName).value(annualInterestRate).notNull().zeroOrPositiveAmount();
if (this.fromApiJsonHelper.parameterExists(interestRateForFemaleParamName, element)) {
final BigDecimal interestRateForFemale = this.fromApiJsonHelper.extractBigDecimalNamed(interestRateForFemaleParamName, element,
locale);
baseDataValidator.reset().parameter(interestRateForFemaleParamName).value(interestRateForFemale).notNull().zeroOrPositiveAmount();
}
if (this.fromApiJsonHelper.parameterExists(interestRateForChildrenParamName, element)) {
final BigDecimal interestRateForChildren = this.fromApiJsonHelper.extractBigDecimalNamed(interestRateForChildrenParamName, element,
locale);
baseDataValidator.reset().parameter(interestRateForChildrenParamName).value(interestRateForChildren).notNull().zeroOrPositiveAmount();
}
if (this.fromApiJsonHelper.parameterExists(interestRateForSeniorCitizenParamName, element)) {
final BigDecimal interestRateForSeniorCitizen = this.fromApiJsonHelper.extractBigDecimalNamed(interestRateForSeniorCitizenParamName, element,
locale);
baseDataValidator.reset().parameter(interestRateForSeniorCitizenParamName).value(interestRateForSeniorCitizen).notNull().zeroOrPositiveAmount();
}
}
public void validateUpdate(final String json) {
@@ -138,7 +159,6 @@ public class InterestRateChartSlabDataValidator {
}
public void validateChartSlabsUpdate(final JsonElement element, final DataValidatorBuilder baseDataValidator, final Locale locale) {
if (this.fromApiJsonHelper.parameterExists(descriptionParamName, element)) {
final String description = this.fromApiJsonHelper.extractStringNamed(descriptionParamName, element);
@@ -148,7 +168,7 @@ public class InterestRateChartSlabDataValidator {
if (this.fromApiJsonHelper.parameterExists(periodTypeParamName, element)) {
final Integer periodType = this.fromApiJsonHelper.extractIntegerNamed(periodTypeParamName, element, locale);
baseDataValidator.reset().parameter(periodTypeParamName).value(periodType).notNull()
.isOneOfTheseValues(InterestRateChartPeriodType.integerValues());
.isOneOfTheseValues(PeriodFrequencyType.integerValues());
}
Integer fromPeriod = null;
@@ -192,6 +212,24 @@ public class InterestRateChartSlabDataValidator {
locale);
baseDataValidator.reset().parameter(annualInterestRateParamName).value(annualInterestRate).notNull().zeroOrPositiveAmount();
}
if (this.fromApiJsonHelper.parameterExists(interestRateForFemaleParamName, element)) {
final BigDecimal interestRateForFemale = this.fromApiJsonHelper.extractBigDecimalNamed(interestRateForFemaleParamName, element,
locale);
baseDataValidator.reset().parameter(interestRateForFemaleParamName).value(interestRateForFemale).notNull().zeroOrPositiveAmount();
}
if (this.fromApiJsonHelper.parameterExists(interestRateForChildrenParamName, element)) {
final BigDecimal interestRateForChildren = this.fromApiJsonHelper.extractBigDecimalNamed(interestRateForChildrenParamName, element,
locale);
baseDataValidator.reset().parameter(interestRateForChildrenParamName).value(interestRateForChildren).notNull().zeroOrPositiveAmount();
}
if (this.fromApiJsonHelper.parameterExists(interestRateForSeniorCitizenParamName, element)) {
final BigDecimal interestRateForSeniorCitizen = this.fromApiJsonHelper.extractBigDecimalNamed(interestRateForSeniorCitizenParamName, element,
locale);
baseDataValidator.reset().parameter(interestRateForSeniorCitizenParamName).value(interestRateForSeniorCitizen).notNull().zeroOrPositiveAmount();
}
if (this.fromApiJsonHelper.parameterExists(currencyCodeParamName, element)) {
final String currencyCode = this.fromApiJsonHelper.extractStringNamed(currencyCodeParamName, element);
@@ -6,15 +6,18 @@
package org.mifosplatform.portfolio.interestratechart.domain;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.INTERESTRATE_CHART_RESOURCE_NAME;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.amountRangeFromParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.amountRangeToParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.annualInterestRateParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.amountRangeFromParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.amountRangeToParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.annualInterestRateParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.deleteParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.descriptionParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.fromPeriodParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.fromPeriodParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.idParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.periodTypeParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.toPeriodParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.interestRateForChildrenParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.interestRateForFemaleParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.interestRateForSeniorCitizenParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.periodTypeParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.toPeriodParamName;
import java.math.BigDecimal;
import java.util.ArrayList;
@@ -202,8 +205,12 @@ public class InterestRateChart extends AbstractPersistable<Long> {
final BigDecimal amountRangeTo = chartSlabsCommand.bigDecimalValueOfParameterNamed(amountRangeToParamName);
final BigDecimal annualInterestRate = chartSlabsCommand
.bigDecimalValueOfParameterNamed(annualInterestRateParamName);
final BigDecimal interestRateForFemale = chartSlabsCommand.bigDecimalValueOfParameterNamed(interestRateForFemaleParamName);
final BigDecimal interestRateForChildren = chartSlabsCommand.bigDecimalValueOfParameterNamed(interestRateForChildrenParamName);
final BigDecimal interestRateForSeniorCitizen = chartSlabsCommand.bigDecimalValueOfParameterNamed(interestRateForSeniorCitizenParamName);
final InterestRateChartSlabFields slabFields = InterestRateChartSlabFields.createNew(description, periodFrequencyType,
fromPeriod, toPeriod, amountRangeFrom, amountRangeTo, annualInterestRate, currencyCode);
fromPeriod, toPeriod, amountRangeFrom, amountRangeTo, annualInterestRate, interestRateForFemale, interestRateForChildren, interestRateForSeniorCitizen, currencyCode);
final InterestRateChartSlab chartSlab = InterestRateChartSlab.createNew(slabFields, this);
chartSlab.slabFields().validateChartSlabPlatformRules(chartSlabsCommand, baseDataValidator);
this.addChartSlab(chartSlab);
@@ -84,7 +84,7 @@ public class InterestRateChartFields {
this.fromDate = newValue.toDate();
}
if (command.isChangeInLocalDateParameterNamed(endDateParamName, getFromDateAsLocalDate())) {
if (command.isChangeInLocalDateParameterNamed(endDateParamName, getEndDateAsLocalDate())) {
final LocalDate newValue = command.localDateValueOfParameterNamed(endDateParamName);
final String newValueAsString = command.stringValueOfParameterNamed(endDateParamName);
actualChanges.put(endDateParamName, newValueAsString);
@@ -135,7 +135,7 @@ public class InterestRateChartFields {
final LocalDateInterval thisInterval = LocalDateInterval.create(thisFromDate, thisEndDate);
final LocalDateInterval thatInterval = LocalDateInterval.create(thatFromDate, thatEndDate);
if(thisInterval.containsPortionOf(thatInterval) || thisInterval.contains(thatInterval)){
if(thisInterval.containsPortionOf(thatInterval) || thatInterval.containsPortionOf(thisInterval)){
return true;
}
return false;// no overlapping
@@ -5,13 +5,16 @@
*/
package org.mifosplatform.portfolio.interestratechart.domain;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.amountRangeFromParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.amountRangeToParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.annualInterestRateParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.descriptionParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.fromPeriodParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.periodTypeParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.toPeriodParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.amountRangeFromParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.amountRangeToParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.annualInterestRateParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.interestRateForFemaleParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.interestRateForChildrenParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.interestRateForSeniorCitizenParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.descriptionParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.fromPeriodParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.periodTypeParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.toPeriodParamName;
import java.math.BigDecimal;
import java.util.Map;
@@ -52,6 +55,15 @@ public class InterestRateChartSlabFields {
@Column(name = "annual_interest_rate", scale = 6, precision = 19, nullable = false)
private BigDecimal annualInterestRate;
@Column(name = "interest_rate_for_female", scale = 6, precision = 19, nullable = true)
private BigDecimal interestRateForFemale;
@Column(name = "interest_rate_for_children", scale = 6, precision = 19, nullable = true)
private BigDecimal interestRateForChildren;
@Column(name = "interest_rate_for_senior_citizen", scale = 6, precision = 19, nullable = true)
private BigDecimal interestRateForSeniorCitizen;
@Column(name = "currency_code", nullable = false)
private String currencyCode;
@@ -59,15 +71,18 @@ public class InterestRateChartSlabFields {
//
}
public static InterestRateChartSlabFields createNew(String description, final SavingsPeriodFrequencyType periodFrequencyType,
Integer fromPeriod, Integer toPeriod, BigDecimal amountRangeFrom, BigDecimal amountRangeTo, BigDecimal annualInterestRate,
String currencyCode) {
public static InterestRateChartSlabFields createNew(final String description, final SavingsPeriodFrequencyType periodFrequencyType,
final Integer fromPeriod, final Integer toPeriod, final BigDecimal amountRangeFrom, final BigDecimal amountRangeTo,
final BigDecimal annualInterestRate, final BigDecimal interestRateForFemale, final BigDecimal interestRateForChildren,
final BigDecimal interestRateForSeniorCitizen, final String currencyCode) {
return new InterestRateChartSlabFields(description, periodFrequencyType, fromPeriod, toPeriod, amountRangeFrom, amountRangeTo,
annualInterestRate, currencyCode);
annualInterestRate, interestRateForFemale, interestRateForChildren, interestRateForSeniorCitizen, currencyCode);
}
private InterestRateChartSlabFields(String description, final SavingsPeriodFrequencyType periodFrequencyType, Integer fromPeriod,
Integer toPeriod, BigDecimal amountRangeFrom, BigDecimal amountRangeTo, BigDecimal annualInterestRate, String currencyCode) {
private InterestRateChartSlabFields(final String description, final SavingsPeriodFrequencyType periodFrequencyType,
final Integer fromPeriod, final Integer toPeriod, final BigDecimal amountRangeFrom, final BigDecimal amountRangeTo,
final BigDecimal annualInterestRate, final BigDecimal interestRateForFemale, final BigDecimal interestRateForChildren,
final BigDecimal interestRateForSeniorCitizen, final String currencyCode) {
this.description = description;
this.periodType = (periodFrequencyType == null) ? null : periodFrequencyType.getValue();
this.fromPeriod = fromPeriod;
@@ -75,10 +90,13 @@ public class InterestRateChartSlabFields {
this.amountRangeFrom = amountRangeFrom;
this.amountRangeTo = amountRangeTo;
this.annualInterestRate = annualInterestRate;
this.interestRateForFemale = interestRateForFemale;
this.interestRateForChildren = interestRateForChildren;
this.interestRateForSeniorCitizen = interestRateForSeniorCitizen;
this.currencyCode = currencyCode;
}
public void update(JsonCommand command, final Map<String, Object> actualChanges, final DataValidatorBuilder baseDataValidator) {
public void update(final JsonCommand command, final Map<String, Object> actualChanges, final DataValidatorBuilder baseDataValidator) {
if (command.isChangeInStringParameterNamed(descriptionParamName, this.description)) {
final String newValue = command.stringValueOfParameterNamed(descriptionParamName);
@@ -86,52 +104,70 @@ public class InterestRateChartSlabFields {
this.description = newValue;
}
if (command.isChangeInIntegerParameterNamed(periodTypeParamName, periodType)) {
if (command.isChangeInIntegerParameterNamed(periodTypeParamName, this.periodType)) {
final Integer newValue = command.integerValueOfParameterNamed(periodTypeParamName);
actualChanges.put(periodTypeParamName, newValue);
this.periodType = newValue;
}
if (command.isChangeInIntegerParameterNamed(fromPeriodParamName, fromPeriod)) {
if (command.isChangeInIntegerParameterNamed(fromPeriodParamName, this.fromPeriod)) {
final Integer newValue = command.integerValueOfParameterNamed(fromPeriodParamName);
actualChanges.put(fromPeriodParamName, newValue);
this.fromPeriod = newValue;
}
if (command.isChangeInIntegerParameterNamed(toPeriodParamName, toPeriod)) {
if (command.isChangeInIntegerParameterNamed(toPeriodParamName, this.toPeriod)) {
final Integer newValue = command.integerValueOfParameterNamed(toPeriodParamName);
actualChanges.put(toPeriodParamName, newValue);
this.toPeriod = newValue;
}
if (command.isChangeInBigDecimalParameterNamed(amountRangeFromParamName, amountRangeFrom)) {
if (command.isChangeInBigDecimalParameterNamed(amountRangeFromParamName, this.amountRangeFrom)) {
final BigDecimal newValue = command.bigDecimalValueOfParameterNamed(amountRangeFromParamName);
actualChanges.put(amountRangeFromParamName, newValue);
this.amountRangeFrom = newValue;
}
if (command.isChangeInBigDecimalParameterNamed(amountRangeToParamName, amountRangeTo)) {
if (command.isChangeInBigDecimalParameterNamed(amountRangeToParamName, this.amountRangeTo)) {
final BigDecimal newValue = command.bigDecimalValueOfParameterNamed(amountRangeToParamName);
actualChanges.put(amountRangeToParamName, newValue);
this.amountRangeTo = newValue;
}
if (command.isChangeInBigDecimalParameterNamed(annualInterestRateParamName, annualInterestRate)) {
if (command.isChangeInBigDecimalParameterNamed(annualInterestRateParamName, this.annualInterestRate)) {
final BigDecimal newValue = command.bigDecimalValueOfParameterNamed(annualInterestRateParamName);
actualChanges.put(annualInterestRateParamName, newValue);
this.annualInterestRate = newValue;
}
this.validateChartSlabPlatformRules(command, baseDataValidator);
if (command.isChangeInBigDecimalParameterNamed(interestRateForFemaleParamName, this.interestRateForFemale)) {
final BigDecimal newValue = command.bigDecimalValueOfParameterNamed(interestRateForFemaleParamName);
actualChanges.put(interestRateForFemaleParamName, newValue);
this.interestRateForFemale = newValue;
}
if (command.isChangeInBigDecimalParameterNamed(interestRateForChildrenParamName, this.interestRateForChildren)) {
final BigDecimal newValue = command.bigDecimalValueOfParameterNamed(interestRateForChildrenParamName);
actualChanges.put(interestRateForChildrenParamName, newValue);
this.interestRateForChildren = newValue;
}
if (command.isChangeInBigDecimalParameterNamed(interestRateForSeniorCitizenParamName, this.interestRateForSeniorCitizen)) {
final BigDecimal newValue = command.bigDecimalValueOfParameterNamed(interestRateForSeniorCitizenParamName);
actualChanges.put(interestRateForSeniorCitizenParamName, newValue);
this.interestRateForSeniorCitizen = newValue;
}
validateChartSlabPlatformRules(command, baseDataValidator);
}
public void validateChartSlabPlatformRules(JsonCommand chartSlabsCommand, DataValidatorBuilder baseDataValidator) {
if (this.isFromPeriodGreaterThanToPeriod()) {
public void validateChartSlabPlatformRules(final JsonCommand chartSlabsCommand, final DataValidatorBuilder baseDataValidator) {
if (isFromPeriodGreaterThanToPeriod()) {
final Integer fromPeriod = chartSlabsCommand.integerValueOfParameterNamed(fromPeriodParamName);
baseDataValidator.parameter(fromPeriodParamName).value(fromPeriod).failWithCode("from.period.is.greater.than.to.period");
}
if (this.isAmountRangeFromGreaterThanTo()) {
if (isAmountRangeFromGreaterThanTo()) {
final BigDecimal amountRangeFrom = chartSlabsCommand.bigDecimalValueOfParameterNamed(amountRangeFromParamName);
baseDataValidator.parameter(amountRangeFromParamName).value(amountRangeFrom)
.failWithCode("amount.range.from.is.greater.than.amount.range.to");
@@ -140,7 +176,7 @@ public class InterestRateChartSlabFields {
public boolean isFromPeriodGreaterThanToPeriod() {
boolean isGreater = false;
if (this.toPeriod != null && fromPeriod.compareTo(this.toPeriod) > 1) {
if (this.toPeriod != null && this.fromPeriod.compareTo(this.toPeriod) > 1) {
isGreater = true;
}
return isGreater;
@@ -166,7 +202,7 @@ public class InterestRateChartSlabFields {
return this.toPeriod;
}
public boolean isPeriodOverlapping(InterestRateChartSlabFields that) {
public boolean isPeriodOverlapping(final InterestRateChartSlabFields that) {
if (that.toPeriod == null) {
if (this.toPeriod == null) { return true; }
return that.fromPeriod <= this.toPeriod;
@@ -187,9 +223,21 @@ public class InterestRateChartSlabFields {
return this.annualInterestRate;
}
public BigDecimal interestRateForFemale() {
return this.interestRateForFemale;
}
public BigDecimal interestRateForChildren() {
return this.interestRateForChildren;
}
public BigDecimal interestRateForSeniorCitizen() {
return this.interestRateForSeniorCitizen;
}
public Integer depositPeriod(final LocalDate periodStartDate, final LocalDate periodEndDate) {
Integer actualDepositPeriod = 0;
final SavingsPeriodFrequencyType periodFrequencyType = SavingsPeriodFrequencyType.fromInt(this.periodType());
final SavingsPeriodFrequencyType periodFrequencyType = SavingsPeriodFrequencyType.fromInt(periodType());
switch (periodFrequencyType) {
case DAYS:
actualDepositPeriod = Days.daysBetween(periodStartDate, periodEndDate).getDays();
@@ -216,7 +264,9 @@ public class InterestRateChartSlabFields {
returnValue = depositAmount.compareTo(amountRangeFrom) >= 0 && depositAmount.compareTo(amountRangeTo) <= 0;
} else if (amountRangeFrom != null) {
returnValue = depositAmount.compareTo(amountRangeFrom) >= 0;
} else if (amountRangeTo != null) { return depositAmount.compareTo(amountRangeTo) <= 0; }
} else if (amountRangeTo != null) {
returnValue = depositAmount.compareTo(amountRangeTo) <= 0;
}
return returnValue;
}
@@ -24,6 +24,7 @@ public class DeleteInterestRateChartSlabCommandHandler implements NewCommandSour
@Override
public CommandProcessingResult processCommand(final JsonCommand command) {
return this.writePlatformService.deleteChartSlab(command.entityId(), command.interestRateChartId());
//command.subentityId(); //returns chart id
return this.writePlatformService.deleteChartSlab(command.entityId(), command.subentityId());
}
}
@@ -24,6 +24,7 @@ public class UpdateInterestRateChartSlabCommandHandler implements NewCommandSour
@Override
public CommandProcessingResult processCommand(final JsonCommand command) {
return this.writePlatformService.update(command.entityId(), command.interestRateChartId(), command);
//command.subentityId();//returns chart id
return this.writePlatformService.update(command.entityId(), command.subentityId(), command);
}
}
@@ -8,7 +8,7 @@ package org.mifosplatform.portfolio.interestratechart.service;
import java.util.Collection;
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
import org.mifosplatform.portfolio.interestratechart.InterestRateChartPeriodType;
import org.mifosplatform.portfolio.common.domain.PeriodFrequencyType;
import org.springframework.stereotype.Service;
@Service
@@ -16,7 +16,7 @@ public class InterestRateChartDropdownReadPlatformServiceImpl implements Interes
@Override
public Collection<EnumOptionData> retrievePeriodTypeOptions() {
return InterestRateChartEnumerations.periodType(InterestRateChartPeriodType.values());
return InterestRateChartEnumerations.periodType(PeriodFrequencyType.values());
}
}
@@ -9,45 +9,45 @@ import java.util.ArrayList;
import java.util.List;
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
import org.mifosplatform.portfolio.interestratechart.InterestRateChartPeriodType;
import org.mifosplatform.portfolio.common.domain.PeriodFrequencyType;
public class InterestRateChartEnumerations {
public static EnumOptionData periodType(final Integer type) {
return periodType(InterestRateChartPeriodType.fromInt(type));
return periodType(PeriodFrequencyType.fromInt(type));
}
public static EnumOptionData periodType(final InterestRateChartPeriodType type) {
EnumOptionData optionData = new EnumOptionData(InterestRateChartPeriodType.INVALID.getValue().longValue(),
InterestRateChartPeriodType.INVALID.getCode(), "Invalid");
public static EnumOptionData periodType(final PeriodFrequencyType type) {
EnumOptionData optionData = new EnumOptionData(PeriodFrequencyType.INVALID.getValue().longValue(),
PeriodFrequencyType.INVALID.getCode(), "Invalid");
switch (type) {
case INVALID:
break;
case DAYS:
optionData = new EnumOptionData(InterestRateChartPeriodType.DAYS.getValue().longValue(),
InterestRateChartPeriodType.DAYS.getCode(), "Days");
optionData = new EnumOptionData(PeriodFrequencyType.DAYS.getValue().longValue(),
PeriodFrequencyType.DAYS.getCode(), "Days");
break;
case WEEKS:
optionData = new EnumOptionData(InterestRateChartPeriodType.WEEKS.getValue().longValue(),
InterestRateChartPeriodType.WEEKS.getCode(), "Weeks");
optionData = new EnumOptionData(PeriodFrequencyType.WEEKS.getValue().longValue(),
PeriodFrequencyType.WEEKS.getCode(), "Weeks");
break;
case MONTHS:
optionData = new EnumOptionData(InterestRateChartPeriodType.MONTHS.getValue().longValue(),
InterestRateChartPeriodType.MONTHS.getCode(), "Months");
optionData = new EnumOptionData(PeriodFrequencyType.MONTHS.getValue().longValue(),
PeriodFrequencyType.MONTHS.getCode(), "Months");
break;
case YEARS:
optionData = new EnumOptionData(InterestRateChartPeriodType.YEARS.getValue().longValue(),
InterestRateChartPeriodType.YEARS.getCode(), "Years");
optionData = new EnumOptionData(PeriodFrequencyType.YEARS.getValue().longValue(),
PeriodFrequencyType.YEARS.getCode(), "Years");
break;
}
return optionData;
}
public static List<EnumOptionData> periodType(final InterestRateChartPeriodType[] periodTypes) {
public static List<EnumOptionData> periodType(final PeriodFrequencyType[] periodTypes) {
final List<EnumOptionData> optionDatas = new ArrayList<EnumOptionData>();
for (final InterestRateChartPeriodType periodType : periodTypes) {
for (final PeriodFrequencyType periodType : periodTypes) {
if (!periodType.isInvalid()) {
optionDatas.add(periodType(periodType));
}
@@ -47,13 +47,6 @@ public class InterestRateChartReadPlatformServiceImpl implements InterestRateCha
this.chartDropdownReadPlatformService = chartDropdownReadPlatformService;
}
/*
* @Override public Collection<InterestRateChartData> retrieveAll(Long
* productId) {
*
* // TODO return null; }
*/
@Override
public InterestRateChartData retrieveOne(Long chartId) {
try {
@@ -65,14 +58,6 @@ public class InterestRateChartReadPlatformServiceImpl implements InterestRateCha
}
}
/*
* @Override public Collection<InterestRateChartData>
* retrieveAllWithSlabs() { this.context.authenticatedUser(); final String
* sql = "select " + this.chartExtractor.schema() +
* " order by irc.id, ircd.id "; return this.jdbcTemplate.query(sql,
* this.chartExtractor); }
*/
@Override
public Collection<InterestRateChartData> retrieveAllWithSlabs(Long productId) {
this.context.authenticatedUser();
@@ -143,6 +128,8 @@ public class InterestRateChartReadPlatformServiceImpl implements InterestRateCha
.append("ircd.id as ircdId, ircd.description as ircdDescription, ircd.period_type_enum ircdPeriodTypeId, ")
.append("ircd.from_period as ircdFromPeriod, ircd.to_period as ircdToPeriod, ircd.amount_range_from as ircdAmountRangeFrom, ")
.append("ircd.amount_range_to as ircdAmountRangeTo, ircd.annual_interest_rate as ircdAnnualInterestRate, ")
.append("ircd.interest_rate_for_female as ircdInterestRateForFemale, ircd.interest_rate_for_children as ircdInterestRateForChildren, ")
.append("ircd.interest_rate_for_senior_citizen as ircdInterestRateForSeniorCitizen, ")
.append("curr.code as currencyCode, curr.name as currencyName, curr.internationalized_name_code as currencyNameCode, ")
.append("curr.display_symbol as currencyDisplaySymbol, curr.decimal_places as currencyDigits, curr.currency_multiplesof as inMultiplesOf, ")
.append("sp.id as savingsProductId, sp.name as savingsProductName ")
@@ -198,7 +185,7 @@ public class InterestRateChartReadPlatformServiceImpl implements InterestRateCha
final StringBuilder sqlBuilder = new StringBuilder(400);
sqlBuilder.append("irc.id as ircId, irc.name as ircName, irc.description as ircDescription, ")
.append("irc.from_date as ircFromDate, irc.end_date as ircEndDate, irc.is_active_chart as isActiveChart, ")
.append("irc.from_date as ircFromDate, irc.end_date as ircEndDate, ")
.append("sp.id as savingsProductId, sp.name as savingsProductName ").append("from ")
.append("m_interest_rate_chart irc ")
.append("left join m_deposit_product_interest_rate_chart dpirc on irc.id=dpirc.interest_rate_chart_id ")
@@ -213,10 +200,10 @@ public class InterestRateChartReadPlatformServiceImpl implements InterestRateCha
final String description = rs.getString("ircDescription");
final LocalDate fromDate = JdbcSupport.getLocalDate(rs, "ircFromDate");
final LocalDate endDate = JdbcSupport.getLocalDate(rs, "ircEndDate");
final Long savingsProductId = rs.getLong("savingsProductId");
final Long savingsProductId = JdbcSupport.getLongDefaultToNullIfZero(rs, "savingsProductId");
final String savingsProductName = rs.getString("savingsProductName");
return InterestRateChartData.instance(id, name, description, fromDate, endDate, savingsProductId, savingsProductName, null);
return InterestRateChartData.instance(id, name, description, fromDate, endDate, savingsProductId, savingsProductName);
}
}
@@ -237,6 +224,8 @@ public class InterestRateChartReadPlatformServiceImpl implements InterestRateCha
.append("ircd.id as ircdId, ircd.description as ircdDescription, ircd.period_type_enum ircdPeriodTypeId, ")
.append("ircd.from_period as ircdFromPeriod, ircd.to_period as ircdToPeriod, ircd.amount_range_from as ircdAmountRangeFrom, ")
.append("ircd.amount_range_to as ircdAmountRangeTo, ircd.annual_interest_rate as ircdAnnualInterestRate, ")
.append("ircd.interest_rate_for_female as ircdInterestRateForFemale, ircd.interest_rate_for_children as ircdInterestRateForChildren, ")
.append("ircd.interest_rate_for_senior_citizen as ircdInterestRateForSeniorCitizen, ")
.append("curr.code as currencyCode, curr.name as currencyName, curr.internationalized_name_code as currencyNameCode, ")
.append("curr.display_symbol as currencyDisplaySymbol, curr.decimal_places as currencyDigits, curr.currency_multiplesof as inMultiplesOf ")
.append("from ").append("m_interest_rate_slab ircd ")
@@ -259,6 +248,9 @@ public class InterestRateChartReadPlatformServiceImpl implements InterestRateCha
final BigDecimal amountRangeFrom = rs.getBigDecimal("ircdAmountRangeFrom");
final BigDecimal amountRangeTo = rs.getBigDecimal("ircdAmountRangeTo");
final BigDecimal annualInterestRate = rs.getBigDecimal("ircdAnnualInterestRate");
final BigDecimal interestRateForFemale = rs.getBigDecimal("ircdInterestRateForFemale");
final BigDecimal interestRateForChildren = rs.getBigDecimal("ircdInterestRateForChildren");
final BigDecimal interestRateForSeniorCitizen = rs.getBigDecimal("ircdInterestRateForSeniorCitizen");
// currency Slabs
final String currencyCode = rs.getString("currencyCode");
@@ -272,7 +264,7 @@ public class InterestRateChartReadPlatformServiceImpl implements InterestRateCha
currencyDisplaySymbol, currencyNameCode);
return InterestRateChartSlabData.instance(id, description, periodType, fromPeriod, toPeriod, amountRangeFrom, amountRangeTo,
annualInterestRate, currency);
annualInterestRate, interestRateForFemale, interestRateForChildren, interestRateForSeniorCitizen, currency);
}
}
@@ -5,14 +5,17 @@
*/
package org.mifosplatform.portfolio.interestratechart.service;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.amountRangeFromParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.amountRangeToParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.annualInterestRateParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.amountRangeFromParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.amountRangeToParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.annualInterestRateParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.interestRateForFemaleParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.interestRateForChildrenParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.interestRateForSeniorCitizenParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.chartSlabs;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.descriptionParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.fromPeriodParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.periodTypeParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.toPeriodParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.fromPeriodParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.periodTypeParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.toPeriodParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.INTERESTRATE_CHART_SLAB_RESOURCE_NAME;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.currencyCodeParamName;
@@ -32,6 +35,7 @@ import org.mifosplatform.portfolio.interestratechart.data.InterestRateChartRepos
import org.mifosplatform.portfolio.interestratechart.domain.InterestRateChart;
import org.mifosplatform.portfolio.interestratechart.domain.InterestRateChartSlab;
import org.mifosplatform.portfolio.interestratechart.domain.InterestRateChartSlabFields;
import org.mifosplatform.portfolio.interestratechart.exception.InterestRateChartSlabNotFoundException;
import org.mifosplatform.portfolio.savings.SavingsPeriodFrequencyType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -64,7 +68,7 @@ public class InterestRateChartSlabAssembler {
final Locale locale = this.fromApiJsonHelper.extractLocaleParameter(elementObject);
final String currencyCode = command.stringValueOfParameterNamed(currencyCodeParamName);
final Long chartId = command.interestRateChartId();
final Long chartId = command.subentityId();// returns chart id
final InterestRateChart chart = this.interestRateChartRepositoryWrapper.findOneWithNotFoundDetection(chartId);
@@ -91,8 +95,12 @@ public class InterestRateChartSlabAssembler {
final BigDecimal amountRangeFrom = this.fromApiJsonHelper.extractBigDecimalNamed(amountRangeFromParamName, element, locale);
final BigDecimal amountRangeTo = this.fromApiJsonHelper.extractBigDecimalNamed(amountRangeToParamName, element, locale);
final BigDecimal annualInterestRate = this.fromApiJsonHelper.extractBigDecimalNamed(annualInterestRateParamName, element, locale);
final BigDecimal interestRateForFemale = this.fromApiJsonHelper.extractBigDecimalNamed(interestRateForFemaleParamName, element, locale);
final BigDecimal interestRateForChildren = this.fromApiJsonHelper.extractBigDecimalNamed(interestRateForChildrenParamName, element, locale);
final BigDecimal interestRateForSeniorCitizen = this.fromApiJsonHelper.extractBigDecimalNamed(interestRateForSeniorCitizenParamName, element, locale);
final InterestRateChartSlabFields slabFields = InterestRateChartSlabFields.createNew(description, periodType, fromPeriod, toPeriod,
amountRangeFrom, amountRangeTo, annualInterestRate, currencyCode);
amountRangeFrom, amountRangeTo, annualInterestRate, interestRateForFemale, interestRateForChildren, interestRateForSeniorCitizen, currencyCode);
return InterestRateChartSlab.createNew(slabFields, interestRateChart);
}
@@ -100,6 +108,9 @@ public class InterestRateChartSlabAssembler {
public InterestRateChartSlab assembleFrom(final Long chartSlabId, final Long chartId) {
final InterestRateChart chart = this.interestRateChartRepositoryWrapper.findOneWithNotFoundDetection(chartId);
final InterestRateChartSlab interestRateChartSlab = chart.findChartSlab(chartSlabId);
if (interestRateChartSlab == null) throw new InterestRateChartSlabNotFoundException(chartSlabId, chartId);
return interestRateChartSlab;
}
@@ -16,4 +16,6 @@ public interface InterestRateChartSlabReadPlatformService {
InterestRateChartSlabData retrieveOne(Long chartId, Long chartSlabId);
InterestRateChartSlabData retrieveWithTemplate(InterestRateChartSlabData chartSlab);
InterestRateChartSlabData retrieveTemplate();
}
@@ -62,6 +62,11 @@ public class InterestRateChartSlabReadPlatformServiceImpl implements InterestRat
return InterestRateChartSlabData.withTemplate(chartSlab, this.chartDropdownReadPlatformService.retrievePeriodTypeOptions());
}
@Override
public InterestRateChartSlabData retrieveTemplate() {
return InterestRateChartSlabData.template(this.chartDropdownReadPlatformService.retrievePeriodTypeOptions());
}
private static final class InterestRateChartSlabsMapper implements RowMapper<InterestRateChartSlabData> {
private final String schemaSql;
@@ -77,6 +82,8 @@ public class InterestRateChartSlabReadPlatformServiceImpl implements InterestRat
.append("ircd.id as ircdId, ircd.description as ircdDescription, ircd.period_type_enum ircdPeriodTypeId, ")
.append("ircd.from_period as ircdFromPeriod, ircd.to_period as ircdToPeriod, ircd.amount_range_from as ircdAmountRangeFrom, ")
.append("ircd.amount_range_to as ircdAmountRangeTo, ircd.annual_interest_rate as ircdAnnualInterestRate, ")
.append("ircd.interest_rate_for_female as ircdInterestRateForFemale, ircd.interest_rate_for_children as ircdInterestRateForChildren, ")
.append("ircd.interest_rate_for_senior_citizen as ircdInterestRateForSeniorCitizen, ")
.append("curr.code as currencyCode, curr.name as currencyName, curr.internationalized_name_code as currencyNameCode, ")
.append("curr.display_symbol as currencyDisplaySymbol, curr.decimal_places as currencyDigits, curr.currency_multiplesof as inMultiplesOf ")
.append("from ").append("m_interest_rate_slab ircd ")
@@ -99,6 +106,9 @@ public class InterestRateChartSlabReadPlatformServiceImpl implements InterestRat
final BigDecimal amountRangeFrom = rs.getBigDecimal("ircdAmountRangeFrom");
final BigDecimal amountRangeTo = rs.getBigDecimal("ircdAmountRangeTo");
final BigDecimal annualInterestRate = rs.getBigDecimal("ircdAnnualInterestRate");
final BigDecimal interestRateForFemale = rs.getBigDecimal("ircdInterestRateForFemale");
final BigDecimal interestRateForChildren = rs.getBigDecimal("ircdInterestRateForChildren");
final BigDecimal interestRateForSeniorCitizen = rs.getBigDecimal("ircdInterestRateForSeniorCitizen");
// currency Slabs
final String currencyCode = rs.getString("currencyCode");
@@ -112,7 +122,7 @@ public class InterestRateChartSlabReadPlatformServiceImpl implements InterestRat
currencyDisplaySymbol, currencyNameCode);
return InterestRateChartSlabData.instance(id, description, periodType, fromPeriod, toPeriod, amountRangeFrom, amountRangeTo,
annualInterestRate, currency);
annualInterestRate, interestRateForFemale, interestRateForChildren, interestRateForSeniorCitizen, currency);
}
}
@@ -63,7 +63,7 @@ public class InterestRateChartSlabWritePlatformServiceJpaRepositoryImpl implemen
final InterestRateChartSlab interestRateChartSlab = this.interestRateChartSlabAssembler.assembleFrom(command);
this.chartSlabRepository.saveAndFlush(interestRateChartSlab);
this.chartSlabRepository.save(interestRateChartSlab);
final Long interestRateChartId = interestRateChartSlab.getId();
@@ -121,6 +121,7 @@ import org.mifosplatform.portfolio.note.domain.Note;
import org.mifosplatform.portfolio.note.domain.NoteRepository;
import org.mifosplatform.portfolio.paymentdetail.domain.PaymentDetail;
import org.mifosplatform.portfolio.paymentdetail.service.PaymentDetailWritePlatformService;
import org.mifosplatform.portfolio.savings.domain.SavingsAccount;
import org.mifosplatform.portfolio.savings.exception.InsufficientAccountBalanceException;
import org.mifosplatform.useradministration.domain.AppUser;
import org.slf4j.Logger;
@@ -319,10 +320,11 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale);
for (final Map.Entry<Long, BigDecimal> entrySet : disBuLoanCharges.entrySet()) {
final PortfolioAccountData savingAccountData = this.accountAssociationsReadPlatformService.retriveLoanAssociation(loanId);
final SavingsAccount fromSavingsAccount = null;
final AccountTransferDTO accountTransferDTO = new AccountTransferDTO(actualDisbursementDate, entrySet.getValue(),
PortfolioAccountType.SAVINGS, PortfolioAccountType.LOAN, savingAccountData.accountId(), loanId, "Loan Charge Payment",
locale, fmt, null, null, LoanTransactionType.REPAYMENT_AT_DISBURSEMENT.getValue(), entrySet.getKey(), null,
AccountTransferType.CHARGE_PAYMENT.getValue(), null, null, null, null, null);
AccountTransferType.CHARGE_PAYMENT.getValue(), null, null, null, null, null, fromSavingsAccount);
this.accountTransfersWritePlatformService.transferFunds(accountTransferDTO);
}
@@ -491,10 +493,12 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
for (final Map.Entry<Long, BigDecimal> entrySet : disBuLoanCharges.entrySet()) {
final PortfolioAccountData savingAccountData = this.accountAssociationsReadPlatformService.retriveLoanAssociation(loan
.getId());
final SavingsAccount fromSavingsAccount = null;
final AccountTransferDTO accountTransferDTO = new AccountTransferDTO(actualDisbursementDate, entrySet.getValue(),
PortfolioAccountType.SAVINGS, PortfolioAccountType.LOAN, savingAccountData.accountId(), loan.getId(),
"Loan Charge Payment", locale, fmt, null, null, LoanTransactionType.REPAYMENT_AT_DISBURSEMENT.getValue(),
entrySet.getKey(), null, AccountTransferType.CHARGE_PAYMENT.getValue(), null, null, null, null, null);
entrySet.getKey(), null, AccountTransferType.CHARGE_PAYMENT.getValue(), null, null, null, null, null,
fromSavingsAccount);
this.accountTransfersWritePlatformService.transferFunds(accountTransferDTO);
}
}
@@ -1252,10 +1256,11 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final String errorMessage = "Charge with id:" + loanChargeId + " requires linked savings account for payment";
throw new LinkedAccountRequiredException("loanCharge.pay", errorMessage, loanChargeId);
}
final SavingsAccount fromSavingsAccount = null;
final AccountTransferDTO accountTransferDTO = new AccountTransferDTO(transactionDate, amount, PortfolioAccountType.SAVINGS,
PortfolioAccountType.LOAN, portfolioAccountData.accountId(), loanId, "Loan Charge Payment", locale, fmt, null, null,
LoanTransactionType.CHARGE_PAYMENT.getValue(), loanChargeId, loanInstallmentNumber,
AccountTransferType.CHARGE_PAYMENT.getValue(), null, null, null, null, null);
AccountTransferType.CHARGE_PAYMENT.getValue(), null, null, null, null, null, fromSavingsAccount);
this.accountTransfersWritePlatformService.transferFunds(accountTransferDTO);
return new CommandProcessingResultBuilder() //
@@ -1280,11 +1285,11 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final String errorMessage = "Disburse Loan with id:" + loan.getId() + " requires linked savings account for payment";
throw new LinkedAccountRequiredException("loan.disburse.to.savings", errorMessage, loan.getId());
}
final SavingsAccount fromSavingsAccount = null;
final AccountTransferDTO accountTransferDTO = new AccountTransferDTO(transactionDate, amount.getAmount(),
PortfolioAccountType.LOAN, PortfolioAccountType.SAVINGS, loan.getId(), portfolioAccountData.accountId(),
"Loan Disbursement", locale, fmt, paymentDetail, LoanTransactionType.DISBURSEMENT.getValue(), null, null, null,
AccountTransferType.ACCOUNT_TRANSFER.getValue(), null, null, txnExternalId, loan, null);
AccountTransferType.ACCOUNT_TRANSFER.getValue(), null, null, txnExternalId, loan, null, fromSavingsAccount);
this.accountTransfersWritePlatformService.transferFunds(accountTransferDTO);
}
@@ -1307,23 +1312,25 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
portfolioAccountData = this.accountAssociationsReadPlatformService.retriveLoanAssociation(chargeData
.getLoanId());
}
final SavingsAccount fromSavingsAccount = null;
final AccountTransferDTO accountTransferDTO = new AccountTransferDTO(new LocalDate(),
installmentChargeData.getAmountOutstanding(), PortfolioAccountType.SAVINGS, PortfolioAccountType.LOAN,
portfolioAccountData.accountId(), chargeData.getLoanId(), "Loan Charge Payment", null, null, null,
null, LoanTransactionType.CHARGE_PAYMENT.getValue(), chargeData.getId(),
installmentChargeData.getInstallmentNumber(), AccountTransferType.CHARGE_PAYMENT.getValue(), null,
null, null, null, null);
null, null, null, null, fromSavingsAccount);
transferFeeCharge(sb, accountTransferDTO);
}
}
} else if (chargeData.getDueDate() != null && !chargeData.getDueDate().isAfter(new LocalDate())) {
final PortfolioAccountData portfolioAccountData = this.accountAssociationsReadPlatformService
.retriveLoanAssociation(chargeData.getLoanId());
final SavingsAccount fromSavingsAccount = null;
final AccountTransferDTO accountTransferDTO = new AccountTransferDTO(new LocalDate(),
chargeData.getAmountOutstanding(), PortfolioAccountType.SAVINGS, PortfolioAccountType.LOAN,
portfolioAccountData.accountId(), chargeData.getLoanId(), "Loan Charge Payment", null, null, null, null,
LoanTransactionType.CHARGE_PAYMENT.getValue(), chargeData.getId(), null,
AccountTransferType.CHARGE_PAYMENT.getValue(), null, null, null, null, null);
AccountTransferType.CHARGE_PAYMENT.getValue(), null, null, null, null, null, fromSavingsAccount);
transferFeeCharge(sb, accountTransferDTO);
}
}
@@ -1812,7 +1819,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final JsonElement parsedCommand = this.fromApiJsonHelper.parse(overdueInstallment.toString());
final JsonCommand command = JsonCommand.from(overdueInstallment.toString(), parsedCommand, this.fromApiJsonHelper,
null, null, null, null, null, overdueInstallment.getLoanId(), null, null, null, null, null, null);
null, null, null, null, null, overdueInstallment.getLoanId(), null, null, null, null);
applyChargeToOverdueLoanInstallment(overdueInstallment.getLoanId(), overdueInstallment.getChargeId(),
overdueInstallment.getPeriodNumber(), command);
@@ -2032,10 +2039,11 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final String errorMessage = "Charge with id:" + loanChargeId + " requires linked savings account for payment";
throw new LinkedAccountRequiredException("loanCharge.pay", errorMessage, loanChargeId);
}
final SavingsAccount fromSavingsAccount = null;
final AccountTransferDTO accountTransferDTO = new AccountTransferDTO(transactionDate, amount, PortfolioAccountType.SAVINGS,
PortfolioAccountType.LOAN, portfolioAccountData.accountId(), loanId, "Loan Charge Payment", locale, fmt, null, null,
LoanTransactionType.CHARGE_PAYMENT.getValue(), loanChargeId, loanInstallmentNumber,
AccountTransferType.CHARGE_PAYMENT.getValue(), null, null, null, null, null);
AccountTransferType.CHARGE_PAYMENT.getValue(), null, null, null, null, null, fromSavingsAccount);
this.accountTransfersWritePlatformService.transferFunds(accountTransferDTO);
return transaction;
@@ -247,6 +247,9 @@ public class MeetingsApiResource {
case LOANS:
resourceDetails.withLoanId(entityId);
break;
case SAVINGS:
resourceDetails.withSavingsId(entityId);
break;
case INVALID:
break;
}
@@ -97,10 +97,6 @@ public class DepositsApiConstants {
public static final String bankNumberParamName = "bankNumber";
// Preclosure parameters
public static final String interestFreePeriodApplicableParamName = "interestFreePeriodApplicable";
public static final String interestFreeFromPeriodParamName = "interestFreeFromPeriod";
public static final String interestFreeToPeriodParamName = "interestFreeToPeriod";
public static final String interestFreePeriodFrequencyTypeIdParamName = "interestFreePeriodFrequencyTypeId";
public static final String preClosurePenalApplicableParamName = "preClosurePenalApplicable";
public static final String preClosurePenalInterestParamName = "preClosurePenalInterest";
public static final String preClosurePenalInterestOnTypeIdParamName = "preClosurePenalInterestOnTypeId";
@@ -125,12 +121,14 @@ public class DepositsApiConstants {
public static final String depositPeriodFrequencyIdParamName = "depositPeriodFrequencyId";
// recurring parameters
public static final String recurringDepositAmountParamName = "recurringDepositAmount";
public static final String recurringDepositType = "recurringDepositType";
public static final String recurringDepositFrequencyType = "recurringDepositFrequencyType";
public static final String recurringDepositFrequencyParamName = "recurringDepositFrequency";
public static final String recurringDepositTypeIdParamName = "recurringDepositTypeId";
public static final String recurringDepositFrequencyTypeIdParamName = "recurringDepositFrequencyTypeId";
public static final String mandatoryRecommendedDepositAmountParamName = "mandatoryRecommendedDepositAmount";
public static final String isMandatoryDepositParamName = "isMandatoryDeposit";
public static final String allowWithdrawalParamName = "allowWithdrawal";
public static final String adjustAdvanceTowardsFuturePaymentsParamName = "adjustAdvanceTowardsFuturePayments";
public static final String recurringFrequencyTypeParamName = "recurringFrequencyType";
public static final String recurringFrequencyParamName = "recurringFrequency";
public static final String isCalendarInheritedParamName = "isCalendarInherited";
// transaction parameters
public static final String transactionDateParamName = "transactionDate";
@@ -206,14 +204,10 @@ public class DepositsApiConstants {
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.PENALTY_INCOME_ACCOUNT_MAPPING.getValue(), chartsParamName));
private static final Set<String> PRECLOSURE_REQUEST_DATA_PARAMETERS = new HashSet<String>(Arrays.asList(
interestFreePeriodApplicableParamName, interestFreeFromPeriodParamName, interestFreeToPeriodParamName,
interestFreePeriodFrequencyTypeIdParamName, preClosurePenalApplicableParamName, preClosurePenalInterestParamName,
preClosurePenalInterestOnTypeIdParamName));
preClosurePenalApplicableParamName, preClosurePenalInterestParamName, preClosurePenalInterestOnTypeIdParamName));
private static final Set<String> PRECLOSURE_RESPONSE_DATA_PARAMETERS = new HashSet<String>(Arrays.asList(
interestFreePeriodApplicableParamName, interestFreeFromPeriodParamName, interestFreeToPeriodParamName,
interestFreePeriodFrequencyType, preClosurePenalApplicableParamName, preClosurePenalInterestParamName,
preClosurePenalInterestOnType));
preClosurePenalApplicableParamName, preClosurePenalInterestParamName, preClosurePenalInterestOnType));
private static final Set<String> DEPOSIT_TERM_REQUEST_DATA_PARAMETERS = new HashSet<String>(Arrays.asList(minDepositTermParamName,
maxDepositTermParamName, minDepositTermTypeIdParamName, maxDepositTermTypeIdParamName, inMultiplesOfDepositTermParamName,
@@ -224,11 +218,14 @@ public class DepositsApiConstants {
inMultiplesOfDepositTermType, depositAmountParamName, depositMinAmountParamName, depositMaxAmountParamName));
private static final Set<String> RECURRING_DETAILS_REQUEST_DATA_PARAMETERS = new HashSet<String>(Arrays.asList(
recurringDepositAmountParamName, recurringDepositTypeIdParamName, recurringDepositFrequencyTypeIdParamName,
recurringDepositFrequencyParamName));
mandatoryRecommendedDepositAmountParamName, isMandatoryDepositParamName, allowWithdrawalParamName,
adjustAdvanceTowardsFuturePaymentsParamName, recurringFrequencyTypeParamName, recurringFrequencyParamName,
isCalendarInheritedParamName));
private static final Set<String> RECURRING_DETAILS_RESPONSE_DATA_PARAMETERS = new HashSet<String>(Arrays.asList(
recurringDepositAmountParamName, recurringDepositType, recurringDepositFrequencyParamName, recurringDepositFrequencyType));
mandatoryRecommendedDepositAmountParamName, isMandatoryDepositParamName, allowWithdrawalParamName,
adjustAdvanceTowardsFuturePaymentsParamName, recurringFrequencyTypeParamName, recurringFrequencyParamName,
isCalendarInheritedParamName));
public static final Set<String> DEPOSIT_PRECLOSURE_CALCULATION_REQUEST_DATA_PARAMETERS = new HashSet<String>(
Arrays.asList(preMatureCloseOnDateParamName));
@@ -44,6 +44,7 @@ import org.mifosplatform.organisation.monetary.data.CurrencyData;
import org.mifosplatform.organisation.monetary.service.CurrencyReadPlatformService;
import org.mifosplatform.portfolio.charge.data.ChargeData;
import org.mifosplatform.portfolio.charge.service.ChargeReadPlatformService;
import org.mifosplatform.portfolio.common.service.DropdownReadPlatformService;
import org.mifosplatform.portfolio.interestratechart.data.InterestRateChartData;
import org.mifosplatform.portfolio.interestratechart.service.InterestRateChartReadPlatformService;
import org.mifosplatform.portfolio.paymentdetail.PaymentDetailConstants;
@@ -69,7 +70,7 @@ import org.springframework.util.CollectionUtils;
public class FixedDepositProductsApiResource {
private final DepositProductReadPlatformService depositProductReadPlatformService;
private final SavingsDropdownReadPlatformService dropdownReadPlatformService;
private final SavingsDropdownReadPlatformService savingsDropdownReadPlatformService;
private final CurrencyReadPlatformService currencyReadPlatformService;
private final PlatformSecurityContext context;
private final DefaultToApiJsonSerializer<FixedDepositProductData> toApiJsonSerializer;
@@ -82,10 +83,11 @@ public class FixedDepositProductsApiResource {
private final InterestRateChartReadPlatformService chartReadPlatformService;
private final InterestRateChartReadPlatformService interestRateChartReadPlatformService;
private final DepositsDropdownReadPlatformService depositsDropdownReadPlatformService;
private final DropdownReadPlatformService dropdownReadPlatformService;
@Autowired
public FixedDepositProductsApiResource(final DepositProductReadPlatformService depositProductReadPlatformService,
final SavingsDropdownReadPlatformService dropdownReadPlatformService,
final SavingsDropdownReadPlatformService savingsDropdownReadPlatformService,
final CurrencyReadPlatformService currencyReadPlatformService, final PlatformSecurityContext context,
final DefaultToApiJsonSerializer<FixedDepositProductData> toApiJsonSerializer,
final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService,
@@ -94,9 +96,10 @@ public class FixedDepositProductsApiResource {
final ProductToGLAccountMappingReadPlatformService accountMappingReadPlatformService,
final ChargeReadPlatformService chargeReadPlatformService, final InterestRateChartReadPlatformService chartReadPlatformService,
final InterestRateChartReadPlatformService interestRateChartReadPlatformService,
final DepositsDropdownReadPlatformService depositsDropdownReadPlatformService) {
final DepositsDropdownReadPlatformService depositsDropdownReadPlatformService,
final DropdownReadPlatformService dropdownReadPlatformService) {
this.depositProductReadPlatformService = depositProductReadPlatformService;
this.dropdownReadPlatformService = dropdownReadPlatformService;
this.savingsDropdownReadPlatformService = savingsDropdownReadPlatformService;
this.currencyReadPlatformService = currencyReadPlatformService;
this.context = context;
this.toApiJsonSerializer = toApiJsonSerializer;
@@ -109,6 +112,7 @@ public class FixedDepositProductsApiResource {
this.chartReadPlatformService = chartReadPlatformService;
this.interestRateChartReadPlatformService = interestRateChartReadPlatformService;
this.depositsDropdownReadPlatformService = depositsDropdownReadPlatformService;
this.dropdownReadPlatformService = dropdownReadPlatformService;
}
@POST
@@ -231,22 +235,23 @@ public class FixedDepositProductsApiResource {
currency = new ArrayList<CurrencyData>(currencyOptions).get(0);
}
final Collection<EnumOptionData> interestCompoundingPeriodTypeOptions = this.dropdownReadPlatformService
final Collection<EnumOptionData> interestCompoundingPeriodTypeOptions = this.savingsDropdownReadPlatformService
.retrieveCompoundingInterestPeriodTypeOptions();
final Collection<EnumOptionData> interestPostingPeriodTypeOptions = this.dropdownReadPlatformService
final Collection<EnumOptionData> interestPostingPeriodTypeOptions = this.savingsDropdownReadPlatformService
.retrieveInterestPostingPeriodTypeOptions();
final Collection<EnumOptionData> interestCalculationTypeOptions = this.dropdownReadPlatformService
final Collection<EnumOptionData> interestCalculationTypeOptions = this.savingsDropdownReadPlatformService
.retrieveInterestCalculationTypeOptions();
final Collection<EnumOptionData> interestCalculationDaysInYearTypeOptions = this.dropdownReadPlatformService
final Collection<EnumOptionData> interestCalculationDaysInYearTypeOptions = this.savingsDropdownReadPlatformService
.retrieveInterestCalculationDaysInYearTypeOptions();
final Collection<EnumOptionData> lockinPeriodFrequencyTypeOptions = this.dropdownReadPlatformService
final Collection<EnumOptionData> lockinPeriodFrequencyTypeOptions = this.savingsDropdownReadPlatformService
.retrieveLockinPeriodFrequencyTypeOptions();
final Collection<EnumOptionData> withdrawalFeeTypeOptions = this.dropdownReadPlatformService.retrievewithdrawalFeeTypeOptions();
final Collection<EnumOptionData> withdrawalFeeTypeOptions = this.savingsDropdownReadPlatformService
.retrievewithdrawalFeeTypeOptions();
final Collection<CodeValueData> paymentTypeOptions = this.codeValueReadPlatformService
.retrieveCodeValuesByCode(PaymentDetailConstants.paymentTypeCodeName);
@@ -260,13 +265,7 @@ public class FixedDepositProductsApiResource {
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions = this.depositsDropdownReadPlatformService
.retrievePreClosurePenalInterestOnTypeOptions();
final Collection<EnumOptionData> interestFreePeriodTypeOptions = this.depositsDropdownReadPlatformService
.retrieveInterestFreePeriodFrequencyTypeOptions();
final Collection<EnumOptionData> depositTermTypeOptions = this.depositsDropdownReadPlatformService.retrieveDepositTermTypeOptions();
final Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions = this.depositsDropdownReadPlatformService
.retrieveInMultiplesOfDepositTermTypeOptions();
final Collection<EnumOptionData> periodFrequencyTypeOptions = this.dropdownReadPlatformService.retrievePeriodFrequencyTypeOptions();
// charges
final boolean feeChargesOnly = true;
@@ -285,16 +284,14 @@ public class FixedDepositProductsApiResource {
interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions, interestCalculationTypeOptions,
interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions,
paymentTypeOptions, accountingRuleOptions, accountingMappingOptions, chargeOptions, penaltyOptions, chartTemplate,
interestFreePeriodTypeOptions, preClosurePenalInterestOnTypeOptions, depositTermTypeOptions,
inMultiplesOfDepositTermTypeOptions);
preClosurePenalInterestOnTypeOptions, periodFrequencyTypeOptions);
} else {
fixedDepositProductToReturn = FixedDepositProductData.template(currency, interestCompoundingPeriodType,
interestPostingPeriodType, interestCalculationType, interestCalculationDaysInYearType, accountingRule, currencyOptions,
interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions, interestCalculationTypeOptions,
interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions,
paymentTypeOptions, accountingRuleOptions, accountingMappingOptions, chargeOptions, penaltyOptions, chartTemplate,
interestFreePeriodTypeOptions, preClosurePenalInterestOnTypeOptions, depositTermTypeOptions,
inMultiplesOfDepositTermTypeOptions);
preClosurePenalInterestOnTypeOptions, periodFrequencyTypeOptions);
}
return fixedDepositProductToReturn;
@@ -90,7 +90,7 @@ public class RecurringDepositAccountTransactionsApiResource {
savingsAccount = this.depositAccountReadPlatformService
.retrieveRecurringAccountDepositTransactionTemplate(recurringDepositAccountId);
} else if (is(commandParam, "withdrawal")) {
//
} else {
throw new UnrecognizedQueryParamException("command", commandParam, new Object[] { "deposit", "withdrawal" });
}
@@ -168,7 +168,7 @@ public class RecurringDepositAccountTransactionsApiResource {
CommandProcessingResult result = null;
if (is(commandParam, DepositsApiConstants.COMMAND_UNDO_TRANSACTION)) {
final CommandWrapper commandRequest = builder.undoSavingsAccountTransaction(recurringDepositAccountId, transactionId).build();
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();
@@ -44,6 +44,7 @@ import org.mifosplatform.organisation.monetary.data.CurrencyData;
import org.mifosplatform.organisation.monetary.service.CurrencyReadPlatformService;
import org.mifosplatform.portfolio.charge.data.ChargeData;
import org.mifosplatform.portfolio.charge.service.ChargeReadPlatformService;
import org.mifosplatform.portfolio.common.service.DropdownReadPlatformService;
import org.mifosplatform.portfolio.interestratechart.data.InterestRateChartData;
import org.mifosplatform.portfolio.interestratechart.service.InterestRateChartReadPlatformService;
import org.mifosplatform.portfolio.paymentdetail.PaymentDetailConstants;
@@ -69,7 +70,7 @@ import org.springframework.util.CollectionUtils;
public class RecurringDepositProductsApiResource {
private final DepositProductReadPlatformService depositProductReadPlatformService;
private final SavingsDropdownReadPlatformService dropdownReadPlatformService;
private final SavingsDropdownReadPlatformService savingsDropdownReadPlatformService;
private final CurrencyReadPlatformService currencyReadPlatformService;
private final PlatformSecurityContext context;
private final DefaultToApiJsonSerializer<RecurringDepositProductData> toApiJsonSerializer;
@@ -82,10 +83,11 @@ public class RecurringDepositProductsApiResource {
private final InterestRateChartReadPlatformService chartReadPlatformService;
private final InterestRateChartReadPlatformService interestRateChartReadPlatformService;
private final DepositsDropdownReadPlatformService depositsDropdownReadPlatformService;
private final DropdownReadPlatformService dropdownReadPlatformService;
@Autowired
public RecurringDepositProductsApiResource(final DepositProductReadPlatformService depositProductReadPlatformService,
final SavingsDropdownReadPlatformService dropdownReadPlatformService,
final SavingsDropdownReadPlatformService savingsDropdownReadPlatformService,
final CurrencyReadPlatformService currencyReadPlatformService, final PlatformSecurityContext context,
final DefaultToApiJsonSerializer<RecurringDepositProductData> toApiJsonSerializer,
final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService,
@@ -94,9 +96,10 @@ public class RecurringDepositProductsApiResource {
final ProductToGLAccountMappingReadPlatformService accountMappingReadPlatformService,
final ChargeReadPlatformService chargeReadPlatformService, final InterestRateChartReadPlatformService chartReadPlatformService,
final InterestRateChartReadPlatformService interestRateChartReadPlatformService,
final DepositsDropdownReadPlatformService depositsDropdownReadPlatformService) {
final DepositsDropdownReadPlatformService depositsDropdownReadPlatformService,
final DropdownReadPlatformService dropdownReadPlatformService) {
this.depositProductReadPlatformService = depositProductReadPlatformService;
this.dropdownReadPlatformService = dropdownReadPlatformService;
this.savingsDropdownReadPlatformService = savingsDropdownReadPlatformService;
this.currencyReadPlatformService = currencyReadPlatformService;
this.context = context;
this.toApiJsonSerializer = toApiJsonSerializer;
@@ -109,6 +112,7 @@ public class RecurringDepositProductsApiResource {
this.chartReadPlatformService = chartReadPlatformService;
this.interestRateChartReadPlatformService = interestRateChartReadPlatformService;
this.depositsDropdownReadPlatformService = depositsDropdownReadPlatformService;
this.dropdownReadPlatformService = dropdownReadPlatformService;
}
@POST
@@ -232,22 +236,23 @@ public class RecurringDepositProductsApiResource {
currency = new ArrayList<CurrencyData>(currencyOptions).get(0);
}
final Collection<EnumOptionData> interestCompoundingPeriodTypeOptions = this.dropdownReadPlatformService
final Collection<EnumOptionData> interestCompoundingPeriodTypeOptions = this.savingsDropdownReadPlatformService
.retrieveCompoundingInterestPeriodTypeOptions();
final Collection<EnumOptionData> interestPostingPeriodTypeOptions = this.dropdownReadPlatformService
final Collection<EnumOptionData> interestPostingPeriodTypeOptions = this.savingsDropdownReadPlatformService
.retrieveInterestPostingPeriodTypeOptions();
final Collection<EnumOptionData> interestCalculationTypeOptions = this.dropdownReadPlatformService
final Collection<EnumOptionData> interestCalculationTypeOptions = this.savingsDropdownReadPlatformService
.retrieveInterestCalculationTypeOptions();
final Collection<EnumOptionData> interestCalculationDaysInYearTypeOptions = this.dropdownReadPlatformService
final Collection<EnumOptionData> interestCalculationDaysInYearTypeOptions = this.savingsDropdownReadPlatformService
.retrieveInterestCalculationDaysInYearTypeOptions();
final Collection<EnumOptionData> lockinPeriodFrequencyTypeOptions = this.dropdownReadPlatformService
final Collection<EnumOptionData> lockinPeriodFrequencyTypeOptions = this.savingsDropdownReadPlatformService
.retrieveLockinPeriodFrequencyTypeOptions();
final Collection<EnumOptionData> withdrawalFeeTypeOptions = this.dropdownReadPlatformService.retrievewithdrawalFeeTypeOptions();
final Collection<EnumOptionData> withdrawalFeeTypeOptions = this.savingsDropdownReadPlatformService
.retrievewithdrawalFeeTypeOptions();
final Collection<CodeValueData> paymentTypeOptions = this.codeValueReadPlatformService
.retrieveCodeValuesByCode(PaymentDetailConstants.paymentTypeCodeName);
@@ -257,8 +262,6 @@ public class RecurringDepositProductsApiResource {
.retrieveAccountMappingOptionsForSavingsProducts();
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions = this.depositsDropdownReadPlatformService
.retrievePreClosurePenalInterestOnTypeOptions();
final Collection<EnumOptionData> interestFreePeriodTypeOptions = this.depositsDropdownReadPlatformService
.retrieveInterestFreePeriodFrequencyTypeOptions();
// charges
final boolean feeChargesOnly = true;
@@ -268,15 +271,7 @@ public class RecurringDepositProductsApiResource {
Collection<ChargeData> penaltyOptions = this.chargeReadPlatformService.retrieveSavingsAccountApplicablePenalties();
penaltyOptions = CollectionUtils.isEmpty(penaltyOptions) ? null : penaltyOptions;
Collection<EnumOptionData> recurringDepositTypeOptions = this.depositsDropdownReadPlatformService
.retrieveRecurringDepositTypeOptions();
Collection<EnumOptionData> recurringDepositFrequencyTypeOptions = this.depositsDropdownReadPlatformService
.retrieveRecurringDepositFrequencyTypeOptions();
final Collection<EnumOptionData> depositTermTypeOptions = this.depositsDropdownReadPlatformService.retrieveDepositTermTypeOptions();
final Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions = this.depositsDropdownReadPlatformService
.retrieveInMultiplesOfDepositTermTypeOptions();
final Collection<EnumOptionData> periodFrequencyTypeOptions = this.dropdownReadPlatformService.retrievePeriodFrequencyTypeOptions();
// interest rate chart template
final InterestRateChartData chartTemplate = this.interestRateChartReadPlatformService.template();
@@ -287,16 +282,14 @@ public class RecurringDepositProductsApiResource {
interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions, interestCalculationTypeOptions,
interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions,
paymentTypeOptions, accountingRuleOptions, accountingMappingOptions, chargeOptions, penaltyOptions, chartTemplate,
interestFreePeriodTypeOptions, preClosurePenalInterestOnTypeOptions, recurringDepositTypeOptions,
recurringDepositFrequencyTypeOptions, depositTermTypeOptions, inMultiplesOfDepositTermTypeOptions);
preClosurePenalInterestOnTypeOptions, periodFrequencyTypeOptions);
} else {
recurringDepositProductToReturn = RecurringDepositProductData.template(currency, interestCompoundingPeriodType,
interestPostingPeriodType, interestCalculationType, interestCalculationDaysInYearType, accountingRule, currencyOptions,
interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions, interestCalculationTypeOptions,
interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions,
paymentTypeOptions, accountingRuleOptions, accountingMappingOptions, chargeOptions, penaltyOptions, chartTemplate,
interestFreePeriodTypeOptions, preClosurePenalInterestOnTypeOptions, recurringDepositTypeOptions,
recurringDepositFrequencyTypeOptions, depositTermTypeOptions, inMultiplesOfDepositTermTypeOptions);
preClosurePenalInterestOnTypeOptions, periodFrequencyTypeOptions);
}
return recurringDepositProductToReturn;
@@ -29,8 +29,8 @@ public class DepositAccountData {
protected final String groupName;
protected final Long clientId;
protected final String clientName;
protected final Long savingsProductId;
protected final String savingsProductName;
protected final Long depositProductId;
protected final String depositProductName;
protected final Long fieldOfficerId;
protected final String fieldOfficerName;
protected final SavingsAccountStatusEnumData status;
@@ -177,8 +177,8 @@ public class DepositAccountData {
this.groupName = groupName;
this.clientId = clientId;
this.clientName = clientName;
this.savingsProductId = productId;
this.savingsProductName = productName;
this.depositProductId = productId;
this.depositProductName = productName;
this.fieldOfficerId = fieldofficerId;
this.fieldOfficerName = fieldofficerName;
this.status = status;
@@ -244,7 +244,7 @@ public class DepositAccountData {
}
public Long productId() {
return this.savingsProductId;
return this.depositProductId;
}
public CurrencyData currency() {
@@ -5,16 +5,17 @@
*/
package org.mifosplatform.portfolio.savings.data;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.adjustAdvanceTowardsFuturePaymentsParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.allowWithdrawalParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.depositAmountParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.depositPeriodFrequencyIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.depositPeriodParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.inMultiplesOfDepositTermParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.inMultiplesOfDepositTermTypeIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.interestFreeFromPeriodParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.interestFreePeriodApplicableParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.interestFreePeriodFrequencyTypeIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.interestFreeToPeriodParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.isCalendarInheritedParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.isMandatoryDepositParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.linkedAccountParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.mandatoryRecommendedDepositAmountParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.maxDepositTermParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.maxDepositTermTypeIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.minDepositTermParamName;
@@ -22,9 +23,8 @@ import static org.mifosplatform.portfolio.savings.DepositsApiConstants.minDeposi
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.preClosurePenalApplicableParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.preClosurePenalInterestOnTypeIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.preClosurePenalInterestParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.recurringDepositFrequencyParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.recurringDepositFrequencyTypeIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.recurringDepositTypeIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.recurringFrequencyParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.recurringFrequencyTypeParamName;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.accountNoParamName;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.amountParamName;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.chargeIdParamName;
@@ -62,11 +62,10 @@ import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder;
import org.mifosplatform.infrastructure.core.exception.InvalidJsonException;
import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException;
import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper;
import org.mifosplatform.portfolio.interestratechart.InterestRateChartPeriodType;
import org.mifosplatform.portfolio.calendar.domain.CalendarFrequencyType;
import org.mifosplatform.portfolio.savings.DepositAccountType;
import org.mifosplatform.portfolio.savings.DepositsApiConstants;
import org.mifosplatform.portfolio.savings.PreClosurePenalInterestOnType;
import org.mifosplatform.portfolio.savings.RecurringDepositType;
import org.mifosplatform.portfolio.savings.SavingsCompoundingInterestPeriodType;
import org.mifosplatform.portfolio.savings.SavingsInterestCalculationDaysInYearType;
import org.mifosplatform.portfolio.savings.SavingsInterestCalculationType;
@@ -93,7 +92,7 @@ public class DepositAccountDataValidator {
this.productDataValidator = productDataValidator;
}
private void validateFixedDepositForSubmit(final String json) {
public void validateFixedDepositForSubmit(final String json) {
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
@@ -113,7 +112,7 @@ public class DepositAccountDataValidator {
throwExceptionIfValidationWarningsExist(dataValidationErrors);
}
private void validateFixedDepositForUpdate(final String json) {
public void validateFixedDepositForUpdate(final String json) {
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
@@ -133,7 +132,7 @@ public class DepositAccountDataValidator {
throwExceptionIfValidationWarningsExist(dataValidationErrors);
}
private void validateRecurringDepositForSubmit(final String json) {
public void validateRecurringDepositForSubmit(final String json) {
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
@@ -154,7 +153,7 @@ public class DepositAccountDataValidator {
throwExceptionIfValidationWarningsExist(dataValidationErrors);
}
private void validateRecurringDepositForUpdate(final String json) {
public void validateRecurringDepositForUpdate(final String json) {
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
@@ -253,13 +252,16 @@ public class DepositAccountDataValidator {
baseDataValidator.reset().parameter(minRequiredOpeningBalanceParamName).value(minOpeningBalance).zeroOrPositiveAmount();
}
boolean isLockinPeriodFrequencyValidated = false;
boolean isLockinPeriodFrequencyTypeValidated = false;
if (this.fromApiJsonHelper.parameterExists(lockinPeriodFrequencyParamName, element)) {
isLockinPeriodFrequencyValidated = true;
final Integer lockinPeriodFrequency = this.fromApiJsonHelper.extractIntegerWithLocaleNamed(lockinPeriodFrequencyParamName,
element);
baseDataValidator.reset().parameter(lockinPeriodFrequencyParamName).value(lockinPeriodFrequency).integerZeroOrGreater();
if (lockinPeriodFrequency != null) {
isLockinPeriodFrequencyTypeValidated = true;
final Integer lockinPeriodFrequencyType = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(
lockinPeriodFrequencyTypeParamName, element);
baseDataValidator.reset().parameter(lockinPeriodFrequencyTypeParamName).value(lockinPeriodFrequencyType).notNull()
@@ -267,12 +269,12 @@ public class DepositAccountDataValidator {
}
}
if (this.fromApiJsonHelper.parameterExists(lockinPeriodFrequencyTypeParamName, element)) {
if (!isLockinPeriodFrequencyTypeValidated && this.fromApiJsonHelper.parameterExists(lockinPeriodFrequencyTypeParamName, element)) {
final Integer lockinPeriodFrequencyType = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(
lockinPeriodFrequencyTypeParamName, element);
baseDataValidator.reset().parameter(lockinPeriodFrequencyTypeParamName).value(lockinPeriodFrequencyType).inMinMaxRange(0, 3);
if (lockinPeriodFrequencyType != null) {
if (lockinPeriodFrequencyType != null && !isLockinPeriodFrequencyValidated) {
final Integer lockinPeriodFrequency = this.fromApiJsonHelper.extractIntegerWithLocaleNamed(lockinPeriodFrequencyParamName,
element);
baseDataValidator.reset().parameter(lockinPeriodFrequencyParamName).value(lockinPeriodFrequency).notNull()
@@ -425,31 +427,6 @@ public class DepositAccountDataValidator {
}
private void validatePreClosureDetailForSubmit(final JsonElement element, final DataValidatorBuilder baseDataValidator) {
if (fromApiJsonHelper.parameterExists(interestFreePeriodApplicableParamName, element)) {
final boolean interestFreePeriodApplicable = fromApiJsonHelper.extractBooleanNamed(interestFreePeriodApplicableParamName,
element);
if (interestFreePeriodApplicable) {
final Integer interestFreeFromPeriod = fromApiJsonHelper.extractIntegerSansLocaleNamed(interestFreeFromPeriodParamName,
element);
baseDataValidator.reset().parameter(interestFreeFromPeriodParamName).value(interestFreeFromPeriod)
.cantBeBlankWhenParameterProvidedIs(interestFreePeriodApplicableParamName, interestFreePeriodApplicable)
.integerZeroOrGreater();
final Integer interestFreeToPeriod = fromApiJsonHelper
.extractIntegerSansLocaleNamed(interestFreeToPeriodParamName, element);
baseDataValidator.reset().parameter(interestFreeToPeriodParamName).value(interestFreeToPeriod)
.cantBeBlankWhenParameterProvidedIs(interestFreePeriodApplicableParamName, interestFreePeriodApplicable)
.integerZeroOrGreater().integerGreaterThanNumber(interestFreeFromPeriod);
final Integer periodFrequencyType = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(
interestFreePeriodFrequencyTypeIdParamName, element);
baseDataValidator.reset().parameter(interestFreePeriodFrequencyTypeIdParamName).value(periodFrequencyType)
.cantBeBlankWhenParameterProvidedIs(interestFreePeriodApplicableParamName, interestFreePeriodApplicable)
.isOneOfTheseValues(InterestRateChartPeriodType.integerValues());
}
}
if (fromApiJsonHelper.parameterExists(preClosurePenalApplicableParamName, element)) {
final boolean preClosurePenalApplicable = fromApiJsonHelper.extractBooleanNamed(preClosurePenalApplicableParamName, element);
@@ -549,38 +526,106 @@ public class DepositAccountDataValidator {
}
private void validateRecurringDetailForSubmit(final JsonElement element, final DataValidatorBuilder baseDataValidator) {
if (fromApiJsonHelper.parameterExists(recurringDepositTypeIdParamName, element)) {
final Integer rdTypeId = fromApiJsonHelper.extractIntegerSansLocaleNamed(recurringDepositTypeIdParamName, element);
baseDataValidator.reset().parameter(recurringDepositTypeIdParamName).value(rdTypeId).notNull()
.isOneOfTheseValues(RecurringDepositType.integerValues());
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);
baseDataValidator.reset().parameter(isMandatoryDepositParamName).value(isMandatoryDeposit).ignoreIfNull()
.validateForBooleanValue();
}
if (fromApiJsonHelper.parameterExists(recurringDepositFrequencyParamName, element)) {
final Integer rdFrequency = fromApiJsonHelper.extractIntegerSansLocaleNamed(recurringDepositFrequencyParamName, element);
baseDataValidator.reset().parameter(recurringDepositFrequencyParamName).value(rdFrequency).notNull().integerGreaterThanZero();
if (this.fromApiJsonHelper.parameterExists(allowWithdrawalParamName, element)) {
final Boolean allowWithdrawal = this.fromApiJsonHelper.extractBooleanNamed(allowWithdrawalParamName, element);
baseDataValidator.reset().parameter(allowWithdrawalParamName).value(allowWithdrawal).ignoreIfNull().validateForBooleanValue();
}
if (fromApiJsonHelper.parameterExists(recurringDepositFrequencyTypeIdParamName, element)) {
final Integer rdFrequencyTypeId = fromApiJsonHelper.extractIntegerSansLocaleNamed(recurringDepositFrequencyTypeIdParamName,
element);
baseDataValidator.reset().parameter(recurringDepositFrequencyTypeIdParamName).value(rdFrequencyTypeId).notNull()
.isOneOfTheseValues(SavingsPeriodFrequencyType.integerValues());
if (this.fromApiJsonHelper.parameterExists(adjustAdvanceTowardsFuturePaymentsParamName, element)) {
final Boolean adjustAdvanceTowardsFuturePayments = this.fromApiJsonHelper.extractBooleanNamed(
adjustAdvanceTowardsFuturePaymentsParamName, element);
baseDataValidator.reset().parameter(adjustAdvanceTowardsFuturePaymentsParamName).value(adjustAdvanceTowardsFuturePayments)
.ignoreIfNull().validateForBooleanValue();
}
// First validate if string is empty
final String isCalendarInheritedString = this.fromApiJsonHelper.extractStringNamed(isCalendarInheritedParamName, element);
if (StringUtils.isBlank(isCalendarInheritedString)) {
baseDataValidator.reset().parameter(isCalendarInheritedParamName).value(isCalendarInheritedString).notBlank();
} else {
// validate the boolean value
final Boolean isCalendarInherited = this.fromApiJsonHelper.extractBooleanNamed(isCalendarInheritedParamName, element);
baseDataValidator.reset().parameter(isCalendarInheritedParamName).value(isCalendarInherited).notNull()
.validateForBooleanValue();
if (!isCalendarInherited) {
final Integer frequencyType = this.fromApiJsonHelper
.extractIntegerSansLocaleNamed(recurringFrequencyTypeParamName, element);
baseDataValidator.reset().parameter(recurringFrequencyTypeParamName).value(frequencyType).notBlank()
.inMinMaxRange(CalendarFrequencyType.getMinValue(), CalendarFrequencyType.getMaxValue());
final Integer frequency = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(recurringFrequencyParamName, element);
baseDataValidator.reset().parameter(recurringFrequencyParamName).value(frequency).notNull().integerGreaterThanZero();
/*
* if (CalendarFrequencyType.fromInt(frequency).isWeekly()) {
* final Integer repeatsOnDay =
* this.fromApiJsonHelper.extractIntegerSansLocaleNamed
* (repeatsOnDayParamName, element);
* baseDataValidator.reset().parameter
* (repeatsOnDayParamName).value(repeatsOnDay).notBlank()
* .inMinMaxRange(CalendarWeekDaysType.getMinValue(),
* CalendarWeekDaysType.getMaxValue()); }
*/
}
}
}
private void validateRecurringDetailForUpdate(final JsonElement element, final DataValidatorBuilder baseDataValidator) {
this.productDataValidator.validateRecurringDepositUpdate(element, baseDataValidator);
}
if (this.fromApiJsonHelper.parameterExists(isMandatoryDepositParamName, element)) {
final Boolean isMandatoryDeposit = this.fromApiJsonHelper.extractBooleanNamed(isMandatoryDepositParamName, element);
baseDataValidator.reset().parameter(isMandatoryDepositParamName).value(isMandatoryDeposit).ignoreIfNull()
.validateForBooleanValue();
}
public void validateForSubmit(final String json, final DepositAccountType depositAccountType) {
if (this.fromApiJsonHelper.parameterExists(allowWithdrawalParamName, element)) {
final Boolean allowWithdrawal = this.fromApiJsonHelper.extractBooleanNamed(allowWithdrawalParamName, element);
baseDataValidator.reset().parameter(allowWithdrawalParamName).value(allowWithdrawal).ignoreIfNull().validateForBooleanValue();
}
if (depositAccountType.isFixedDeposit()) {
this.validateFixedDepositForSubmit(json);
} else if (depositAccountType.isRecurringDeposit()) {
this.validateRecurringDepositForSubmit(json);
} else {
// FIXME: AA handle unsupported deposit account type
// throw unsupported account type exception
if (this.fromApiJsonHelper.parameterExists(adjustAdvanceTowardsFuturePaymentsParamName, element)) {
final Boolean adjustAdvanceTowardsFuturePayments = this.fromApiJsonHelper.extractBooleanNamed(
adjustAdvanceTowardsFuturePaymentsParamName, element);
baseDataValidator.reset().parameter(adjustAdvanceTowardsFuturePaymentsParamName).value(adjustAdvanceTowardsFuturePayments)
.ignoreIfNull().validateForBooleanValue();
}
if (this.fromApiJsonHelper.parameterExists(isCalendarInheritedParamName, element)) {
final Boolean isCalendarInherited = this.fromApiJsonHelper.extractBooleanNamed(isCalendarInheritedParamName, element);
baseDataValidator.reset().parameter(isCalendarInheritedParamName).value(isCalendarInherited).notNull()
.validateForBooleanValue();
}
if (this.fromApiJsonHelper.parameterExists(recurringFrequencyTypeParamName, element)) {
final Integer frequencyType = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(recurringFrequencyTypeParamName, element);
baseDataValidator.reset().parameter(recurringFrequencyTypeParamName).value(frequencyType).notBlank()
.inMinMaxRange(CalendarFrequencyType.getMinValue(), CalendarFrequencyType.getMaxValue());
}
if (this.fromApiJsonHelper.parameterExists(recurringFrequencyParamName, element)) {
final Integer frequency = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(recurringFrequencyParamName, element);
baseDataValidator.reset().parameter(recurringFrequencyParamName).value(frequency).notNull().integerGreaterThanZero();
/*
* if (this.fromApiJsonHelper.parameterExists(repeatsOnDayParamName,
* element)) { if
* (CalendarFrequencyType.fromInt(frequency).isWeekly()) { final
* Integer repeatsOnDay =
* this.fromApiJsonHelper.extractIntegerSansLocaleNamed
* (repeatsOnDayParamName, element);
* baseDataValidator.reset().parameter
* (repeatsOnDayParamName).value(repeatsOnDay).notBlank()
* .inMinMaxRange(CalendarWeekDaysType.getMinValue(),
* CalendarWeekDaysType.getMaxValue()); } }
*/
}
}
@@ -649,19 +694,6 @@ public class DepositAccountDataValidator {
}
}
public void validateForUpdate(final String json, final DepositAccountType depositAccountType) {
if (depositAccountType.isFixedDeposit()) {
this.validateFixedDepositForUpdate(json);
} else if (depositAccountType.isRecurringDeposit()) {
this.validateRecurringDepositForUpdate(json);
} else {
// FIXME: AA handle unsupported deposit account type
// throw unsupported account type exception
}
}
private void throwExceptionIfValidationWarningsExist(final List<ApiParameterError> dataValidationErrors) {
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
}
@@ -25,34 +25,47 @@ public class DepositAccountInterestRateChartSlabData {
private final BigDecimal amountRangeFrom;
private final BigDecimal amountRangeTo;
private final BigDecimal annualInterestRate;
private final BigDecimal interestRateForFemale;
private final BigDecimal interestRateForChildren;
private final BigDecimal interestRateForSeniorCitizen;
private final CurrencyData currency;
// associations
// template
@SuppressWarnings("unused")
private Collection<EnumOptionData> periodTypes;
private final Collection<EnumOptionData> periodTypes;
public static DepositAccountInterestRateChartSlabData instance(Long id, String description, EnumOptionData periodType, Integer fromPeriod,
Integer toPeriod, BigDecimal amountRangeFrom, BigDecimal amountRangeTo, BigDecimal annualInterestRate, CurrencyData currency) {
Collection<EnumOptionData> periodTypes = null;
return new DepositAccountInterestRateChartSlabData(id, description, periodType, fromPeriod, toPeriod, amountRangeFrom, amountRangeTo,
annualInterestRate, currency, periodTypes);
}
public static DepositAccountInterestRateChartSlabData from(InterestRateChartSlabData chartSlabData) {
final Long id = null;
return new DepositAccountInterestRateChartSlabData(id, chartSlabData.description(), chartSlabData.periodType(), chartSlabData.fromPeriod(), chartSlabData.toPeriod(), chartSlabData.amountRangeFrom(), chartSlabData.amountRangeTo(),
chartSlabData.annualInterestRate(), chartSlabData.currency(), chartSlabData.periodTypes());
}
public static DepositAccountInterestRateChartSlabData withTemplate(DepositAccountInterestRateChartSlabData chartSlab, Collection<EnumOptionData> periodTypes) {
return new DepositAccountInterestRateChartSlabData(chartSlab.id, chartSlab.description, chartSlab.periodType, chartSlab.fromPeriod, chartSlab.toPeriod, chartSlab.amountRangeFrom, chartSlab.amountRangeTo,
chartSlab.annualInterestRate, chartSlab.currency, periodTypes);
public static DepositAccountInterestRateChartSlabData instance(final Long id, final String description,
final EnumOptionData periodType, final Integer fromPeriod, final Integer toPeriod, final BigDecimal amountRangeFrom,
final BigDecimal amountRangeTo, final BigDecimal annualInterestRate, final BigDecimal interestRateForFemale,
final BigDecimal interestRateForChildren, final BigDecimal interestRateForSeniorCitizen, final CurrencyData currency) {
final Collection<EnumOptionData> periodTypes = null;
return new DepositAccountInterestRateChartSlabData(id, description, periodType, fromPeriod, toPeriod, amountRangeFrom,
amountRangeTo, annualInterestRate, interestRateForFemale, interestRateForChildren, interestRateForSeniorCitizen, currency,
periodTypes);
}
private DepositAccountInterestRateChartSlabData(Long id, String description, EnumOptionData periodType, Integer fromPeriod, Integer toPeriod,
BigDecimal amountRangeFrom, BigDecimal amountRangeTo, BigDecimal annualInterestRate, CurrencyData currency, Collection<EnumOptionData> periodTypes) {
public static DepositAccountInterestRateChartSlabData from(final InterestRateChartSlabData chartSlabData) {
final Long id = null;
return new DepositAccountInterestRateChartSlabData(id, chartSlabData.description(), chartSlabData.periodType(),
chartSlabData.fromPeriod(), chartSlabData.toPeriod(), chartSlabData.amountRangeFrom(), chartSlabData.amountRangeTo(),
chartSlabData.annualInterestRate(), chartSlabData.interestRateForFemale(), chartSlabData.interestRateForChildren(),
chartSlabData.interestRateForSeniorCitizen(), chartSlabData.currency(), chartSlabData.periodTypes());
}
public static DepositAccountInterestRateChartSlabData withTemplate(final DepositAccountInterestRateChartSlabData chartSlab,
final Collection<EnumOptionData> periodTypes) {
return new DepositAccountInterestRateChartSlabData(chartSlab.id, chartSlab.description, chartSlab.periodType, chartSlab.fromPeriod,
chartSlab.toPeriod, chartSlab.amountRangeFrom, chartSlab.amountRangeTo, chartSlab.annualInterestRate,
chartSlab.interestRateForFemale, chartSlab.interestRateForChildren, chartSlab.interestRateForSeniorCitizen,
chartSlab.currency, periodTypes);
}
private DepositAccountInterestRateChartSlabData(final Long id, final String description, final EnumOptionData periodType,
final Integer fromPeriod, final Integer toPeriod, final BigDecimal amountRangeFrom, final BigDecimal amountRangeTo,
final BigDecimal annualInterestRate, final BigDecimal interestRateForFemale, final BigDecimal interestRateForChildren,
final BigDecimal interestRateForSeniorCitizen, final CurrencyData currency, final Collection<EnumOptionData> periodTypes) {
this.id = id;
this.description = description;
this.periodType = periodType;
@@ -61,6 +74,9 @@ public class DepositAccountInterestRateChartSlabData {
this.amountRangeFrom = amountRangeFrom;
this.amountRangeTo = amountRangeTo;
this.annualInterestRate = annualInterestRate;
this.interestRateForFemale = interestRateForFemale;
this.interestRateForChildren = interestRateForChildren;
this.interestRateForSeniorCitizen = interestRateForSeniorCitizen;
this.currency = currency;
this.periodTypes = periodTypes;
}
@@ -159,7 +159,7 @@ public class DepositAccountTransactionDataValidator {
if (accountOnClosureType.isTransferToSavings()) {
final Long toSavingsAccountId = this.fromApiJsonHelper.extractLongNamed(toSavingsAccountIdParamName, element);
baseDataValidator.reset().parameter(toSavingsAccountIdParamName).value(toSavingsAccountId)
.cantBeBlankWhenParameterProvidedIs(onAccountClosureIdParamName, onAccountClosureId);
.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");
@@ -10,16 +10,15 @@ import static org.mifosplatform.portfolio.savings.DepositsApiConstants.FIXED_DEP
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.FIXED_DEPOSIT_PRODUCT_RESOURCE_NAME;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.RECURRING_DEPOSIT_PRODUCT_REQUEST_DATA_PARAMETERS;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.RECURRING_DEPOSIT_PRODUCT_RESOURCE_NAME;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.adjustAdvanceTowardsFuturePaymentsParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.allowWithdrawalParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.chartsParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.depositAmountParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.depositMaxAmountParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.depositMinAmountParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.inMultiplesOfDepositTermParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.inMultiplesOfDepositTermTypeIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.interestFreeFromPeriodParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.interestFreePeriodApplicableParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.interestFreePeriodFrequencyTypeIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.interestFreeToPeriodParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.isMandatoryDepositParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.maxDepositTermParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.maxDepositTermTypeIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.minDepositTermParamName;
@@ -27,9 +26,6 @@ import static org.mifosplatform.portfolio.savings.DepositsApiConstants.minDeposi
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.preClosurePenalApplicableParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.preClosurePenalInterestOnTypeIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.preClosurePenalInterestParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.recurringDepositFrequencyParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.recurringDepositFrequencyTypeIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.recurringDepositTypeIdParamName;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.currencyCodeParamName;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.descriptionParamName;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.digitsAfterDecimalParamName;
@@ -64,10 +60,8 @@ import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder;
import org.mifosplatform.infrastructure.core.exception.InvalidJsonException;
import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException;
import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper;
import org.mifosplatform.portfolio.interestratechart.InterestRateChartPeriodType;
import org.mifosplatform.portfolio.interestratechart.data.InterestRateChartDataValidator;
import org.mifosplatform.portfolio.savings.PreClosurePenalInterestOnType;
import org.mifosplatform.portfolio.savings.RecurringDepositType;
import org.mifosplatform.portfolio.savings.SavingsCompoundingInterestPeriodType;
import org.mifosplatform.portfolio.savings.SavingsInterestCalculationDaysInYearType;
import org.mifosplatform.portfolio.savings.SavingsInterestCalculationType;
@@ -321,32 +315,6 @@ public class DepositProductDataValidator {
}
public void validatePreClosureDetailForCreate(JsonElement element, DataValidatorBuilder baseDataValidator) {
if (fromApiJsonHelper.parameterExists(interestFreePeriodApplicableParamName, element)) {
final boolean interestFreePeriodApplicable = fromApiJsonHelper.extractBooleanNamed(interestFreePeriodApplicableParamName,
element);
if (interestFreePeriodApplicable) {
final Integer interestFreeFromPeriod = fromApiJsonHelper.extractIntegerSansLocaleNamed(interestFreeFromPeriodParamName,
element);
baseDataValidator.reset().parameter(interestFreeFromPeriodParamName).value(interestFreeFromPeriod)
.cantBeBlankWhenParameterProvidedIs(interestFreePeriodApplicableParamName, interestFreePeriodApplicable)
.integerZeroOrGreater();
final Integer interestFreeToPeriod = fromApiJsonHelper
.extractIntegerSansLocaleNamed(interestFreeToPeriodParamName, element);
baseDataValidator.reset().parameter(interestFreeToPeriodParamName).value(interestFreeToPeriod)
.cantBeBlankWhenParameterProvidedIs(interestFreePeriodApplicableParamName, interestFreePeriodApplicable)
.integerZeroOrGreater().integerGreaterThanNumber(interestFreeFromPeriod);
final Integer periodFrequencyType = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(
interestFreePeriodFrequencyTypeIdParamName, element);
baseDataValidator.reset().parameter(interestFreePeriodFrequencyTypeIdParamName).value(periodFrequencyType)
.cantBeBlankWhenParameterProvidedIs(interestFreePeriodApplicableParamName, interestFreePeriodApplicable)
.isOneOfTheseValues(InterestRateChartPeriodType.integerValues());
}
}
if (fromApiJsonHelper.parameterExists(preClosurePenalApplicableParamName, element)) {
final boolean preClosurePenalApplicable = fromApiJsonHelper.extractBooleanNamed(preClosurePenalApplicableParamName, element);
@@ -369,7 +337,7 @@ public class DepositProductDataValidator {
public void validateDepositTermDeatilForCreate(JsonElement element, DataValidatorBuilder baseDataValidator) {
final Integer minTerm = fromApiJsonHelper.extractIntegerSansLocaleNamed(minDepositTermParamName, element);
baseDataValidator.reset().parameter(minDepositTermParamName).value(minTerm).integerGreaterThanZero();
baseDataValidator.reset().parameter(minDepositTermParamName).value(minTerm).notNull().integerGreaterThanZero();
if (fromApiJsonHelper.parameterExists(maxDepositTermParamName, element)) {
final Integer maxTerm = fromApiJsonHelper.extractIntegerSansLocaleNamed(maxDepositTermParamName, element);
@@ -546,33 +514,6 @@ public class DepositProductDataValidator {
}
public void validatePreClosureDetailForUpdate(JsonElement element, DataValidatorBuilder baseDataValidator) {
if (fromApiJsonHelper.parameterExists(interestFreePeriodApplicableParamName, element)) {
final Boolean interestFreePeriodApplicable = fromApiJsonHelper.extractBooleanNamed(interestFreePeriodApplicableParamName,
element);
baseDataValidator.reset().parameter(interestFreePeriodApplicableParamName).value(interestFreePeriodApplicable).notNull();
}
if (fromApiJsonHelper.parameterExists(interestFreeFromPeriodParamName, element)) {
final Integer interestFreeFromPeriod = fromApiJsonHelper
.extractIntegerSansLocaleNamed(interestFreeFromPeriodParamName, element);
baseDataValidator.reset().parameter(interestFreeFromPeriodParamName).value(interestFreeFromPeriod).notNull()
.integerZeroOrGreater();
}
if (fromApiJsonHelper.parameterExists(interestFreeToPeriodParamName, element)) {
final Integer interestFreeToPeriod = fromApiJsonHelper.extractIntegerSansLocaleNamed(interestFreeToPeriodParamName, element);
baseDataValidator.reset().parameter(interestFreeToPeriodParamName).value(interestFreeToPeriod).notNull().integerZeroOrGreater();
}
if (fromApiJsonHelper.parameterExists(interestFreePeriodFrequencyTypeIdParamName, element)) {
final Integer periodFrequencyType = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(
interestFreePeriodFrequencyTypeIdParamName, element);
baseDataValidator.reset().parameter(interestFreePeriodFrequencyTypeIdParamName).value(periodFrequencyType).notNull()
.isOneOfTheseValues(InterestRateChartPeriodType.integerValues());
}
if (fromApiJsonHelper.parameterExists(preClosurePenalApplicableParamName, element)) {
final Boolean preClosurePenalApplicable = fromApiJsonHelper.extractBooleanNamed(preClosurePenalApplicableParamName, element);
baseDataValidator.reset().parameter(preClosurePenalApplicableParamName).value(preClosurePenalApplicable).notNull();
@@ -711,37 +652,34 @@ public class DepositProductDataValidator {
public void validateRecurringDetailForCreate(JsonElement element, DataValidatorBuilder baseDataValidator) {
final Integer rdTypeId = fromApiJsonHelper.extractIntegerSansLocaleNamed(recurringDepositTypeIdParamName, element);
baseDataValidator.reset().parameter(recurringDepositTypeIdParamName).value(rdTypeId).notNull()
.isOneOfTheseValues(RecurringDepositType.integerValues());
final Integer rdFrequency = fromApiJsonHelper.extractIntegerSansLocaleNamed(recurringDepositFrequencyParamName, element);
baseDataValidator.reset().parameter(recurringDepositFrequencyParamName).value(rdFrequency).notNull().integerGreaterThanZero();
final Integer rdFrequencyTypeId = fromApiJsonHelper
.extractIntegerSansLocaleNamed(recurringDepositFrequencyTypeIdParamName, element);
baseDataValidator.reset().parameter(recurringDepositFrequencyTypeIdParamName).value(rdFrequencyTypeId).notNull()
.isOneOfTheseValues(SavingsPeriodFrequencyType.integerValues());
final Boolean isMandatoryDeposit = this.fromApiJsonHelper.extractBooleanNamed(isMandatoryDepositParamName, element);
baseDataValidator.reset().parameter(isMandatoryDepositParamName).value(isMandatoryDeposit).ignoreIfNull().validateForBooleanValue();
final Boolean allowWithdrawal = this.fromApiJsonHelper.extractBooleanNamed(allowWithdrawalParamName, element);
baseDataValidator.reset().parameter(allowWithdrawalParamName).value(allowWithdrawal).ignoreIfNull().validateForBooleanValue();
final Boolean adjustAdvanceTowardsFuturePayments = this.fromApiJsonHelper.extractBooleanNamed(
adjustAdvanceTowardsFuturePaymentsParamName, element);
baseDataValidator.reset().parameter(adjustAdvanceTowardsFuturePaymentsParamName).value(adjustAdvanceTowardsFuturePayments)
.ignoreIfNull().validateForBooleanValue();
}
public void validateRecurringDepositUpdate(JsonElement element, DataValidatorBuilder baseDataValidator) {
if (fromApiJsonHelper.parameterExists(recurringDepositTypeIdParamName, element)) {
final Integer rdTypeId = fromApiJsonHelper.extractIntegerSansLocaleNamed(recurringDepositTypeIdParamName, element);
baseDataValidator.reset().parameter(recurringDepositTypeIdParamName).value(rdTypeId).notNull()
.isOneOfTheseValues(RecurringDepositType.integerValues());
if (this.fromApiJsonHelper.parameterExists(isMandatoryDepositParamName, element)) {
final Boolean isMandatoryDeposit = this.fromApiJsonHelper.extractBooleanNamed(isMandatoryDepositParamName, element);
baseDataValidator.reset().parameter(isMandatoryDepositParamName).value(isMandatoryDeposit).ignoreIfNull()
.validateForBooleanValue();
}
if (fromApiJsonHelper.parameterExists(recurringDepositFrequencyParamName, element)) {
final Integer rdFrequency = fromApiJsonHelper.extractIntegerSansLocaleNamed(recurringDepositFrequencyParamName, element);
baseDataValidator.reset().parameter(recurringDepositFrequencyParamName).value(rdFrequency).notNull().integerGreaterThanZero();
if (this.fromApiJsonHelper.parameterExists(allowWithdrawalParamName, element)) {
final Boolean allowWithdrawal = this.fromApiJsonHelper.extractBooleanNamed(allowWithdrawalParamName, element);
baseDataValidator.reset().parameter(allowWithdrawalParamName).value(allowWithdrawal).ignoreIfNull().validateForBooleanValue();
}
if (fromApiJsonHelper.parameterExists(recurringDepositFrequencyTypeIdParamName, element)) {
final Integer rdFrequencyTypeId = fromApiJsonHelper.extractIntegerSansLocaleNamed(recurringDepositFrequencyTypeIdParamName,
element);
baseDataValidator.reset().parameter(recurringDepositFrequencyTypeIdParamName).value(rdFrequencyTypeId).notNull()
.isOneOfTheseValues(SavingsPeriodFrequencyType.integerValues());
if (this.fromApiJsonHelper.parameterExists(adjustAdvanceTowardsFuturePaymentsParamName, element)) {
final Boolean adjustAdvanceTowardsFuturePayments = this.fromApiJsonHelper.extractBooleanNamed(
adjustAdvanceTowardsFuturePaymentsParamName, element);
baseDataValidator.reset().parameter(adjustAdvanceTowardsFuturePaymentsParamName).value(adjustAdvanceTowardsFuturePayments)
.ignoreIfNull().validateForBooleanValue();
}
}
@@ -25,11 +25,6 @@ import org.mifosplatform.portfolio.savings.service.SavingsEnumerations;
*/
public class FixedDepositAccountData extends DepositAccountData {
// additional fields
private boolean interestFreePeriodApplicable;
private Integer interestFreeFromPeriod;
private Integer interestFreeToPeriod;
private EnumOptionData interestFreePeriodFrequencyType;
private boolean preClosurePenalApplicable;
private BigDecimal preClosurePenalInterest;
private EnumOptionData preClosurePenalInterestOnType;
@@ -51,32 +46,25 @@ public class FixedDepositAccountData extends DepositAccountData {
private final PortfolioAccountData linkedAccount;
private final Boolean transferInterestToSavings;
private Collection<EnumOptionData> interestFreePeriodTypeOptions;
private Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions;
private Collection<EnumOptionData> depositTermTypeOptions;
private Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions;
private Collection<EnumOptionData> depositPeriodFrequencyOptions;
private Collection<EnumOptionData> periodFrequencyTypeOptions;
private Collection<SavingsAccountData> savingsAccounts;
// for account close
private Collection<EnumOptionData> onAccountClosureOptions;
private Collection<CodeValueData> paymentTypeOptions;
public static FixedDepositAccountData instance(final DepositAccountData depositAccountData, final boolean interestFreePeriodApplicable,
final Integer interestFreeFromPeriod, final Integer interestFreeToPeriod, final EnumOptionData interestFreePeriodFrequencyType,
final boolean preClosurePenalApplicable, final BigDecimal preClosurePenalInterest,
final EnumOptionData preClosurePenalInterestOnType, final Integer minDepositTerm, final Integer maxDepositTerm,
final EnumOptionData minDepositTermType, final EnumOptionData maxDepositTermType, final Integer inMultiplesOfDepositTerm,
final EnumOptionData inMultiplesOfDepositTermType, final BigDecimal depositAmount, final BigDecimal maturityAmount,
final LocalDate maturityDate, final Integer depositPeriod, final EnumOptionData depositPeriodFrequency,
final EnumOptionData onAccountClosure, final Boolean transferInterestToSavings) {
public static FixedDepositAccountData instance(final DepositAccountData depositAccountData, final boolean preClosurePenalApplicable,
final BigDecimal preClosurePenalInterest, final EnumOptionData preClosurePenalInterestOnType, final Integer minDepositTerm,
final Integer maxDepositTerm, final EnumOptionData minDepositTermType, final EnumOptionData maxDepositTermType,
final Integer inMultiplesOfDepositTerm, final EnumOptionData inMultiplesOfDepositTermType, final BigDecimal depositAmount,
final BigDecimal maturityAmount, final LocalDate maturityDate, final Integer depositPeriod,
final EnumOptionData depositPeriodFrequency, final EnumOptionData onAccountClosure, final Boolean transferInterestToSavings) {
final PortfolioAccountData linkedAccount = null;
final Collection<EnumOptionData> interestFreePeriodTypeOptions = null;
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions = null;
final Collection<EnumOptionData> depositTermTypeOptions = null;
final Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions = null;
final Collection<EnumOptionData> depositPeriodFrequencyOptions = null;
final Collection<EnumOptionData> periodFrequencyTypeOptions = null;
final EnumOptionData depositType = SavingsEnumerations.depositType(DepositAccountType.FIXED_DEPOSIT.getValue());
final Collection<EnumOptionData> onAccountClosureOptions = null;
final Collection<CodeValueData> paymentTypeOptions = null;
@@ -84,7 +72,7 @@ public class FixedDepositAccountData extends DepositAccountData {
return new FixedDepositAccountData(depositAccountData.id, depositAccountData.accountNo, depositAccountData.externalId,
depositAccountData.groupId, depositAccountData.groupName, depositAccountData.clientId, depositAccountData.clientName,
depositAccountData.savingsProductId, depositAccountData.savingsProductName, depositAccountData.fieldOfficerId,
depositAccountData.depositProductId, depositAccountData.depositProductName, depositAccountData.fieldOfficerId,
depositAccountData.fieldOfficerName, depositAccountData.status, depositAccountData.timeline, depositAccountData.currency,
depositAccountData.nominalAnnualInterestRate, depositAccountData.interestCompoundingPeriodType,
depositAccountData.interestPostingPeriodType, depositAccountData.interestCalculationType,
@@ -96,19 +84,17 @@ public class FixedDepositAccountData extends DepositAccountData {
depositAccountData.interestCalculationTypeOptions, depositAccountData.interestCalculationDaysInYearTypeOptions,
depositAccountData.lockinPeriodFrequencyTypeOptions, depositAccountData.withdrawalFeeTypeOptions,
depositAccountData.charges, depositAccountData.chargeOptions, depositAccountData.accountChart,
depositAccountData.chartTemplate, interestFreePeriodApplicable, interestFreeFromPeriod, interestFreeToPeriod,
interestFreePeriodFrequencyType, preClosurePenalApplicable, preClosurePenalInterest, preClosurePenalInterestOnType,
interestFreePeriodTypeOptions, preClosurePenalInterestOnTypeOptions, minDepositTerm, maxDepositTerm, minDepositTermType,
maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType, depositAmount, maturityAmount, maturityDate,
depositPeriod, depositPeriodFrequency, depositTermTypeOptions, inMultiplesOfDepositTermTypeOptions,
depositPeriodFrequencyOptions, depositType, onAccountClosure, onAccountClosureOptions, paymentTypeOptions,
savingsAccountDatas, linkedAccount, transferInterestToSavings);
depositAccountData.chartTemplate, preClosurePenalApplicable, preClosurePenalInterest, preClosurePenalInterestOnType,
preClosurePenalInterestOnTypeOptions, minDepositTerm, maxDepositTerm, minDepositTermType, maxDepositTermType,
inMultiplesOfDepositTerm, inMultiplesOfDepositTermType, depositAmount, maturityAmount, maturityDate, depositPeriod,
depositPeriodFrequency, periodFrequencyTypeOptions, depositType, onAccountClosure, onAccountClosureOptions,
paymentTypeOptions, savingsAccountDatas, linkedAccount, transferInterestToSavings);
}
public static FixedDepositAccountData withInterestChart(final FixedDepositAccountData account,
final DepositAccountInterestRateChartData accountChart) {
return new FixedDepositAccountData(account.id, account.accountNo, account.externalId, account.groupId, account.groupName,
account.clientId, account.clientName, account.savingsProductId, account.savingsProductName, account.fieldOfficerId,
account.clientId, account.clientName, account.depositProductId, account.depositProductName, account.fieldOfficerId,
account.fieldOfficerName, account.status, account.timeline, account.currency, account.nominalAnnualInterestRate,
account.interestCompoundingPeriodType, account.interestPostingPeriodType, account.interestCalculationType,
account.interestCalculationDaysInYearType, account.minRequiredOpeningBalance, account.lockinPeriodFrequency,
@@ -117,15 +103,12 @@ public class FixedDepositAccountData extends DepositAccountData {
account.interestPostingPeriodTypeOptions, account.interestCalculationTypeOptions,
account.interestCalculationDaysInYearTypeOptions, account.lockinPeriodFrequencyTypeOptions,
account.withdrawalFeeTypeOptions, account.charges, account.chargeOptions, accountChart, account.chartTemplate,
account.interestFreePeriodApplicable, account.interestFreeFromPeriod, account.interestFreeToPeriod,
account.interestFreePeriodFrequencyType, account.preClosurePenalApplicable, account.preClosurePenalInterest,
account.preClosurePenalInterestOnType, account.interestFreePeriodTypeOptions, account.preClosurePenalInterestOnTypeOptions,
account.minDepositTerm, account.maxDepositTerm, account.minDepositTermType, account.maxDepositTermType,
account.inMultiplesOfDepositTerm, account.inMultiplesOfDepositTermType, account.depositAmount, account.maturityAmount,
account.maturityDate, account.depositPeriod, account.depositPeriodFrequency, account.depositTermTypeOptions,
account.inMultiplesOfDepositTermTypeOptions, account.depositTermTypeOptions, account.depositType, account.onAccountClosure,
account.onAccountClosureOptions, account.paymentTypeOptions, account.savingsAccounts, account.linkedAccount,
account.transferInterestToSavings);
account.preClosurePenalApplicable, account.preClosurePenalInterest, account.preClosurePenalInterestOnType,
account.preClosurePenalInterestOnTypeOptions, account.minDepositTerm, account.maxDepositTerm, account.minDepositTermType,
account.maxDepositTermType, account.inMultiplesOfDepositTerm, account.inMultiplesOfDepositTermType, account.depositAmount,
account.maturityAmount, account.maturityDate, account.depositPeriod, account.depositPeriodFrequency,
account.periodFrequencyTypeOptions, account.depositType, account.onAccountClosure, account.onAccountClosureOptions,
account.paymentTypeOptions, account.savingsAccounts, account.linkedAccount, account.transferInterestToSavings);
}
public static FixedDepositAccountData associationsAndTemplate(final FixedDepositAccountData account, FixedDepositAccountData template,
@@ -137,7 +120,7 @@ public class FixedDepositAccountData extends DepositAccountData {
}
return new FixedDepositAccountData(account.id, account.accountNo, account.externalId, account.groupId, account.groupName,
account.clientId, account.clientName, account.savingsProductId, account.savingsProductName, account.fieldOfficerId,
account.clientId, account.clientName, account.depositProductId, account.depositProductName, account.fieldOfficerId,
account.fieldOfficerName, account.status, account.timeline, account.currency, account.nominalAnnualInterestRate,
account.interestCompoundingPeriodType, account.interestPostingPeriodType, account.interestCalculationType,
account.interestCalculationDaysInYearType, account.minRequiredOpeningBalance, account.lockinPeriodFrequency,
@@ -146,15 +129,12 @@ public class FixedDepositAccountData extends DepositAccountData {
template.interestPostingPeriodTypeOptions, template.interestCalculationTypeOptions,
template.interestCalculationDaysInYearTypeOptions, template.lockinPeriodFrequencyTypeOptions,
template.withdrawalFeeTypeOptions, charges, template.chargeOptions, account.accountChart, account.chartTemplate,
account.interestFreePeriodApplicable, account.interestFreeFromPeriod, account.interestFreeToPeriod,
account.interestFreePeriodFrequencyType, account.preClosurePenalApplicable, account.preClosurePenalInterest,
account.preClosurePenalInterestOnType, template.interestFreePeriodTypeOptions,
account.preClosurePenalApplicable, account.preClosurePenalInterest, account.preClosurePenalInterestOnType,
template.preClosurePenalInterestOnTypeOptions, account.minDepositTerm, account.maxDepositTerm, account.minDepositTermType,
account.maxDepositTermType, account.inMultiplesOfDepositTerm, account.inMultiplesOfDepositTermType, account.depositAmount,
account.maturityAmount, account.maturityDate, account.depositPeriod, account.depositPeriodFrequency,
template.depositTermTypeOptions, template.inMultiplesOfDepositTermTypeOptions, template.depositPeriodFrequencyOptions,
account.depositType, account.onAccountClosure, account.onAccountClosureOptions, account.paymentTypeOptions,
template.savingsAccounts, linkedAccount, account.transferInterestToSavings);
template.periodFrequencyTypeOptions, account.depositType, account.onAccountClosure, account.onAccountClosureOptions,
account.paymentTypeOptions, template.savingsAccounts, linkedAccount, account.transferInterestToSavings);
}
public static FixedDepositAccountData withTemplateOptions(final FixedDepositAccountData account,
@@ -165,13 +145,12 @@ public class FixedDepositAccountData extends DepositAccountData {
final Collection<EnumOptionData> interestCalculationDaysInYearTypeOptions,
final Collection<EnumOptionData> lockinPeriodFrequencyTypeOptions, final Collection<EnumOptionData> withdrawalFeeTypeOptions,
final Collection<SavingsAccountTransactionData> transactions, final Collection<SavingsAccountChargeData> charges,
final Collection<ChargeData> chargeOptions, final Collection<EnumOptionData> interestFreePeriodTypeOptions,
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions, final Collection<EnumOptionData> depositTermTypeOptions,
final Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions,
final Collection<EnumOptionData> depositPeriodFrequencyOptions, final Collection<SavingsAccountData> savingsAccounts) {
final Collection<ChargeData> chargeOptions, final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions,
final Collection<EnumOptionData> periodFrequencyTypeOptions, final Collection<SavingsAccountData> savingsAccounts) {
return new FixedDepositAccountData(account.id, account.accountNo, account.externalId, account.groupId, account.groupName,
account.clientId, account.clientName, account.savingsProductId, account.savingsProductName, account.fieldOfficerId,
account.clientId, account.clientName, account.depositProductId, account.depositProductName, account.fieldOfficerId,
account.fieldOfficerName, account.status, account.timeline, account.currency, account.nominalAnnualInterestRate,
account.interestCompoundingPeriodType, account.interestPostingPeriodType, account.interestCalculationType,
account.interestCalculationDaysInYearType, account.minRequiredOpeningBalance, account.lockinPeriodFrequency,
@@ -179,15 +158,12 @@ public class FixedDepositAccountData extends DepositAccountData {
fieldOfficerOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions,
interestCalculationTypeOptions, interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions,
withdrawalFeeTypeOptions, charges, chargeOptions, account.accountChart, account.chartTemplate,
account.interestFreePeriodApplicable, account.interestFreeFromPeriod, account.interestFreeToPeriod,
account.interestFreePeriodFrequencyType, account.preClosurePenalApplicable, account.preClosurePenalInterest,
account.preClosurePenalInterestOnType, interestFreePeriodTypeOptions, preClosurePenalInterestOnTypeOptions,
account.minDepositTerm, account.maxDepositTerm, account.minDepositTermType, account.maxDepositTermType,
account.inMultiplesOfDepositTerm, account.inMultiplesOfDepositTermType, account.depositAmount, account.maturityAmount,
account.maturityDate, account.depositPeriod, account.depositPeriodFrequency, depositTermTypeOptions,
inMultiplesOfDepositTermTypeOptions, depositPeriodFrequencyOptions, account.depositType, account.onAccountClosure,
account.onAccountClosureOptions, account.paymentTypeOptions, savingsAccounts, account.linkedAccount,
account.transferInterestToSavings);
account.preClosurePenalApplicable, account.preClosurePenalInterest, account.preClosurePenalInterestOnType,
preClosurePenalInterestOnTypeOptions, account.minDepositTerm, account.maxDepositTerm, account.minDepositTermType,
account.maxDepositTermType, account.inMultiplesOfDepositTerm, account.inMultiplesOfDepositTermType, account.depositAmount,
account.maturityAmount, account.maturityDate, account.depositPeriod, account.depositPeriodFrequency,
periodFrequencyTypeOptions, account.depositType, account.onAccountClosure, account.onAccountClosureOptions,
account.paymentTypeOptions, savingsAccounts, account.linkedAccount, account.transferInterestToSavings);
}
public static FixedDepositAccountData withClientTemplate(final Long clientId, final String clientName, final Long groupId,
@@ -229,10 +205,6 @@ public class FixedDepositAccountData extends DepositAccountData {
final DepositAccountInterestRateChartData accountChart = null;
final DepositAccountInterestRateChartData chartTemplate = null;
final boolean interestFreePeriodApplicable = false;
final Integer interestFreeFromPeriod = null;
final Integer interestFreeToPeriod = null;
final EnumOptionData interestFreePeriodFrequencyType = null;
final boolean preClosurePenalApplicable = false;
final BigDecimal preClosurePenalInterest = null;
final EnumOptionData preClosurePenalInterestOnType = null;
@@ -250,12 +222,9 @@ public class FixedDepositAccountData extends DepositAccountData {
final EnumOptionData onAccountClosure = null;
final PortfolioAccountData linkedAccount = null;
final Boolean transferInterestToSavings = null;
final Collection<EnumOptionData> interestFreePeriodTypeOptions = null;
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions = null;
final Collection<EnumOptionData> depositTermTypeOptions = null;
final Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions = null;
final Collection<EnumOptionData> depositPeriodFrequencyOptions = null;
final Collection<EnumOptionData> periodFrequencyTypeOptions = null;
final EnumOptionData depositType = SavingsEnumerations.depositType(DepositAccountType.FIXED_DEPOSIT.getValue());
final Collection<EnumOptionData> onAccountClosureOptions = null;
final Collection<CodeValueData> paymentTypeOptions = null;
@@ -267,14 +236,11 @@ public class FixedDepositAccountData extends DepositAccountData {
lockinPeriodFrequency, lockinPeriodFrequencyType, withdrawalFeeForTransfers, summary, transactions, productOptions,
fieldOfficerOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions,
interestCalculationTypeOptions, interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions,
withdrawalFeeTypeOptions, charges, chargeOptions, accountChart, chartTemplate, interestFreePeriodApplicable,
interestFreeFromPeriod, interestFreeToPeriod, interestFreePeriodFrequencyType, preClosurePenalApplicable,
preClosurePenalInterest, preClosurePenalInterestOnType, interestFreePeriodTypeOptions,
preClosurePenalInterestOnTypeOptions, minDepositTerm, maxDepositTerm, minDepositTermType, maxDepositTermType,
inMultiplesOfDepositTerm, inMultiplesOfDepositTermType, depositAmount, maturityAmount, maturityDate, depositPeriod,
depositPeriodFrequency, depositTermTypeOptions, inMultiplesOfDepositTermTypeOptions, depositPeriodFrequencyOptions,
depositType, onAccountClosure, onAccountClosureOptions, paymentTypeOptions, savingsAccountDatas, linkedAccount,
transferInterestToSavings);
withdrawalFeeTypeOptions, charges, chargeOptions, accountChart, chartTemplate, preClosurePenalApplicable,
preClosurePenalInterest, preClosurePenalInterestOnType, preClosurePenalInterestOnTypeOptions, minDepositTerm,
maxDepositTerm, minDepositTermType, maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType,
depositAmount, maturityAmount, maturityDate, depositPeriod, depositPeriodFrequency, periodFrequencyTypeOptions,
depositType, onAccountClosure, onAccountClosureOptions, paymentTypeOptions, savingsAccountDatas, linkedAccount, transferInterestToSavings);
}
public static FixedDepositAccountData preClosureDetails(final Long accountId, BigDecimal maturityAmount,
@@ -305,7 +271,6 @@ public class FixedDepositAccountData extends DepositAccountData {
final boolean withdrawalFeeForTransfers = false;
final SavingsAccountSummaryData summary = null;
final Collection<SavingsAccountTransactionData> transactions = null;
final Collection<DepositProductData> productOptions = null;
final Collection<StaffData> fieldOfficerOptions = null;
final Collection<EnumOptionData> interestCompoundingPeriodTypeOptions = null;
@@ -320,10 +285,6 @@ public class FixedDepositAccountData extends DepositAccountData {
final DepositAccountInterestRateChartData accountChart = null;
final DepositAccountInterestRateChartData chartTemplate = null;
final boolean interestFreePeriodApplicable = false;
final Integer interestFreeFromPeriod = null;
final Integer interestFreeToPeriod = null;
final EnumOptionData interestFreePeriodFrequencyType = null;
final boolean preClosurePenalApplicable = false;
final BigDecimal preClosurePenalInterest = null;
final EnumOptionData preClosurePenalInterestOnType = null;
@@ -340,11 +301,9 @@ public class FixedDepositAccountData extends DepositAccountData {
final EnumOptionData onAccountClosure = null;
final Boolean transferInterestToSavings = null;
final Collection<EnumOptionData> interestFreePeriodTypeOptions = null;
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions = null;
final Collection<EnumOptionData> depositTermTypeOptions = null;
final Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions = null;
final Collection<EnumOptionData> depositPeriodFrequencyOptions = null;
final Collection<EnumOptionData> periodFrequencyTypeOptions = null;
final EnumOptionData depositType = SavingsEnumerations.depositType(DepositAccountType.FIXED_DEPOSIT.getValue());
final PortfolioAccountData linkedAccount = null;
@@ -354,14 +313,11 @@ public class FixedDepositAccountData extends DepositAccountData {
lockinPeriodFrequency, lockinPeriodFrequencyType, withdrawalFeeForTransfers, summary, transactions, productOptions,
fieldOfficerOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions,
interestCalculationTypeOptions, interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions,
withdrawalFeeTypeOptions, charges, chargeOptions, accountChart, chartTemplate, interestFreePeriodApplicable,
interestFreeFromPeriod, interestFreeToPeriod, interestFreePeriodFrequencyType, preClosurePenalApplicable,
preClosurePenalInterest, preClosurePenalInterestOnType, interestFreePeriodTypeOptions,
preClosurePenalInterestOnTypeOptions, minDepositTerm, maxDepositTerm, minDepositTermType, maxDepositTermType,
inMultiplesOfDepositTerm, inMultiplesOfDepositTermType, depositAmount, maturityAmount, maturityDate, depositPeriod,
depositPeriodFrequency, depositTermTypeOptions, inMultiplesOfDepositTermTypeOptions, depositPeriodFrequencyOptions,
depositType, onAccountClosure, onAccountClosureOptions, paymentTypeOptions, savingsAccountDatas, linkedAccount,
transferInterestToSavings);
withdrawalFeeTypeOptions, charges, chargeOptions, accountChart, chartTemplate, preClosurePenalApplicable,
preClosurePenalInterest, preClosurePenalInterestOnType, preClosurePenalInterestOnTypeOptions, minDepositTerm,
maxDepositTerm, minDepositTermType, maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType,
depositAmount, maturityAmount, maturityDate, depositPeriod, depositPeriodFrequency, periodFrequencyTypeOptions,
depositType, onAccountClosure, onAccountClosureOptions, paymentTypeOptions, savingsAccountDatas, linkedAccount, transferInterestToSavings);
}
public static FixedDepositAccountData withClosureTemplateDetails(final FixedDepositAccountData account,
@@ -369,7 +325,7 @@ public class FixedDepositAccountData extends DepositAccountData {
final Collection<SavingsAccountData> savingsAccountDatas) {
return new FixedDepositAccountData(account.id, account.accountNo, account.externalId, account.groupId, account.groupName,
account.clientId, account.clientName, account.savingsProductId, account.savingsProductName, account.fieldOfficerId,
account.clientId, account.clientName, account.depositProductId, account.depositProductName, account.fieldOfficerId,
account.fieldOfficerName, account.status, account.timeline, account.currency, account.nominalAnnualInterestRate,
account.interestCompoundingPeriodType, account.interestPostingPeriodType, account.interestCalculationType,
account.interestCalculationDaysInYearType, account.minRequiredOpeningBalance, account.lockinPeriodFrequency,
@@ -378,15 +334,13 @@ public class FixedDepositAccountData extends DepositAccountData {
account.interestPostingPeriodTypeOptions, account.interestCalculationTypeOptions,
account.interestCalculationDaysInYearTypeOptions, account.lockinPeriodFrequencyTypeOptions,
account.withdrawalFeeTypeOptions, account.charges, account.chargeOptions, account.accountChart, account.chartTemplate,
account.interestFreePeriodApplicable, account.interestFreeFromPeriod, account.interestFreeToPeriod,
account.interestFreePeriodFrequencyType, account.preClosurePenalApplicable, account.preClosurePenalInterest,
account.preClosurePenalInterestOnType, account.interestFreePeriodTypeOptions, account.preClosurePenalInterestOnTypeOptions,
account.minDepositTerm, account.maxDepositTerm, account.minDepositTermType, account.maxDepositTermType,
account.inMultiplesOfDepositTerm, account.inMultiplesOfDepositTermType, account.depositAmount, account.maturityAmount,
account.maturityDate, account.depositPeriod, account.depositPeriodFrequency, account.depositTermTypeOptions,
account.inMultiplesOfDepositTermTypeOptions, account.depositPeriodFrequencyOptions, account.depositType,
account.onAccountClosure, onAccountClosureOptions, paymentTypeOptions, savingsAccountDatas, account.linkedAccount,
account.transferInterestToSavings);
account.preClosurePenalApplicable, account.preClosurePenalInterest, account.preClosurePenalInterestOnType,
account.preClosurePenalInterestOnTypeOptions, account.minDepositTerm, account.maxDepositTerm, account.minDepositTermType,
account.maxDepositTermType, account.inMultiplesOfDepositTerm, account.inMultiplesOfDepositTermType, account.depositAmount,
account.maturityAmount, account.maturityDate, account.depositPeriod, account.depositPeriodFrequency,
account.periodFrequencyTypeOptions, account.depositType, account.onAccountClosure, onAccountClosureOptions,
paymentTypeOptions, savingsAccountDatas, account.linkedAccount, account.transferInterestToSavings);
}
private FixedDepositAccountData(final Long id, final String accountNo, final String externalId, final Long groupId,
@@ -406,17 +360,13 @@ public class FixedDepositAccountData extends DepositAccountData {
final Collection<EnumOptionData> lockinPeriodFrequencyTypeOptions, final Collection<EnumOptionData> withdrawalFeeTypeOptions,
final Collection<SavingsAccountChargeData> charges, final Collection<ChargeData> chargeOptions,
final DepositAccountInterestRateChartData accountChart, final DepositAccountInterestRateChartData chartTemplate,
final boolean interestFreePeriodApplicable, final Integer interestFreeFromPeriod, final Integer interestFreeToPeriod,
final EnumOptionData interestFreePeriodFrequencyType, final boolean preClosurePenalApplicable,
final BigDecimal preClosurePenalInterest, final EnumOptionData preClosurePenalInterestOnType,
final Collection<EnumOptionData> interestFreePeriodTypeOptions,
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions, final Integer minDepositTerm,
final Integer maxDepositTerm, final EnumOptionData minDepositTermType, final EnumOptionData maxDepositTermType,
final Integer inMultiplesOfDepositTerm, final EnumOptionData inMultiplesOfDepositTermType, final BigDecimal depositAmount,
final BigDecimal maturityAmount, final LocalDate maturityDate, final Integer depositPeriod,
final EnumOptionData depositPeriodFrequency, final Collection<EnumOptionData> depositTermTypeOptions,
final Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions,
final Collection<EnumOptionData> depositPeriodFrequencyOptions, final EnumOptionData depositType,
final boolean preClosurePenalApplicable, final BigDecimal preClosurePenalInterest,
final EnumOptionData preClosurePenalInterestOnType, final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions,
final Integer minDepositTerm, final Integer maxDepositTerm, final EnumOptionData minDepositTermType,
final EnumOptionData maxDepositTermType, final Integer inMultiplesOfDepositTerm,
final EnumOptionData inMultiplesOfDepositTermType, final BigDecimal depositAmount, final BigDecimal maturityAmount,
final LocalDate maturityDate, final Integer depositPeriod, final EnumOptionData depositPeriodFrequency,
final Collection<EnumOptionData> periodFrequencyTypeOptions, final EnumOptionData depositType,
final EnumOptionData onAccountClosure, final Collection<EnumOptionData> onAccountClosureOptions,
final Collection<CodeValueData> paymentTypeOptions, final Collection<SavingsAccountData> savingsAccountDatas,
final PortfolioAccountData linkedAccount, final Boolean transferInterestToSavings) {
@@ -429,11 +379,6 @@ public class FixedDepositAccountData extends DepositAccountData {
interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, charges,
chargeOptions, accountChart, chartTemplate, depositType);
// fixed deposit additional fields
this.interestFreePeriodApplicable = interestFreePeriodApplicable;
this.interestFreeFromPeriod = interestFreeFromPeriod;
this.interestFreeToPeriod = interestFreeToPeriod;
this.interestFreePeriodFrequencyType = interestFreePeriodFrequencyType;
this.preClosurePenalApplicable = preClosurePenalApplicable;
this.preClosurePenalInterest = preClosurePenalInterest;
this.preClosurePenalInterestOnType = preClosurePenalInterestOnType;
@@ -453,11 +398,8 @@ public class FixedDepositAccountData extends DepositAccountData {
this.transferInterestToSavings = transferInterestToSavings;
// template
this.interestFreePeriodTypeOptions = interestFreePeriodTypeOptions;
this.preClosurePenalInterestOnTypeOptions = preClosurePenalInterestOnTypeOptions;
this.depositTermTypeOptions = depositTermTypeOptions;
this.inMultiplesOfDepositTermTypeOptions = inMultiplesOfDepositTermTypeOptions;
this.depositPeriodFrequencyOptions = depositPeriodFrequencyOptions;
this.periodFrequencyTypeOptions = periodFrequencyTypeOptions;
// account close template options
this.onAccountClosureOptions = onAccountClosureOptions;
@@ -25,10 +25,6 @@ import org.mifosplatform.portfolio.interestratechart.data.InterestRateChartData;
public class FixedDepositProductData extends DepositProductData {
// additional fields
private boolean interestFreePeriodApplicable;
private Integer interestFreeFromPeriod;
private Integer interestFreeToPeriod;
protected EnumOptionData interestFreePeriodFrequencyType;
private boolean preClosurePenalApplicable;
protected BigDecimal preClosurePenalInterest;
protected EnumOptionData preClosurePenalInterestOnType;
@@ -42,10 +38,8 @@ public class FixedDepositProductData extends DepositProductData {
protected BigDecimal depositAmount;
protected BigDecimal maxDepositAmount;
private Collection<EnumOptionData> interestFreePeriodTypeOptions;
private Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions;
private Collection<EnumOptionData> depositTermTypeOptions;
private Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions;
private Collection<EnumOptionData> periodFrequencyTypeOptions;
public static FixedDepositProductData template(final CurrencyData currency, final EnumOptionData interestCompoundingPeriodType,
final EnumOptionData interestPostingPeriodType, final EnumOptionData interestCalculationType,
@@ -58,9 +52,8 @@ public class FixedDepositProductData extends DepositProductData {
final Collection<CodeValueData> paymentTypeOptions, final Collection<EnumOptionData> accountingRuleOptions,
final Map<String, List<GLAccountData>> accountingMappingOptions, final Collection<ChargeData> chargeOptions,
final Collection<ChargeData> penaltyOptions, final InterestRateChartData chartTemplate,
final Collection<EnumOptionData> interestFreePeriodTypes,
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions, final Collection<EnumOptionData> depositTermTypeOptions,
final Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions) {
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions,
final Collection<EnumOptionData> periodFrequencyTypeOptions) {
final Long id = null;
final String name = null;
@@ -75,10 +68,7 @@ public class FixedDepositProductData extends DepositProductData {
final Collection<ChargeToGLAccountMapper> feeToIncomeAccountMappings = null;
final Collection<ChargeToGLAccountMapper> penaltyToIncomeAccountMappings = null;
final Collection<InterestRateChartData> interestRateCharts = null;
final boolean interestFreePeriodApplicable = false;
final Integer interestFreeFromPeriod = null;
final Integer interestFreeToPeriod = null;
final EnumOptionData interestFreePeriodFrequencyType = null;
final boolean preClosurePenalApplicable = false;
final BigDecimal preClosurePenalInterest = null;
final EnumOptionData preClosurePenalInterestOnType = null;
@@ -98,11 +88,10 @@ public class FixedDepositProductData extends DepositProductData {
currencyOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions, interestCalculationTypeOptions,
interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, paymentTypeOptions,
accountingRuleOptions, accountingMappingOptions, charges, chargeOptions, penaltyOptions, feeToIncomeAccountMappings,
penaltyToIncomeAccountMappings, interestRateCharts, chartTemplate, interestFreePeriodApplicable, interestFreeFromPeriod,
interestFreeToPeriod, interestFreePeriodFrequencyType, preClosurePenalApplicable, preClosurePenalInterest,
preClosurePenalInterestOnType, interestFreePeriodTypes, preClosurePenalInterestOnTypeOptions, minDepositTerm,
maxDepositTerm, minDepositTermType, maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType,
minDepositAmount, depositAmount, maxDepositAmount, depositTermTypeOptions, inMultiplesOfDepositTermTypeOptions);
penaltyToIncomeAccountMappings, interestRateCharts, chartTemplate, preClosurePenalApplicable, preClosurePenalInterest,
preClosurePenalInterestOnType, preClosurePenalInterestOnTypeOptions, minDepositTerm, maxDepositTerm, minDepositTermType,
maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType, minDepositAmount, depositAmount,
maxDepositAmount, periodFrequencyTypeOptions);
}
public static FixedDepositProductData withCharges(final FixedDepositProductData existingProduct, final Collection<ChargeData> charges) {
@@ -118,14 +107,12 @@ public class FixedDepositProductData extends DepositProductData {
existingProduct.paymentTypeOptions, existingProduct.accountingRuleOptions, existingProduct.accountingMappingOptions,
charges, existingProduct.chargeOptions, existingProduct.penaltyOptions, existingProduct.feeToIncomeAccountMappings,
existingProduct.penaltyToIncomeAccountMappings, existingProduct.interestRateCharts, existingProduct.chartTemplate,
existingProduct.interestFreePeriodApplicable, existingProduct.interestFreeFromPeriod, existingProduct.interestFreeToPeriod,
existingProduct.interestFreePeriodFrequencyType, existingProduct.preClosurePenalApplicable,
existingProduct.preClosurePenalInterest, existingProduct.preClosurePenalInterestOnType,
existingProduct.interestFreePeriodTypeOptions, existingProduct.preClosurePenalInterestOnTypeOptions,
existingProduct.preClosurePenalApplicable, existingProduct.preClosurePenalInterest,
existingProduct.preClosurePenalInterestOnType, existingProduct.preClosurePenalInterestOnTypeOptions,
existingProduct.minDepositTerm, existingProduct.maxDepositTerm, existingProduct.minDepositTermType,
existingProduct.maxDepositTermType, existingProduct.inMultiplesOfDepositTerm, existingProduct.inMultiplesOfDepositTermType,
existingProduct.minDepositAmount, existingProduct.depositAmount, existingProduct.maxDepositAmount,
existingProduct.depositTermTypeOptions, existingProduct.inMultiplesOfDepositTermTypeOptions);
existingProduct.periodFrequencyTypeOptions);
}
/**
@@ -142,9 +129,8 @@ public class FixedDepositProductData extends DepositProductData {
final Collection<CodeValueData> paymentTypeOptions, final Collection<EnumOptionData> accountingRuleOptions,
final Map<String, List<GLAccountData>> accountingMappingOptions, final Collection<ChargeData> chargeOptions,
final Collection<ChargeData> penaltyOptions, final InterestRateChartData chartTemplate,
final Collection<EnumOptionData> interestFreePeriodTypes,
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions, final Collection<EnumOptionData> depositTermTypeOptions,
final Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions) {
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions,
final Collection<EnumOptionData> periodFrequencyTypeOptions) {
return new FixedDepositProductData(existingProduct.id, existingProduct.name, existingProduct.shortName,
existingProduct.description, existingProduct.currency, existingProduct.nominalAnnualInterestRate,
@@ -156,14 +142,12 @@ public class FixedDepositProductData extends DepositProductData {
interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, paymentTypeOptions,
accountingRuleOptions, accountingMappingOptions, existingProduct.charges, chargeOptions, penaltyOptions,
existingProduct.feeToIncomeAccountMappings, existingProduct.penaltyToIncomeAccountMappings,
existingProduct.interestRateCharts, chartTemplate, existingProduct.interestFreePeriodApplicable,
existingProduct.interestFreeFromPeriod, existingProduct.interestFreeToPeriod,
existingProduct.interestFreePeriodFrequencyType, existingProduct.preClosurePenalApplicable,
existingProduct.preClosurePenalInterest, existingProduct.preClosurePenalInterestOnType, interestFreePeriodTypes,
existingProduct.interestRateCharts, chartTemplate, existingProduct.preClosurePenalApplicable,
existingProduct.preClosurePenalInterest, existingProduct.preClosurePenalInterestOnType,
preClosurePenalInterestOnTypeOptions, existingProduct.minDepositTerm, existingProduct.maxDepositTerm,
existingProduct.minDepositTermType, existingProduct.maxDepositTermType, existingProduct.inMultiplesOfDepositTerm,
existingProduct.inMultiplesOfDepositTermType, existingProduct.minDepositAmount, existingProduct.depositAmount,
existingProduct.maxDepositAmount, depositTermTypeOptions, inMultiplesOfDepositTermTypeOptions);
existingProduct.maxDepositAmount, periodFrequencyTypeOptions);
}
public static FixedDepositProductData withAccountingDetails(final FixedDepositProductData existingProduct,
@@ -195,23 +179,19 @@ public class FixedDepositProductData extends DepositProductData {
lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, paymentTypeOptions, accountingRuleOptions,
accountingMappingOptions, existingProduct.charges, chargeOptions, penaltyOptions, feeToIncomeAccountMappings,
penaltyToIncomeAccountMappings, existingProduct.interestRateCharts, existingProduct.chartTemplate,
existingProduct.interestFreePeriodApplicable, existingProduct.interestFreeFromPeriod, existingProduct.interestFreeToPeriod,
existingProduct.interestFreePeriodFrequencyType, existingProduct.preClosurePenalApplicable,
existingProduct.preClosurePenalInterest, existingProduct.preClosurePenalInterestOnType,
existingProduct.interestFreePeriodTypeOptions, existingProduct.preClosurePenalInterestOnTypeOptions,
existingProduct.preClosurePenalApplicable, existingProduct.preClosurePenalInterest,
existingProduct.preClosurePenalInterestOnType, existingProduct.preClosurePenalInterestOnTypeOptions,
existingProduct.minDepositTerm, existingProduct.maxDepositTerm, existingProduct.minDepositTermType,
existingProduct.maxDepositTermType, existingProduct.inMultiplesOfDepositTerm, existingProduct.inMultiplesOfDepositTermType,
existingProduct.minDepositAmount, existingProduct.depositAmount, existingProduct.maxDepositAmount,
existingProduct.depositTermTypeOptions, existingProduct.inMultiplesOfDepositTermTypeOptions);
existingProduct.periodFrequencyTypeOptions);
}
public static FixedDepositProductData instance(final DepositProductData depositProductData, final boolean interestFreePeriodApplicable,
final Integer interestFreeFromPeriod, final Integer interestFreeToPeriod, final EnumOptionData interestFreePeriodFrequencyType,
final boolean preClosurePenalApplicable, final BigDecimal preClosurePenalInterest,
final EnumOptionData preClosurePenalInterestOnType, final Integer minDepositTerm, final Integer maxDepositTerm,
final EnumOptionData minDepositTermType, final EnumOptionData maxDepositTermType, final Integer inMultiplesOfDepositTerm,
final EnumOptionData inMultiplesOfDepositTermType, final BigDecimal minDepositAmount, final BigDecimal depositAmount,
final BigDecimal maxDepositAmount) {
public static FixedDepositProductData instance(final DepositProductData depositProductData, final boolean preClosurePenalApplicable,
final BigDecimal preClosurePenalInterest, final EnumOptionData preClosurePenalInterestOnType, final Integer minDepositTerm,
final Integer maxDepositTerm, final EnumOptionData minDepositTermType, final EnumOptionData maxDepositTermType,
final Integer inMultiplesOfDepositTerm, final EnumOptionData inMultiplesOfDepositTermType, final BigDecimal minDepositAmount,
final BigDecimal depositAmount, final BigDecimal maxDepositAmount) {
final Map<String, Object> accountingMappings = null;
final Collection<PaymentTypeToGLAccountMapper> paymentChannelToFundSourceMappings = null;
@@ -233,10 +213,8 @@ public class FixedDepositProductData extends DepositProductData {
final Collection<ChargeToGLAccountMapper> penaltyToIncomeAccountMappings = null;
final Collection<InterestRateChartData> interestRateCharts = null;
final InterestRateChartData chartTemplate = null;
final Collection<EnumOptionData> interestFreePeriodTypes = null;
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions = null;
final Collection<EnumOptionData> depositTermTypeOptions = null;
final Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions = null;
final Collection<EnumOptionData> periodFrequencyTypeOptions = null;
return new FixedDepositProductData(depositProductData.id, depositProductData.name, depositProductData.shortName,
depositProductData.description, depositProductData.currency, depositProductData.nominalAnnualInterestRate,
@@ -247,11 +225,10 @@ public class FixedDepositProductData extends DepositProductData {
interestPostingPeriodTypeOptions, interestCalculationTypeOptions, interestCalculationDaysInYearTypeOptions,
lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, paymentTypeOptions, accountingRuleOptions,
accountingMappingOptions, charges, chargeOptions, penaltyOptions, feeToIncomeAccountMappings,
penaltyToIncomeAccountMappings, interestRateCharts, chartTemplate, interestFreePeriodApplicable, interestFreeFromPeriod,
interestFreeToPeriod, interestFreePeriodFrequencyType, preClosurePenalApplicable, preClosurePenalInterest,
preClosurePenalInterestOnType, interestFreePeriodTypes, preClosurePenalInterestOnTypeOptions, minDepositTerm,
maxDepositTerm, minDepositTermType, maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType,
minDepositAmount, depositAmount, maxDepositAmount, depositTermTypeOptions, inMultiplesOfDepositTermTypeOptions);
penaltyToIncomeAccountMappings, interestRateCharts, chartTemplate, preClosurePenalApplicable, preClosurePenalInterest,
preClosurePenalInterestOnType, preClosurePenalInterestOnTypeOptions, minDepositTerm, maxDepositTerm, minDepositTermType,
maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType, minDepositAmount, depositAmount,
maxDepositAmount, periodFrequencyTypeOptions);
}
public static FixedDepositProductData lookup(final Long id, final String name) {
@@ -287,14 +264,9 @@ public class FixedDepositProductData extends DepositProductData {
final Collection<ChargeToGLAccountMapper> penaltyToIncomeAccountMappings = null;
final Collection<InterestRateChartData> interestRateCharts = null;
final InterestRateChartData chartTemplate = null;
final boolean interestFreePeriodApplicable = false;
final Integer interestFreeFromPeriod = null;
final Integer interestFreeToPeriod = null;
final EnumOptionData interestFreePeriodFrequencyType = null;
final boolean preClosurePenalApplicable = false;
final BigDecimal preClosurePenalInterest = null;
final EnumOptionData preClosurePenalInterestOnType = null;
final Collection<EnumOptionData> interestFreePeriodTypes = null;
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions = null;
final Integer minDepositTerm = null;
final Integer maxDepositTerm = null;
@@ -305,8 +277,7 @@ public class FixedDepositProductData extends DepositProductData {
final BigDecimal minDepositAmount = null;
final BigDecimal depositAmount = null;
final BigDecimal maxDepositAmount = null;
final Collection<EnumOptionData> depositTermTypeOptions = null;
final Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions = null;
final Collection<EnumOptionData> periodFrequencyTypeOptions = null;
return new FixedDepositProductData(id, name, shortName, description, currency, nominalAnnualInterestRate,
interestCompoundingPeriodType, interestPostingPeriodType, interestCalculationType, interestCalculationDaysInYearType,
@@ -314,11 +285,10 @@ public class FixedDepositProductData extends DepositProductData {
currencyOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions, interestCalculationTypeOptions,
interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, paymentTypeOptions,
accountingRuleOptions, accountingMappingOptions, charges, chargeOptions, penaltyOptions, feeToIncomeAccountMappings,
penaltyToIncomeAccountMappings, interestRateCharts, chartTemplate, interestFreePeriodApplicable, interestFreeFromPeriod,
interestFreeToPeriod, interestFreePeriodFrequencyType, preClosurePenalApplicable, preClosurePenalInterest,
preClosurePenalInterestOnType, interestFreePeriodTypes, preClosurePenalInterestOnTypeOptions, minDepositTerm,
maxDepositTerm, minDepositTermType, maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType,
minDepositAmount, depositAmount, maxDepositAmount, depositTermTypeOptions, inMultiplesOfDepositTermTypeOptions);
penaltyToIncomeAccountMappings, interestRateCharts, chartTemplate, preClosurePenalApplicable, preClosurePenalInterest,
preClosurePenalInterestOnType, preClosurePenalInterestOnTypeOptions, minDepositTerm, maxDepositTerm, minDepositTermType,
maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType, minDepositAmount, depositAmount,
maxDepositAmount, periodFrequencyTypeOptions);
}
public static FixedDepositProductData withInterestChart(final FixedDepositProductData existingProduct,
@@ -335,15 +305,13 @@ public class FixedDepositProductData extends DepositProductData {
existingProduct.paymentTypeOptions, existingProduct.accountingRuleOptions, existingProduct.accountingMappingOptions,
existingProduct.charges, existingProduct.chargeOptions, existingProduct.penaltyOptions,
existingProduct.feeToIncomeAccountMappings, existingProduct.penaltyToIncomeAccountMappings, interestRateCharts,
existingProduct.chartTemplate, existingProduct.interestFreePeriodApplicable, existingProduct.interestFreeFromPeriod,
existingProduct.interestFreeToPeriod, existingProduct.interestFreePeriodFrequencyType,
existingProduct.preClosurePenalApplicable, existingProduct.preClosurePenalInterest,
existingProduct.preClosurePenalInterestOnType, existingProduct.interestFreePeriodTypeOptions,
existingProduct.preClosurePenalInterestOnTypeOptions, existingProduct.minDepositTerm, existingProduct.maxDepositTerm,
existingProduct.minDepositTermType, existingProduct.maxDepositTermType, existingProduct.inMultiplesOfDepositTerm,
existingProduct.inMultiplesOfDepositTermType, existingProduct.minDepositAmount, existingProduct.depositAmount,
existingProduct.maxDepositAmount, existingProduct.depositTermTypeOptions,
existingProduct.inMultiplesOfDepositTermTypeOptions);
existingProduct.chartTemplate, existingProduct.preClosurePenalApplicable, existingProduct.preClosurePenalInterest,
existingProduct.preClosurePenalInterestOnType, existingProduct.preClosurePenalInterestOnTypeOptions,
existingProduct.minDepositTerm, existingProduct.maxDepositTerm, existingProduct.minDepositTermType,
existingProduct.maxDepositTermType, existingProduct.inMultiplesOfDepositTerm, existingProduct.inMultiplesOfDepositTermType,
existingProduct.minDepositAmount, existingProduct.depositAmount, existingProduct.maxDepositAmount,
existingProduct.periodFrequencyTypeOptions);
}
private FixedDepositProductData(final Long id, final String name, final String shortName, final String description,
@@ -364,15 +332,12 @@ public class FixedDepositProductData extends DepositProductData {
final Collection<ChargeToGLAccountMapper> feeToIncomeAccountMappings,
final Collection<ChargeToGLAccountMapper> penaltyToIncomeAccountMappings,
final Collection<InterestRateChartData> interestRateCharts, final InterestRateChartData chartTemplate,
final boolean interestFreePeriodApplicable, final Integer interestFreeFromPeriod, final Integer interestFreeToPeriod,
final EnumOptionData interestFreePeriodFrequencyType, final boolean preClosurePenalApplicable,
final BigDecimal preClosurePenalInterest, final EnumOptionData preClosurePenalInterestOnType,
final Collection<EnumOptionData> interestFreePeriodTypeOptions,
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions, final Integer minDepositTerm,
final Integer maxDepositTerm, final EnumOptionData minDepositTermType, final EnumOptionData maxDepositTermType,
final Integer inMultiplesOfDepositTerm, final EnumOptionData inMultiplesOfDepositTermType,
final BigDecimal minDepositAmount, final BigDecimal depositAmount, final BigDecimal maxDepositAmount,
final Collection<EnumOptionData> depositTermTypeOptions, Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions) {
final boolean preClosurePenalApplicable, final BigDecimal preClosurePenalInterest,
final EnumOptionData preClosurePenalInterestOnType, final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions,
final Integer minDepositTerm, final Integer maxDepositTerm, final EnumOptionData minDepositTermType,
final EnumOptionData maxDepositTermType, final Integer inMultiplesOfDepositTerm,
final EnumOptionData inMultiplesOfDepositTermType, final BigDecimal minDepositAmount, final BigDecimal depositAmount,
final BigDecimal maxDepositAmount, final Collection<EnumOptionData> periodFrequencyTypeOptions) {
super(id, name, shortName, description, currency, nominalAnnualInterestRate, interestCompoundingPeriodType,
interestPostingPeriodType, interestCalculationType, interestCalculationDaysInYearType, lockinPeriodFrequency,
@@ -383,10 +348,6 @@ public class FixedDepositProductData extends DepositProductData {
penaltyToIncomeAccountMappings, interestRateCharts, chartTemplate);
// fixed deposit additional fields
this.interestFreePeriodApplicable = interestFreePeriodApplicable;
this.interestFreeFromPeriod = interestFreeFromPeriod;
this.interestFreeToPeriod = interestFreeToPeriod;
this.interestFreePeriodFrequencyType = interestFreePeriodFrequencyType;
this.preClosurePenalApplicable = preClosurePenalApplicable;
this.preClosurePenalInterest = preClosurePenalInterest;
this.preClosurePenalInterestOnType = preClosurePenalInterestOnType;
@@ -401,10 +362,8 @@ public class FixedDepositProductData extends DepositProductData {
this.maxDepositAmount = maxDepositAmount;
// template
this.interestFreePeriodTypeOptions = interestFreePeriodTypeOptions;
this.preClosurePenalInterestOnTypeOptions = preClosurePenalInterestOnTypeOptions;
this.depositTermTypeOptions = depositTermTypeOptions;
this.inMultiplesOfDepositTermTypeOptions = inMultiplesOfDepositTermTypeOptions;
this.periodFrequencyTypeOptions = periodFrequencyTypeOptions;
}
}
@@ -25,73 +25,65 @@ import org.mifosplatform.portfolio.savings.service.SavingsEnumerations;
public class RecurringDepositAccountData extends DepositAccountData {
// additional fields
private boolean interestFreePeriodApplicable;
private Integer interestFreeFromPeriod;
private Integer interestFreeToPeriod;
private EnumOptionData interestFreePeriodFrequencyType;
private boolean preClosurePenalApplicable;
private BigDecimal preClosurePenalInterest;
private EnumOptionData preClosurePenalInterestOnType;
private Integer minDepositTerm;
private Integer maxDepositTerm;
private EnumOptionData minDepositTermType;
private EnumOptionData maxDepositTermType;
private Integer inMultiplesOfDepositTerm;
private EnumOptionData inMultiplesOfDepositTermType;
private BigDecimal depositAmount;
private BigDecimal maturityAmount;
private LocalDate maturityDate;
private Integer depositPeriod;
private EnumOptionData depositPeriodFrequency;
private BigDecimal recurringDepositAmount;
private EnumOptionData recurringDepositType;
private Integer recurringDepositFrequency;
private EnumOptionData recurringDepositFrequencyType;
private LocalDate expectedFirstDepositOnDate;
private final boolean preClosurePenalApplicable;
private final BigDecimal preClosurePenalInterest;
private final EnumOptionData preClosurePenalInterestOnType;
private final Integer minDepositTerm;
private final Integer maxDepositTerm;
private final EnumOptionData minDepositTermType;
private final EnumOptionData maxDepositTermType;
private final Integer inMultiplesOfDepositTerm;
private final EnumOptionData inMultiplesOfDepositTermType;
private final BigDecimal depositAmount;
private final BigDecimal maturityAmount;
private final LocalDate maturityDate;
private final Integer depositPeriod;
private final EnumOptionData depositPeriodFrequency;
private final BigDecimal mandatoryRecommendedDepositAmount;
private final BigDecimal totalOverdueAmount;
private final Integer noOfOverdueInstallments;
private final boolean isMandatoryDeposit;
private final boolean allowWithdrawal;
private final boolean adjustAdvanceTowardsFuturePayments;
private final LocalDate expectedFirstDepositOnDate;
private final boolean isCalendarInherited;
private final Integer recurringFrequency;
private final EnumOptionData recurringFrequencyType;
// used for account close
private EnumOptionData onAccountClosure;
private final EnumOptionData onAccountClosure;
private Collection<EnumOptionData> interestFreePeriodTypeOptions;
private Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions;
private Collection<EnumOptionData> recurringDepositTypeOptions;
private Collection<EnumOptionData> recurringDepositFrequencyTypeOptions;
private Collection<EnumOptionData> depositTermTypeOptions;
private Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions;
private Collection<EnumOptionData> depositPeriodFrequencyOptions;
private Collection<SavingsAccountData> savingsAccounts;
private final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions;
private final Collection<EnumOptionData> periodFrequencyTypeOptions;
private final Collection<SavingsAccountData> savingsAccounts;
// for account close
private Collection<EnumOptionData> onAccountClosureOptions;
private Collection<CodeValueData> paymentTypeOptions;
private final Collection<EnumOptionData> onAccountClosureOptions;
private final Collection<CodeValueData> paymentTypeOptions;
public static RecurringDepositAccountData instance(final DepositAccountData depositAccountData,
final boolean interestFreePeriodApplicable, final Integer interestFreeFromPeriod, final Integer interestFreeToPeriod,
final EnumOptionData interestFreePeriodFrequencyType, final boolean preClosurePenalApplicable,
final BigDecimal preClosurePenalInterest, final EnumOptionData preClosurePenalInterestOnType, final Integer minDepositTerm,
final Integer maxDepositTerm, final EnumOptionData minDepositTermType, final EnumOptionData maxDepositTermType,
final Integer inMultiplesOfDepositTerm, final EnumOptionData inMultiplesOfDepositTermType, final BigDecimal depositAmount,
final BigDecimal maturityAmount, final LocalDate maturityDate, final Integer depositPeriod,
final EnumOptionData depositPeriodFrequency, final BigDecimal recurringDepositAmount,
final EnumOptionData recurringDepositType, final Integer recurringDepositFrequency,
final EnumOptionData recurringDepositFrequencyType, final EnumOptionData onAccountClosure,
final LocalDate expectedFirstDepositOnDate) {
final boolean preClosurePenalApplicable, final BigDecimal preClosurePenalInterest,
final EnumOptionData preClosurePenalInterestOnType, final Integer minDepositTerm, final Integer maxDepositTerm,
final EnumOptionData minDepositTermType, final EnumOptionData maxDepositTermType, final Integer inMultiplesOfDepositTerm,
final EnumOptionData inMultiplesOfDepositTermType, final BigDecimal depositAmount, final BigDecimal maturityAmount,
final LocalDate maturityDate, final Integer depositPeriod, final EnumOptionData depositPeriodFrequency,
final BigDecimal mandatoryRecommendedDepositAmount, final EnumOptionData onAccountClosure,
final LocalDate expectedFirstDepositOnDate, final BigDecimal totalOverdueAmount, final Integer noOfOverdueInstallments,
final boolean isMandatoryDeposit, final boolean allowWithdrawal, final boolean adjustAdvanceTowardsFuturePayments, final boolean isCalendarInherited) {
final Collection<EnumOptionData> interestFreePeriodTypeOptions = null;
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions = null;
final Collection<EnumOptionData> depositTermTypeOptions = null;
final Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions = null;
final Collection<EnumOptionData> recurringDepositTypeOptions = null;
final Collection<EnumOptionData> recurringDepositFrequencyTypeOptions = null;
final Collection<EnumOptionData> depositPeriodFrequencyOptions = null;
final Collection<EnumOptionData> periodFrequencyTypeOptions = null;
final EnumOptionData depositType = SavingsEnumerations.depositType(DepositAccountType.FIXED_DEPOSIT.getValue());
final Collection<EnumOptionData> onAccountClosureOptions = null;
final Collection<CodeValueData> paymentTypeOptions = null;
final Collection<SavingsAccountData> savingsAccountDatas = null;
final Integer recurringFrequency = null;
final EnumOptionData recurringFrequencyType = null;
return new RecurringDepositAccountData(depositAccountData.id, depositAccountData.accountNo, depositAccountData.externalId,
depositAccountData.groupId, depositAccountData.groupName, depositAccountData.clientId, depositAccountData.clientName,
depositAccountData.savingsProductId, depositAccountData.savingsProductName, depositAccountData.fieldOfficerId,
depositAccountData.depositProductId, depositAccountData.depositProductName, depositAccountData.fieldOfficerId,
depositAccountData.fieldOfficerName, depositAccountData.status, depositAccountData.timeline, depositAccountData.currency,
depositAccountData.nominalAnnualInterestRate, depositAccountData.interestCompoundingPeriodType,
depositAccountData.interestPostingPeriodType, depositAccountData.interestCalculationType,
@@ -103,20 +95,18 @@ public class RecurringDepositAccountData extends DepositAccountData {
depositAccountData.interestCalculationTypeOptions, depositAccountData.interestCalculationDaysInYearTypeOptions,
depositAccountData.lockinPeriodFrequencyTypeOptions, depositAccountData.withdrawalFeeTypeOptions,
depositAccountData.charges, depositAccountData.chargeOptions, depositAccountData.accountChart,
depositAccountData.chartTemplate, interestFreePeriodApplicable, interestFreeFromPeriod, interestFreeToPeriod,
interestFreePeriodFrequencyType, preClosurePenalApplicable, preClosurePenalInterest, preClosurePenalInterestOnType,
interestFreePeriodTypeOptions, preClosurePenalInterestOnTypeOptions, minDepositTerm, maxDepositTerm, minDepositTermType,
maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType, depositAmount, maturityAmount, maturityDate,
depositPeriod, depositPeriodFrequency, recurringDepositAmount, depositTermTypeOptions, inMultiplesOfDepositTermTypeOptions,
recurringDepositType, recurringDepositFrequency, recurringDepositFrequencyType, recurringDepositTypeOptions,
recurringDepositFrequencyTypeOptions, depositPeriodFrequencyOptions, depositType, onAccountClosure,
onAccountClosureOptions, paymentTypeOptions, savingsAccountDatas, expectedFirstDepositOnDate);
depositAccountData.chartTemplate, preClosurePenalApplicable, preClosurePenalInterest, preClosurePenalInterestOnType,
preClosurePenalInterestOnTypeOptions, minDepositTerm, maxDepositTerm, minDepositTermType, maxDepositTermType,
inMultiplesOfDepositTerm, inMultiplesOfDepositTermType, depositAmount, maturityAmount, maturityDate, depositPeriod,
depositPeriodFrequency, mandatoryRecommendedDepositAmount, periodFrequencyTypeOptions, depositType, onAccountClosure,
onAccountClosureOptions, paymentTypeOptions, savingsAccountDatas, expectedFirstDepositOnDate, totalOverdueAmount,
noOfOverdueInstallments, isMandatoryDeposit, allowWithdrawal, adjustAdvanceTowardsFuturePayments, isCalendarInherited, recurringFrequency, recurringFrequencyType);
}
public static RecurringDepositAccountData withInterestChart(final RecurringDepositAccountData account,
final DepositAccountInterestRateChartData accountChart) {
public static RecurringDepositAccountData withInterestChartAndRecurringDetails(final RecurringDepositAccountData account,
final DepositAccountInterestRateChartData accountChart, final Integer recurringFrequency, final EnumOptionData recurringFrequencyType) {
return new RecurringDepositAccountData(account.id, account.accountNo, account.externalId, account.groupId, account.groupName,
account.clientId, account.clientName, account.savingsProductId, account.savingsProductName, account.fieldOfficerId,
account.clientId, account.clientName, account.depositProductId, account.depositProductName, account.fieldOfficerId,
account.fieldOfficerName, account.status, account.timeline, account.currency, account.nominalAnnualInterestRate,
account.interestCompoundingPeriodType, account.interestPostingPeriodType, account.interestCalculationType,
account.interestCalculationDaysInYearType, account.minRequiredOpeningBalance, account.lockinPeriodFrequency,
@@ -125,17 +115,15 @@ public class RecurringDepositAccountData extends DepositAccountData {
account.interestPostingPeriodTypeOptions, account.interestCalculationTypeOptions,
account.interestCalculationDaysInYearTypeOptions, account.lockinPeriodFrequencyTypeOptions,
account.withdrawalFeeTypeOptions, account.charges, account.chargeOptions, accountChart, account.chartTemplate,
account.interestFreePeriodApplicable, account.interestFreeFromPeriod, account.interestFreeToPeriod,
account.interestFreePeriodFrequencyType, account.preClosurePenalApplicable, account.preClosurePenalInterest,
account.preClosurePenalInterestOnType, account.interestFreePeriodTypeOptions, account.preClosurePenalInterestOnTypeOptions,
account.minDepositTerm, account.maxDepositTerm, account.minDepositTermType, account.maxDepositTermType,
account.inMultiplesOfDepositTerm, account.inMultiplesOfDepositTermType, account.depositAmount, account.maturityAmount,
account.maturityDate, account.depositPeriod, account.depositPeriodFrequency, account.recurringDepositAmount,
account.depositTermTypeOptions, account.inMultiplesOfDepositTermTypeOptions, account.recurringDepositType,
account.recurringDepositFrequency, account.recurringDepositFrequencyType, account.recurringDepositTypeOptions,
account.recurringDepositFrequencyTypeOptions, account.depositPeriodFrequencyOptions, account.depositType,
account.preClosurePenalApplicable, account.preClosurePenalInterest, account.preClosurePenalInterestOnType,
account.preClosurePenalInterestOnTypeOptions, account.minDepositTerm, account.maxDepositTerm, account.minDepositTermType,
account.maxDepositTermType, account.inMultiplesOfDepositTerm, account.inMultiplesOfDepositTermType, account.depositAmount,
account.maturityAmount, account.maturityDate, account.depositPeriod, account.depositPeriodFrequency,
account.mandatoryRecommendedDepositAmount, account.periodFrequencyTypeOptions, account.depositType,
account.onAccountClosure, account.onAccountClosureOptions, account.paymentTypeOptions, account.savingsAccounts,
account.expectedFirstDepositOnDate);
account.expectedFirstDepositOnDate, account.totalOverdueAmount, account.noOfOverdueInstallments,
account.isMandatoryDeposit, account.allowWithdrawal, account.adjustAdvanceTowardsFuturePayments,
account.isCalendarInherited, recurringFrequency, recurringFrequencyType);
}
public static RecurringDepositAccountData withTemplateOptions(final RecurringDepositAccountData account,
@@ -153,24 +141,17 @@ public class RecurringDepositAccountData extends DepositAccountData {
final Collection<EnumOptionData> withdrawalFeeTypeOptions = null;
final Collection<ChargeData> chargeOptions = null;
final Collection<EnumOptionData> interestFreePeriodTypeOptions = null;
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions = null;
final Collection<EnumOptionData> depositTermTypeOptions = null;
final Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions = null;
final Collection<EnumOptionData> recurringDepositTypeOptions = null;
final Collection<EnumOptionData> recurringDepositFrequencyTypeOptions = null;
final Collection<EnumOptionData> depositPeriodFrequencyOptions = null;
final Collection<EnumOptionData> periodFrequencyTypeOptions = null;
return withTemplateOptions(account, productOptions, fieldOfficerOptions, interestCompoundingPeriodTypeOptions,
interestPostingPeriodTypeOptions, interestCalculationTypeOptions, interestCalculationDaysInYearTypeOptions,
lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, transactions, charges, chargeOptions,
interestFreePeriodTypeOptions, preClosurePenalInterestOnTypeOptions, depositTermTypeOptions,
inMultiplesOfDepositTermTypeOptions, recurringDepositTypeOptions, recurringDepositFrequencyTypeOptions,
depositPeriodFrequencyOptions);
preClosurePenalInterestOnTypeOptions, periodFrequencyTypeOptions);
}
return new RecurringDepositAccountData(account.id, account.accountNo, account.externalId, account.groupId, account.groupName,
account.clientId, account.clientName, account.savingsProductId, account.savingsProductName, account.fieldOfficerId,
account.clientId, account.clientName, account.depositProductId, account.depositProductName, account.fieldOfficerId,
account.fieldOfficerName, account.status, account.timeline, account.currency, account.nominalAnnualInterestRate,
account.interestCompoundingPeriodType, account.interestPostingPeriodType, account.interestCalculationType,
account.interestCalculationDaysInYearType, account.minRequiredOpeningBalance, account.lockinPeriodFrequency,
@@ -179,17 +160,15 @@ public class RecurringDepositAccountData extends DepositAccountData {
template.interestPostingPeriodTypeOptions, template.interestCalculationTypeOptions,
template.interestCalculationDaysInYearTypeOptions, template.lockinPeriodFrequencyTypeOptions,
template.withdrawalFeeTypeOptions, charges, template.chargeOptions, account.accountChart, account.chartTemplate,
account.interestFreePeriodApplicable, account.interestFreeFromPeriod, account.interestFreeToPeriod,
account.interestFreePeriodFrequencyType, account.preClosurePenalApplicable, account.preClosurePenalInterest,
account.preClosurePenalInterestOnType, template.interestFreePeriodTypeOptions,
account.preClosurePenalApplicable, account.preClosurePenalInterest, account.preClosurePenalInterestOnType,
template.preClosurePenalInterestOnTypeOptions, account.minDepositTerm, account.maxDepositTerm, account.minDepositTermType,
account.maxDepositTermType, account.inMultiplesOfDepositTerm, account.inMultiplesOfDepositTermType, account.depositAmount,
account.maturityAmount, account.maturityDate, account.depositPeriod, account.depositPeriodFrequency,
account.recurringDepositAmount, template.depositTermTypeOptions, template.inMultiplesOfDepositTermTypeOptions,
account.recurringDepositType, account.recurringDepositFrequency, account.recurringDepositFrequencyType,
template.recurringDepositTypeOptions, template.recurringDepositFrequencyTypeOptions,
template.depositPeriodFrequencyOptions, account.depositType, account.onAccountClosure, account.onAccountClosureOptions,
account.paymentTypeOptions, account.savingsAccounts, account.expectedFirstDepositOnDate);
account.mandatoryRecommendedDepositAmount, template.periodFrequencyTypeOptions, account.depositType,
account.onAccountClosure, account.onAccountClosureOptions, account.paymentTypeOptions, account.savingsAccounts,
account.expectedFirstDepositOnDate, account.totalOverdueAmount, account.noOfOverdueInstallments,
account.isMandatoryDeposit, account.allowWithdrawal, account.adjustAdvanceTowardsFuturePayments,
account.isCalendarInherited, account.recurringFrequency, account.recurringFrequencyType);
}
@@ -201,15 +180,11 @@ public class RecurringDepositAccountData extends DepositAccountData {
final Collection<EnumOptionData> interestCalculationDaysInYearTypeOptions,
final Collection<EnumOptionData> lockinPeriodFrequencyTypeOptions, final Collection<EnumOptionData> withdrawalFeeTypeOptions,
final Collection<SavingsAccountTransactionData> transactions, final Collection<SavingsAccountChargeData> charges,
final Collection<ChargeData> chargeOptions, final Collection<EnumOptionData> interestFreePeriodTypeOptions,
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions, final Collection<EnumOptionData> depositTermTypeOptions,
final Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions,
final Collection<EnumOptionData> recurringDepositTypeOptions,
final Collection<EnumOptionData> recurringDepositFrequencyTypeOptions,
final Collection<EnumOptionData> depositPeriodFrequencyOptions) {
final Collection<ChargeData> chargeOptions, final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions,
final Collection<EnumOptionData> periodFrequencyTypeOptions) {
return new RecurringDepositAccountData(account.id, account.accountNo, account.externalId, account.groupId, account.groupName,
account.clientId, account.clientName, account.savingsProductId, account.savingsProductName, account.fieldOfficerId,
account.clientId, account.clientName, account.depositProductId, account.depositProductName, account.fieldOfficerId,
account.fieldOfficerName, account.status, account.timeline, account.currency, account.nominalAnnualInterestRate,
account.interestCompoundingPeriodType, account.interestPostingPeriodType, account.interestCalculationType,
account.interestCalculationDaysInYearType, account.minRequiredOpeningBalance, account.lockinPeriodFrequency,
@@ -217,16 +192,15 @@ public class RecurringDepositAccountData extends DepositAccountData {
fieldOfficerOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions,
interestCalculationTypeOptions, interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions,
withdrawalFeeTypeOptions, charges, chargeOptions, account.accountChart, account.chartTemplate,
account.interestFreePeriodApplicable, account.interestFreeFromPeriod, account.interestFreeToPeriod,
account.interestFreePeriodFrequencyType, account.preClosurePenalApplicable, account.preClosurePenalInterest,
account.preClosurePenalInterestOnType, interestFreePeriodTypeOptions, preClosurePenalInterestOnTypeOptions,
account.minDepositTerm, account.maxDepositTerm, account.minDepositTermType, account.maxDepositTermType,
account.inMultiplesOfDepositTerm, account.inMultiplesOfDepositTermType, account.depositAmount, account.maturityAmount,
account.maturityDate, account.depositPeriod, account.depositPeriodFrequency, account.recurringDepositAmount,
depositTermTypeOptions, inMultiplesOfDepositTermTypeOptions, account.recurringDepositType,
account.recurringDepositFrequency, account.recurringDepositFrequencyType, recurringDepositTypeOptions,
recurringDepositFrequencyTypeOptions, depositPeriodFrequencyOptions, account.depositType, account.onAccountClosure,
account.onAccountClosureOptions, account.paymentTypeOptions, account.savingsAccounts, account.expectedFirstDepositOnDate);
account.preClosurePenalApplicable, account.preClosurePenalInterest, account.preClosurePenalInterestOnType,
preClosurePenalInterestOnTypeOptions, account.minDepositTerm, account.maxDepositTerm, account.minDepositTermType,
account.maxDepositTermType, account.inMultiplesOfDepositTerm, account.inMultiplesOfDepositTermType, account.depositAmount,
account.maturityAmount, account.maturityDate, account.depositPeriod, account.depositPeriodFrequency,
account.mandatoryRecommendedDepositAmount, periodFrequencyTypeOptions, account.depositType, account.onAccountClosure,
account.onAccountClosureOptions, account.paymentTypeOptions, account.savingsAccounts, account.expectedFirstDepositOnDate,
account.totalOverdueAmount, account.noOfOverdueInstallments, account.isMandatoryDeposit, account.allowWithdrawal,
account.adjustAdvanceTowardsFuturePayments, account.isCalendarInherited, account.recurringFrequency,
account.recurringFrequencyType);
}
public static RecurringDepositAccountData withClientTemplate(final Long clientId, final String clientName, final Long groupId,
@@ -268,10 +242,6 @@ public class RecurringDepositAccountData extends DepositAccountData {
final DepositAccountInterestRateChartData accountChart = null;
final DepositAccountInterestRateChartData chartTemplate = null;
final boolean interestFreePeriodApplicable = false;
final Integer interestFreeFromPeriod = null;
final Integer interestFreeToPeriod = null;
final EnumOptionData interestFreePeriodFrequencyType = null;
final boolean preClosurePenalApplicable = false;
final BigDecimal preClosurePenalInterest = null;
final EnumOptionData preClosurePenalInterestOnType = null;
@@ -286,45 +256,46 @@ public class RecurringDepositAccountData extends DepositAccountData {
final LocalDate maturityDate = null;
final Integer depositPeriod = null;
final EnumOptionData depositPeriodFrequency = null;
final BigDecimal recurringDepositAmount = null;
final BigDecimal mandatoryRecommendedDepositAmount = null;
final EnumOptionData onAccountClosure = null;
final Collection<EnumOptionData> interestFreePeriodTypeOptions = null;
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions = null;
final Collection<EnumOptionData> depositTermTypeOptions = null;
final Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions = null;
final Collection<EnumOptionData> periodFrequencyTypeOptions = null;
final EnumOptionData recurringDepositType = null;
final Integer recurringDepositFrequency = null;
final EnumOptionData recurringDepositFrequencyType = null;
final Collection<EnumOptionData> recurringDepositTypeOptions = null;
final Collection<EnumOptionData> recurringDepositFrequencyTypeOptions = null;
final Collection<EnumOptionData> depositPeriodFrequencyOptions = null;
final EnumOptionData depositType = SavingsEnumerations.depositType(DepositAccountType.RECURRING_DEPOSIT.getValue());
final Collection<EnumOptionData> onAccountClosureOptions = null;
final Collection<CodeValueData> paymentTypeOptions = null;
final Collection<SavingsAccountData> savingsAccountDatas = null;
final LocalDate expectedFirstDepositOnDate = null;
final BigDecimal totalOverdueAmount = null;
final Integer noOfOverdueInstallments = null;
final boolean isMandatoryDeposit = false;
final boolean allowWithdrawal = false;
final boolean adjustAdvanceTowardsFuturePayments = false;
final boolean isCalendarInherited = false;
final Integer recurringFrequency = null;
final EnumOptionData recurringFrequencyType = null;
return new RecurringDepositAccountData(id, accountNo, externalId, groupId, groupName, clientId, clientName, productId, productName,
fieldOfficerId, fieldOfficerName, status, timeline, currency, nominalAnnualInterestRate, interestPeriodType,
interestPostingPeriodType, interestCalculationType, interestCalculationDaysInYearType, minRequiredOpeningBalance,
lockinPeriodFrequency, lockinPeriodFrequencyType, withdrawalFeeForTransfers, summary, transactions, productOptions,
fieldOfficerOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions,
interestCalculationTypeOptions, interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions,
withdrawalFeeTypeOptions, charges, chargeOptions, accountChart, chartTemplate, interestFreePeriodApplicable,
interestFreeFromPeriod, interestFreeToPeriod, interestFreePeriodFrequencyType, preClosurePenalApplicable,
preClosurePenalInterest, preClosurePenalInterestOnType, interestFreePeriodTypeOptions,
preClosurePenalInterestOnTypeOptions, minDepositTerm, maxDepositTerm, minDepositTermType, maxDepositTermType,
inMultiplesOfDepositTerm, inMultiplesOfDepositTermType, depositAmount, maturityAmount, maturityDate, depositPeriod,
depositPeriodFrequency, recurringDepositAmount, depositTermTypeOptions, inMultiplesOfDepositTermTypeOptions,
recurringDepositType, recurringDepositFrequency, recurringDepositFrequencyType, recurringDepositTypeOptions,
recurringDepositFrequencyTypeOptions, depositPeriodFrequencyOptions, depositType, onAccountClosure,
onAccountClosureOptions, paymentTypeOptions, savingsAccountDatas, expectedFirstDepositOnDate);
withdrawalFeeTypeOptions, charges, chargeOptions, accountChart, chartTemplate, preClosurePenalApplicable,
preClosurePenalInterest, preClosurePenalInterestOnType, preClosurePenalInterestOnTypeOptions, minDepositTerm,
maxDepositTerm, minDepositTermType, maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType,
depositAmount, maturityAmount, maturityDate, depositPeriod, depositPeriodFrequency, mandatoryRecommendedDepositAmount,
periodFrequencyTypeOptions, depositType, onAccountClosure, onAccountClosureOptions, paymentTypeOptions,
savingsAccountDatas, expectedFirstDepositOnDate, totalOverdueAmount, noOfOverdueInstallments, isMandatoryDeposit,
allowWithdrawal, adjustAdvanceTowardsFuturePayments, isCalendarInherited, recurringFrequency, recurringFrequencyType);
}
public static RecurringDepositAccountData preClosureDetails(final Long accountId, BigDecimal maturityAmount,
final Collection<EnumOptionData> onAccountClosureOptions, final Collection<CodeValueData> paymentTypeOptions, final Collection<SavingsAccountData> savingsAccountDatas) {
public static RecurringDepositAccountData preClosureDetails(final Long accountId, final BigDecimal maturityAmount,
final Collection<EnumOptionData> onAccountClosureOptions, final Collection<CodeValueData> paymentTypeOptions,
final Collection<SavingsAccountData> savingsAccountDatas) {
final String accountNo = null;
final String externalId = null;
@@ -361,10 +332,6 @@ public class RecurringDepositAccountData extends DepositAccountData {
final DepositAccountInterestRateChartData accountChart = null;
final DepositAccountInterestRateChartData chartTemplate = null;
final boolean interestFreePeriodApplicable = false;
final Integer interestFreeFromPeriod = null;
final Integer interestFreeToPeriod = null;
final EnumOptionData interestFreePeriodFrequencyType = null;
final boolean preClosurePenalApplicable = false;
final BigDecimal preClosurePenalInterest = null;
final EnumOptionData preClosurePenalInterestOnType = null;
@@ -378,20 +345,10 @@ public class RecurringDepositAccountData extends DepositAccountData {
final LocalDate maturityDate = null;
final Integer depositPeriod = null;
final EnumOptionData depositPeriodFrequency = null;
final BigDecimal recurringDepositAmount = null;
final BigDecimal mandatoryRecommendedDepositAmount = null;
final EnumOptionData onAccountClosure = null;
final Collection<EnumOptionData> interestFreePeriodTypeOptions = null;
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions = null;
final Collection<EnumOptionData> depositTermTypeOptions = null;
final Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions = null;
final EnumOptionData recurringDepositType = null;
final Integer recurringDepositFrequency = null;
final EnumOptionData recurringDepositFrequencyType = null;
final Collection<EnumOptionData> recurringDepositTypeOptions = null;
final Collection<EnumOptionData> recurringDepositFrequencyTypeOptions = null;
final Collection<EnumOptionData> depositPeriodFrequencyOptions = null;
final Collection<EnumOptionData> periodFrequencyTypeOptions = null;
final EnumOptionData depositType = SavingsEnumerations.depositType(DepositAccountType.RECURRING_DEPOSIT.getValue());
final Long groupId = null;
@@ -400,28 +357,36 @@ public class RecurringDepositAccountData extends DepositAccountData {
final String clientName = null;
final LocalDate expectedFirstDepositOnDate = null;
final BigDecimal totalOverdueAmount = null;
final Integer noOfOverdueInstallments = null;
final boolean isMandatoryDeposit = false;
final boolean allowWithdrawal = false;
final boolean adjustAdvanceTowardsFuturePayments = false;
final boolean isCalendarInherited = false;
final Integer recurringFrequency = null;
final EnumOptionData recurringFrequencyType = null;
return new RecurringDepositAccountData(accountId, accountNo, externalId, groupId, groupName, clientId, clientName, productId,
productName, fieldOfficerId, fieldOfficerName, status, timeline, currency, nominalAnnualInterestRate, interestPeriodType,
interestPostingPeriodType, interestCalculationType, interestCalculationDaysInYearType, minRequiredOpeningBalance,
lockinPeriodFrequency, lockinPeriodFrequencyType, withdrawalFeeForTransfers, summary, transactions, productOptions,
fieldOfficerOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions,
interestCalculationTypeOptions, interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions,
withdrawalFeeTypeOptions, charges, chargeOptions, accountChart, chartTemplate, interestFreePeriodApplicable,
interestFreeFromPeriod, interestFreeToPeriod, interestFreePeriodFrequencyType, preClosurePenalApplicable,
preClosurePenalInterest, preClosurePenalInterestOnType, interestFreePeriodTypeOptions,
preClosurePenalInterestOnTypeOptions, minDepositTerm, maxDepositTerm, minDepositTermType, maxDepositTermType,
inMultiplesOfDepositTerm, inMultiplesOfDepositTermType, depositAmount, maturityAmount, maturityDate, depositPeriod,
depositPeriodFrequency, recurringDepositAmount, depositTermTypeOptions, inMultiplesOfDepositTermTypeOptions,
recurringDepositType, recurringDepositFrequency, recurringDepositFrequencyType, recurringDepositTypeOptions,
recurringDepositFrequencyTypeOptions, depositPeriodFrequencyOptions, depositType, onAccountClosure,
onAccountClosureOptions, paymentTypeOptions, savingsAccountDatas, expectedFirstDepositOnDate);
withdrawalFeeTypeOptions, charges, chargeOptions, accountChart, chartTemplate, preClosurePenalApplicable,
preClosurePenalInterest, preClosurePenalInterestOnType, preClosurePenalInterestOnTypeOptions, minDepositTerm,
maxDepositTerm, minDepositTermType, maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType,
depositAmount, maturityAmount, maturityDate, depositPeriod, depositPeriodFrequency, mandatoryRecommendedDepositAmount,
periodFrequencyTypeOptions, depositType, onAccountClosure, onAccountClosureOptions, paymentTypeOptions,
savingsAccountDatas, expectedFirstDepositOnDate, totalOverdueAmount, noOfOverdueInstallments, isMandatoryDeposit,
allowWithdrawal, adjustAdvanceTowardsFuturePayments, isCalendarInherited, recurringFrequency, recurringFrequencyType);
}
public static RecurringDepositAccountData withClosureTemplateDetails(final RecurringDepositAccountData account,
final Collection<EnumOptionData> onAccountClosureOptions, final Collection<CodeValueData> paymentTypeOptions, final Collection<SavingsAccountData> savingsAccountDatas) {
final Collection<EnumOptionData> onAccountClosureOptions, final Collection<CodeValueData> paymentTypeOptions,
final Collection<SavingsAccountData> savingsAccountDatas) {
return new RecurringDepositAccountData(account.id, account.accountNo, account.externalId, account.groupId, account.groupName,
account.clientId, account.clientName, account.savingsProductId, account.savingsProductName, account.fieldOfficerId,
account.clientId, account.clientName, account.depositProductId, account.depositProductName, account.fieldOfficerId,
account.fieldOfficerName, account.status, account.timeline, account.currency, account.nominalAnnualInterestRate,
account.interestCompoundingPeriodType, account.interestPostingPeriodType, account.interestCalculationType,
account.interestCalculationDaysInYearType, account.minRequiredOpeningBalance, account.lockinPeriodFrequency,
@@ -430,17 +395,15 @@ public class RecurringDepositAccountData extends DepositAccountData {
account.interestPostingPeriodTypeOptions, account.interestCalculationTypeOptions,
account.interestCalculationDaysInYearTypeOptions, account.lockinPeriodFrequencyTypeOptions,
account.withdrawalFeeTypeOptions, account.charges, account.chargeOptions, account.accountChart, account.chartTemplate,
account.interestFreePeriodApplicable, account.interestFreeFromPeriod, account.interestFreeToPeriod,
account.interestFreePeriodFrequencyType, account.preClosurePenalApplicable, account.preClosurePenalInterest,
account.preClosurePenalInterestOnType, account.interestFreePeriodTypeOptions, account.preClosurePenalInterestOnTypeOptions,
account.minDepositTerm, account.maxDepositTerm, account.minDepositTermType, account.maxDepositTermType,
account.inMultiplesOfDepositTerm, account.inMultiplesOfDepositTermType, account.depositAmount, account.maturityAmount,
account.maturityDate, account.depositPeriod, account.depositPeriodFrequency, account.recurringDepositAmount,
account.depositTermTypeOptions, account.inMultiplesOfDepositTermTypeOptions, account.recurringDepositType,
account.recurringDepositFrequency, account.recurringDepositFrequencyType, account.recurringDepositTypeOptions,
account.recurringDepositFrequencyTypeOptions, account.depositPeriodFrequencyOptions, account.depositType,
account.preClosurePenalApplicable, account.preClosurePenalInterest, account.preClosurePenalInterestOnType,
account.preClosurePenalInterestOnTypeOptions, account.minDepositTerm, account.maxDepositTerm, account.minDepositTermType,
account.maxDepositTermType, account.inMultiplesOfDepositTerm, account.inMultiplesOfDepositTermType, account.depositAmount,
account.maturityAmount, account.maturityDate, account.depositPeriod, account.depositPeriodFrequency,
account.mandatoryRecommendedDepositAmount, account.periodFrequencyTypeOptions, account.depositType,
account.onAccountClosure, onAccountClosureOptions, paymentTypeOptions, savingsAccountDatas,
account.expectedFirstDepositOnDate);
account.expectedFirstDepositOnDate, account.totalOverdueAmount, account.noOfOverdueInstallments,
account.isMandatoryDeposit, account.allowWithdrawal, account.adjustAdvanceTowardsFuturePayments,
account.isCalendarInherited, account.recurringFrequency, account.recurringFrequencyType);
}
private RecurringDepositAccountData(final Long id, final String accountNo, final String externalId, final Long groupId,
@@ -460,23 +423,19 @@ public class RecurringDepositAccountData extends DepositAccountData {
final Collection<EnumOptionData> lockinPeriodFrequencyTypeOptions, final Collection<EnumOptionData> withdrawalFeeTypeOptions,
final Collection<SavingsAccountChargeData> charges, final Collection<ChargeData> chargeOptions,
final DepositAccountInterestRateChartData accountChart, final DepositAccountInterestRateChartData chartTemplate,
final boolean interestFreePeriodApplicable, final Integer interestFreeFromPeriod, final Integer interestFreeToPeriod,
final EnumOptionData interestFreePeriodFrequencyType, final boolean preClosurePenalApplicable,
final BigDecimal preClosurePenalInterest, final EnumOptionData preClosurePenalInterestOnType,
final Collection<EnumOptionData> interestFreePeriodTypeOptions,
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions, final Integer minDepositTerm,
final Integer maxDepositTerm, final EnumOptionData minDepositTermType, final EnumOptionData maxDepositTermType,
final Integer inMultiplesOfDepositTerm, final EnumOptionData inMultiplesOfDepositTermType, final BigDecimal depositAmount,
final BigDecimal maturityAmount, final LocalDate maturityDate, final Integer depositPeriod,
final EnumOptionData depositPeriodFrequency, final BigDecimal recurringDepositAmount,
final Collection<EnumOptionData> depositTermTypeOptions, Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions,
final EnumOptionData recurringDepositType, final Integer recurringDepositFrequency,
final EnumOptionData recurringDepositFrequencyType, final Collection<EnumOptionData> recurringDepositTypeOptions,
final Collection<EnumOptionData> recurringDepositFrequencyTypeOptions,
final Collection<EnumOptionData> depositPeriodFrequencyOptions, final EnumOptionData depositType,
final EnumOptionData onAccountClosure, final Collection<EnumOptionData> onAccountClosureOptions,
final Collection<CodeValueData> paymentTypeOptions, final Collection<SavingsAccountData> savingsAccountDatas,
final LocalDate expectedFirstDepositOnDate) {
final boolean preClosurePenalApplicable, final BigDecimal preClosurePenalInterest,
final EnumOptionData preClosurePenalInterestOnType, final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions,
final Integer minDepositTerm, final Integer maxDepositTerm, final EnumOptionData minDepositTermType,
final EnumOptionData maxDepositTermType, final Integer inMultiplesOfDepositTerm,
final EnumOptionData inMultiplesOfDepositTermType, final BigDecimal depositAmount, final BigDecimal maturityAmount,
final LocalDate maturityDate, final Integer depositPeriod, final EnumOptionData depositPeriodFrequency,
final BigDecimal mandatoryRecommendedDepositAmount, final Collection<EnumOptionData> periodFrequencyTypeOptions,
final EnumOptionData depositType, final EnumOptionData onAccountClosure,
final Collection<EnumOptionData> onAccountClosureOptions, final Collection<CodeValueData> paymentTypeOptions,
final Collection<SavingsAccountData> savingsAccountDatas, final LocalDate expectedFirstDepositOnDate,
final BigDecimal totalOverdueAmount, final Integer noOfOverdueInstallments, final boolean isMandatoryDeposit,
final boolean allowWithdrawal, final boolean adjustAdvanceTowardsFuturePayments, final boolean isCalendarInherited,
final Integer recurringFrequency, final EnumOptionData recurringFrequencyType) {
super(id, accountNo, externalId, groupId, groupName, clientId, clientName, productId, productName, fieldofficerId,
fieldofficerName, status, timeline, currency, nominalAnnualInterestRate, interestPeriodType, interestPostingPeriodType,
@@ -486,10 +445,6 @@ public class RecurringDepositAccountData extends DepositAccountData {
interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, charges,
chargeOptions, accountChart, chartTemplate, depositType);
this.interestFreePeriodApplicable = interestFreePeriodApplicable;
this.interestFreeFromPeriod = interestFreeFromPeriod;
this.interestFreeToPeriod = interestFreeToPeriod;
this.interestFreePeriodFrequencyType = interestFreePeriodFrequencyType;
this.preClosurePenalApplicable = preClosurePenalApplicable;
this.preClosurePenalInterest = preClosurePenalInterest;
this.preClosurePenalInterestOnType = preClosurePenalInterestOnType;
@@ -504,20 +459,20 @@ public class RecurringDepositAccountData extends DepositAccountData {
this.maturityDate = maturityDate;
this.depositPeriod = depositPeriod;
this.depositPeriodFrequency = depositPeriodFrequency;
this.recurringDepositAmount = recurringDepositAmount;
this.recurringDepositFrequencyType = recurringDepositFrequencyType;
this.recurringDepositFrequency = recurringDepositFrequency;
this.recurringDepositType = recurringDepositType;
this.expectedFirstDepositOnDate = expectedFirstDepositOnDate;
this.mandatoryRecommendedDepositAmount = mandatoryRecommendedDepositAmount;
this.totalOverdueAmount = totalOverdueAmount;
this.noOfOverdueInstallments = noOfOverdueInstallments;
this.isMandatoryDeposit = isMandatoryDeposit;
this.allowWithdrawal = allowWithdrawal;
this.adjustAdvanceTowardsFuturePayments = adjustAdvanceTowardsFuturePayments;
this.isCalendarInherited = isCalendarInherited;
this.recurringFrequency = recurringFrequency;
this.recurringFrequencyType = recurringFrequencyType;
// template data
this.interestFreePeriodTypeOptions = interestFreePeriodTypeOptions;
this.preClosurePenalInterestOnTypeOptions = preClosurePenalInterestOnTypeOptions;
this.recurringDepositTypeOptions = recurringDepositTypeOptions;
this.recurringDepositFrequencyTypeOptions = recurringDepositFrequencyTypeOptions;
this.depositTermTypeOptions = depositTermTypeOptions;
this.inMultiplesOfDepositTermTypeOptions = inMultiplesOfDepositTermTypeOptions;
this.depositPeriodFrequencyOptions = depositPeriodFrequencyOptions;
this.periodFrequencyTypeOptions = periodFrequencyTypeOptions;
this.onAccountClosure = onAccountClosure;
this.savingsAccounts = savingsAccountDatas;
@@ -24,10 +24,6 @@ import org.mifosplatform.portfolio.interestratechart.data.InterestRateChartData;
*/
public class RecurringDepositProductData extends DepositProductData {
private boolean interestFreePeriodApplicable;
private Integer interestFreeFromPeriod;
private Integer interestFreeToPeriod;
protected EnumOptionData interestFreePeriodFrequencyType;
private boolean preClosurePenalApplicable;
private BigDecimal preClosurePenalInterest;
private EnumOptionData preClosurePenalInterestOnType;
@@ -37,19 +33,15 @@ public class RecurringDepositProductData extends DepositProductData {
private EnumOptionData maxDepositTermType;
private Integer inMultiplesOfDepositTerm;
private EnumOptionData inMultiplesOfDepositTermType;
private EnumOptionData recurringDepositType;
private Integer recurringDepositFrequency;
private EnumOptionData recurringDepositFrequencyType;
private BigDecimal minDepositAmount;
private BigDecimal depositAmount;
private BigDecimal maxDepositAmount;
private boolean isMandatoryDeposit;
private boolean allowWithdrawal;
private boolean adjustAdvanceTowardsFuturePayments;
private Collection<EnumOptionData> interestFreePeriodTypeOptions;
private Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions;
private Collection<EnumOptionData> recurringDepositTypeOptions;
private Collection<EnumOptionData> recurringDepositFrequencyTypeOptions;
private Collection<EnumOptionData> depositTermTypeOptions;
private Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions;
private Collection<EnumOptionData> periodFrequencyTypeOptions;
public static RecurringDepositProductData template(final CurrencyData currency, final EnumOptionData interestCompoundingPeriodType,
final EnumOptionData interestPostingPeriodType, final EnumOptionData interestCalculationType,
@@ -62,11 +54,8 @@ public class RecurringDepositProductData extends DepositProductData {
final Collection<CodeValueData> paymentTypeOptions, final Collection<EnumOptionData> accountingRuleOptions,
final Map<String, List<GLAccountData>> accountingMappingOptions, final Collection<ChargeData> chargeOptions,
final Collection<ChargeData> penaltyOptions, final InterestRateChartData chartTemplate,
final Collection<EnumOptionData> interestFreePeriodTypes,
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions,
final Collection<EnumOptionData> recurringDepositTypeOptions,
final Collection<EnumOptionData> recurringDepositFrequencyTypeOptions, final Collection<EnumOptionData> depositTermTypeOptions,
final Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions) {
final Collection<EnumOptionData> periodFrequencyTypeOptions) {
final Long id = null;
final String name = null;
@@ -83,16 +72,12 @@ public class RecurringDepositProductData extends DepositProductData {
final Collection<ChargeToGLAccountMapper> feeToIncomeAccountMappings = null;
final Collection<ChargeToGLAccountMapper> penaltyToIncomeAccountMappings = null;
final Collection<InterestRateChartData> interestRateCharts = null;
final boolean interestFreePeriodApplicable = false;
final Integer interestFreeFromPeriod = null;
final Integer interestFreeToPeriod = null;
final EnumOptionData interestFreePeriodFrequencyType = null;
final boolean preClosurePenalApplicable = false;
final BigDecimal preClosurePenalInterest = null;
final EnumOptionData preClosurePenalInterestOnType = null;
final EnumOptionData recurringDepositType = null;
final Integer recurringDepositFrequency = null;
final EnumOptionData recurringDepositFrequencyType = null;
final boolean isMandatoryDeposit = false;
final boolean allowWithdrawal = false;
final boolean adjustAdvanceTowardsFuturePayments = false;
final Integer minDepositTerm = null;
final Integer maxDepositTerm = null;
final EnumOptionData minDepositTermType = null;
@@ -102,20 +87,17 @@ public class RecurringDepositProductData extends DepositProductData {
final BigDecimal minDepositAmount = null;
final BigDecimal depositAmount = null;
final BigDecimal maxDepositAmount = null;
return new RecurringDepositProductData(id, name, shortName, description, currency, nominalAnnualInterestRate,
interestCompoundingPeriodType, interestPostingPeriodType, interestCalculationType, interestCalculationDaysInYearType,
lockinPeriodFrequency, lockinPeriodFrequencyType, accountingRule, accountingMappings, paymentChannelToFundSourceMappings,
currencyOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions, interestCalculationTypeOptions,
interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, paymentTypeOptions,
accountingRuleOptions, accountingMappingOptions, charges, chargeOptions, penaltyOptions, feeToIncomeAccountMappings,
penaltyToIncomeAccountMappings, interestRateCharts, chartTemplate, interestFreePeriodApplicable, interestFreeFromPeriod,
interestFreeToPeriod, interestFreePeriodFrequencyType, preClosurePenalApplicable, preClosurePenalInterest,
preClosurePenalInterestOnType, interestFreePeriodTypes, preClosurePenalInterestOnTypeOptions, minDepositTerm,
maxDepositTerm, minDepositTermType, maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType, recurringDepositType,
recurringDepositFrequency, recurringDepositFrequencyType, recurringDepositTypeOptions,
recurringDepositFrequencyTypeOptions, depositTermTypeOptions, inMultiplesOfDepositTermTypeOptions,
minDepositAmount, depositAmount, maxDepositAmount);
penaltyToIncomeAccountMappings, interestRateCharts, chartTemplate, preClosurePenalApplicable, preClosurePenalInterest,
preClosurePenalInterestOnType, preClosurePenalInterestOnTypeOptions, minDepositTerm, maxDepositTerm, minDepositTermType,
maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType, isMandatoryDeposit, allowWithdrawal,
adjustAdvanceTowardsFuturePayments, periodFrequencyTypeOptions, minDepositAmount, depositAmount, maxDepositAmount);
}
public static RecurringDepositProductData withCharges(final RecurringDepositProductData existingProduct,
@@ -132,17 +114,13 @@ public class RecurringDepositProductData extends DepositProductData {
existingProduct.paymentTypeOptions, existingProduct.accountingRuleOptions, existingProduct.accountingMappingOptions,
charges, existingProduct.chargeOptions, existingProduct.penaltyOptions, existingProduct.feeToIncomeAccountMappings,
existingProduct.penaltyToIncomeAccountMappings, existingProduct.interestRateCharts, existingProduct.chartTemplate,
existingProduct.interestFreePeriodApplicable, existingProduct.interestFreeFromPeriod, existingProduct.interestFreeToPeriod,
existingProduct.interestFreePeriodFrequencyType, existingProduct.preClosurePenalApplicable,
existingProduct.preClosurePenalInterest, existingProduct.preClosurePenalInterestOnType,
existingProduct.interestFreePeriodTypeOptions, existingProduct.preClosurePenalInterestOnTypeOptions,
existingProduct.preClosurePenalApplicable, existingProduct.preClosurePenalInterest,
existingProduct.preClosurePenalInterestOnType, existingProduct.preClosurePenalInterestOnTypeOptions,
existingProduct.minDepositTerm, existingProduct.maxDepositTerm, existingProduct.minDepositTermType,
existingProduct.maxDepositTermType, existingProduct.inMultiplesOfDepositTerm, existingProduct.inMultiplesOfDepositTermType,
existingProduct.recurringDepositType, existingProduct.recurringDepositFrequency,
existingProduct.recurringDepositFrequencyType, existingProduct.recurringDepositTypeOptions,
existingProduct.recurringDepositFrequencyTypeOptions, existingProduct.depositTermTypeOptions,
existingProduct.inMultiplesOfDepositTermTypeOptions, existingProduct.minDepositAmount,
existingProduct.depositAmount, existingProduct.maxDepositAmount);
existingProduct.isMandatoryDeposit, existingProduct.allowWithdrawal, existingProduct.adjustAdvanceTowardsFuturePayments,
existingProduct.periodFrequencyTypeOptions, existingProduct.minDepositAmount, existingProduct.depositAmount,
existingProduct.maxDepositAmount);
}
/**
@@ -159,11 +137,8 @@ public class RecurringDepositProductData extends DepositProductData {
final Collection<CodeValueData> paymentTypeOptions, final Collection<EnumOptionData> accountingRuleOptions,
final Map<String, List<GLAccountData>> accountingMappingOptions, final Collection<ChargeData> chargeOptions,
final Collection<ChargeData> penaltyOptions, final InterestRateChartData chartTemplate,
final Collection<EnumOptionData> interestFreePeriodTypes,
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions,
final Collection<EnumOptionData> recurringDepositTypeOptions,
final Collection<EnumOptionData> recurringDepositFrequencyTypeOptions, final Collection<EnumOptionData> depositTermTypeOptions,
final Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions) {
final Collection<EnumOptionData> periodFrequencyTypeOptions) {
return new RecurringDepositProductData(existingProduct.id, existingProduct.name, existingProduct.shortName,
existingProduct.description, existingProduct.currency, existingProduct.nominalAnnualInterestRate,
@@ -175,16 +150,14 @@ public class RecurringDepositProductData extends DepositProductData {
interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, paymentTypeOptions,
accountingRuleOptions, accountingMappingOptions, existingProduct.charges, chargeOptions, penaltyOptions,
existingProduct.feeToIncomeAccountMappings, existingProduct.penaltyToIncomeAccountMappings,
existingProduct.interestRateCharts, chartTemplate, existingProduct.interestFreePeriodApplicable,
existingProduct.interestFreeFromPeriod, existingProduct.interestFreeToPeriod,
existingProduct.interestFreePeriodFrequencyType, existingProduct.preClosurePenalApplicable,
existingProduct.preClosurePenalInterest, existingProduct.preClosurePenalInterestOnType, interestFreePeriodTypes,
existingProduct.interestRateCharts, chartTemplate, existingProduct.preClosurePenalApplicable,
existingProduct.preClosurePenalInterest, existingProduct.preClosurePenalInterestOnType,
preClosurePenalInterestOnTypeOptions, existingProduct.minDepositTerm, existingProduct.maxDepositTerm,
existingProduct.minDepositTermType, existingProduct.maxDepositTermType, existingProduct.inMultiplesOfDepositTerm,
existingProduct.inMultiplesOfDepositTermType, existingProduct.recurringDepositType,
existingProduct.recurringDepositFrequency, existingProduct.recurringDepositFrequencyType, recurringDepositTypeOptions,
recurringDepositFrequencyTypeOptions, depositTermTypeOptions, inMultiplesOfDepositTermTypeOptions, existingProduct.minDepositAmount,
existingProduct.inMultiplesOfDepositTermType, existingProduct.isMandatoryDeposit, existingProduct.allowWithdrawal,
existingProduct.adjustAdvanceTowardsFuturePayments, periodFrequencyTypeOptions, existingProduct.minDepositAmount,
existingProduct.depositAmount, existingProduct.maxDepositAmount);
}
public static RecurringDepositProductData withAccountingDetails(final RecurringDepositProductData existingProduct,
@@ -216,28 +189,21 @@ public class RecurringDepositProductData extends DepositProductData {
lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, paymentTypeOptions, accountingRuleOptions,
accountingMappingOptions, existingProduct.charges, chargeOptions, penaltyOptions, feeToIncomeAccountMappings,
penaltyToIncomeAccountMappings, existingProduct.interestRateCharts, existingProduct.chartTemplate,
existingProduct.interestFreePeriodApplicable, existingProduct.interestFreeFromPeriod, existingProduct.interestFreeToPeriod,
existingProduct.interestFreePeriodFrequencyType, existingProduct.preClosurePenalApplicable,
existingProduct.preClosurePenalInterest, existingProduct.preClosurePenalInterestOnType,
existingProduct.interestFreePeriodTypeOptions, existingProduct.preClosurePenalInterestOnTypeOptions,
existingProduct.preClosurePenalApplicable, existingProduct.preClosurePenalInterest,
existingProduct.preClosurePenalInterestOnType, existingProduct.preClosurePenalInterestOnTypeOptions,
existingProduct.minDepositTerm, existingProduct.maxDepositTerm, existingProduct.minDepositTermType,
existingProduct.maxDepositTermType, existingProduct.inMultiplesOfDepositTerm, existingProduct.inMultiplesOfDepositTermType,
existingProduct.recurringDepositType, existingProduct.recurringDepositFrequency,
existingProduct.recurringDepositFrequencyType, existingProduct.recurringDepositTypeOptions,
existingProduct.recurringDepositFrequencyTypeOptions, existingProduct.depositTermTypeOptions,
existingProduct.inMultiplesOfDepositTermTypeOptions, existingProduct.minDepositAmount,
existingProduct.depositAmount, existingProduct.maxDepositAmount);
existingProduct.isMandatoryDeposit, existingProduct.allowWithdrawal, existingProduct.adjustAdvanceTowardsFuturePayments,
existingProduct.periodFrequencyTypeOptions, existingProduct.minDepositAmount, existingProduct.depositAmount,
existingProduct.maxDepositAmount);
}
public static RecurringDepositProductData instance(final DepositProductData depositProductData,
final boolean interestFreePeriodApplicable, final Integer interestFreeFromPeriod, final Integer interestFreeToPeriod,
final EnumOptionData interestFreePeriodFrequencyType, final boolean preClosurePenalApplicable,
final BigDecimal preClosurePenalInterest, final EnumOptionData preClosurePenalInterestOnType, final Integer minDepositTerm,
final Integer maxDepositTerm, final EnumOptionData minDepositTermType, final EnumOptionData maxDepositTermType,
final Integer inMultiplesOfDepositTerm, final EnumOptionData inMultiplesOfDepositTermType,
final EnumOptionData recurringDepositType, final Integer recurringDepositFrequency,
final EnumOptionData recurringDepositFrequencyType,
final BigDecimal minDepositAmount,final BigDecimal depositAmount,
final boolean preClosurePenalApplicable, final BigDecimal preClosurePenalInterest,
final EnumOptionData preClosurePenalInterestOnType, final Integer minDepositTerm, final Integer maxDepositTerm,
final EnumOptionData minDepositTermType, final EnumOptionData maxDepositTermType, final Integer inMultiplesOfDepositTerm,
final EnumOptionData inMultiplesOfDepositTermType, final boolean isMandatoryDeposit, boolean allowWithdrawal,
boolean adjustAdvanceTowardsFuturePayments, final BigDecimal minDepositAmount, final BigDecimal depositAmount,
final BigDecimal maxDepositAmount) {
final Map<String, Object> accountingMappings = null;
@@ -260,12 +226,8 @@ public class RecurringDepositProductData extends DepositProductData {
final Collection<ChargeToGLAccountMapper> penaltyToIncomeAccountMappings = null;
final Collection<InterestRateChartData> interestRateCharts = null;
final InterestRateChartData chartTemplate = null;
final Collection<EnumOptionData> interestFreePeriodTypes = null;
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions = null;
final Collection<EnumOptionData> recurringDepositTypeOptions = null;
final Collection<EnumOptionData> recurringDepositFrequencyTypeOptions = null;
final Collection<EnumOptionData> depositTermTypeOptions = null;
final Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions = null;
final Collection<EnumOptionData> periodFrequencyTypeOptions = null;
return new RecurringDepositProductData(depositProductData.id, depositProductData.name, depositProductData.shortName,
depositProductData.description, depositProductData.currency, depositProductData.nominalAnnualInterestRate,
@@ -276,13 +238,10 @@ public class RecurringDepositProductData extends DepositProductData {
interestPostingPeriodTypeOptions, interestCalculationTypeOptions, interestCalculationDaysInYearTypeOptions,
lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, paymentTypeOptions, accountingRuleOptions,
accountingMappingOptions, charges, chargeOptions, penaltyOptions, feeToIncomeAccountMappings,
penaltyToIncomeAccountMappings, interestRateCharts, chartTemplate, interestFreePeriodApplicable, interestFreeFromPeriod,
interestFreeToPeriod, interestFreePeriodFrequencyType, preClosurePenalApplicable, preClosurePenalInterest,
preClosurePenalInterestOnType, interestFreePeriodTypes, preClosurePenalInterestOnTypeOptions, minDepositTerm,
maxDepositTerm, minDepositTermType, maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType,
recurringDepositType, recurringDepositFrequency, recurringDepositFrequencyType, recurringDepositTypeOptions,
recurringDepositFrequencyTypeOptions, depositTermTypeOptions, inMultiplesOfDepositTermTypeOptions,
minDepositAmount, depositAmount, maxDepositAmount);
penaltyToIncomeAccountMappings, interestRateCharts, chartTemplate, preClosurePenalApplicable, preClosurePenalInterest,
preClosurePenalInterestOnType, preClosurePenalInterestOnTypeOptions, minDepositTerm, maxDepositTerm, minDepositTermType,
maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType, isMandatoryDeposit, allowWithdrawal,
adjustAdvanceTowardsFuturePayments, periodFrequencyTypeOptions, minDepositAmount, depositAmount, maxDepositAmount);
}
public static RecurringDepositProductData lookup(final Long id, final String name) {
@@ -320,28 +279,20 @@ public class RecurringDepositProductData extends DepositProductData {
final Collection<ChargeToGLAccountMapper> penaltyToIncomeAccountMappings = null;
final Collection<InterestRateChartData> interestRateCharts = null;
final InterestRateChartData chartTemplate = null;
final boolean interestFreePeriodApplicable = false;
final Integer interestFreeFromPeriod = null;
final Integer interestFreeToPeriod = null;
final EnumOptionData interestFreePeriodFrequencyType = null;
final boolean preClosurePenalApplicable = false;
final BigDecimal preClosurePenalInterest = null;
final EnumOptionData preClosurePenalInterestOnType = null;
final Collection<EnumOptionData> interestFreePeriodTypes = null;
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions = null;
final EnumOptionData recurringDepositType = null;
final Integer recurringDepositFrequency = null;
final EnumOptionData recurringDepositFrequencyType = null;
final Collection<EnumOptionData> recurringDepositTypeOptions = null;
final Collection<EnumOptionData> recurringDepositFrequencyTypeOptions = null;
final boolean isMandatoryDeposit = false;
final boolean allowWithdrawal = false;
final boolean adjustAdvanceTowardsFuturePayments = false;
final Integer minDepositTerm = null;
final Integer maxDepositTerm = null;
final EnumOptionData minDepositTermType = null;
final EnumOptionData maxDepositTermType = null;
final Integer inMultiplesOfDepositTerm = null;
final EnumOptionData inMultiplesOfDepositTermType = null;
final Collection<EnumOptionData> depositTermTypeOptions = null;
final Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions = null;
final Collection<EnumOptionData> periodFrequencyTypeOptions = null;
final BigDecimal minDepositAmount = null;
final BigDecimal depositAmount = null;
final BigDecimal maxDepositAmount = null;
@@ -352,13 +303,10 @@ public class RecurringDepositProductData extends DepositProductData {
currencyOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions, interestCalculationTypeOptions,
interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, paymentTypeOptions,
accountingRuleOptions, accountingMappingOptions, charges, chargeOptions, penaltyOptions, feeToIncomeAccountMappings,
penaltyToIncomeAccountMappings, interestRateCharts, chartTemplate, interestFreePeriodApplicable, interestFreeFromPeriod,
interestFreeToPeriod, interestFreePeriodFrequencyType, preClosurePenalApplicable, preClosurePenalInterest,
preClosurePenalInterestOnType, interestFreePeriodTypes, preClosurePenalInterestOnTypeOptions, minDepositTerm,
maxDepositTerm, minDepositTermType, maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType,
recurringDepositType, recurringDepositFrequency, recurringDepositFrequencyType, recurringDepositTypeOptions,
recurringDepositFrequencyTypeOptions, depositTermTypeOptions, inMultiplesOfDepositTermTypeOptions,
minDepositAmount, depositAmount, maxDepositAmount);
penaltyToIncomeAccountMappings, interestRateCharts, chartTemplate, preClosurePenalApplicable, preClosurePenalInterest,
preClosurePenalInterestOnType, preClosurePenalInterestOnTypeOptions, minDepositTerm, maxDepositTerm, minDepositTermType,
maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType, isMandatoryDeposit, allowWithdrawal,
adjustAdvanceTowardsFuturePayments, periodFrequencyTypeOptions, minDepositAmount, depositAmount, maxDepositAmount);
}
public static RecurringDepositProductData withInterestChart(final RecurringDepositProductData product,
@@ -373,14 +321,12 @@ public class RecurringDepositProductData extends DepositProductData {
product.withdrawalFeeTypeOptions, product.paymentTypeOptions, product.accountingRuleOptions,
product.accountingMappingOptions, product.charges, product.chargeOptions, product.penaltyOptions,
product.feeToIncomeAccountMappings, product.penaltyToIncomeAccountMappings, interestRateCharts, product.chartTemplate,
product.interestFreePeriodApplicable, product.interestFreeFromPeriod, product.interestFreeToPeriod,
product.interestFreePeriodFrequencyType, product.preClosurePenalApplicable, product.preClosurePenalInterest,
product.preClosurePenalInterestOnType, product.interestFreePeriodTypeOptions, product.preClosurePenalInterestOnTypeOptions,
product.minDepositTerm, product.maxDepositTerm, product.minDepositTermType, product.maxDepositTermType,
product.inMultiplesOfDepositTerm, product.inMultiplesOfDepositTermType, product.recurringDepositType,
product.recurringDepositFrequency, product.recurringDepositFrequencyType, product.recurringDepositTypeOptions,
product.recurringDepositFrequencyTypeOptions, product.depositTermTypeOptions, product.inMultiplesOfDepositTermTypeOptions, product.minDepositAmount,
product.depositAmount, product.maxDepositAmount);
product.preClosurePenalApplicable, product.preClosurePenalInterest, product.preClosurePenalInterestOnType,
product.preClosurePenalInterestOnTypeOptions, product.minDepositTerm, product.maxDepositTerm, product.minDepositTermType,
product.maxDepositTermType, product.inMultiplesOfDepositTerm, product.inMultiplesOfDepositTermType,
product.isMandatoryDeposit, product.allowWithdrawal, product.adjustAdvanceTowardsFuturePayments,
product.periodFrequencyTypeOptions, product.minDepositAmount, product.depositAmount, product.maxDepositAmount);
}
private RecurringDepositProductData(final Long id, final String name, final String shortName, final String description,
@@ -401,18 +347,13 @@ public class RecurringDepositProductData extends DepositProductData {
final Collection<ChargeToGLAccountMapper> feeToIncomeAccountMappings,
final Collection<ChargeToGLAccountMapper> penaltyToIncomeAccountMappings,
final Collection<InterestRateChartData> interestRateCharts, final InterestRateChartData chartTemplate,
final boolean interestFreePeriodApplicable, final Integer interestFreeFromPeriod, final Integer interestFreeToPeriod,
final EnumOptionData interestFreePeriodFrequencyType, final boolean preClosurePenalApplicable,
final BigDecimal preClosurePenalInterest, final EnumOptionData preClosurePenalInterestOnType,
final Collection<EnumOptionData> interestFreePeriodTypeOptions,
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions, final Integer minDepositTerm,
final Integer maxDepositTerm, final EnumOptionData minDepositTermType, final EnumOptionData maxDepositTermType,
final Integer inMultiplesOfDepositTerm, final EnumOptionData inMultiplesOfDepositTermType,
final EnumOptionData recurringDepositType, final Integer recurringDepositFrequency,
final EnumOptionData recurringDepositFrequencyType, final Collection<EnumOptionData> recurringDepositTypeOptions,
final Collection<EnumOptionData> recurringDepositFrequencyTypeOptions, final Collection<EnumOptionData> depositTermTypeOptions,
final Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions,final BigDecimal minDepositAmount,
final BigDecimal depositAmount, final BigDecimal maxDepositAmount) {
final boolean preClosurePenalApplicable, final BigDecimal preClosurePenalInterest,
final EnumOptionData preClosurePenalInterestOnType, final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions,
final Integer minDepositTerm, final Integer maxDepositTerm, final EnumOptionData minDepositTermType,
final EnumOptionData maxDepositTermType, final Integer inMultiplesOfDepositTerm,
final EnumOptionData inMultiplesOfDepositTermType, final boolean isMandatoryDeposit, boolean allowWithdrawal,
boolean adjustAdvanceTowardsFuturePayments, final Collection<EnumOptionData> periodFrequencyTypeOptions,
final BigDecimal minDepositAmount, final BigDecimal depositAmount, final BigDecimal maxDepositAmount) {
super(id, name, shortName, description, currency, nominalAnnualInterestRate, interestCompoundingPeriodType,
interestPostingPeriodType, interestCalculationType, interestCalculationDaysInYearType, lockinPeriodFrequency,
@@ -422,10 +363,6 @@ public class RecurringDepositProductData extends DepositProductData {
accountingRuleOptions, accountingMappingOptions, charges, chargeOptions, penaltyOptions, feeToIncomeAccountMappings,
penaltyToIncomeAccountMappings, interestRateCharts, chartTemplate);
this.interestFreePeriodApplicable = interestFreePeriodApplicable;
this.interestFreeFromPeriod = interestFreeFromPeriod;
this.interestFreeToPeriod = interestFreeToPeriod;
this.interestFreePeriodFrequencyType = interestFreePeriodFrequencyType;
this.preClosurePenalApplicable = preClosurePenalApplicable;
this.preClosurePenalInterest = preClosurePenalInterest;
this.preClosurePenalInterestOnType = preClosurePenalInterestOnType;
@@ -435,21 +372,16 @@ public class RecurringDepositProductData extends DepositProductData {
this.maxDepositTermType = maxDepositTermType;
this.inMultiplesOfDepositTerm = inMultiplesOfDepositTerm;
this.inMultiplesOfDepositTermType = inMultiplesOfDepositTermType;
this.recurringDepositFrequencyType = recurringDepositFrequencyType;
this.recurringDepositFrequency = recurringDepositFrequency;
this.recurringDepositType = recurringDepositType;
this.minDepositAmount = minDepositAmount;
this.depositAmount = depositAmount;
this.maxDepositAmount = maxDepositAmount;
this.isMandatoryDeposit = isMandatoryDeposit;
this.allowWithdrawal = allowWithdrawal;
this.adjustAdvanceTowardsFuturePayments = adjustAdvanceTowardsFuturePayments;
// template data
this.interestFreePeriodTypeOptions = interestFreePeriodTypeOptions;
this.preClosurePenalInterestOnTypeOptions = preClosurePenalInterestOnTypeOptions;
this.recurringDepositTypeOptions = recurringDepositTypeOptions;
this.recurringDepositFrequencyTypeOptions = recurringDepositFrequencyTypeOptions;
this.depositTermTypeOptions = depositTermTypeOptions;
this.inMultiplesOfDepositTermTypeOptions = inMultiplesOfDepositTermTypeOptions;
this.periodFrequencyTypeOptions = periodFrequencyTypeOptions;
}
}
@@ -14,6 +14,7 @@ public class SavingsAccountTransactionDTO {
private final BigDecimal transactionAmount;
private final PaymentDetail paymentDetail;
private final Date createdDate;
private final Long savingsAccountId;
public SavingsAccountTransactionDTO(final DateTimeFormatter formatter, final LocalDate transactionDate,
final BigDecimal transactionAmount, final PaymentDetail paymentDetail, final Date createdDate) {
@@ -22,7 +23,28 @@ public class SavingsAccountTransactionDTO {
this.transactionAmount = transactionAmount;
this.paymentDetail = paymentDetail;
this.createdDate = createdDate;
this.savingsAccountId = null;
}
/** This constructor is used for bulk deposit transactions
* @param formatter
* @param transactionDate
* @param transactionAmount
* @param paymentDetail
* @param createdDate
* @param savingsAccountId
*/
public SavingsAccountTransactionDTO(DateTimeFormatter formatter, LocalDate transactionDate, BigDecimal transactionAmount,
PaymentDetail paymentDetail, Date createdDate, Long savingsAccountId) {
this.formatter = formatter;
this.transactionDate = transactionDate;
this.transactionAmount = transactionAmount;
this.paymentDetail = paymentDetail;
this.createdDate = createdDate;
this.savingsAccountId = savingsAccountId;
}
public DateTimeFormatter getFormatter() {
return this.formatter;
@@ -43,4 +65,9 @@ public class SavingsAccountTransactionDTO {
public Date getCreatedDate() {
return this.createdDate;
}
public Long getSavingsAccountId() {
return this.savingsAccountId;
}
}
@@ -330,4 +330,15 @@ public class SavingsProductData {
public int accountingRuleTypeId() {
return this.accountingRule.getId().intValue();
}
@Override
public boolean equals(final Object obj) {
final SavingsProductData productData = (SavingsProductData) obj;
return productData.id.compareTo(this.id) == 0;
}
@Override
public int hashCode() {
return this.id.hashCode();
}
}
@@ -5,15 +5,20 @@
*/
package org.mifosplatform.portfolio.savings.domain;
import static org.mifosplatform.portfolio.collectionsheet.CollectionSheetConstants.bulkSavingsDueTransactionsParamName;
import static org.mifosplatform.portfolio.collectionsheet.CollectionSheetConstants.savingsIdParamName;
import static org.mifosplatform.portfolio.collectionsheet.CollectionSheetConstants.transactionAmountParamName;
import static org.mifosplatform.portfolio.collectionsheet.CollectionSheetConstants.transactionDateParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.adjustAdvanceTowardsFuturePaymentsParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.allowWithdrawalParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.chartIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.depositAmountParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.depositPeriodFrequencyIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.depositPeriodParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.expectedFirstDepositOnDateParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.recurringDepositAmountParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.recurringDepositFrequencyParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.recurringDepositFrequencyTypeIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.recurringDepositTypeIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.isCalendarInheritedParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.isMandatoryDepositParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.mandatoryRecommendedDepositAmountParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.transferInterestToSavingsParamName;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.accountNoParamName;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.clientIdParamName;
@@ -33,10 +38,19 @@ import static org.mifosplatform.portfolio.savings.SavingsApiConstants.submittedO
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.withdrawalFeeForTransfersParamName;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.Locale;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.joda.time.LocalDate;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.mifosplatform.infrastructure.configuration.domain.ConfigurationDomainService;
import org.mifosplatform.infrastructure.core.api.JsonCommand;
import org.mifosplatform.infrastructure.core.exception.InvalidJsonException;
import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper;
import org.mifosplatform.infrastructure.core.service.DateUtils;
import org.mifosplatform.organisation.staff.domain.Staff;
@@ -52,14 +66,15 @@ import org.mifosplatform.portfolio.group.exception.CenterNotActiveException;
import org.mifosplatform.portfolio.group.exception.ClientNotInGroupException;
import org.mifosplatform.portfolio.group.exception.GroupNotActiveException;
import org.mifosplatform.portfolio.interestratechart.domain.InterestRateChart;
import org.mifosplatform.portfolio.paymentdetail.domain.PaymentDetail;
import org.mifosplatform.portfolio.savings.DepositAccountOnClosureType;
import org.mifosplatform.portfolio.savings.DepositAccountType;
import org.mifosplatform.portfolio.savings.RecurringDepositType;
import org.mifosplatform.portfolio.savings.SavingsCompoundingInterestPeriodType;
import org.mifosplatform.portfolio.savings.SavingsInterestCalculationDaysInYearType;
import org.mifosplatform.portfolio.savings.SavingsInterestCalculationType;
import org.mifosplatform.portfolio.savings.SavingsPeriodFrequencyType;
import org.mifosplatform.portfolio.savings.SavingsPostingInterestPeriodType;
import org.mifosplatform.portfolio.savings.data.SavingsAccountTransactionDTO;
import org.mifosplatform.portfolio.savings.exception.FixedDepositProductNotFoundException;
import org.mifosplatform.portfolio.savings.exception.RecurringDepositProductNotFoundException;
import org.mifosplatform.portfolio.savings.exception.SavingsProductNotFoundException;
@@ -67,7 +82,9 @@ import org.mifosplatform.useradministration.domain.AppUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
@Service
public class DepositAccountAssembler {
@@ -83,6 +100,7 @@ public class DepositAccountAssembler {
private final SavingsAccountChargeAssembler savingsAccountChargeAssembler;
private final FromJsonHelper fromApiJsonHelper;
private final DepositProductAssembler depositProductAssembler;
private final ConfigurationDomainService configurationDomainService;
@Autowired
public DepositAccountAssembler(final SavingsAccountTransactionSummaryWrapper savingsAccountTransactionSummaryWrapper,
@@ -92,7 +110,9 @@ public class DepositAccountAssembler {
final SavingsAccountChargeAssembler savingsAccountChargeAssembler, final FromJsonHelper fromApiJsonHelper,
final DepositProductAssembler depositProductAssembler,
final RecurringDepositProductRepository recurringDepositProductRepository,
final AccountTransfersReadPlatformService accountTransfersReadPlatformService) {
final AccountTransfersReadPlatformService accountTransfersReadPlatformService,
final ConfigurationDomainService configurationDomainService) {
this.savingsAccountTransactionSummaryWrapper = savingsAccountTransactionSummaryWrapper;
this.clientRepository = clientRepository;
this.groupRepository = groupRepository;
@@ -104,6 +124,7 @@ public class DepositAccountAssembler {
this.depositProductAssembler = depositProductAssembler;
this.recurringDepositProductRepository = recurringDepositProductRepository;
this.savingsHelper = new SavingsHelper(accountTransfersReadPlatformService);
this.configurationDomainService = configurationDomainService;
}
/**
@@ -246,7 +267,9 @@ public class DepositAccountAssembler {
productChart = product.applicableChart(submittedOnDate);
}
accountChart = DepositAccountInterestRateChart.from(productChart);
if (productChart != null) {
accountChart = DepositAccountInterestRateChart.from(productChart);
}
SavingsAccount account = null;
if (depositAccountType.isFixedDeposit()) {
@@ -287,6 +310,7 @@ public class DepositAccountAssembler {
if (account != null) {
account.setHelpers(this.savingsAccountTransactionSummaryWrapper, this.savingsHelper);
account.validateNewApplicationState(DateUtils.getLocalDateOfTenant(), depositAccountType.resourceName());
updateIncentiveAttributes(account.getClient(), account.accountSubmittedOrActivationDate());
}
return account;
@@ -295,10 +319,17 @@ public class DepositAccountAssembler {
public SavingsAccount assembleFrom(final Long savingsId, DepositAccountType depositAccountType) {
final SavingsAccount account = this.savingsAccountRepository.findOneWithNotFoundDetection(savingsId, depositAccountType);
account.setHelpers(this.savingsAccountTransactionSummaryWrapper, this.savingsHelper);
updateIncentiveAttributes(account.getClient(), account.accountSubmittedOrActivationDate());
return account;
}
private void updateIncentiveAttributes(final Client client, final LocalDate compareOnDate) {
if (client == null) return;
final Long ageLimitForSeniorCitizen = this.configurationDomainService.ageLimitForSeniorCitizen();
final Long ageLimitForChildren = this.configurationDomainService.ageLimitForChildren();
client.updateIncentiveAttributes(ageLimitForChildren, ageLimitForSeniorCitizen, compareOnDate);
}
public void assignSavingAccountHelpers(final SavingsAccount savingsAccount) {
savingsAccount.setHelpers(this.savingsAccountTransactionSummaryWrapper, this.savingsHelper);
}
@@ -334,44 +365,71 @@ public class DepositAccountAssembler {
public DepositAccountRecurringDetail assembleAccountRecurringDetail(final JsonCommand command,
final DepositRecurringDetail prodRecurringDetail) {
RecurringDepositType recurringDepositType = null;
Integer recurringDepositTypeValue = null;
final BigDecimal recurringDepositAmount = command.bigDecimalValueOfParameterNamed(mandatoryRecommendedDepositAmountParamName);
boolean isMandatoryDeposit;
boolean allowWithdrawal;
boolean adjustAdvanceTowardsFuturePayments;
boolean isCalendarInherited;
final BigDecimal recurringDepositAmount = command.bigDecimalValueOfParameterNamed(recurringDepositAmountParamName);
if (command.parameterExists(recurringDepositTypeIdParamName)) {
recurringDepositTypeValue = command.integerValueOfParameterNamed(recurringDepositTypeIdParamName);
if (command.parameterExists(isMandatoryDepositParamName)) {
isMandatoryDeposit = command.booleanObjectValueOfParameterNamed(isMandatoryDepositParamName);
} else {
recurringDepositTypeValue = prodRecurringDetail.recurringDepositType();
isMandatoryDeposit = prodRecurringDetail.isMandatoryDeposit();
}
if (recurringDepositTypeValue != null) {
recurringDepositType = RecurringDepositType.fromInt(recurringDepositTypeValue);
}
SavingsPeriodFrequencyType recurringDepositFrequencyType = null;
Integer recurringDepositFrequencyTypeValue = null;
if (command.parameterExists(recurringDepositFrequencyTypeIdParamName)) {
recurringDepositFrequencyTypeValue = command.integerValueOfParameterNamed(recurringDepositFrequencyTypeIdParamName);
if (command.parameterExists(allowWithdrawalParamName)) {
allowWithdrawal = command.booleanObjectValueOfParameterNamed(allowWithdrawalParamName);
} else {
recurringDepositFrequencyTypeValue = prodRecurringDetail.recurringDepositFrequencyTypeId();
allowWithdrawal = prodRecurringDetail.allowWithdrawal();
}
if (recurringDepositFrequencyTypeValue != null) {
recurringDepositFrequencyType = SavingsPeriodFrequencyType.fromInt(recurringDepositFrequencyTypeValue);
}
Integer recurringDepositFrequency = null;
if (command.parameterExists(recurringDepositFrequencyTypeIdParamName)) {
recurringDepositFrequency = command.integerValueOfParameterNamed(recurringDepositFrequencyParamName);
if (command.parameterExists(adjustAdvanceTowardsFuturePaymentsParamName)) {
adjustAdvanceTowardsFuturePayments = command.booleanObjectValueOfParameterNamed(adjustAdvanceTowardsFuturePaymentsParamName);
} else {
recurringDepositFrequency = prodRecurringDetail.recurringDepositFrequency();
adjustAdvanceTowardsFuturePayments = prodRecurringDetail.adjustAdvanceTowardsFuturePayments();
}
final DepositRecurringDetail depositRecurringDetail = DepositRecurringDetail.createFrom(recurringDepositType,
recurringDepositFrequency, recurringDepositFrequencyType);
if (command.parameterExists(isCalendarInheritedParamName)) {
isCalendarInherited = command.booleanObjectValueOfParameterNamed(isCalendarInheritedParamName);
} else {
isCalendarInherited = false;
}
final DepositRecurringDetail depositRecurringDetail = DepositRecurringDetail.createFrom(isMandatoryDeposit, allowWithdrawal,
adjustAdvanceTowardsFuturePayments);
final DepositAccountRecurringDetail depositAccountRecurringDetail = DepositAccountRecurringDetail.createNew(recurringDepositAmount,
depositRecurringDetail, null);
depositRecurringDetail, null, isCalendarInherited);
return depositAccountRecurringDetail;
}
public Collection<SavingsAccountTransactionDTO> assembleBulkMandatorySavingsAccountTransactionDTOs(final JsonCommand command){
final String json = command.json();
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
final JsonElement element = this.fromApiJsonHelper.parse(json);
final Collection<SavingsAccountTransactionDTO> savingsAccountTransactions = new ArrayList<SavingsAccountTransactionDTO>();
final PaymentDetail paymentDetail = null;
final LocalDate transactionDate = this.fromApiJsonHelper.extractLocalDateNamed(transactionDateParamName, element);
final String dateFormat = this.fromApiJsonHelper.extractDateFormatParameter(element.getAsJsonObject());
final JsonObject topLevelJsonElement = element.getAsJsonObject();
final Locale locale = this.fromApiJsonHelper.extractLocaleParameter(topLevelJsonElement);
final DateTimeFormatter formatter = DateTimeFormat.forPattern(dateFormat).withLocale(locale);
if (element.isJsonObject()) {
if (topLevelJsonElement.has(bulkSavingsDueTransactionsParamName)
&& topLevelJsonElement.get(bulkSavingsDueTransactionsParamName).isJsonArray()) {
final JsonArray array = topLevelJsonElement.get(bulkSavingsDueTransactionsParamName).getAsJsonArray();
for (int i = 0; i < array.size(); i++) {
final JsonObject savingsTransactionElement = array.get(i).getAsJsonObject();
final Long savingsId = this.fromApiJsonHelper.extractLongNamed(savingsIdParamName, savingsTransactionElement);
final BigDecimal dueAmount = this.fromApiJsonHelper.extractBigDecimalNamed(transactionAmountParamName,
savingsTransactionElement, locale);
final SavingsAccountTransactionDTO savingsAccountTransactionDTO = new SavingsAccountTransactionDTO(formatter, transactionDate, dueAmount, paymentDetail, new Date(), savingsId);
savingsAccountTransactions.add(savingsAccountTransactionDTO);
}
}
}
return savingsAccountTransactions;
}
}
@@ -19,12 +19,21 @@ public interface DepositAccountDomainService {
SavingsAccountTransaction handleWithdrawal(SavingsAccount account, DateTimeFormatter fmt, LocalDate transactionDate,
BigDecimal transactionAmount, PaymentDetail paymentDetail, boolean applyWithdrawFee);
SavingsAccountTransaction handleDeposit(SavingsAccount account, DateTimeFormatter fmt, LocalDate transactionDate,
SavingsAccountTransaction handleFDDeposit(FixedDepositAccount account, DateTimeFormatter fmt, LocalDate transactionDate,
BigDecimal transactionAmount, PaymentDetail paymentDetail);
SavingsAccountTransaction handleRDDeposit(RecurringDepositAccount account, DateTimeFormatter fmt, LocalDate transactionDate,
BigDecimal transactionAmount, PaymentDetail paymentDetail);
SavingsAccountTransaction handleAccountClosure(SavingsAccount account, PaymentDetail paymentDetail, AppUser user, JsonCommand command,
Long handleFDAccountClosure(FixedDepositAccount account, PaymentDetail paymentDetail, AppUser user, JsonCommand command,
LocalDate tenantsTodayDate, Map<String, Object> changes);
SavingsAccountTransaction handleAccountPreMatureClosure(SavingsAccount account, PaymentDetail paymentDetail, AppUser user, JsonCommand command,
Long handleRDAccountClosure(RecurringDepositAccount account, PaymentDetail paymentDetail, AppUser user, JsonCommand command,
LocalDate tenantsTodayDate, Map<String, Object> changes);
Long handleFDAccountPreMatureClosure(FixedDepositAccount account, PaymentDetail paymentDetail, AppUser user, JsonCommand command,
LocalDate tenantsTodayDate, Map<String, Object> changes);
Long handleRDAccountPreMatureClosure(RecurringDepositAccount account, PaymentDetail paymentDetail, AppUser user, JsonCommand command,
LocalDate tenantsTodayDate, Map<String, Object> changes);
}
@@ -26,14 +26,15 @@ import org.mifosplatform.organisation.monetary.domain.ApplicationCurrency;
import org.mifosplatform.organisation.monetary.domain.ApplicationCurrencyRepositoryWrapper;
import org.mifosplatform.organisation.monetary.domain.MonetaryCurrency;
import org.mifosplatform.organisation.monetary.domain.Money;
import org.mifosplatform.portfolio.account.domain.AccountTransferDetailRepository;
import org.mifosplatform.portfolio.account.domain.AccountTransferDetails;
import org.mifosplatform.portfolio.account.domain.AccountTransferTransaction;
import org.mifosplatform.portfolio.account.PortfolioAccountType;
import org.mifosplatform.portfolio.account.data.AccountTransferDTO;
import org.mifosplatform.portfolio.account.domain.AccountTransferType;
import org.mifosplatform.portfolio.account.service.AccountTransfersWritePlatformService;
import org.mifosplatform.portfolio.client.domain.AccountNumberGenerator;
import org.mifosplatform.portfolio.client.domain.AccountNumberGeneratorFactory;
import org.mifosplatform.portfolio.paymentdetail.domain.PaymentDetail;
import org.mifosplatform.portfolio.savings.DepositAccountType;
import org.mifosplatform.portfolio.savings.SavingsApiConstants;
import org.mifosplatform.portfolio.savings.data.SavingsAccountTransactionDTO;
import org.mifosplatform.useradministration.domain.AppUser;
import org.springframework.beans.factory.annotation.Autowired;
@@ -48,26 +49,26 @@ public class DepositAccountDomainServiceJpa implements DepositAccountDomainServi
private final ApplicationCurrencyRepositoryWrapper applicationCurrencyRepositoryWrapper;
private final JournalEntryWritePlatformService journalEntryWritePlatformService;
private final AccountNumberGeneratorFactory accountIdentifierGeneratorFactory;
private final AccountTransferDetailRepository accountTransferDetailRepository;
private final DepositAccountAssembler depositAccountAssembler;
private final SavingsAccountDomainService savingsAccountDomainService;
private final AccountTransfersWritePlatformService accountTransfersWritePlatformService;
@Autowired
public DepositAccountDomainServiceJpa(final SavingsAccountRepositoryWrapper savingsAccountRepository,
final SavingsAccountTransactionRepository savingsAccountTransactionRepository,
final ApplicationCurrencyRepositoryWrapper applicationCurrencyRepositoryWrapper,
final JournalEntryWritePlatformService journalEntryWritePlatformService,
final AccountNumberGeneratorFactory accountIdentifierGeneratorFactory,
final AccountTransferDetailRepository accountTransferDetailRepository, final DepositAccountAssembler depositAccountAssembler,
final SavingsAccountDomainService savingsAccountDomainService) {
final AccountNumberGeneratorFactory accountIdentifierGeneratorFactory, final DepositAccountAssembler depositAccountAssembler,
final SavingsAccountDomainService savingsAccountDomainService,
final AccountTransfersWritePlatformService accountTransfersWritePlatformService) {
this.savingsAccountRepository = savingsAccountRepository;
this.savingsAccountTransactionRepository = savingsAccountTransactionRepository;
this.applicationCurrencyRepositoryWrapper = applicationCurrencyRepositoryWrapper;
this.journalEntryWritePlatformService = journalEntryWritePlatformService;
this.accountIdentifierGeneratorFactory = accountIdentifierGeneratorFactory;
this.accountTransferDetailRepository = accountTransferDetailRepository;
this.depositAccountAssembler = depositAccountAssembler;
this.savingsAccountDomainService = savingsAccountDomainService;
this.accountTransfersWritePlatformService = accountTransfersWritePlatformService;
}
@Transactional
@@ -102,12 +103,36 @@ public class DepositAccountDomainServiceJpa implements DepositAccountDomainServi
@Transactional
@Override
public SavingsAccountTransaction handleDeposit(final SavingsAccount account, final DateTimeFormatter fmt,
public SavingsAccountTransaction handleFDDeposit(final FixedDepositAccount account, final DateTimeFormatter fmt,
final LocalDate transactionDate, final BigDecimal transactionAmount, final PaymentDetail paymentDetail) {
return this.savingsAccountDomainService.handleDeposit(account, fmt, transactionDate, transactionAmount, paymentDetail);
}
@Transactional
@Override
public SavingsAccountTransaction handleRDDeposit(final RecurringDepositAccount account, final DateTimeFormatter fmt,
final LocalDate transactionDate, final BigDecimal transactionAmount, final PaymentDetail paymentDetail) {
final MathContext mc = MathContext.DECIMAL64;
final SavingsAccountTransaction deposit = this.savingsAccountDomainService.handleDeposit(account, fmt, transactionDate,
transactionAmount, paymentDetail);
account.handleScheduleInstallments(deposit);
account.updateMaturityDateAndAmount(mc);
account.updateOverduePayments(DateUtils.getLocalDateOfTenant());
return deposit;
}
@Transactional
@Override
public Long handleFDAccountClosure(final FixedDepositAccount account, final PaymentDetail paymentDetail, final AppUser user,
final JsonCommand command, final LocalDate tenantsTodayDate, final Map<String, Object> changes) {
final Set<Long> existingTransactionIds = new HashSet<Long>();
final Set<Long> existingReversedTransactionIds = new HashSet<Long>();
updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds);
/*<<<<<<< HEAD
final SavingsAccountTransactionDTO transactionDTO = new SavingsAccountTransactionDTO(fmt, transactionDate, transactionAmount,
paymentDetail, new Date());
final SavingsAccountTransaction deposit = account.deposit(transactionDTO);
@@ -119,108 +144,107 @@ public class DepositAccountDomainServiceJpa implements DepositAccountDomainServi
} else {
final LocalDate today = DateUtils.getLocalDateOfTenant();
account.calculateInterestUsing(mc, today, isInterestTransfer);
=======
*/
final MathContext mc = MathContext.DECIMAL64;
final Locale locale = command.extractLocale();
final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale);
final LocalDate closedDate = command.localDateValueOfParameterNamed(SavingsApiConstants.closedOnDateParamName);
Long savingsTransactionId = null;
account.postMaturityInterest();
if (account.isReinvestOnClosure()) {
FixedDepositAccount reinvestedDeposit = account.reInvest(account.getAccountBalance());
this.depositAccountAssembler.assignSavingAccountHelpers(reinvestedDeposit);
reinvestedDeposit.updateMaturityDateAndAmountBeforeAccountActivation(mc);
this.savingsAccountRepository.save(reinvestedDeposit);
autoGenerateAccountNumber(reinvestedDeposit);
final SavingsAccountTransaction withdrawal = this.handleWithdrawal(account, fmt, closedDate, account.getAccountBalance(),
paymentDetail, false);
savingsTransactionId = withdrawal.getId();
} else if (account.isTransferToSavingsOnClosure()) {
final Long toSavingsId = command.longValueOfParameterNamed(toSavingsAccountIdParamName);
final String transferDescription = command.stringValueOfParameterNamed(transferDescriptionParamName);
final SavingsAccount toSavingsAccount = this.depositAccountAssembler.assembleFrom(toSavingsId,
DepositAccountType.SAVINGS_DEPOSIT);
final AccountTransferDTO accountTransferDTO = new AccountTransferDTO(closedDate, account.getAccountBalance(),
PortfolioAccountType.SAVINGS, PortfolioAccountType.SAVINGS, null, null, transferDescription, locale, fmt, null, null,
null, null, null, AccountTransferType.ACCOUNT_TRANSFER.getValue(), null, null, null, null, toSavingsAccount, account);
this.accountTransfersWritePlatformService.transferFunds(accountTransferDTO);
} else {
final SavingsAccountTransaction withdrawal = this.handleWithdrawal(account, fmt, closedDate, account.getAccountBalance(),
paymentDetail, false);
savingsTransactionId = withdrawal.getId();
}
saveTransactionToGenerateTransactionId(deposit);
account.close(user, command, tenantsTodayDate, changes);
this.savingsAccountRepository.save(account);
postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds);
return deposit;
return savingsTransactionId;
}
@Transactional
@Override
public SavingsAccountTransaction handleAccountClosure(final SavingsAccount account, final PaymentDetail paymentDetail,
final AppUser user, final JsonCommand command, final LocalDate tenantsTodayDate, final Map<String, Object> changes) {
public Long handleRDAccountClosure(final RecurringDepositAccount account, final PaymentDetail paymentDetail, final AppUser user,
final JsonCommand command, final LocalDate tenantsTodayDate, final Map<String, Object> changes) {
final Set<Long> existingTransactionIds = new HashSet<Long>();
final Set<Long> existingReversedTransactionIds = new HashSet<Long>();
updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds);
final DepositAccountType depositAccountType = account.depositAccountType();
SavingsAccountTransaction withdrawal = null;
final MathContext mc = MathContext.DECIMAL64;
if (depositAccountType.isFixedDeposit()) {
final FixedDepositAccount fdAccount = (FixedDepositAccount) account;
withdrawal = fdAccount.close(user, command, tenantsTodayDate, paymentDetail, changes);
final Money transactionAmount = withdrawal.getAmount(fdAccount.getCurrency());
final LocalDate transactionDate = withdrawal.transactionLocalDate();
if (fdAccount.isReinvestOnClosure()) {
FixedDepositAccount reinvestedDeposit = fdAccount.reInvest(transactionAmount);
fdAccount.updateMaturityDateAndAmountBeforeAccountActivation(mc);
this.savingsAccountRepository.save(reinvestedDeposit);
autoGenerateAccountNumber(reinvestedDeposit);
} else if (fdAccount.isTransferToSavingsOnClosure()) {
final Locale locale = command.extractLocale();
final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale);
final Long toSavingsId = command.longValueOfParameterNamed(toSavingsAccountIdParamName);
final String transferDescription = command.stringValueOfParameterNamed(transferDescriptionParamName);
final SavingsAccount toSavingsAccount = this.depositAccountAssembler.assembleFrom(toSavingsId,
DepositAccountType.SAVINGS_DEPOSIT);
final SavingsAccountTransaction deposit = this.savingsAccountDomainService.handleDeposit(toSavingsAccount, fmt,
withdrawal.transactionLocalDate(), transactionAmount.getAmount(), null);
final Locale locale = command.extractLocale();
final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale);
final LocalDate closedDate = command.localDateValueOfParameterNamed(SavingsApiConstants.closedOnDateParamName);
Long savingsTransactionId = null;
account.postMaturityInterest();
final BigDecimal transactionAmount = account.getAccountBalance();
if (account.isReinvestOnClosure()) {
RecurringDepositAccount reinvestedDeposit = account.reInvest(transactionAmount);
depositAccountAssembler.assignSavingAccountHelpers(reinvestedDeposit);
reinvestedDeposit.updateMaturityDateAndAmount(mc);
reinvestedDeposit.processAccountUponActivation(fmt);
reinvestedDeposit.updateMaturityDateAndAmount(mc);
this.savingsAccountRepository.save(reinvestedDeposit);
final AccountTransferDetails accountTransferDetails = AccountTransferDetails.savingsToSavingsTransfer(fdAccount.office(),
fdAccount.getClient(), fdAccount, toSavingsAccount.office(), toSavingsAccount.getClient(), toSavingsAccount,
AccountTransferType.ACCOUNT_TRANSFER.getValue());
AccountTransferTransaction accountTransferTransaction = AccountTransferTransaction.savingsToSavingsTransfer(
accountTransferDetails, withdrawal, deposit, transactionDate, transactionAmount, transferDescription);
accountTransferDetails.addAccountTransferTransaction(accountTransferTransaction);
this.accountTransferDetailRepository.save(accountTransferDetails);
Money amountForDeposit = reinvestedDeposit.activateWithBalance();
if (amountForDeposit.isGreaterThanZero()) {
handleRDDeposit(reinvestedDeposit, fmt, reinvestedDeposit.getActivationLocalDate(), amountForDeposit.getAmount(),
paymentDetail);
}
} else if (depositAccountType.isRecurringDeposit()) {
final RecurringDepositAccount rdAccount = (RecurringDepositAccount) account;
withdrawal = rdAccount.close(user, command, tenantsTodayDate, paymentDetail, changes);
final Money transactionAmount = withdrawal.getAmount(rdAccount.getCurrency());
final LocalDate transactionDate = withdrawal.transactionLocalDate();
if (rdAccount.isReinvestOnClosure()) {
RecurringDepositAccount reinvestedDeposit = rdAccount.reInvest(transactionAmount);
depositAccountAssembler.assignSavingAccountHelpers(reinvestedDeposit);
final Locale locale = command.extractLocale();
final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale);
final LocalDate transactionStartDate = reinvestedDeposit.getActivationLocalDate();
final LocalDate nextTransactionStartDate = reinvestedDeposit.nextDepositDate(transactionStartDate);
reinvestedDeposit.updateMaturityDateAndAmount(mc, nextTransactionStartDate);
this.savingsAccountRepository.save(reinvestedDeposit);
Money amountForDeposit = reinvestedDeposit.activateWithBalance();
if (amountForDeposit.isGreaterThanZero()) {
handleDeposit(reinvestedDeposit, fmt, reinvestedDeposit.getActivationLocalDate(), amountForDeposit.getAmount(), null);
}
reinvestedDeposit.updateMaturityDateAndAmount(mc, nextTransactionStartDate);
reinvestedDeposit.updateMaturityDateAndAmount(mc);
this.savingsAccountRepository.save(reinvestedDeposit);
autoGenerateAccountNumber(reinvestedDeposit);
this.savingsAccountRepository.save(reinvestedDeposit);
autoGenerateAccountNumber(reinvestedDeposit);
} else if (rdAccount.isTransferToSavingsOnClosure()) {
final Locale locale = command.extractLocale();
final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale);
final Long toSavingsId = command.longValueOfParameterNamed(toSavingsAccountIdParamName);
final String transferDescription = command.stringValueOfParameterNamed(transferDescriptionParamName);
final SavingsAccount toSavingsAccount = this.depositAccountAssembler.assembleFrom(toSavingsId,
DepositAccountType.SAVINGS_DEPOSIT);
final SavingsAccountTransaction deposit = this.savingsAccountDomainService.handleDeposit(toSavingsAccount, fmt,
withdrawal.transactionLocalDate(), transactionAmount.getAmount(), null);
final SavingsAccountTransaction withdrawal = this.handleWithdrawal(account, fmt, closedDate, account.getAccountBalance(),
paymentDetail, false);
savingsTransactionId = withdrawal.getId();
final AccountTransferDetails accountTransferDetails = AccountTransferDetails.savingsToSavingsTransfer(rdAccount.office(),
rdAccount.getClient(), rdAccount, toSavingsAccount.office(), toSavingsAccount.getClient(), toSavingsAccount,
AccountTransferType.ACCOUNT_TRANSFER.getValue());
AccountTransferTransaction accountTransferTransaction = AccountTransferTransaction.savingsToSavingsTransfer(
accountTransferDetails, withdrawal, deposit, transactionDate, transactionAmount, transferDescription);
} else if (account.isTransferToSavingsOnClosure()) {
final Long toSavingsId = command.longValueOfParameterNamed(toSavingsAccountIdParamName);
final String transferDescription = command.stringValueOfParameterNamed(transferDescriptionParamName);
final SavingsAccount toSavingsAccount = this.depositAccountAssembler.assembleFrom(toSavingsId,
DepositAccountType.SAVINGS_DEPOSIT);
accountTransferDetails.addAccountTransferTransaction(accountTransferTransaction);
this.accountTransferDetailRepository.save(accountTransferDetails);
}
final AccountTransferDTO accountTransferDTO = new AccountTransferDTO(closedDate, transactionAmount,
PortfolioAccountType.SAVINGS, PortfolioAccountType.SAVINGS, null, null, transferDescription, locale, fmt, null, null,
null, null, null, AccountTransferType.ACCOUNT_TRANSFER.getValue(), null, null, null, null, toSavingsAccount, account);
this.accountTransfersWritePlatformService.transferFunds(accountTransferDTO);
} else {
final SavingsAccountTransaction withdrawal = this.handleWithdrawal(account, fmt, closedDate, account.getAccountBalance(),
paymentDetail, false);
savingsTransactionId = withdrawal.getId();
}
account.close(user, command, tenantsTodayDate, changes);
this.savingsAccountRepository.save(account);
postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds);
return withdrawal;
return savingsTransactionId;
}
private void autoGenerateAccountNumber(final SavingsAccount account) {
@@ -234,75 +258,79 @@ public class DepositAccountDomainServiceJpa implements DepositAccountDomainServi
@Transactional
@Override
public SavingsAccountTransaction handleAccountPreMatureClosure(final SavingsAccount account, final PaymentDetail paymentDetail,
public Long handleFDAccountPreMatureClosure(final FixedDepositAccount account, final PaymentDetail paymentDetail, final AppUser user,
final JsonCommand command, final LocalDate tenantsTodayDate, final Map<String, Object> changes) {
final Set<Long> existingTransactionIds = new HashSet<Long>();
final Set<Long> existingReversedTransactionIds = new HashSet<Long>();
updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds);
final LocalDate closedDate = command.localDateValueOfParameterNamed(SavingsApiConstants.closedOnDateParamName);
final Locale locale = command.extractLocale();
final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale);
Long savingsTransactionId = null;
// post interest
account.postPreMaturityInterest(closedDate);
if (account.isTransferToSavingsOnClosure()) {
final Long toSavingsId = command.longValueOfParameterNamed(toSavingsAccountIdParamName);
final String transferDescription = command.stringValueOfParameterNamed(transferDescriptionParamName);
final SavingsAccount toSavingsAccount = this.depositAccountAssembler.assembleFrom(toSavingsId,
DepositAccountType.SAVINGS_DEPOSIT);
final AccountTransferDTO accountTransferDTO = new AccountTransferDTO(closedDate, account.getAccountBalance(),
PortfolioAccountType.SAVINGS, PortfolioAccountType.SAVINGS, null, null, transferDescription, locale, fmt, null, null,
null, null, null, AccountTransferType.ACCOUNT_TRANSFER.getValue(), null, null, null, null, toSavingsAccount, account);
this.accountTransfersWritePlatformService.transferFunds(accountTransferDTO);
} else {
final SavingsAccountTransaction withdrawal = this.handleWithdrawal(account, fmt, closedDate, account.getAccountBalance(),
paymentDetail, false);
savingsTransactionId = withdrawal.getId();
}
account.prematureClosure(user, command, tenantsTodayDate, changes);
this.savingsAccountRepository.save(account);
postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds);
return savingsTransactionId;
}
@Transactional
@Override
public Long handleRDAccountPreMatureClosure(final RecurringDepositAccount account, final PaymentDetail paymentDetail,
final AppUser user, final JsonCommand command, final LocalDate tenantsTodayDate, final Map<String, Object> changes) {
final Set<Long> existingTransactionIds = new HashSet<Long>();
final Set<Long> existingReversedTransactionIds = new HashSet<Long>();
updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds);
final DepositAccountType depositAccountType = account.depositAccountType();
SavingsAccountTransaction withdrawal = null;
if (depositAccountType.isFixedDeposit()) {
final FixedDepositAccount fdAccount = (FixedDepositAccount) account;
withdrawal = fdAccount.prematureClosure(user, command, tenantsTodayDate, paymentDetail, changes);
final Money transactionAmount = withdrawal.getAmount(fdAccount.getCurrency());
final LocalDate transactionDate = withdrawal.transactionLocalDate();
if (fdAccount.isTransferToSavingsOnClosure()) {
final Locale locale = command.extractLocale();
final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale);
final Long toSavingsId = command.longValueOfParameterNamed(toSavingsAccountIdParamName);
final String transferDescription = command.stringValueOfParameterNamed(transferDescriptionParamName);
final SavingsAccount toSavingsAccount = this.depositAccountAssembler.assembleFrom(toSavingsId,
DepositAccountType.SAVINGS_DEPOSIT);
final SavingsAccountTransaction deposit = this.savingsAccountDomainService.handleDeposit(toSavingsAccount, fmt,
withdrawal.transactionLocalDate(), transactionAmount.getAmount(), null);
final LocalDate closedDate = command.localDateValueOfParameterNamed(SavingsApiConstants.closedOnDateParamName);
final Locale locale = command.extractLocale();
final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale);
Long savingsTransactionId = null;
// post interest
account.postPreMaturityInterest(closedDate);
final AccountTransferDetails accountTransferDetails = AccountTransferDetails.savingsToSavingsTransfer(fdAccount.office(),
fdAccount.getClient(), fdAccount, toSavingsAccount.office(), toSavingsAccount.getClient(), toSavingsAccount,
AccountTransferType.ACCOUNT_TRANSFER.getValue());
AccountTransferTransaction accountTransferTransaction = AccountTransferTransaction.savingsToSavingsTransfer(
accountTransferDetails, withdrawal, deposit, transactionDate, transactionAmount, transferDescription);
accountTransferDetails.addAccountTransferTransaction(accountTransferTransaction);
this.accountTransferDetailRepository.save(accountTransferDetails);
}
} else if (depositAccountType.isRecurringDeposit()) {
final RecurringDepositAccount rdAccount = (RecurringDepositAccount) account;
withdrawal = rdAccount.prematureClosure(user, command, tenantsTodayDate, paymentDetail, changes);
final Money transactionAmount = withdrawal.getAmount(rdAccount.getCurrency());
final LocalDate transactionDate = withdrawal.transactionLocalDate();
if (rdAccount.isTransferToSavingsOnClosure()) {
final Locale locale = command.extractLocale();
final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale);
final Long toSavingsId = command.longValueOfParameterNamed(toSavingsAccountIdParamName);
final String transferDescription = command.stringValueOfParameterNamed(transferDescriptionParamName);
final SavingsAccount toSavingsAccount = this.depositAccountAssembler.assembleFrom(toSavingsId,
DepositAccountType.SAVINGS_DEPOSIT);
final SavingsAccountTransaction deposit = this.savingsAccountDomainService.handleDeposit(toSavingsAccount, fmt,
transactionDate, transactionAmount.getAmount(), null);
final AccountTransferDetails accountTransferDetails = AccountTransferDetails.savingsToSavingsTransfer(rdAccount.office(),
rdAccount.getClient(), rdAccount, toSavingsAccount.office(), toSavingsAccount.getClient(), toSavingsAccount,
AccountTransferType.ACCOUNT_TRANSFER.getValue());
AccountTransferTransaction accountTransferTransaction = AccountTransferTransaction.savingsToSavingsTransfer(
accountTransferDetails, withdrawal, deposit, transactionDate, transactionAmount, transferDescription);
accountTransferDetails.addAccountTransferTransaction(accountTransferTransaction);
this.accountTransferDetailRepository.save(accountTransferDetails);
}
}
if (withdrawal != null) {
saveTransactionToGenerateTransactionId(withdrawal);
if (account.isTransferToSavingsOnClosure()) {
final Long toSavingsId = command.longValueOfParameterNamed(toSavingsAccountIdParamName);
final String transferDescription = command.stringValueOfParameterNamed(transferDescriptionParamName);
final SavingsAccount toSavingsAccount = this.depositAccountAssembler.assembleFrom(toSavingsId,
DepositAccountType.SAVINGS_DEPOSIT);
final AccountTransferDTO accountTransferDTO = new AccountTransferDTO(closedDate, account.getAccountBalance(),
PortfolioAccountType.SAVINGS, PortfolioAccountType.SAVINGS, null, null, transferDescription, locale, fmt, null, null,
null, null, null, AccountTransferType.ACCOUNT_TRANSFER.getValue(), null, null, null, null, toSavingsAccount, account);
this.accountTransfersWritePlatformService.transferFunds(accountTransferDTO);
} else {
final SavingsAccountTransaction withdrawal = this.handleWithdrawal(account, fmt, closedDate, account.getAccountBalance(),
paymentDetail, false);
savingsTransactionId = withdrawal.getId();
}
account.prematureClosure(user, command, tenantsTodayDate, changes);
this.savingsAccountRepository.save(account);
postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds);
return withdrawal;
return savingsTransactionId;
}
private Long saveTransactionToGenerateTransactionId(final SavingsAccountTransaction transaction) {
@@ -20,6 +20,7 @@ import javax.persistence.Table;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.joda.time.LocalDate;
import org.mifosplatform.portfolio.interestratechart.data.ClientIncentiveAttributes;
import org.mifosplatform.portfolio.interestratechart.domain.InterestRateChart;
import org.mifosplatform.portfolio.interestratechart.domain.InterestRateChartFields;
import org.mifosplatform.portfolio.interestratechart.domain.InterestRateChartSlab;
@@ -50,8 +51,9 @@ public class DepositAccountInterestRateChart extends AbstractPersistable<Long> {
for (InterestRateChartSlab interestRateChartSlab : chartSlabs) {
depostiChartSlabs.add(DepositAccountInterestRateChartSlabs.from(interestRateChartSlab.slabFields(), null));
}
final DepositAccountInterestRateChart depositChart = new DepositAccountInterestRateChart(productChart.chartFields(), null, depostiChartSlabs);
//update deposit account interest rate chart ference to chart Slabs
final DepositAccountInterestRateChart depositChart = new DepositAccountInterestRateChart(productChart.chartFields(), null,
depostiChartSlabs);
// update deposit account interest rate chart ference to chart Slabs
depositChart.updateChartSlabsReference();
return depositChart;
}
@@ -63,13 +65,13 @@ public class DepositAccountInterestRateChart extends AbstractPersistable<Long> {
this.chartSlabs = chartSlabs;
}
private void updateChartSlabsReference(){
private void updateChartSlabsReference() {
final Set<DepositAccountInterestRateChartSlabs> chartSlabs = setOfChartSlabs();
for (DepositAccountInterestRateChartSlabs chartSlab : chartSlabs) {
chartSlab.updateChartReference(this);
}
}
public Set<DepositAccountInterestRateChartSlabs> setOfChartSlabs() {
if (this.chartSlabs == null) {
this.chartSlabs = new HashSet<DepositAccountInterestRateChartSlabs>();
@@ -86,11 +88,6 @@ public class DepositAccountInterestRateChart extends AbstractPersistable<Long> {
return null;
}
/*private boolean removeChartSlab(DepositAccountInterestRateChartSlabs chartSlab) {
final Set<DepositAccountInterestRateChartSlabs> chartSlabs = setOfChartSlabs();
return chartSlabs.remove(chartSlab);
}*/
public LocalDate getFromDateAsLocalDate() {
return this.chartFields.getFromDateAsLocalDate();
}
@@ -107,26 +104,43 @@ public class DepositAccountInterestRateChart extends AbstractPersistable<Long> {
return this.account;
}
/*private void throwExceptionIfValidationWarningsExist(final List<ApiParameterError> dataValidationErrors) {
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
}*/
public InterestRateChartFields chartFields() {
return this.chartFields;
}
public void updateDepositAccountReference(final SavingsAccount account){
public void updateDepositAccountReference(final SavingsAccount account) {
this.account = account;
}
public BigDecimal getApplicableInterestRate(final BigDecimal depositAmount, final LocalDate periodStartDate, final LocalDate periodEndDate){
public BigDecimal getApplicableInterestRate(final BigDecimal depositAmount,
final LocalDate periodStartDate, final LocalDate periodEndDate, final ClientIncentiveAttributes incentiveAttributes) {
BigDecimal effectiveInterestRate = BigDecimal.ZERO;
for (DepositAccountInterestRateChartSlabs slab : setOfChartSlabs()) {
if(slab.slabFields().isBetweenPeriod(periodStartDate, periodEndDate) && slab.slabFields().isAmountBetween(depositAmount)){
effectiveInterestRate = slab.slabFields().annualInterestRate();
if (slab.slabFields().isBetweenPeriod(periodStartDate, periodEndDate) && slab.slabFields().isAmountBetween(depositAmount)) {
if (incentiveAttributes == null) {
effectiveInterestRate = slab.slabFields().annualInterestRate();
} else {
if (incentiveAttributes.isSeniorCitizen()) {
effectiveInterestRate = slab.slabFields().interestRateForSeniorCitizen();
}
if (incentiveAttributes.isFemale()) {
effectiveInterestRate = slab.slabFields().interestRateForFemale();
}
if (incentiveAttributes.isChild()) {
effectiveInterestRate = slab.slabFields().interestRateForChildren();
}
}
// effectiveInterestRate is zero or null then reset to default
// interest rate.
if (effectiveInterestRate == null || effectiveInterestRate.compareTo(BigDecimal.ZERO) == 0) {
effectiveInterestRate = slab.slabFields().annualInterestRate();
}
}
}
return effectiveInterestRate;
}
}
@@ -5,7 +5,7 @@
*/
package org.mifosplatform.portfolio.savings.domain;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.recurringDepositAmountParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.mandatoryRecommendedDepositAmountParamName;
import java.math.BigDecimal;
import java.util.LinkedHashMap;
@@ -19,48 +19,76 @@ import javax.persistence.OneToOne;
import javax.persistence.Table;
import org.mifosplatform.infrastructure.core.api.JsonCommand;
import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder;
import org.mifosplatform.portfolio.savings.SavingsPeriodFrequencyType;
import org.mifosplatform.organisation.monetary.domain.Money;
import org.springframework.data.jpa.domain.AbstractPersistable;
@Entity
@Table(name = "m_deposit_account_recurring_detail")
public class DepositAccountRecurringDetail extends AbstractPersistable<Long> {
@Column(name = "recurring_deposit_amount", scale = 6, precision = 19, nullable = true)
private BigDecimal recurringDepositAmount;
@Column(name = "mandatory_recommended_deposit_amount", scale = 6, precision = 19, nullable = true)
private BigDecimal mandatoryRecommendedDepositAmount;
@Column(name = "total_overdue_amount", scale = 6, precision = 19, nullable = true)
private BigDecimal totalOverdueAmount;
@Column(name = "is_calendar_inherited", nullable = false)
private boolean isCalendarInherited;
@Column(name = "no_of_overdue_installments", nullable = false)
private Integer noOfOverdueInstallments;
@Embedded
private DepositRecurringDetail recurringDetail;
@OneToOne
@JoinColumn(name = "savings_account_id", nullable = false)
private SavingsAccount account;
protected DepositAccountRecurringDetail() {
super();
/**
*
*/
public DepositAccountRecurringDetail() {
this.noOfOverdueInstallments = 0;
this.isCalendarInherited = false;
}
public static DepositAccountRecurringDetail createNew(final BigDecimal recurringDepositAmount, DepositRecurringDetail recurringDetail, SavingsAccount account) {
return new DepositAccountRecurringDetail(recurringDepositAmount, recurringDetail, account);
public static DepositAccountRecurringDetail createNew(final BigDecimal mandatoryRecommendedDepositAmount,
final DepositRecurringDetail recurringDetail, final SavingsAccount account, final boolean isCalendarInherited) {
final BigDecimal totalOverdueAmount = null;
final Integer noOfOverdueInstallments = null;
return new DepositAccountRecurringDetail(mandatoryRecommendedDepositAmount, totalOverdueAmount, noOfOverdueInstallments,
recurringDetail, account, isCalendarInherited);
}
private DepositAccountRecurringDetail(final BigDecimal recurringDepositAmount, DepositRecurringDetail recurringDetail, SavingsAccount account) {
this.recurringDepositAmount = recurringDepositAmount;
/**
* @param mandatoryRecommendedDepositAmount
* @param totalOverdueAmount
* @param noOfOverdueInstallments
* @param recurringDetail
* @param account
*/
protected DepositAccountRecurringDetail(final BigDecimal mandatoryRecommendedDepositAmount, final BigDecimal totalOverdueAmount,
final Integer noOfOverdueInstallments, final DepositRecurringDetail recurringDetail, final SavingsAccount account, final boolean isCalendarInherited) {
this.mandatoryRecommendedDepositAmount = mandatoryRecommendedDepositAmount;
this.totalOverdueAmount = totalOverdueAmount;
this.noOfOverdueInstallments = noOfOverdueInstallments;
this.recurringDetail = recurringDetail;
this.account = account;
this.isCalendarInherited = isCalendarInherited;
}
public Map<String, Object> update(final JsonCommand command, final DataValidatorBuilder baseDataValidator) {
public Map<String, Object> update(final JsonCommand command) {
final Map<String, Object> actualChanges = new LinkedHashMap<String, Object>(10);
if (command.isChangeInBigDecimalParameterNamed(recurringDepositAmountParamName, this.recurringDepositAmount)) {
final BigDecimal newValue = command.bigDecimalValueOfParameterNamed(recurringDepositAmountParamName);
actualChanges.put(recurringDepositAmountParamName, newValue);
this.recurringDepositAmount = newValue;
if (command.isChangeInBigDecimalParameterNamed(mandatoryRecommendedDepositAmountParamName, this.mandatoryRecommendedDepositAmount)) {
final BigDecimal newValue = command.bigDecimalValueOfParameterNamed(mandatoryRecommendedDepositAmountParamName);
actualChanges.put(mandatoryRecommendedDepositAmountParamName, newValue);
this.mandatoryRecommendedDepositAmount = newValue;
}
if (this.recurringDetail != null) {
actualChanges.putAll(this.recurringDetail.update(command, baseDataValidator));
actualChanges.putAll(this.recurringDetail.update(command));
}
return actualChanges;
}
@@ -72,30 +100,36 @@ public class DepositAccountRecurringDetail extends AbstractPersistable<Long> {
public void updateAccountReference(final SavingsAccount account) {
this.account = account;
}
public Integer recurringDepositType() {
return this.recurringDetail().recurringDepositType();
public boolean isMandatoryDeposit() {
return this.recurringDetail.isMandatoryDeposit();
}
public Integer recurringDepositFrequency() {
return this.recurringDetail().recurringDepositFrequency();
public boolean allowWithdrawal() {
return this.recurringDetail.allowWithdrawal();
}
public Integer recurringDepositFrequencyTypeId() {
return this.recurringDetail().recurringDepositFrequencyTypeId();
public boolean adjustAdvanceTowardsFuturePayments() {
return this.recurringDetail.adjustAdvanceTowardsFuturePayments();
}
public BigDecimal mandatoryRecommendedDepositAmount() {
return this.mandatoryRecommendedDepositAmount;
}
public boolean isCalendarInherited(){
return this.isCalendarInherited;
}
public SavingsPeriodFrequencyType recurringDepositFrequencyType() {
return SavingsPeriodFrequencyType.fromInt(this.recurringDepositFrequencyTypeId());
}
public BigDecimal recurringDepositAmount(){
return this.recurringDepositAmount;
}
public DepositAccountRecurringDetail copy(){
final BigDecimal recurringDepositAmount = this.recurringDepositAmount;
public DepositAccountRecurringDetail copy() {
final BigDecimal mandatoryRecommendedDepositAmount = this.mandatoryRecommendedDepositAmount;
final DepositRecurringDetail recurringDetail = this.recurringDetail.copy();
return DepositAccountRecurringDetail.createNew(recurringDepositAmount, recurringDetail, account);
final boolean isCalendarInherited = this.isCalendarInherited;
return DepositAccountRecurringDetail.createNew(mandatoryRecommendedDepositAmount, recurringDetail, null, isCalendarInherited);
}
public void updateOverdueDetails(final int noOfOverdueInstallments, final Money totalOverdueAmount){
this.noOfOverdueInstallments = noOfOverdueInstallments;
this.totalOverdueAmount = totalOverdueAmount.getAmount();
}
}
@@ -5,11 +5,13 @@
*/
package org.mifosplatform.portfolio.savings.domain;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.dateFormatParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.depositAmountParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.depositPeriodFrequencyIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.depositPeriodParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.expectedFirstDepositOnDateParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.transferInterestToSavingsParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.localeParamName;
import java.math.BigDecimal;
import java.util.Date;
@@ -32,9 +34,7 @@ import org.joda.time.Weeks;
import org.joda.time.Years;
import org.mifosplatform.infrastructure.core.api.JsonCommand;
import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder;
import org.mifosplatform.organisation.monetary.domain.Money;
import org.mifosplatform.portfolio.savings.DepositAccountOnClosureType;
import org.mifosplatform.portfolio.savings.SavingsApiConstants;
import org.mifosplatform.portfolio.savings.SavingsPeriodFrequencyType;
import org.mifosplatform.portfolio.savings.service.SavingsEnumerations;
import org.springframework.data.jpa.domain.AbstractPersistable;
@@ -132,13 +132,12 @@ public class DepositAccountTermAndPreClosure extends AbstractPersistable<Long> {
final String localeAsInput = command.locale();
final String dateFormat = command.dateFormat();
if (command.isChangeInLocalDateParameterNamed(expectedFirstDepositOnDateParamName, getExpectedFirstDepositOnDate())) {
if (command.isChangeInLocalDateParameterNamed(expectedFirstDepositOnDateParamName, this.getExpectedFirstDepositOnDate())) {
final LocalDate newValue = command.localDateValueOfParameterNamed(expectedFirstDepositOnDateParamName);
final String newValueAsString = command.stringValueOfParameterNamed(expectedFirstDepositOnDateParamName);
actualChanges.put(expectedFirstDepositOnDateParamName, newValueAsString);
actualChanges.put(SavingsApiConstants.localeParamName, localeAsInput);
actualChanges.put(SavingsApiConstants.dateFormatParamName, dateFormat);
actualChanges.put(localeParamName, localeAsInput);
actualChanges.put(dateFormatParamName, dateFormat);
this.expectedFirstDepositOnDate = newValue.toDate();
}
@@ -263,10 +262,10 @@ public class DepositAccountTermAndPreClosure extends AbstractPersistable<Long> {
return DepositAccountOnClosureType.fromInt(this.onAccountClosureType).isTransferToSavings();
}
public DepositAccountTermAndPreClosure deepCopy(Money depositAmount) {
public DepositAccountTermAndPreClosure copy(BigDecimal depositAmount) {
final SavingsAccount account = null;
final BigDecimal maturityAmount = null;
final BigDecimal actualDepositAmount = null;
final BigDecimal actualDepositAmount = depositAmount;
final LocalDate maturityDate = null;
final Integer depositPeriod = this.depositPeriod;
final SavingsPeriodFrequencyType depositPeriodFrequency = SavingsPeriodFrequencyType.fromInt(this.depositPeriodFrequency);
@@ -285,8 +284,15 @@ public class DepositAccountTermAndPreClosure extends AbstractPersistable<Long> {
this.expectedFirstDepositOnDate = expectedFirstDepositOnDate.toDate();
}
public boolean isTransferInterestToLinkedAccount() {
return this.transferInterestToLinkedAccount;
}
public boolean isAfterExpectedFirstDepositDate(final LocalDate compareDate) {
boolean isAfterExpectedFirstDepositDate = false;
if (this.expectedFirstDepositOnDate != null) {
isAfterExpectedFirstDepositDate = compareDate.isAfter(getExpectedFirstDepositOnDate());
}
return isAfterExpectedFirstDepositDate;
}
}
@@ -5,10 +5,6 @@
*/
package org.mifosplatform.portfolio.savings.domain;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.interestFreeFromPeriodParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.interestFreePeriodApplicableParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.interestFreePeriodFrequencyTypeIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.interestFreeToPeriodParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.preClosurePenalApplicableParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.preClosurePenalInterestOnTypeIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.preClosurePenalInterestParamName;
@@ -23,8 +19,6 @@ import javax.persistence.Embeddable;
import org.mifosplatform.infrastructure.core.api.JsonCommand;
import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder;
import org.mifosplatform.portfolio.interestratechart.InterestRateChartPeriodType;
import org.mifosplatform.portfolio.interestratechart.service.InterestRateChartEnumerations;
import org.mifosplatform.portfolio.savings.PreClosurePenalInterestOnType;
import org.mifosplatform.portfolio.savings.service.SavingsEnumerations;
@@ -36,46 +30,27 @@ import org.mifosplatform.portfolio.savings.service.SavingsEnumerations;
@Embeddable
public class DepositPreClosureDetail {
@Column(name = "interest_free_period_applicable")
private boolean interestFreePeriodApplicable;
@Column(name = "pre_closure_penal_applicable")
private boolean preClosurePenalApplicable;
@Column(name = "interest_free_from_period", nullable = true)
private Integer interestFreeFromPeriod;
@Column(name = "interest_free_to_period", nullable = true)
private Integer interestFreeToPeriod;
@Column(name = "interest_free_period_frequency_enum", nullable = true)
private Integer interestFreePeriodFrequencyType;
@Column(name = "pre_closure_penal_interest", scale = 6, precision = 19, nullable = true)
private BigDecimal preClosurePenalInterest;
@Column(name = "pre_closure_penal_interest_on_enum", nullable = true)
private Integer preClosurePenalInterestOnType;
public static DepositPreClosureDetail createFrom(final boolean interestFreePeriodApplicable, final Integer interestFreeFromPeriod,
final Integer interestFreeToPeriod, final InterestRateChartPeriodType periodType, final boolean preClosurePenalApplicable,
final BigDecimal preClosurePenalInterest, final PreClosurePenalInterestOnType preClosurePenalInterestType) {
public static DepositPreClosureDetail createFrom(final boolean preClosurePenalApplicable, final BigDecimal preClosurePenalInterest,
final PreClosurePenalInterestOnType preClosurePenalInterestType) {
return new DepositPreClosureDetail(interestFreePeriodApplicable, interestFreeFromPeriod, interestFreeToPeriod, periodType,
preClosurePenalApplicable, preClosurePenalInterest, preClosurePenalInterestType);
return new DepositPreClosureDetail(preClosurePenalApplicable, preClosurePenalInterest, preClosurePenalInterestType);
}
protected DepositPreClosureDetail() {
//
}
private DepositPreClosureDetail(final boolean interestFreePeriodApplicable, final Integer interestFreeFromPeriod,
final Integer interestFreeToPeriod, final InterestRateChartPeriodType periodType, final boolean preClosurePenalApplicable,
final BigDecimal preClosurePenalInterest, final PreClosurePenalInterestOnType preClosurePenalInterestType) {
this.interestFreePeriodApplicable = interestFreePeriodApplicable;
this.interestFreeFromPeriod = interestFreeFromPeriod;
this.interestFreeToPeriod = interestFreeToPeriod;
this.interestFreePeriodFrequencyType = (periodType == null) ? null : periodType.getValue();
private DepositPreClosureDetail(final boolean preClosurePenalApplicable, final BigDecimal preClosurePenalInterest,
final PreClosurePenalInterestOnType preClosurePenalInterestType) {
this.preClosurePenalApplicable = preClosurePenalApplicable;
this.preClosurePenalInterest = preClosurePenalInterest;
this.preClosurePenalInterestOnType = (preClosurePenalInterestType == null) ? null : preClosurePenalInterestType.getValue();
@@ -86,52 +61,6 @@ public class DepositPreClosureDetail {
final String localeAsInput = command.locale();
if (command.isChangeInBooleanParameterNamed(interestFreePeriodApplicableParamName, this.interestFreePeriodApplicable)) {
final boolean newValue = command.booleanPrimitiveValueOfParameterNamed(interestFreePeriodApplicableParamName);
actualChanges.put(interestFreePeriodApplicableParamName, newValue);
this.interestFreePeriodApplicable = newValue;
}
if (this.interestFreePeriodApplicable) {
if (command.isChangeInIntegerParameterNamed(interestFreeFromPeriodParamName, this.interestFreeFromPeriod)) {
final Integer newValue = command.integerValueOfParameterNamed(interestFreeFromPeriodParamName);
actualChanges.put(interestFreeFromPeriodParamName, newValue);
this.interestFreeFromPeriod = newValue;
}
if (command.isChangeInIntegerParameterNamed(interestFreeToPeriodParamName, this.interestFreeToPeriod)) {
final Integer newValue = command.integerValueOfParameterNamed(interestFreeToPeriodParamName);
actualChanges.put(interestFreeToPeriodParamName, newValue);
this.interestFreeToPeriod = newValue;
}
if (command.isChangeInIntegerParameterNamed(interestFreePeriodFrequencyTypeIdParamName, this.interestFreePeriodFrequencyType)) {
final Integer newValue = command.integerValueOfParameterNamed(interestFreePeriodFrequencyTypeIdParamName);
actualChanges.put(interestFreePeriodFrequencyTypeIdParamName, InterestRateChartEnumerations.periodType(newValue));
this.interestFreePeriodFrequencyType = newValue;
}
if (this.interestFreeFromPeriod == null) {
baseDataValidator.parameter(interestFreeFromPeriodParamName).value(this.interestFreeFromPeriod)
.cantBeBlankWhenParameterProvidedIs(interestFreePeriodApplicableParamName, this.interestFreePeriodApplicable);
}
if (this.interestFreeToPeriod == null) {
baseDataValidator.parameter(interestFreeToPeriodParamName).value(this.interestFreeToPeriod)
.cantBeBlankWhenParameterProvidedIs(interestFreePeriodApplicableParamName, this.interestFreePeriodApplicable);
}
if (this.interestFreePeriodFrequencyType == null) {
baseDataValidator.parameter(interestFreePeriodFrequencyTypeIdParamName).value(this.interestFreePeriodFrequencyType)
.cantBeBlankWhenParameterProvidedIs(interestFreePeriodApplicableParamName, this.interestFreePeriodApplicable);
}
} else { // reset if interest free period is not applicable
this.interestFreeFromPeriod = null;
this.interestFreeToPeriod = null;
this.interestFreePeriodFrequencyType = null;
}
if (command.isChangeInBooleanParameterNamed(preClosurePenalApplicableParamName, this.preClosurePenalApplicable)) {
final boolean newValue = command.booleanPrimitiveValueOfParameterNamed(preClosurePenalApplicableParamName);
actualChanges.put(preClosurePenalApplicableParamName, newValue);
@@ -167,44 +96,13 @@ public class DepositPreClosureDetail {
this.preClosurePenalInterestOnType = null;
}
if (isFromPeriodAfterToPeriod()) {
baseDataValidator
.parameter(interestFreeFromPeriodParamName)
.value(this.interestFreeFromPeriod)
.failWithCode("interest.free.from.period.is.greater.than.to.period", this.interestFreeFromPeriod,
this.interestFreeToPeriod);
}
return actualChanges;
}
private boolean isFromPeriodAfterToPeriod() {
if (this.interestFreePeriodApplicable && this.interestFreeFromPeriod != null && this.interestFreeToPeriod != null) {
if (this.interestFreeFromPeriod.compareTo(interestFreeToPeriod) > 0) { return true; }
}
return false;
}
public boolean interestFreePeriodApplicable() {
return this.interestFreePeriodApplicable;
}
public boolean preClosurePenalApplicable() {
return this.preClosurePenalApplicable;
}
public Integer interestFreeFromPeriod() {
return this.interestFreeFromPeriod;
}
public Integer interestFreeToPeriod() {
return this.interestFreeToPeriod;
}
public Integer interestFreePeriodFrequencyType() {
return this.interestFreePeriodFrequencyType;
}
public BigDecimal preClosurePenalInterest() {
return this.preClosurePenalInterest;
}
@@ -213,19 +111,16 @@ public class DepositPreClosureDetail {
return this.preClosurePenalInterestOnType;
}
public PreClosurePenalInterestOnType preClosurePenalInterestOnType(){
public PreClosurePenalInterestOnType preClosurePenalInterestOnType() {
return PreClosurePenalInterestOnType.fromInt(preClosurePenalInterestOnType);
}
public DepositPreClosureDetail copy(){
final boolean interestFreePeriodApplicable = this.interestFreePeriodApplicable;
final Integer interestFreeFromPeriod = this.interestFreeFromPeriod;
final Integer interestFreeToPeriod = this.interestFreeToPeriod;
public DepositPreClosureDetail copy() {
final boolean preClosurePenalApplicable = this.preClosurePenalApplicable;
final BigDecimal preClosurePenalInterest = this.preClosurePenalInterest;
final InterestRateChartPeriodType periodType = InterestRateChartPeriodType.fromInt(this.interestFreePeriodFrequencyType);
final PreClosurePenalInterestOnType preClosurePenalInterestType = PreClosurePenalInterestOnType.fromInt(this.preClosurePenalInterestOnType);
return DepositPreClosureDetail.createFrom(interestFreePeriodApplicable, interestFreeFromPeriod, interestFreeToPeriod, periodType, preClosurePenalApplicable, preClosurePenalInterest, preClosurePenalInterestType);
final PreClosurePenalInterestOnType preClosurePenalInterestType = PreClosurePenalInterestOnType
.fromInt(this.preClosurePenalInterestOnType);
return DepositPreClosureDetail.createFrom(preClosurePenalApplicable, preClosurePenalInterest, preClosurePenalInterestType);
}
}
@@ -13,7 +13,6 @@ import javax.persistence.Column;
import javax.persistence.Embeddable;
import org.mifosplatform.infrastructure.core.api.JsonCommand;
import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder;
/**
* RecurringDepositProductAmountDetails encapsulates all recurring Deposit
@@ -47,7 +46,7 @@ public class DepositProductAmountDetails {
this.maxDepositAmount = maxDepositAmount;
}
public Map<String, Object> update(final JsonCommand command, final DataValidatorBuilder baseDataValidator) {
public Map<String, Object> update(final JsonCommand command) {
final Map<String, Object> actualChanges = new LinkedHashMap<String, Object>(20);
@@ -5,15 +5,15 @@
*/
package org.mifosplatform.portfolio.savings.domain;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.FIXED_DEPOSIT_PRODUCT_RESOURCE_NAME;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.RECURRING_DEPOSIT_PRODUCT_RESOURCE_NAME;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.adjustAdvanceTowardsFuturePaymentsParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.allowWithdrawalParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.chartsParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.depositAmountParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.depositMaxAmountParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.depositMinAmountParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.inMultiplesOfDepositTermParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.inMultiplesOfDepositTermTypeIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.interestFreeFromPeriodParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.interestFreePeriodApplicableParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.interestFreePeriodFrequencyTypeIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.interestFreeToPeriodParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.isMandatoryDepositParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.maxDepositTermParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.maxDepositTermTypeIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.minDepositTermParamName;
@@ -21,12 +21,6 @@ import static org.mifosplatform.portfolio.savings.DepositsApiConstants.minDeposi
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.preClosurePenalApplicableParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.preClosurePenalInterestOnTypeIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.preClosurePenalInterestParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.recurringDepositFrequencyParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.recurringDepositFrequencyTypeIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.recurringDepositTypeIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.depositAmountParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.depositMinAmountParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.depositMaxAmountParamName;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.chargesParamName;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.currencyCodeParamName;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.descriptionParamName;
@@ -44,38 +38,31 @@ import static org.mifosplatform.portfolio.savings.SavingsApiConstants.nominalAnn
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.shortNameParamName;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.mifosplatform.accounting.common.AccountingRuleType;
import org.mifosplatform.infrastructure.core.api.JsonCommand;
import org.mifosplatform.infrastructure.core.data.ApiParameterError;
import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder;
import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException;
import org.mifosplatform.organisation.monetary.domain.MonetaryCurrency;
import org.mifosplatform.portfolio.charge.domain.Charge;
import org.mifosplatform.portfolio.charge.domain.ChargeRepositoryWrapper;
import org.mifosplatform.portfolio.charge.exception.ChargeCannotBeAppliedToException;
import org.mifosplatform.portfolio.interestratechart.InterestRateChartPeriodType;
import org.mifosplatform.portfolio.interestratechart.domain.InterestRateChart;
import org.mifosplatform.portfolio.interestratechart.service.InterestRateChartAssembler;
import org.mifosplatform.portfolio.loanproduct.exception.InvalidCurrencyException;
import org.mifosplatform.portfolio.savings.PreClosurePenalInterestOnType;
import org.mifosplatform.portfolio.savings.RecurringDepositType;
import org.mifosplatform.portfolio.savings.SavingsCompoundingInterestPeriodType;
import org.mifosplatform.portfolio.savings.SavingsInterestCalculationDaysInYearType;
import org.mifosplatform.portfolio.savings.SavingsInterestCalculationType;
import org.mifosplatform.portfolio.savings.SavingsPeriodFrequencyType;
import org.mifosplatform.portfolio.savings.SavingsPostingInterestPeriodType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
@Component
@Service
public class DepositProductAssembler {
private final ChargeRepositoryWrapper chargeRepository;
@@ -131,7 +118,7 @@ public class DepositProductAssembler {
if (lockinPeriodFrequencyTypeValue != null) {
lockinPeriodFrequencyType = SavingsPeriodFrequencyType.fromInt(lockinPeriodFrequencyTypeValue);
}
final AccountingRuleType accountingRuleType = AccountingRuleType.fromInt(command.integerValueOfParameterNamed("accountingRule"));
final DepositPreClosureDetail preClosureDetail = this.assemblePreClosureDetail(command);
@@ -154,27 +141,11 @@ public class DepositProductAssembler {
// update product reference
productTermAndPreClosure.updateProductReference(fixedDepositProduct);
validateFixedDepositProductDomainRules(fixedDepositProduct);
fixedDepositProduct.validateDomainRules();
return fixedDepositProduct;
}
private void validateFixedDepositProductDomainRules(FixedDepositProduct fixedDepositProduct) {
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
.resource(FIXED_DEPOSIT_PRODUCT_RESOURCE_NAME);
final DepositTermDetail termDetails = fixedDepositProduct.depositProductTermAndPreClosure().depositTermDetail();
final boolean isMinTermGreaterThanMax = termDetails.isMinDepositTermGreaterThanMaxDepositTerm();
if (isMinTermGreaterThanMax) {
final Integer maxTerm = termDetails.maxDepositTerm();
baseDataValidator.reset().parameter(maxDepositTermParamName).value(maxTerm)
.failWithCodeNoParameterAddedToErrorCode("max.term.lessthan.min.term");
}
fixedDepositProduct.validateCharts(baseDataValidator);
fixedDepositProduct.validateInterestPostingAndCompoundingPeriodTypes(baseDataValidator);
throwExceptionIfValidationWarningsExist(dataValidationErrors);
}
public RecurringDepositProduct assembleRecurringDepositProduct(final JsonCommand command) {
final String name = command.stringValueOfParameterNamed(nameParamName);
@@ -212,14 +183,14 @@ public class DepositProductAssembler {
if (interestCalculationDaysInYearTypeValue != null) {
interestCalculationDaysInYearType = SavingsInterestCalculationDaysInYearType.fromInt(interestCalculationDaysInYearTypeValue);
}
final Integer lockinPeriodFrequency = command.integerValueOfParameterNamedDefaultToNullIfZero(lockinPeriodFrequencyParamName);
SavingsPeriodFrequencyType lockinPeriodFrequencyType = null;
final Integer lockinPeriodFrequencyTypeValue = command.integerValueOfParameterNamed(lockinPeriodFrequencyTypeParamName);
if (lockinPeriodFrequencyTypeValue != null) {
lockinPeriodFrequencyType = SavingsPeriodFrequencyType.fromInt(lockinPeriodFrequencyTypeValue);
}
final AccountingRuleType accountingRuleType = AccountingRuleType.fromInt(command.integerValueOfParameterNamed("accountingRule"));
final DepositPreClosureDetail preClosureDetail = this.assemblePreClosureDetail(command);
@@ -248,46 +219,13 @@ public class DepositProductAssembler {
productTermAndPreClosure.updateProductReference(recurringDepositProduct);
productRecurringDetail.updateProductReference(recurringDepositProduct);
validateRecurringDepositProductDomainRules(recurringDepositProduct);
recurringDepositProduct.validateDomainRules();
return recurringDepositProduct;
}
private void validateRecurringDepositProductDomainRules(RecurringDepositProduct recurringDepositProduct) {
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
.resource(RECURRING_DEPOSIT_PRODUCT_RESOURCE_NAME);
final DepositTermDetail termDetails = recurringDepositProduct.depositProductTermAndPreClosure().depositTermDetail();
final boolean isMinTermGreaterThanMax = termDetails.isMinDepositTermGreaterThanMaxDepositTerm();
if (isMinTermGreaterThanMax) {
final Integer maxTerm = termDetails.maxDepositTerm();
baseDataValidator.reset().parameter(maxDepositTermParamName).value(maxTerm)
.failWithCodeNoParameterAddedToErrorCode("max.term.lessthan.min.term");
}
recurringDepositProduct.validateCharts(baseDataValidator);
recurringDepositProduct.validateInterestPostingAndCompoundingPeriodTypes(baseDataValidator);
throwExceptionIfValidationWarningsExist(dataValidationErrors);
}
public DepositPreClosureDetail assemblePreClosureDetail(final JsonCommand command) {
boolean interestFreePeriodApplicable = false;
Integer interestFreeFromPeriod = null;
Integer interestFreeToPeriod = null;
InterestRateChartPeriodType interestFreePeriodFrequencyType = null;
if (command.parameterExists(interestFreePeriodApplicableParamName)) {
interestFreePeriodApplicable = command.booleanObjectValueOfParameterNamed(interestFreePeriodApplicableParamName);
if (interestFreePeriodApplicable) {
interestFreeFromPeriod = command.integerValueOfParameterNamed(interestFreeFromPeriodParamName);
interestFreeToPeriod = command.integerValueOfParameterNamed(interestFreeToPeriodParamName);
final Integer interestFreePreriodTypeId = command.integerValueOfParameterNamed(interestFreePeriodFrequencyTypeIdParamName);
interestFreePeriodFrequencyType = (interestFreePreriodTypeId == null) ? null : InterestRateChartPeriodType
.fromInt(interestFreePreriodTypeId);
}
}
boolean preClosurePenalApplicable = false;
BigDecimal preClosurePenalInterest = null;
PreClosurePenalInterestOnType preClosurePenalInterestType = null;
@@ -303,53 +241,13 @@ public class DepositProductAssembler {
}
}
DepositPreClosureDetail preClosureDetail = DepositPreClosureDetail.createFrom(interestFreePeriodApplicable, interestFreeFromPeriod,
interestFreeToPeriod, interestFreePeriodFrequencyType, preClosurePenalApplicable, preClosurePenalInterest,
DepositPreClosureDetail preClosureDetail = DepositPreClosureDetail.createFrom(preClosurePenalApplicable, preClosurePenalInterest,
preClosurePenalInterestType);
return preClosureDetail;
}
public DepositPreClosureDetail assemblePreClosureDetail(final JsonCommand command, DepositPreClosureDetail produPreClosureDetail) {
boolean interestFreePeriodApplicable = false;
Integer interestFreeFromPeriod = null;
Integer interestFreeToPeriod = null;
InterestRateChartPeriodType interestFreePeriodFrequencyType = null;
Integer interestFreePreriodTypeId = null;
if (command.parameterExists(interestFreePeriodApplicableParamName)) {
interestFreePeriodApplicable = command.booleanObjectValueOfParameterNamed(interestFreePeriodApplicableParamName);
if (interestFreePeriodApplicable) {
if (command.parameterExists(interestFreeFromPeriodParamName)) {
interestFreeFromPeriod = command.integerValueOfParameterNamed(interestFreeFromPeriodParamName);
} else {
interestFreeFromPeriod = produPreClosureDetail.interestFreeFromPeriod();
}
if (command.parameterExists(interestFreeToPeriodParamName)) {
interestFreeToPeriod = command.integerValueOfParameterNamed(interestFreeToPeriodParamName);
} else {
interestFreeToPeriod = produPreClosureDetail.interestFreeToPeriod();
}
if (command.parameterExists(interestFreePeriodFrequencyTypeIdParamName)) {
interestFreePreriodTypeId = command.integerValueOfParameterNamed(interestFreePeriodFrequencyTypeIdParamName);
} else {
interestFreePreriodTypeId = produPreClosureDetail.interestFreePeriodFrequencyType();
}
interestFreePeriodFrequencyType = (interestFreePreriodTypeId == null) ? null : InterestRateChartPeriodType
.fromInt(interestFreePreriodTypeId);
}
} else {
interestFreePeriodApplicable = produPreClosureDetail.interestFreePeriodApplicable();
interestFreeFromPeriod = produPreClosureDetail.interestFreeFromPeriod();
interestFreeToPeriod = produPreClosureDetail.interestFreeToPeriod();
interestFreePreriodTypeId = produPreClosureDetail.interestFreePeriodFrequencyType();
interestFreePeriodFrequencyType = (interestFreePreriodTypeId == null) ? null : InterestRateChartPeriodType
.fromInt(interestFreePreriodTypeId);
}
boolean preClosurePenalApplicable = false;
BigDecimal preClosurePenalInterest = null;
PreClosurePenalInterestOnType preClosurePenalInterestType = null;
@@ -378,9 +276,8 @@ public class DepositProductAssembler {
preClosurePenalInterestType = preClosurePenalInterestOnTypeId == null ? null : PreClosurePenalInterestOnType
.fromInt(preClosurePenalInterestOnTypeId);
DepositPreClosureDetail preClosureDetail1 = DepositPreClosureDetail.createFrom(interestFreePeriodApplicable,
interestFreeFromPeriod, interestFreeToPeriod, interestFreePeriodFrequencyType, preClosurePenalApplicable,
preClosurePenalInterest, preClosurePenalInterestType);
DepositPreClosureDetail preClosureDetail1 = DepositPreClosureDetail.createFrom(preClosurePenalApplicable, preClosurePenalInterest,
preClosurePenalInterestType);
return preClosureDetail1;
}
@@ -468,22 +365,17 @@ public class DepositProductAssembler {
public DepositRecurringDetail assembleRecurringDetail(final JsonCommand command) {
RecurringDepositType recurringDepositType = null;
final Integer recurringDepositTypeValue = command.integerValueOfParameterNamed(recurringDepositTypeIdParamName);
if (recurringDepositTypeValue != null) {
recurringDepositType = RecurringDepositType.fromInt(recurringDepositTypeValue);
}
Boolean isMandatoryDeposit = command.booleanObjectValueOfParameterNamed(isMandatoryDepositParamName);
Boolean allowWithdrawal = command.booleanObjectValueOfParameterNamed(allowWithdrawalParamName);
Boolean adjustAdvanceTowardsFuturePayments = command
.booleanObjectValueOfParameterNamed(adjustAdvanceTowardsFuturePaymentsParamName);
SavingsPeriodFrequencyType recurringDepositFrequencyType = null;
final Integer recurringDepositFrequencyTypeValue = command.integerValueOfParameterNamed(recurringDepositFrequencyTypeIdParamName);
if (recurringDepositFrequencyTypeValue != null) {
recurringDepositFrequencyType = SavingsPeriodFrequencyType.fromInt(recurringDepositFrequencyTypeValue);
}
if (isMandatoryDeposit == null) isMandatoryDeposit = false;
if (allowWithdrawal == null) allowWithdrawal = false;
if (adjustAdvanceTowardsFuturePayments == null) adjustAdvanceTowardsFuturePayments = false;
final Integer recurringDepositFrequency = command.integerValueOfParameterNamed(recurringDepositFrequencyParamName);
final DepositRecurringDetail depositRecurringDetail = DepositRecurringDetail.createFrom(recurringDepositType,
recurringDepositFrequency, recurringDepositFrequencyType);
final DepositRecurringDetail depositRecurringDetail = DepositRecurringDetail.createFrom(isMandatoryDeposit, allowWithdrawal,
adjustAdvanceTowardsFuturePayments);
return depositRecurringDetail;
}
@@ -538,29 +430,25 @@ public class DepositProductAssembler {
return charts;
}
private void throwExceptionIfValidationWarningsExist(final List<ApiParameterError> dataValidationErrors) {
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
}
public DepositProductAmountDetails assembleDepositAmountDetails(final JsonCommand command) {
BigDecimal minDepositAmount = null;
if(command.parameterExists(depositMinAmountParamName)) {
minDepositAmount = command.bigDecimalValueOfParameterNamed(depositMinAmountParamName);
if (command.parameterExists(depositMinAmountParamName)) {
minDepositAmount = command.bigDecimalValueOfParameterNamed(depositMinAmountParamName);
}
BigDecimal maxDepositAmount = null;
if(command.parameterExists(depositMaxAmountParamName)) {
maxDepositAmount = command.bigDecimalValueOfParameterNamed(depositMaxAmountParamName);
if (command.parameterExists(depositMaxAmountParamName)) {
maxDepositAmount = command.bigDecimalValueOfParameterNamed(depositMaxAmountParamName);
}
BigDecimal depositAmount = null;
if(command.parameterExists(depositAmountParamName)) {
depositAmount = command.bigDecimalValueOfParameterNamed(depositAmountParamName);
if (command.parameterExists(depositAmountParamName)) {
depositAmount = command.bigDecimalValueOfParameterNamed(depositAmountParamName);
}
final DepositProductAmountDetails depositRecurringDetail = new DepositProductAmountDetails(minDepositAmount,
depositAmount, maxDepositAmount);
final DepositProductAmountDetails depositRecurringDetail = new DepositProductAmountDetails(minDepositAmount, depositAmount,
maxDepositAmount);
return depositRecurringDetail;
}
@@ -15,7 +15,6 @@ import javax.persistence.OneToOne;
import javax.persistence.Table;
import org.mifosplatform.infrastructure.core.api.JsonCommand;
import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder;
import org.springframework.data.jpa.domain.AbstractPersistable;
@Entity
@@ -43,10 +42,10 @@ public class DepositProductRecurringDetail extends AbstractPersistable<Long> {
this.product = (RecurringDepositProduct) product;
}
public Map<String, Object> update(final JsonCommand command, final DataValidatorBuilder baseDataValidator) {
public Map<String, Object> update(final JsonCommand command) {
final Map<String, Object> actualChanges = new LinkedHashMap<String, Object>(10);
if (this.recurringDetail != null) {
actualChanges.putAll(this.recurringDetail.update(command, baseDataValidator));
actualChanges.putAll(this.recurringDetail.update(command));
}
return actualChanges;
}
@@ -65,7 +65,7 @@ public class DepositProductTermAndPreClosure extends AbstractPersistable<Long> {
}
if(this.depositProductAmountDetails != null) {
actualChanges.putAll(this.depositProductAmountDetails.update(command, baseDataValidator));
actualChanges.putAll(this.depositProductAmountDetails.update(command));
}
return actualChanges;
}
@@ -5,9 +5,9 @@
*/
package org.mifosplatform.portfolio.savings.domain;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.recurringDepositFrequencyParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.recurringDepositFrequencyTypeIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.recurringDepositTypeIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.adjustAdvanceTowardsFuturePaymentsParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.allowWithdrawalParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.isMandatoryDepositParamName;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -16,10 +16,6 @@ import javax.persistence.Column;
import javax.persistence.Embeddable;
import org.mifosplatform.infrastructure.core.api.JsonCommand;
import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder;
import org.mifosplatform.portfolio.savings.RecurringDepositType;
import org.mifosplatform.portfolio.savings.SavingsPeriodFrequencyType;
import org.mifosplatform.portfolio.savings.service.SavingsEnumerations;
/**
* DepositRecurringDetail encapsulates all the details of a
@@ -29,77 +25,68 @@ import org.mifosplatform.portfolio.savings.service.SavingsEnumerations;
@Embeddable
public class DepositRecurringDetail {
@Column(name = "recurring_deposit_type_enum", nullable = true)
private Integer recurringDepositType;
@Column(name = "is_mandatory", nullable = true)
private boolean isMandatoryDeposit;
@Column(name = "recurring_deposit_frequency", nullable = true)
private Integer recurringDepositFrequency;
@Column(name = "allow_withdrawal", nullable = true)
private boolean allowWithdrawal;
@Column(name = "recurring_deposit_frequency_type_enum", nullable = true)
private Integer recurringDepositFrequencyType;
public static DepositRecurringDetail createFrom(final RecurringDepositType recurringDepositType,
final Integer recurringDepositFrequency, final SavingsPeriodFrequencyType recurringDepositFrequencyType) {
return new DepositRecurringDetail(recurringDepositType, recurringDepositFrequency, recurringDepositFrequencyType);
}
@Column(name = "adjust_advance_towards_future_payments", nullable = true)
private boolean adjustAdvanceTowardsFuturePayments;
protected DepositRecurringDetail() {
//
}
private DepositRecurringDetail(final RecurringDepositType recurringDepositType, final Integer recurringDepositFrequency,
final SavingsPeriodFrequencyType recurringDepositFrequencyType) {
this.recurringDepositFrequency = recurringDepositFrequency;
this.recurringDepositFrequencyType = recurringDepositFrequencyType.getValue();
this.recurringDepositType = recurringDepositType.getValue();
public static DepositRecurringDetail createFrom(final boolean isMandatoryDeposit, boolean allowWithdrawal,
boolean adjustAdvanceTowardsFuturePayments) {
return new DepositRecurringDetail(isMandatoryDeposit, allowWithdrawal, adjustAdvanceTowardsFuturePayments);
}
public Map<String, Object> update(final JsonCommand command, @SuppressWarnings("unused") final DataValidatorBuilder baseDataValidator) {
private DepositRecurringDetail(final boolean isMandatoryDeposit, boolean allowWithdrawal, boolean adjustAdvanceTowardsFuturePayments) {
this.isMandatoryDeposit = isMandatoryDeposit;
this.allowWithdrawal = allowWithdrawal;
this.adjustAdvanceTowardsFuturePayments = adjustAdvanceTowardsFuturePayments;
}
public Map<String, Object> update(final JsonCommand command) {
final Map<String, Object> actualChanges = new LinkedHashMap<String, Object>(10);
if (command.isChangeInIntegerParameterNamed(recurringDepositFrequencyParamName, this.recurringDepositFrequency)) {
final Integer newValue = command.integerValueOfParameterNamed(recurringDepositFrequencyParamName);
actualChanges.put(recurringDepositFrequencyParamName, newValue);
this.recurringDepositFrequency = newValue;
if (command.isChangeInBooleanParameterNamed(isMandatoryDepositParamName, this.isMandatoryDeposit)) {
final boolean newValue = command.booleanObjectValueOfParameterNamed(isMandatoryDepositParamName);
actualChanges.put(isMandatoryDepositParamName, newValue);
this.isMandatoryDeposit = newValue;
}
if (command.isChangeInIntegerParameterNamed(recurringDepositFrequencyTypeIdParamName, this.recurringDepositFrequencyType)) {
final Integer newValue = command.integerValueOfParameterNamed(recurringDepositFrequencyTypeIdParamName);
actualChanges.put(recurringDepositFrequencyTypeIdParamName, SavingsEnumerations.recurringDepositFrequencyType(newValue));
this.recurringDepositFrequencyType = newValue;
if (command.isChangeInBooleanParameterNamed(allowWithdrawalParamName, this.allowWithdrawal)) {
final boolean newValue = command.booleanObjectValueOfParameterNamed(allowWithdrawalParamName);
actualChanges.put(allowWithdrawalParamName, newValue);
this.allowWithdrawal = newValue;
}
if (command.isChangeInIntegerParameterNamed(recurringDepositTypeIdParamName, this.recurringDepositType)) {
final Integer newValue = command.integerValueOfParameterNamed(recurringDepositTypeIdParamName);
actualChanges.put(recurringDepositTypeIdParamName, SavingsEnumerations.recurringDepositType(newValue));
this.recurringDepositType = newValue;
if (command.isChangeInBooleanParameterNamed(adjustAdvanceTowardsFuturePaymentsParamName, this.adjustAdvanceTowardsFuturePayments)) {
final boolean newValue = command.booleanObjectValueOfParameterNamed(adjustAdvanceTowardsFuturePaymentsParamName);
actualChanges.put(adjustAdvanceTowardsFuturePaymentsParamName, newValue);
this.adjustAdvanceTowardsFuturePayments = newValue;
}
return actualChanges;
}
public Integer recurringDepositType() {
return this.recurringDepositType;
public boolean isMandatoryDeposit() {
return this.isMandatoryDeposit;
}
public Integer recurringDepositFrequency() {
return this.recurringDepositFrequency;
public boolean allowWithdrawal() {
return this.allowWithdrawal;
}
public Integer recurringDepositFrequencyTypeId() {
return this.recurringDepositFrequencyType;
}
public SavingsPeriodFrequencyType recurringDepositFrequencyType() {
return SavingsPeriodFrequencyType.fromInt(this.recurringDepositFrequencyType);
public boolean adjustAdvanceTowardsFuturePayments() {
return this.adjustAdvanceTowardsFuturePayments;
}
public DepositRecurringDetail copy() {
final RecurringDepositType recurringDepositType = RecurringDepositType.fromInt(this.recurringDepositType);
final Integer recurringDepositFrequency = this.recurringDepositFrequency;
final SavingsPeriodFrequencyType recurringDepositFrequencyType = SavingsPeriodFrequencyType
.fromInt(this.recurringDepositFrequencyType);
return DepositRecurringDetail.createFrom(recurringDepositType, recurringDepositFrequency, recurringDepositFrequencyType);
return DepositRecurringDetail.createFrom(this.isMandatoryDeposit, this.allowWithdrawal, this.adjustAdvanceTowardsFuturePayments);
}
}
@@ -164,21 +164,27 @@ public class DepositTermDetail {
public boolean isValidInMultiplesOfPeriod(final Integer depositPeriod, final SavingsPeriodFrequencyType depositPeriodFrequencyType) {
boolean isValidInMultiplesOfPeriod = true;
final Integer depositPeriodInDays = this.convertToSafeDays(depositPeriod, depositPeriodFrequencyType);
final Integer inMultiplesOfInDays = this.convertToSafeDays(this.inMultiplesOfDepositTerm(),
SavingsPeriodFrequencyType.fromInt(this.inMultiplesOfDepositTermType()));
final Integer minDepositInDays = this.convertToSafeDays(minDepositTerm, SavingsPeriodFrequencyType.fromInt(minDepositTermType));
if (this.inMultiplesOfDepositTerm() != null) {
final Integer inMultiplesOfInDays = this.convertToSafeDays(this.inMultiplesOfDepositTerm(),
SavingsPeriodFrequencyType.fromInt(this.inMultiplesOfDepositTermType()));
final Integer minDepositInDays = this.convertToSafeDays(minDepositTerm, SavingsPeriodFrequencyType.fromInt(minDepositTermType));
isValidInMultiplesOfPeriod = ((depositPeriodInDays - minDepositInDays) % inMultiplesOfInDays == 0);
}
return ((depositPeriodInDays - minDepositInDays) % inMultiplesOfInDays == 0);
return isValidInMultiplesOfPeriod;
}
private boolean isEqualOrGreaterThanMin(LocalDate depositStartDate, LocalDate depositEndDate) {
if (minDepositTerm() == null) return true;
final SavingsPeriodFrequencyType periodFrequencyType = SavingsPeriodFrequencyType.fromInt(this.minDepositTermType());
final Integer depositPeriod = depositPeriod(depositStartDate, depositEndDate, periodFrequencyType);
return minDepositTerm() == null || depositPeriod.compareTo(minDepositTerm()) >= 0;
}
private boolean isEqualOrLessThanMax(LocalDate depositStartDate, LocalDate depositEndDate) {
if (maxDepositTerm() == null) return true;
final SavingsPeriodFrequencyType periodFrequencyType = SavingsPeriodFrequencyType.fromInt(this.maxDepositTermType());
final Integer depositPeriod = depositPeriod(depositStartDate, depositEndDate, periodFrequencyType);
return maxDepositTerm() == null || depositPeriod.compareTo(maxDepositTerm()) <= 0;
@@ -41,9 +41,9 @@ import org.mifosplatform.organisation.staff.domain.Staff;
import org.mifosplatform.portfolio.accountdetails.domain.AccountType;
import org.mifosplatform.portfolio.client.domain.Client;
import org.mifosplatform.portfolio.group.domain.Group;
import org.mifosplatform.portfolio.interestratechart.data.ClientIncentiveAttributes;
import org.mifosplatform.portfolio.interestratechart.domain.InterestRateChart;
import org.mifosplatform.portfolio.interestratechart.service.InterestRateChartAssembler;
import org.mifosplatform.portfolio.paymentdetail.domain.PaymentDetail;
import org.mifosplatform.portfolio.savings.DepositAccountOnClosureType;
import org.mifosplatform.portfolio.savings.DepositsApiConstants;
import org.mifosplatform.portfolio.savings.PreClosurePenalInterestOnType;
@@ -125,8 +125,8 @@ public class FixedDepositAccount extends SavingsAccount {
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
.resource(FIXED_DEPOSIT_ACCOUNT_RESOURCE_NAME + SavingsApiConstants.modifyApplicationAction);
super.modifyApplication(command, actualChanges, baseDataValidator);
accountTermAndPreClosure.update(command, baseDataValidator);
final Map<String, Object> termAndPreClosureChanges = accountTermAndPreClosure.update(command, baseDataValidator);
actualChanges.putAll(termAndPreClosureChanges);
validateDomainRules(baseDataValidator);
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
}
@@ -134,33 +134,38 @@ public class FixedDepositAccount extends SavingsAccount {
@Override
protected BigDecimal getEffectiveInterestRateAsFraction(final MathContext mc, final LocalDate interestPostingUpToDate) {
final boolean isPreMatureClosure = SavingsAccountStatusType.fromInt(this.status).isPreMatureClosure();
boolean applyPreMaturePenalty = false;
BigDecimal penalInterest = BigDecimal.ZERO;
LocalDate depositCloseDate = calculateMaturityDate();
if (isPreMatureClosure) {
if (this.accountTermAndPreClosure.isPreClosurePenalApplicable()) {
applyPreMaturePenalty = true;
penalInterest = this.accountTermAndPreClosure.depositPreClosureDetail().preClosurePenalInterest();
final PreClosurePenalInterestOnType preClosurePenalInterestOnType = this.accountTermAndPreClosure.depositPreClosureDetail()
.preClosurePenalInterestOnType();
if (preClosurePenalInterestOnType.isWholeTerm()) {
depositCloseDate = interestCalculatedUpto();
} else if (preClosurePenalInterestOnType.isTillPrematureWithdrawal()) {
depositCloseDate = interestPostingUpToDate;
// default it to nominalAnnualInterst rate. interest chart overrrides
// this value.
BigDecimal applicableInterestRate = this.nominalAnnualInterestRate;
if (this.chart != null) {
final boolean isPreMatureClosure = SavingsAccountStatusType.fromInt(this.status).isPreMatureClosure();
boolean applyPreMaturePenalty = false;
BigDecimal penalInterest = BigDecimal.ZERO;
LocalDate depositCloseDate = calculateMaturityDate();
if (isPreMatureClosure) {
if (this.accountTermAndPreClosure.isPreClosurePenalApplicable()) {
applyPreMaturePenalty = true;
penalInterest = this.accountTermAndPreClosure.depositPreClosureDetail().preClosurePenalInterest();
final PreClosurePenalInterestOnType preClosurePenalInterestOnType = this.accountTermAndPreClosure
.depositPreClosureDetail().preClosurePenalInterestOnType();
if (preClosurePenalInterestOnType.isWholeTerm()) {
depositCloseDate = interestCalculatedUpto();
} else if (preClosurePenalInterestOnType.isTillPrematureWithdrawal()) {
depositCloseDate = interestPostingUpToDate;
}
}
}
final BigDecimal depositAmount = accountTermAndPreClosure.depositAmount();
final ClientIncentiveAttributes incentiveAttributes = (this.client == null) ? null : this.client.incentiveAttributes();
applicableInterestRate = this.chart.getApplicableInterestRate(depositAmount, depositStartDate(), depositCloseDate,
incentiveAttributes);
if (applyPreMaturePenalty) {
applicableInterestRate = applicableInterestRate.subtract(penalInterest);
applicableInterestRate = applicableInterestRate.compareTo(BigDecimal.ZERO) == -1 ? BigDecimal.ZERO : applicableInterestRate;
}
}
final BigDecimal depositAmount = accountTermAndPreClosure.depositAmount();
BigDecimal applicableInterestRate = this.chart.getApplicableInterestRate(depositAmount, depositStartDate(), depositCloseDate);
if (applyPreMaturePenalty) {
applicableInterestRate = applicableInterestRate.subtract(penalInterest);
applicableInterestRate = applicableInterestRate.compareTo(BigDecimal.ZERO) == -1 ? BigDecimal.ZERO : applicableInterestRate;
}
this.nominalAnnualInterestRate = applicableInterestRate;
return applicableInterestRate.divide(BigDecimal.valueOf(100l), mc);
@@ -177,10 +182,23 @@ public class FixedDepositAccount extends SavingsAccount {
updateMaturityDateAndAmount(mc, allTransactions);
}
public void updateMaturityDateAndAmount(final MathContext mc) {
updateMaturityDateAndAmount(mc, retreiveOrderedNonInterestPostingTransactions());
}
public void updateMaturityDateAndAmount(final MathContext mc, final List<SavingsAccountTransaction> transactions) {
final LocalDate maturityDate = calculateMaturityDate();
final LocalDate interestCalculationUpto = maturityDate.minusDays(1);
// set end of day balance to maturity date for maturity interest
// calculation
this.resetAccountTransactionsEndOfDayBalances(transactions, maturityDate);
final List<PostingPeriod> postingPeriods = calculateInterestPayable(mc, interestCalculationUpto, transactions);
// reset end of day balance back to today's date
this.resetAccountTransactionsEndOfDayBalances(transactions, DateUtils.getLocalDateOfTenant());
Money totalInterestPayable = Money.zero(getCurrency());
for (PostingPeriod postingPeriod : postingPeriods) {
totalInterestPayable = totalInterestPayable.plus(postingPeriod.getInterestEarned());
@@ -206,7 +224,7 @@ public class FixedDepositAccount extends SavingsAccount {
if (!this.maturityDate().isAfter(todayDate)) {
// update account status
this.status = SavingsAccountStatusType.MATURED.getValue();
postMaturityInterest(maturityDate());
postMaturityInterest();
}
}
@@ -238,11 +256,6 @@ public class FixedDepositAccount extends SavingsAccount {
private List<PostingPeriod> calculateInterestPayable(final MathContext mc, final LocalDate maturityDate,
final List<SavingsAccountTransaction> transactions) {
// 1. default to calculate interest based on entire history OR
// 2. determine latest 'posting period' and find interest credited to
// that period
// A generate list of EndOfDayBalances (not including interest postings)
final SavingsPostingInterestPeriodType postingPeriodType = SavingsPostingInterestPeriodType.fromInt(this.interestPostingPeriodType);
final SavingsCompoundingInterestPeriodType compoundingPeriodType = SavingsCompoundingInterestPeriodType
@@ -279,8 +292,8 @@ public class FixedDepositAccount extends SavingsAccount {
return allPostingPeriods;
}
public SavingsAccountTransaction prematureClosure(final AppUser currentUser, final JsonCommand command,
final LocalDate tenantsTodayDate, final PaymentDetail paymentDetail, final Map<String, Object> actualChanges) {
public void prematureClosure(final AppUser currentUser, final JsonCommand command,
final LocalDate tenantsTodayDate, final Map<String, Object> actualChanges) {
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
@@ -302,6 +315,12 @@ public class FixedDepositAccount extends SavingsAccount {
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
}
if (isAccountLocked(closedDate)) {
baseDataValidator.reset().parameter(SavingsApiConstants.closedOnDateParamName).value(closedDate)
.failWithCode("must.be.after.lockin.period");
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
}
if (closedDate.isAfter(maturityDate())) {
baseDataValidator.reset().parameter(SavingsApiConstants.closedOnDateParamName).value(closedDate)
.failWithCode("must.be.before.maturity.date");
@@ -329,15 +348,14 @@ public class FixedDepositAccount extends SavingsAccount {
final Integer onAccountClosureId = command.integerValueOfParameterNamed(onAccountClosureIdParamName);
final DepositAccountOnClosureType onClosureType = DepositAccountOnClosureType.fromInt(onAccountClosureId);
this.accountTermAndPreClosure.updateOnAccountClosureStatus(onClosureType);
postPreMaturityInterest(closedDate);
// withdraw deposit amount before closing the account
/* // withdraw deposit amount before closing the account
final Money transactionAmountMoney = Money.of(this.currency, this.getAccountBalance());
final SavingsAccountTransaction withdraw = SavingsAccountTransaction.withdrawal(this, office(), paymentDetail, closedDate,
transactionAmountMoney, new Date());
this.transactions.add(withdraw);
*/
actualChanges.put(SavingsApiConstants.statusParamName, SavingsEnumerations.status(this.status));
actualChanges.put(SavingsApiConstants.localeParamName, command.locale());
actualChanges.put(SavingsApiConstants.dateFormatParamName, command.dateFormat());
@@ -349,8 +367,7 @@ public class FixedDepositAccount extends SavingsAccount {
this.withdrawnBy = null;
this.closedOnDate = closedDate.toDate();
this.closedBy = currentUser;
return withdraw;
this.summary.updateSummary(this.currency, this.savingsAccountTransactionSummaryWrapper, this.transactions);
}
@Override
@@ -358,8 +375,8 @@ public class FixedDepositAccount extends SavingsAccount {
return Money.of(this.currency, this.accountTermAndPreClosure.depositAmount());
}
public SavingsAccountTransaction close(final AppUser currentUser, final JsonCommand command, final LocalDate tenantsTodayDate,
final PaymentDetail paymentDetail, final Map<String, Object> actualChanges) {
public void close(final AppUser currentUser, final JsonCommand command, final LocalDate tenantsTodayDate,
final Map<String, Object> actualChanges) {
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
@@ -390,6 +407,7 @@ public class FixedDepositAccount extends SavingsAccount {
.failWithCode("cannot.be.a.future.date");
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
}
final List<SavingsAccountTransaction> savingsAccountTransactions = retreiveListOfTransactions();
if (savingsAccountTransactions.size() > 0) {
final SavingsAccountTransaction accountTransaction = savingsAccountTransactions.get(savingsAccountTransactions.size() - 1);
@@ -407,13 +425,14 @@ public class FixedDepositAccount extends SavingsAccount {
final DepositAccountOnClosureType onClosureType = DepositAccountOnClosureType.fromInt(onAccountClosureId);
this.accountTermAndPreClosure.updateOnAccountClosureStatus(onClosureType);
postMaturityInterest(maturityDate());
// withdraw deposit amount before closing the account
final Money transactionAmountMoney = Money.of(this.currency, this.getAccountBalance());
final SavingsAccountTransaction withdraw = SavingsAccountTransaction.withdrawal(this, office(), paymentDetail, closedDate,
transactionAmountMoney, new Date());
this.transactions.add(withdraw);
// // withdraw deposit amount before closing the account
// final Money transactionAmountMoney = Money.of(this.currency,
// this.getAccountBalance());
// final SavingsAccountTransaction withdraw =
// SavingsAccountTransaction.withdrawal(this, office(), paymentDetail,
// closedDate,
// transactionAmountMoney, new Date());
// this.transactions.add(withdraw);
actualChanges.put(SavingsApiConstants.statusParamName, SavingsEnumerations.status(this.status));
actualChanges.put(SavingsApiConstants.localeParamName, command.locale());
@@ -426,12 +445,12 @@ public class FixedDepositAccount extends SavingsAccount {
this.withdrawnBy = null;
this.closedOnDate = closedDate.toDate();
this.closedBy = currentUser;
return withdraw;
// this.summary.updateSummary(this.currency,
// this.savingsAccountTransactionSummaryWrapper, this.transactions);
}
public void postMaturityInterest(final LocalDate interestPostingUpToDate) {
public void postMaturityInterest() {
final LocalDate interestPostingUpToDate = maturityDate();
final MathContext mc = MathContext.DECIMAL64;
final boolean isInterestTransfer = false;
final List<PostingPeriod> postingPeriods = calculateInterestUsing(mc, interestPostingUpToDate, isInterestTransfer);
@@ -569,10 +588,22 @@ public class FixedDepositAccount extends SavingsAccount {
return interestPostedToDate;
}
public void updateMaturityDateAndAmountAfterAccountActivation(final MathContext mc) {
List<SavingsAccountTransaction> allTransactions = new ArrayList<SavingsAccountTransaction>();
allTransactions.addAll(retreiveOrderedNonInterestPostingTransactions());
updateMaturityDateAndAmount(mc, allTransactions);
@Override
public Map<String, Object> activate(final AppUser currentUser, final JsonCommand command, final LocalDate tenantsTodayDate) {
final Map<String, Object> actualChanges = super.activate(currentUser, command, tenantsTodayDate);
// if (isAccountLocked(calculateMaturityDate())) {
// final List<ApiParameterError> dataValidationErrors = new
// ArrayList<ApiParameterError>();
// final DataValidatorBuilder baseDataValidator = new
// DataValidatorBuilder(dataValidationErrors)
// .resource(FIXED_DEPOSIT_ACCOUNT_RESOURCE_NAME);
// baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode("deposit.period.must.be.greater.than.lock.in.period",
// "Deposit period must be greater than account lock-in period.");
// if (!dataValidationErrors.isEmpty()) { throw new
// PlatformApiDataValidationException(dataValidationErrors); }
// }
return actualChanges;
}
private LocalDate depositStartDate() {
@@ -629,9 +660,7 @@ public class FixedDepositAccount extends SavingsAccount {
}
}
if (this.chart == null) {
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode("no.valid.interest.rate.slab.available");
} else {
if (this.chart != null) {
final LocalDate chartFromDate = this.chart.getFromDateAsLocalDate();
LocalDate chartEndDate = this.chart.getEndDateAsLocalDate();
chartEndDate = chartEndDate == null ? DateUtils.getLocalDateOfTenant() : chartEndDate;
@@ -640,7 +669,22 @@ public class FixedDepositAccount extends SavingsAccount {
if (!chartInterval.contains(accountSubmittedOrActivationDate())) {
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode("no.valid.interest.rate.slab.available");
}
final BigDecimal depositAmount = accountTermAndPreClosure.depositAmount();
final ClientIncentiveAttributes incentiveAttributes = (this.client == null) ? null : this.client.incentiveAttributes();
BigDecimal applicableInterestRate = this.chart.getApplicableInterestRate(depositAmount, depositStartDate(),
calculateMaturityDate(), incentiveAttributes);
if (applicableInterestRate.equals(BigDecimal.ZERO)) {
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode(
"no.applicable.interest.rate.is.found.based.on.amount.and.deposit.period");
}
} else if (this.nominalAnnualInterestRate == null || this.nominalAnnualInterestRate.compareTo(BigDecimal.ZERO) == 0) {
baseDataValidator.reset().parameter(DepositsApiConstants.nominalAnnualInterestRateParamName).value(nominalAnnualInterestRate)
.failWithCodeNoParameterAddedToErrorCode("valid.interest.chart.or.nominal.interest.rate.required");
}
}
public boolean isReinvestOnClosure() {
@@ -651,9 +695,9 @@ public class FixedDepositAccount extends SavingsAccount {
return this.accountTermAndPreClosure.isTransferToSavingsOnClosure();
}
public FixedDepositAccount reInvest(Money depositAmount) {
public FixedDepositAccount reInvest(BigDecimal depositAmount) {
final DepositAccountTermAndPreClosure newAccountTermAndPreClosure = this.accountTermAndPreClosure.deepCopy(depositAmount);
final DepositAccountTermAndPreClosure newAccountTermAndPreClosure = this.accountTermAndPreClosure.copy(depositAmount);
final SavingsProduct product = this.product;
final InterestRateChart productChart = product.applicableChart(getClosedOnDate());
final DepositAccountInterestRateChart newChart = DepositAccountInterestRateChart.from(productChart);
@@ -8,6 +8,7 @@ package org.mifosplatform.portfolio.savings.domain;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.deleteParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.idParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.FIXED_DEPOSIT_PRODUCT_RESOURCE_NAME;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.maxDepositTermParamName;
import java.math.BigDecimal;
import java.util.ArrayList;
@@ -72,16 +73,15 @@ public class FixedDepositProduct extends SavingsProduct {
final MonetaryCurrency currency, final BigDecimal interestRate,
final SavingsCompoundingInterestPeriodType interestCompoundingPeriodType,
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) {
final SavingsInterestCalculationDaysInYearType interestCalculationDaysInYearType, final Integer lockinPeriodFrequency,
final SavingsPeriodFrequencyType lockinPeriodFrequencyType, final AccountingRuleType accountingRuleType,
final Set<Charge> charges, final DepositProductTermAndPreClosure productTermAndPreClosure, final Set<InterestRateChart> charts) {
final BigDecimal minRequiredOpeningBalance = null;
final boolean withdrawalFeeApplicableForTransfer = false;
final boolean allowOverdraft = false;
final BigDecimal overdraftLimit = null;
return new FixedDepositProduct(name, shortName, description, currency, interestRate, interestCompoundingPeriodType,
interestPostingPeriodType, interestCalculationType, interestCalculationDaysInYearType, minRequiredOpeningBalance,
lockinPeriodFrequency, lockinPeriodFrequencyType, withdrawalFeeApplicableForTransfer, accountingRuleType, charges,
@@ -135,6 +135,8 @@ public class FixedDepositProduct extends SavingsProduct {
actualChanges.putAll(this.update(command, baseDataValidator));
validateDomainRules(baseDataValidator);
throwExceptionIfValidationWarningsExist(dataValidationErrors);
return actualChanges;
@@ -188,7 +190,7 @@ public class FixedDepositProduct extends SavingsProduct {
}
}
this.validateCharts(baseDataValidator);
// this.validateCharts(baseDataValidator);
// add chart changes to actual changes list.
if (!chartsChanges.isEmpty()) {
@@ -249,7 +251,7 @@ public class FixedDepositProduct extends SavingsProduct {
InterestRateChart applicableChart = null;
if (this.charts != null) {
for (InterestRateChart chart : this.charts) {
if(chart.isApplicableChartFor(target)){
if (chart.isApplicableChartFor(target)) {
applicableChart = chart;
break;
}
@@ -261,37 +263,70 @@ public class FixedDepositProduct extends SavingsProduct {
public DepositProductTermAndPreClosure depositProductTermAndPreClosure() {
return this.productTermAndPreClosure;
}
@SuppressWarnings("unchecked")
public void validateInterestPostingAndCompoundingPeriodTypes(final DataValidatorBuilder baseDataValidator) {
Map<SavingsPostingInterestPeriodType, List<SavingsCompoundingInterestPeriodType>> postingtoCompoundMap =
new HashMap<SavingsPostingInterestPeriodType, List<SavingsCompoundingInterestPeriodType>>();
postingtoCompoundMap.put(SavingsPostingInterestPeriodType.MONTHLY,
Arrays.asList(new SavingsCompoundingInterestPeriodType[]{SavingsCompoundingInterestPeriodType.DAILY,SavingsCompoundingInterestPeriodType.MONTHLY}));
postingtoCompoundMap.put(SavingsPostingInterestPeriodType.QUATERLY,
Arrays.asList(new SavingsCompoundingInterestPeriodType[]{SavingsCompoundingInterestPeriodType.DAILY
,SavingsCompoundingInterestPeriodType.MONTHLY,SavingsCompoundingInterestPeriodType.QUATERLY}));
postingtoCompoundMap.put(SavingsPostingInterestPeriodType.BIANNUAL,
Arrays.asList(new SavingsCompoundingInterestPeriodType[]{SavingsCompoundingInterestPeriodType.DAILY,
SavingsCompoundingInterestPeriodType.MONTHLY,SavingsCompoundingInterestPeriodType.QUATERLY,SavingsCompoundingInterestPeriodType.BI_ANNUAL}));
postingtoCompoundMap.put(SavingsPostingInterestPeriodType.ANNUAL,
Arrays.asList(new SavingsCompoundingInterestPeriodType[]{SavingsCompoundingInterestPeriodType.DAILY,
SavingsCompoundingInterestPeriodType.MONTHLY,SavingsCompoundingInterestPeriodType.QUATERLY
,SavingsCompoundingInterestPeriodType.BI_ANNUAL,SavingsCompoundingInterestPeriodType.ANNUAL}));
SavingsPostingInterestPeriodType savingsPostingInterestPeriodType = SavingsPostingInterestPeriodType.fromInt(interestPostingPeriodType);
SavingsCompoundingInterestPeriodType savingsCompoundingInterestPeriodType = SavingsCompoundingInterestPeriodType.fromInt(interestCompoundingPeriodType);
if(postingtoCompoundMap.get(savingsPostingInterestPeriodType) == null ||
!postingtoCompoundMap.get(savingsPostingInterestPeriodType).contains(savingsCompoundingInterestPeriodType)) {
baseDataValidator.failWithCodeNoParameterAddedToErrorCode("posting.period.type.is.less.than.compound.period.type",
savingsPostingInterestPeriodType.name(),savingsCompoundingInterestPeriodType.name());
public void validateInterestPostingAndCompoundingPeriodTypes(final DataValidatorBuilder baseDataValidator) {
Map<SavingsPostingInterestPeriodType, List<SavingsCompoundingInterestPeriodType>> postingtoCompoundMap = new HashMap<SavingsPostingInterestPeriodType, List<SavingsCompoundingInterestPeriodType>>();
postingtoCompoundMap.put(
SavingsPostingInterestPeriodType.MONTHLY,
Arrays.asList(new SavingsCompoundingInterestPeriodType[] { SavingsCompoundingInterestPeriodType.DAILY,
SavingsCompoundingInterestPeriodType.MONTHLY }));
postingtoCompoundMap.put(
SavingsPostingInterestPeriodType.QUATERLY,
Arrays.asList(new SavingsCompoundingInterestPeriodType[] { SavingsCompoundingInterestPeriodType.DAILY,
SavingsCompoundingInterestPeriodType.MONTHLY, SavingsCompoundingInterestPeriodType.QUATERLY }));
postingtoCompoundMap.put(
SavingsPostingInterestPeriodType.BIANNUAL,
Arrays.asList(new SavingsCompoundingInterestPeriodType[] { SavingsCompoundingInterestPeriodType.DAILY,
SavingsCompoundingInterestPeriodType.MONTHLY, SavingsCompoundingInterestPeriodType.QUATERLY,
SavingsCompoundingInterestPeriodType.BI_ANNUAL }));
postingtoCompoundMap.put(
SavingsPostingInterestPeriodType.ANNUAL,
Arrays.asList(new SavingsCompoundingInterestPeriodType[] { SavingsCompoundingInterestPeriodType.DAILY,
SavingsCompoundingInterestPeriodType.MONTHLY, SavingsCompoundingInterestPeriodType.QUATERLY,
SavingsCompoundingInterestPeriodType.BI_ANNUAL, SavingsCompoundingInterestPeriodType.ANNUAL }));
SavingsPostingInterestPeriodType savingsPostingInterestPeriodType = SavingsPostingInterestPeriodType
.fromInt(interestPostingPeriodType);
SavingsCompoundingInterestPeriodType savingsCompoundingInterestPeriodType = SavingsCompoundingInterestPeriodType
.fromInt(interestCompoundingPeriodType);
if (postingtoCompoundMap.get(savingsPostingInterestPeriodType) == null
|| !postingtoCompoundMap.get(savingsPostingInterestPeriodType).contains(savingsCompoundingInterestPeriodType)) {
baseDataValidator.failWithCodeNoParameterAddedToErrorCode("posting.period.type.is.less.than.compound.period.type",
savingsPostingInterestPeriodType.name(), savingsCompoundingInterestPeriodType.name());
}
}
public void validateDomainRules() {
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
.resource(FIXED_DEPOSIT_PRODUCT_RESOURCE_NAME);
validateDomainRules(baseDataValidator);
throwExceptionIfValidationWarningsExist(dataValidationErrors);
}
private void validateDomainRules(final DataValidatorBuilder baseDataValidator) {
final DepositTermDetail termDetails = this.depositProductTermAndPreClosure().depositTermDetail();
final boolean isMinTermGreaterThanMax = termDetails.isMinDepositTermGreaterThanMaxDepositTerm();
if (isMinTermGreaterThanMax) {
final Integer maxTerm = termDetails.maxDepositTerm();
baseDataValidator.reset().parameter(maxDepositTermParamName).value(maxTerm)
.failWithCodeNoParameterAddedToErrorCode("max.term.lessthan.min.term");
}
if (this.charts != null) {
validateCharts(baseDataValidator);
} else if (this.nominalAnnualInterestRate == null || this.nominalAnnualInterestRate.compareTo(BigDecimal.ZERO) == 0) {
baseDataValidator.reset().parameter(DepositsApiConstants.nominalAnnualInterestRateParamName).value(nominalAnnualInterestRate)
.failWithCodeNoParameterAddedToErrorCode("interest.chart.or.nominal.interest.rate.required");
}
this.validateInterestPostingAndCompoundingPeriodTypes(baseDataValidator);
}
}
@@ -25,9 +25,12 @@ import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Transient;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.joda.time.LocalDate;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
@@ -41,10 +44,11 @@ import org.mifosplatform.organisation.monetary.domain.Money;
import org.mifosplatform.organisation.staff.domain.Staff;
import org.mifosplatform.portfolio.accountdetails.domain.AccountType;
import org.mifosplatform.portfolio.client.domain.Client;
import org.mifosplatform.portfolio.common.domain.PeriodFrequencyType;
import org.mifosplatform.portfolio.group.domain.Group;
import org.mifosplatform.portfolio.interestratechart.data.ClientIncentiveAttributes;
import org.mifosplatform.portfolio.interestratechart.domain.InterestRateChart;
import org.mifosplatform.portfolio.interestratechart.service.InterestRateChartAssembler;
import org.mifosplatform.portfolio.paymentdetail.domain.PaymentDetail;
import org.mifosplatform.portfolio.savings.DepositAccountOnClosureType;
import org.mifosplatform.portfolio.savings.DepositsApiConstants;
import org.mifosplatform.portfolio.savings.PreClosurePenalInterestOnType;
@@ -70,10 +74,14 @@ public class RecurringDepositAccount extends SavingsAccount {
private DepositAccountRecurringDetail recurringDetail;
@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "account")
protected DepositAccountInterestRateChart chart;
private DepositAccountInterestRateChart chart;
@LazyCollection(LazyCollectionOption.FALSE)
@OneToMany(cascade = CascadeType.ALL, mappedBy = "account", orphanRemoval = true)
private List<RecurringDepositScheduleInstallment> depositScheduleInstallments = new ArrayList<RecurringDepositScheduleInstallment>();
@Transient
protected InterestRateChartAssembler chartAssembler;
private InterestRateChartAssembler chartAssembler;
protected RecurringDepositAccount() {
//
@@ -153,9 +161,9 @@ public class RecurringDepositAccount extends SavingsAccount {
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
.resource(RECURRING_DEPOSIT_ACCOUNT_RESOURCE_NAME + SavingsApiConstants.modifyApplicationAction);
super.modifyApplication(command, actualChanges, baseDataValidator);
accountTermAndPreClosure.update(command, baseDataValidator);
recurringDetail.update(command, baseDataValidator);
final Map<String, Object> termAndPreClosureChanges = accountTermAndPreClosure.update(command, baseDataValidator);
actualChanges.putAll(termAndPreClosureChanges);
recurringDetail.update(command);
validateDomainRules(baseDataValidator);
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
@@ -182,9 +190,10 @@ public class RecurringDepositAccount extends SavingsAccount {
}
}
final BigDecimal depositAmount = recurringDetail.recurringDepositAmount();
BigDecimal applicableInterestRate = this.chart.getApplicableInterestRate(depositAmount, depositStartDate(), depositCloseDate);
final BigDecimal depositAmount = accountTermAndPreClosure.depositAmount();
final ClientIncentiveAttributes incentiveAttributes = (this.client == null) ? null : this.client.incentiveAttributes();
BigDecimal applicableInterestRate = this.chart.getApplicableInterestRate(depositAmount, depositStartDate(), depositCloseDate,
incentiveAttributes);
if (applyPreMaturePenalty) {
applicableInterestRate = applicableInterestRate.subtract(penalInterest);
@@ -196,11 +205,10 @@ public class RecurringDepositAccount extends SavingsAccount {
return applicableInterestRate.divide(BigDecimal.valueOf(100l), mc);
}
public void updateMaturityDateAndAmount(final MathContext mc, final LocalDate transactionStartDate) {
public void updateMaturityDateAndAmount(final MathContext mc) {
final LocalDate maturityDate = calculateMaturityDate();
final LocalDate interestCalculationUpto = maturityDate.minusDays(1);
final List<SavingsAccountTransaction> allTransactions = generateIncludingFutureTransactions(transactionStartDate,
interestCalculationUpto);
final List<SavingsAccountTransaction> allTransactions = generateIncludingFutureTransactions(interestCalculationUpto);
final List<PostingPeriod> postingPeriods = calculateInterestPayable(mc, interestCalculationUpto, allTransactions);
Money totalInterestPayable = Money.zero(getCurrency());
@@ -228,7 +236,7 @@ public class RecurringDepositAccount extends SavingsAccount {
if (!this.maturityDate().isAfter(todayDate)) {
// update account status
this.status = SavingsAccountStatusType.MATURED.getValue();
postMaturityInterest(maturityDate());
postMaturityInterest();
}
}
@@ -301,19 +309,16 @@ public class RecurringDepositAccount extends SavingsAccount {
return allPostingPeriods;
}
private List<SavingsAccountTransaction> generateIncludingFutureTransactions(final LocalDate transactionStartDate,
final LocalDate depositEndDate) {
LocalDate transactionDate = transactionStartDate;
final BigDecimal recurringDepositAmount = this.recurringDetail.recurringDepositAmount();
private List<SavingsAccountTransaction> generateIncludingFutureTransactions(final LocalDate depositEndDate) {
List<SavingsAccountTransaction> allTransactions = new ArrayList<SavingsAccountTransaction>();
// add existing transactions
allTransactions.addAll(retreiveOrderedNonInterestPostingTransactions());
while (!transactionDate.isAfter(depositEndDate) && !transactionDate.isEqual(depositEndDate)) {
final Money transactionAmountMoney = Money.of(this.currency, recurringDepositAmount);
final SavingsAccountTransaction transaction = SavingsAccountTransaction.deposit(null, office(), null, transactionDate,
transactionAmountMoney, new Date());
allTransactions.add(transaction);
transactionDate = nextDepositDate(transactionDate);
for (RecurringDepositScheduleInstallment installment : depositScheduleInstallments()) {
if (installment.isPrincipalNotCompleted(getCurrency())) {
final SavingsAccountTransaction transaction = SavingsAccountTransaction.deposit(null, office(), null,
installment.dueDate(), installment.getDepositAmountOutstanding(getCurrency()), installment.dueDate().toDate());
allTransactions.add(transaction);
}
}
allTransactions = sortTransactions(allTransactions);
@@ -338,7 +343,7 @@ public class RecurringDepositAccount extends SavingsAccount {
LocalDate endOfBalanceDate = depositEndDate;
for (int i = allTransactions.size() - 1; i >= 0; i--) {
final SavingsAccountTransaction transaction = allTransactions.get(i);
if (transaction.isNotReversed()) {
if (transaction.isNotReversed() && !transaction.isInterestPostingAndNotReversed()) {
transaction.updateCumulativeBalanceAndDates(this.currency, endOfBalanceDate);
endOfBalanceDate = transaction.transactionLocalDate().minusDays(1);
}
@@ -346,49 +351,37 @@ public class RecurringDepositAccount extends SavingsAccount {
return allTransactions;
}
public LocalDate nextDepositDate(LocalDate depositDate) {
final LocalDate depositStartDate = depositStartDate();
LocalDate nextDepositDate = depositStartDate;
while (!depositDate.isBefore(nextDepositDate)) {
nextDepositDate = calculateNextDepositDate(nextDepositDate);
}
return nextDepositDate;
}
private LocalDate calculateNextDepositDate(final LocalDate lastDepositDate, final PeriodFrequencyType frequency,
final int recurringEvery) {
LocalDate nextDepositDate = lastDepositDate;
private LocalDate calculateNextDepositDate(final LocalDate depositDate) {
final Integer depositFrequency = this.recurringDetail.recurringDepositFrequency();
LocalDate nextDepositDate = depositDate;
final SavingsPeriodFrequencyType depositFrequencyType = this.recurringDetail.recurringDepositFrequencyType();
switch (depositFrequencyType) {
switch (frequency) {
case DAYS:
nextDepositDate = depositDate.plusDays(depositFrequency);
nextDepositDate = lastDepositDate.plusDays(recurringEvery);
break;
case WEEKS:
nextDepositDate = depositDate.plusWeeks(depositFrequency);
nextDepositDate = lastDepositDate.plusWeeks(recurringEvery);
break;
case MONTHS:
nextDepositDate = depositDate.plusMonths(depositFrequency);
nextDepositDate = lastDepositDate.plusMonths(recurringEvery);
break;
case YEARS:
nextDepositDate = depositDate.plusYears(depositFrequency);
nextDepositDate = lastDepositDate.plusYears(recurringEvery);
break;
case INVALID:
nextDepositDate = null;
break;
}
return nextDepositDate;
}
public LocalDate depositStartDate() {
// TODO: Support to add deposit start date which can be a date after
// account activation date.
final LocalDate depositStartDate = accountTermAndPreClosure.getExpectedFirstDepositOnDate();
if (depositStartDate == null) return accountSubmittedOrActivationDate();
return depositStartDate;
}
public SavingsAccountTransaction prematureClosure(final AppUser currentUser, final JsonCommand command,
final LocalDate tenantsTodayDate, final PaymentDetail paymentDetail, final Map<String, Object> actualChanges) {
public void prematureClosure(final AppUser currentUser, final JsonCommand command, final LocalDate tenantsTodayDate,
final Map<String, Object> actualChanges) {
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
@@ -410,6 +403,12 @@ public class RecurringDepositAccount extends SavingsAccount {
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
}
if (isAccountLocked(closedDate)) {
baseDataValidator.reset().parameter(SavingsApiConstants.closedOnDateParamName).value(closedDate)
.failWithCode("must.be.after.lockin.period");
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
}
if (closedDate.isAfter(maturityDate())) {
baseDataValidator.reset().parameter(SavingsApiConstants.closedOnDateParamName).value(closedDate)
.failWithCode("must.be.before.maturity.date");
@@ -421,6 +420,13 @@ public class RecurringDepositAccount extends SavingsAccount {
.failWithCode("cannot.be.a.future.date");
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
}
if (isAccountLocked(calculateMaturityDate())) {
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode("deposit.period.must.be.greater.than.lock.in.period",
"Deposit period must be greater than account lock-in period.");
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
}
final List<SavingsAccountTransaction> savingsAccountTransactions = retreiveListOfTransactions();
if (savingsAccountTransactions.size() > 0) {
final SavingsAccountTransaction accountTransaction = savingsAccountTransactions.get(savingsAccountTransactions.size() - 1);
@@ -438,14 +444,14 @@ public class RecurringDepositAccount extends SavingsAccount {
final DepositAccountOnClosureType onClosureType = DepositAccountOnClosureType.fromInt(onAccountClosureId);
this.accountTermAndPreClosure.updateOnAccountClosureStatus(onClosureType);
postPreMaturityInterest(closedDate);
// withdraw deposit amount before closing the account
final Money transactionAmountMoney = Money.of(this.currency, this.getAccountBalance());
final SavingsAccountTransaction withdraw = SavingsAccountTransaction.withdrawal(this, office(), paymentDetail, closedDate,
transactionAmountMoney, new Date());
this.transactions.add(withdraw);
/*
* // withdraw deposit amount before closing the account final Money
* transactionAmountMoney = Money.of(this.currency,
* this.getAccountBalance()); final SavingsAccountTransaction withdraw =
* SavingsAccountTransaction.withdrawal(this, office(), paymentDetail,
* closedDate, transactionAmountMoney, new Date());
* this.transactions.add(withdraw);
*/
actualChanges.put(SavingsApiConstants.statusParamName, SavingsEnumerations.status(this.status));
actualChanges.put(SavingsApiConstants.localeParamName, command.locale());
actualChanges.put(SavingsApiConstants.dateFormatParamName, command.dateFormat());
@@ -457,8 +463,8 @@ public class RecurringDepositAccount extends SavingsAccount {
this.withdrawnBy = null;
this.closedOnDate = closedDate.toDate();
this.closedBy = currentUser;
this.summary.updateSummary(this.currency, this.savingsAccountTransactionSummaryWrapper, this.transactions);
return withdraw;
}
@Override
@@ -466,8 +472,21 @@ public class RecurringDepositAccount extends SavingsAccount {
return Money.of(this.currency, this.minRequiredOpeningBalance);
}
public SavingsAccountTransaction close(final AppUser currentUser, final JsonCommand command, final LocalDate tenantsTodayDate,
final PaymentDetail paymentDetail, final Map<String, Object> actualChanges) {
protected void processAccountUponActivation(final DateTimeFormatter fmt) {
final Money minRequiredOpeningBalance = Money.of(this.currency, this.minRequiredOpeningBalance);
if (minRequiredOpeningBalance.isGreaterThanZero()) {
final SavingsAccountTransactionDTO transactionDTO = new SavingsAccountTransactionDTO(fmt, getActivationLocalDate(),
minRequiredOpeningBalance.getAmount(), null, new Date());
deposit(transactionDTO);
// update existing transactions so derived balance fields are
// correct.
recalculateDailyBalances(Money.zero(this.currency), DateUtils.getLocalDateOfTenant());
}
}
public void close(final AppUser currentUser, final JsonCommand command, final LocalDate tenantsTodayDate,
final Map<String, Object> actualChanges) {
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
@@ -515,13 +534,14 @@ public class RecurringDepositAccount extends SavingsAccount {
final DepositAccountOnClosureType onClosureType = DepositAccountOnClosureType.fromInt(onAccountClosureId);
this.accountTermAndPreClosure.updateOnAccountClosureStatus(onClosureType);
postMaturityInterest(maturityDate());
// withdraw deposit amount before closing the account
final Money transactionAmountMoney = Money.of(this.currency, this.getAccountBalance());
final SavingsAccountTransaction withdraw = SavingsAccountTransaction.withdrawal(this, office(), paymentDetail, closedDate,
transactionAmountMoney, new Date());
this.transactions.add(withdraw);
/*
* // withdraw deposit amount before closing the account final Money
* transactionAmountMoney = Money.of(this.currency,
* this.getAccountBalance()); final SavingsAccountTransaction withdraw =
* SavingsAccountTransaction.withdrawal(this, office(), paymentDetail,
* closedDate, transactionAmountMoney, new Date());
* this.transactions.add(withdraw);
*/
actualChanges.put(SavingsApiConstants.statusParamName, SavingsEnumerations.status(this.status));
actualChanges.put(SavingsApiConstants.localeParamName, command.locale());
@@ -534,15 +554,14 @@ public class RecurringDepositAccount extends SavingsAccount {
this.withdrawnBy = null;
this.closedOnDate = closedDate.toDate();
this.closedBy = currentUser;
return withdraw;
this.summary.updateSummary(this.currency, this.savingsAccountTransactionSummaryWrapper, this.transactions);
}
public void postMaturityInterest(final LocalDate interestPostingUpToDate) {
public void postMaturityInterest() {
final LocalDate interestPostingUpToDate = maturityDate();
final MathContext mc = MathContext.DECIMAL64;
boolean isInterestTransfer = false;
final List<PostingPeriod> postingPeriods = calculateInterestUsing(mc, interestPostingUpToDate,isInterestTransfer);
final List<PostingPeriod> postingPeriods = calculateInterestUsing(mc, interestPostingUpToDate, isInterestTransfer);
Money interestPostedToDate = Money.zero(this.currency);
@@ -632,12 +651,12 @@ public class RecurringDepositAccount extends SavingsAccount {
final Money interestEarnedForPeriod = interestPostingPeriod.getInterestEarned();
interestOnMaturity = interestOnMaturity.plus(interestEarnedForPeriod);
}
this.summary.updateFromInterestPeriodSummaries(this.currency, postingPeriods);
return interestOnMaturity;
}
@Override
public void postInterest(final MathContext mc, final LocalDate postingDate,final boolean isInterestTransfer) {
public void postInterest(final MathContext mc, final LocalDate postingDate, final boolean isInterestTransfer) {
final LocalDate interestPostingUpToDate = interestPostingUpToDate(postingDate);
super.postInterest(mc, interestPostingUpToDate, isInterestTransfer);
}
@@ -657,10 +676,14 @@ public class RecurringDepositAccount extends SavingsAccount {
return interestPostingUpToDate;
}
private LocalDate maturityDate() {
public LocalDate maturityDate() {
return this.accountTermAndPreClosure.getMaturityLocalDate();
}
public BigDecimal maturityAmount() {
return this.accountTermAndPreClosure.maturityAmount();
}
private LocalDate interestCalculatedUpto() {
LocalDate uptoMaturityDate = calculateMaturityDate();
if (uptoMaturityDate != null) {
@@ -683,15 +706,20 @@ public class RecurringDepositAccount extends SavingsAccount {
@Override
public Map<String, Object> activate(final AppUser currentUser, final JsonCommand command, final LocalDate tenantsTodayDate) {
final Map<String, Object> actualChanges = super.activate(currentUser, command, tenantsTodayDate);
final MathContext mc = MathContext.DECIMAL64;
final LocalDate transactionStartDate = getActivationLocalDate();
// TODO: If first deposit and activation date are not same then
// recalculate the nextTransaction date
if (accountTermAndPreClosure.isAfterExpectedFirstDepositDate(getActivationLocalDate())) {
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
.resource(RECURRING_DEPOSIT_ACCOUNT_RESOURCE_NAME);
final DateTimeFormatter formatter = DateTimeFormat.forPattern(command.dateFormat()).withLocale(command.extractLocale());
final String dateAsString = formatter.print(this.accountTermAndPreClosure.getExpectedFirstDepositOnDate());
baseDataValidator.reset().parameter(DepositsApiConstants.activatedOnDateParamName).value(dateAsString)
.failWithCodeNoParameterAddedToErrorCode("cannot.be.before.expected.first.deposit.date");
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
}
final LocalDate nextTransactionStartDate = nextDepositDate(transactionStartDate);
updateMaturityDateAndAmount(mc, nextTransactionStartDate);
return actualChanges;
}
@@ -722,7 +750,7 @@ public class RecurringDepositAccount extends SavingsAccount {
if (!isBeforeMaturityDate(transactionDTO.getTransactionDate())) {
final String defaultUserMessage = "Transaction is not allowed. Transaction date is on or after account maturity date.";
final ApiParameterError error = ApiParameterError.parameterError(
"error.msg.recurring.deposit.account.transaction.date.is.on.or.after.account.maturity.date", defaultUserMessage,
"error.msg.recurring.deposit.account.transaction.date.is.after.account.maturity.date", defaultUserMessage,
"transactionDate", transactionDTO.getTransactionDate().toString(transactionDTO.getFormatter()));
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
@@ -730,15 +758,96 @@ public class RecurringDepositAccount extends SavingsAccount {
throw new PlatformApiDataValidationException(dataValidationErrors);
}
final SavingsAccountTransaction transaction = super.deposit(transactionDTO);
final LocalDate nextTransactionDate = nextDepositDate(transactionDTO.getTransactionDate());
final MathContext mc = MathContext.DECIMAL64;
updateMaturityDateAndAmount(mc, nextTransactionDate);
if (isBeforeDepositStartDate(transactionDTO.getTransactionDate())) {
final String defaultUserMessage = "Transaction is not allowed. Transaction date is on or after account activation and deposit start date.";
final ApiParameterError error = ApiParameterError.parameterError(
"error.msg.recurring.deposit.account.transaction.date.is.before.account.activation.or.deposit.date",
defaultUserMessage, "transactionDate", transactionDTO.getTransactionDate().toString(transactionDTO.getFormatter()));
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
dataValidationErrors.add(error);
throw new PlatformApiDataValidationException(dataValidationErrors);
}
final SavingsAccountTransaction transaction = super.deposit(transactionDTO);
return transaction;
}
public void handleScheduleInstallments(final SavingsAccountTransaction transaction) {
final LocalDate transactionDate = transaction.transactionLocalDate();
Money transactionAmountUnprocessed = transaction.getAmount(getCurrency());
for (RecurringDepositScheduleInstallment currentInstallment : depositScheduleInstallments()) {
if (currentInstallment.isNotFullyPaidOff() && transactionAmountUnprocessed.isGreaterThanZero()) {
if (!this.adjustAdvanceTowardsFuturePayments() && currentInstallment.dueDate().isAfter(transactionDate)) {
transactionAmountUnprocessed = Money.zero(getCurrency());
}
transactionAmountUnprocessed = handleInstallmentTransaction(currentInstallment, transactionAmountUnprocessed,
transactionDate);
}
}
}
public void updateScheduleInstallments() {
// reset all installments to process from the beginning
for (RecurringDepositScheduleInstallment currentInstallment : depositScheduleInstallments()) {
currentInstallment.resetDerivedFields();
}
final List<SavingsAccountTransaction> orderedDepositTransactions = retreiveOrderedDepositTransactions();
for (SavingsAccountTransaction transaction : orderedDepositTransactions) {
handleScheduleInstallments(transaction);
}
}
private List<SavingsAccountTransaction> retreiveOrderedDepositTransactions() {
final List<SavingsAccountTransaction> listOfTransactionsSorted = retreiveListOfTransactions();
final List<SavingsAccountTransaction> orderedDepositTransactions = new ArrayList<SavingsAccountTransaction>();
for (final SavingsAccountTransaction transaction : listOfTransactionsSorted) {
if (transaction.isDepositAndNotReversed()) {
orderedDepositTransactions.add(transaction);
}
}
return orderedDepositTransactions;
}
/**
* This method is responsible for checking if the current transaction is 'an
* advance/early payment' based on the details passed through.
*
* Default implementation is check transaction date is before installment
* due date.
*/
protected boolean isTransactionInAdvanceOfInstallment(final int currentInstallmentIndex,
final List<RecurringDepositScheduleInstallment> installments, final LocalDate transactionDate) {
final RecurringDepositScheduleInstallment currentInstallment = installments.get(currentInstallmentIndex);
return transactionDate.isBefore(currentInstallment.dueDate());
}
private Money handleInstallmentTransaction(final RecurringDepositScheduleInstallment currentInstallment,
final Money transactionAmountUnprocessed, final LocalDate transactionDate) {
Money transactionAmountRemaining = transactionAmountUnprocessed;
Money depositAmountPortion = Money.zero(transactionAmountRemaining.getCurrency());
depositAmountPortion = currentInstallment.payInstallment(transactionDate, transactionAmountRemaining);
transactionAmountRemaining = transactionAmountRemaining.minus(depositAmountPortion);
return transactionAmountRemaining;
}
private boolean isAccountMatured() {
return SavingsAccountStatusType.fromInt(status).isMatured();
}
@@ -748,6 +857,10 @@ public class RecurringDepositAccount extends SavingsAccount {
return compareDate.isBefore(maturityDate);
}
private boolean isBeforeDepositStartDate(LocalDate compareDate) {
return compareDate.isBefore(depositStartDate());
}
public void validateDomainRules() {
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
@@ -760,17 +873,17 @@ public class RecurringDepositAccount extends SavingsAccount {
final boolean isMinTermGreaterThanMax = this.accountTermAndPreClosure.depositTermDetail()
.isMinDepositTermGreaterThanMaxDepositTerm();
final boolean isValidDepositPeriod = this.accountTermAndPreClosure.depositTermDetail().isDepositBetweenMinAndMax(
depositStartDate(), calculateMaturityDate());
// deposit period should be within min and max deposit term
if (isMinTermGreaterThanMax) {
final Integer maxTerm = this.accountTermAndPreClosure.depositTermDetail().maxDepositTerm();
baseDataValidator.reset().parameter(maxDepositTermParamName).value(maxTerm)
.failWithCodeNoParameterAddedToErrorCode("max.term.lessthan.min.term");
}
final Integer depositPeriod = this.accountTermAndPreClosure.depositPeriod();
final SavingsPeriodFrequencyType depositPeriodFrequencyType = this.accountTermAndPreClosure.depositPeriodFrequencyType();
final boolean isValidDepositPeriod = this.accountTermAndPreClosure.depositTermDetail().isDepositBetweenMinAndMax(
depositStartDate(), calculateMaturityDate());
if (!isValidDepositPeriod) {
baseDataValidator.reset().parameter(depositPeriodParamName).value(depositPeriod)
.failWithCodeNoParameterAddedToErrorCode("deposit.period.not.between.min.and.max.deposit.term");
@@ -785,30 +898,59 @@ public class RecurringDepositAccount extends SavingsAccount {
}
}
}
final LocalDate chartFromDate = this.chart.getFromDateAsLocalDate();
LocalDate chartEndDate = this.chart.getEndDateAsLocalDate();
chartEndDate = chartEndDate == null ? DateUtils.getLocalDateOfTenant() : chartEndDate;
final LocalDateInterval chartInterval = LocalDateInterval.create(chartFromDate, chartEndDate);
if (!chartInterval.contains(accountSubmittedOrActivationDate())) {
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode("no.valid.interest.rate.slab.available.for.date.range");
if (isAccountLocked(calculateMaturityDate())) {
baseDataValidator
.reset()
.parameter(depositPeriodParamName)
.value(depositPeriod)
.failWithCode("deposit.period.must.be.greater.than.lock.in.period",
"Deposit period must be greater than account lock-in period.");
}
final boolean firstDepositDateBeforeMaturityAndOnOrAfterActivationDate = firstDepositDateBeforeMaturityAndOnOrAfterActivationDate();
if (!firstDepositDateBeforeMaturityAndOnOrAfterActivationDate) {
if (firstDepositDateBeforeAccountSubmittedOrActivationDate()) {
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode(
"expected.first.deposit.date.is.not.between.maturity.date.and.activation.or.submitted.date");
"expected.first.deposit.date.must.be.after.account.submitted.or.activation.date");
}
final BigDecimal recurringDepositAmount = recurringDetail.recurringDepositAmount();
BigDecimal applicableInterestRate = this.chart.getApplicableInterestRate(recurringDepositAmount, depositStartDate(),
calculateMaturityDate());
// FIXME: Handle this scenario
/*
* //final boolean recurringFrequencyBeforeDepositPeriod =
* recurringFrequencyBeforeDepositPeriod();
*
* if (!recurringFrequencyBeforeDepositPeriod) {
* baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode(
* "recurring.frequency.not.before.deposit.period"); }
*/
}
if (applicableInterestRate.equals(BigDecimal.ZERO)) {
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode(
"no.applicable.interest.rate.is.found.based.on.amount.and.deposit.period");
public void validateApplicableInterestRate() {
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
.resource(RECURRING_DEPOSIT_ACCOUNT_RESOURCE_NAME);
if (this.chart != null) {
final LocalDate chartFromDate = this.chart.getFromDateAsLocalDate();
LocalDate chartEndDate = this.chart.getEndDateAsLocalDate();
chartEndDate = chartEndDate == null ? DateUtils.getLocalDateOfTenant() : chartEndDate;
final LocalDateInterval chartInterval = LocalDateInterval.create(chartFromDate, chartEndDate);
if (!chartInterval.contains(accountSubmittedOrActivationDate())) {
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode("no.valid.interest.rate.slab.available.for.date.range");
}
final BigDecimal maturityAmount = this.accountTermAndPreClosure.maturityAmount();
final ClientIncentiveAttributes incentiveAttributes = (this.client == null) ? null : this.client.incentiveAttributes();
BigDecimal applicableInterestRate = this.chart.getApplicableInterestRate(maturityAmount, depositStartDate(),
calculateMaturityDate(), incentiveAttributes);
if (applicableInterestRate.equals(BigDecimal.ZERO)) {
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode(
"no.applicable.interest.rate.is.found.based.on.amount.and.deposit.period");
}
} else if (this.nominalAnnualInterestRate == null || this.nominalAnnualInterestRate.compareTo(BigDecimal.ZERO) == 0) {
baseDataValidator.reset().parameter(DepositsApiConstants.nominalAnnualInterestRateParamName).value(nominalAnnualInterestRate)
.failWithCodeNoParameterAddedToErrorCode("interest.chart.or.nominal.interest.rate.required");
}
/**
@@ -829,9 +971,9 @@ public class RecurringDepositAccount extends SavingsAccount {
return this.accountTermAndPreClosure.isTransferToSavingsOnClosure();
}
public RecurringDepositAccount reInvest(Money depositAmount) {
public RecurringDepositAccount reInvest(BigDecimal depositAmount) {
final DepositAccountTermAndPreClosure newAccountTermAndPreClosure = this.accountTermAndPreClosure.deepCopy(depositAmount);
final DepositAccountTermAndPreClosure newAccountTermAndPreClosure = this.accountTermAndPreClosure.copy(depositAmount);
final DepositAccountRecurringDetail recurringDetail = this.recurringDetail.copy();
final SavingsProduct product = this.product;
final InterestRateChart productChart = product.applicableChart(getClosedOnDate());
@@ -845,14 +987,14 @@ public class RecurringDepositAccount extends SavingsAccount {
final SavingsInterestCalculationType interestCalculationType = SavingsInterestCalculationType.fromInt(this.interestCalculationType);
final SavingsInterestCalculationDaysInYearType daysInYearType = SavingsInterestCalculationDaysInYearType
.fromInt(this.interestCalculationDaysInYearType);
final BigDecimal minRequiredOpeningBalance = depositAmount.getAmount();
final BigDecimal minRequiredOpeningBalance = depositAmount;
final BigDecimal interestRate = BigDecimal.ZERO;
final Set<SavingsAccountCharge> savingsAccountCharges = null;
final SavingsPeriodFrequencyType lockinPeriodFrequencyType = SavingsPeriodFrequencyType.fromInt(this.lockinPeriodFrequencyType);
final Integer lockinPeriodFrequency = this.lockinPeriodFrequency;
final boolean withdrawalFeeApplicableForTransfer = false;
LocalDate now = LocalDate.now();
LocalDate now = DateUtils.getLocalDateOfTenant();
newAccountTermAndPreClosure.updateExpectedFirstDepositDate(now);
@@ -870,14 +1012,10 @@ public class RecurringDepositAccount extends SavingsAccount {
}
private boolean firstDepositDateBeforeMaturityAndOnOrAfterActivationDate() {
LocalDate expectedFirstDepositLocalDate = accountTermAndPreClosure.getExpectedFirstDepositOnDate();
LocalDate maturityLocalDate = calculateMaturityDate();
LocalDate activateOnSubmittedLocalDate = accountSubmittedOrActivationDate();
if (expectedFirstDepositLocalDate != null) { return expectedFirstDepositLocalDate.isBefore(maturityLocalDate)
&& (activateOnSubmittedLocalDate.isEqual(expectedFirstDepositLocalDate) || activateOnSubmittedLocalDate
.isBefore(expectedFirstDepositLocalDate)); }
return true;
private boolean firstDepositDateBeforeAccountSubmittedOrActivationDate() {
final LocalDate expectedFirstDepositLocalDate = accountTermAndPreClosure.getExpectedFirstDepositOnDate();
if (expectedFirstDepositLocalDate == null) return false;
return expectedFirstDepositLocalDate.isBefore(accountSubmittedOrActivationDate());
}
public void setDatesFrom(final LocalDate now) {
@@ -898,4 +1036,57 @@ public class RecurringDepositAccount extends SavingsAccount {
protected boolean isTransferInterestToOtherAccount() {
return this.accountTermAndPreClosure.isTransferInterestToLinkedAccount();
}
public void generateSchedule(final PeriodFrequencyType frequency, final Integer recurringEvery) {
final List<RecurringDepositScheduleInstallment> depositScheduleInstallments = depositScheduleInstallments();
depositScheduleInstallments.clear();
LocalDate installmentDate = depositStartDate();
final LocalDate maturityDate = calculateMaturityDate();
int installmentNumber = 1;
final BigDecimal depositAmount = this.recurringDetail.mandatoryRecommendedDepositAmount();
while (maturityDate.isAfter(installmentDate)) {
final RecurringDepositScheduleInstallment installment = RecurringDepositScheduleInstallment.installment(this,
installmentNumber, installmentDate.toDate(), depositAmount);
depositScheduleInstallments.add(installment);
installmentDate = calculateNextDepositDate(installmentDate, frequency, recurringEvery);
installmentNumber += 1;
}
}
private List<RecurringDepositScheduleInstallment> depositScheduleInstallments() {
if (this.depositScheduleInstallments == null) {
this.depositScheduleInstallments = new ArrayList<RecurringDepositScheduleInstallment>();
}
return this.depositScheduleInstallments;
}
public boolean isCalendarInherited() {
return this.recurringDetail.isCalendarInherited();
}
public void updateOverduePayments(final LocalDate todayDate) {
LocalDate overdueUptoDate = this.maturityDate();
if (overdueUptoDate.isAfter(todayDate)) {
overdueUptoDate = todayDate;
}
final List<RecurringDepositScheduleInstallment> installments = depositScheduleInstallments();
int noOfOverdueInstallments = 0;
Money totalOverdueAmount = Money.zero(getCurrency());
for (RecurringDepositScheduleInstallment installment : installments) {
if (installment.isNotFullyPaidOff() && overdueUptoDate.isAfter(installment.dueDate())) {
noOfOverdueInstallments++;
totalOverdueAmount = totalOverdueAmount.plus(installment.getDepositAmountOutstanding(getCurrency()));
}
}
this.recurringDetail.updateOverdueDetails(noOfOverdueInstallments, totalOverdueAmount);
}
public boolean allowWithdrawal() {
return this.recurringDetail.allowWithdrawal();
}
public boolean adjustAdvanceTowardsFuturePayments() {
return this.recurringDetail.adjustAdvanceTowardsFuturePayments();
}
}
@@ -6,6 +6,7 @@
package org.mifosplatform.portfolio.savings.domain;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.RECURRING_DEPOSIT_PRODUCT_RESOURCE_NAME;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.maxDepositTermParamName;
import java.math.BigDecimal;
import java.util.ArrayList;
@@ -27,6 +28,7 @@ import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidation
import org.mifosplatform.organisation.monetary.domain.MonetaryCurrency;
import org.mifosplatform.portfolio.charge.domain.Charge;
import org.mifosplatform.portfolio.interestratechart.domain.InterestRateChart;
import org.mifosplatform.portfolio.savings.DepositsApiConstants;
import org.mifosplatform.portfolio.savings.SavingsCompoundingInterestPeriodType;
import org.mifosplatform.portfolio.savings.SavingsInterestCalculationDaysInYearType;
import org.mifosplatform.portfolio.savings.SavingsInterestCalculationType;
@@ -91,6 +93,8 @@ public class RecurringDepositProduct extends FixedDepositProduct {
actualChanges.putAll(this.update(command, baseDataValidator));
validateDomainRules(baseDataValidator);
throwExceptionIfValidationWarningsExist(dataValidationErrors);
return actualChanges;
@@ -103,7 +107,7 @@ public class RecurringDepositProduct extends FixedDepositProduct {
actualChanges.putAll(super.update(command, baseDataValidator));
if (this.recurringDetail != null) {
actualChanges.putAll(this.recurringDetail.update(command, baseDataValidator));
actualChanges.putAll(this.recurringDetail.update(command));
}
return actualChanges;
@@ -117,4 +121,33 @@ public class RecurringDepositProduct extends FixedDepositProduct {
return this.recurringDetail;
}
@Override
public void validateDomainRules() {
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
.resource(RECURRING_DEPOSIT_PRODUCT_RESOURCE_NAME);
validateDomainRules(baseDataValidator);
throwExceptionIfValidationWarningsExist(dataValidationErrors);
}
private void validateDomainRules(final DataValidatorBuilder baseDataValidator) {
final DepositTermDetail termDetails = this.depositProductTermAndPreClosure().depositTermDetail();
final boolean isMinTermGreaterThanMax = termDetails.isMinDepositTermGreaterThanMaxDepositTerm();
if (isMinTermGreaterThanMax) {
final Integer maxTerm = termDetails.maxDepositTerm();
baseDataValidator.reset().parameter(maxDepositTermParamName).value(maxTerm)
.failWithCodeNoParameterAddedToErrorCode("max.term.lessthan.min.term");
}
if (this.charts != null) {
validateCharts(baseDataValidator);
} else if (this.nominalAnnualInterestRate == null || this.nominalAnnualInterestRate.compareTo(BigDecimal.ZERO) == 0) {
baseDataValidator.reset().parameter(DepositsApiConstants.nominalAnnualInterestRateParamName).value(nominalAnnualInterestRate)
.failWithCodeNoParameterAddedToErrorCode("interest.chart.or.nominal.interest.rate.required");
}
this.validateInterestPostingAndCompoundingPeriodTypes(baseDataValidator);
}
}
@@ -0,0 +1,226 @@
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.mifosplatform.portfolio.savings.domain;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.joda.time.LocalDate;
import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom;
import org.mifosplatform.organisation.monetary.domain.MonetaryCurrency;
import org.mifosplatform.organisation.monetary.domain.Money;
import org.mifosplatform.useradministration.domain.AppUser;
@Entity
@Table(name = "m_mandatory_savings_schedule")
public class RecurringDepositScheduleInstallment extends AbstractAuditableCustom<AppUser, Long> {
@ManyToOne(optional = false)
@JoinColumn(name = "savings_account_id")
private RecurringDepositAccount account;
@Column(name = "installment", nullable = false)
private Integer installmentNumber;
@Temporal(TemporalType.DATE)
@Column(name = "fromdate", nullable = true)
private Date fromDate;
@Temporal(TemporalType.DATE)
@Column(name = "duedate", nullable = false)
private Date dueDate;
@Column(name = "deposit_amount", scale = 6, precision = 19, nullable = true)
private BigDecimal depositAmount;
@Column(name = "deposit_amount_completed_derived", scale = 6, precision = 19, nullable = true)
private BigDecimal depositAmountCompleted;
@Column(name = "total_paid_in_advance_derived", scale = 6, precision = 19, nullable = true)
private BigDecimal totalPaidInAdvance;
@Column(name = "total_paid_late_derived", scale = 6, precision = 19, nullable = true)
private BigDecimal totalPaidLate;
@Column(name = "completed_derived", nullable = false)
private boolean obligationsMet;
@Temporal(TemporalType.DATE)
@Column(name = "obligations_met_on_date")
private Date obligationsMetOnDate;
/**
*
*/
protected RecurringDepositScheduleInstallment() {
this.installmentNumber = null;
this.fromDate = null;
this.dueDate = null;
this.obligationsMet = false;
}
/**
* @param account
* @param installmentNumber
* @param fromDate
* @param dueDate
* @param depositAmount
* @param depositAmountCompleted
* @param totalPaidInAdvance
* @param totalPaidLate
* @param obligationsMet
* @param obligationsMetOnDate
*/
private RecurringDepositScheduleInstallment(final RecurringDepositAccount account, final Integer installmentNumber,
final Date fromDate, final Date dueDate, final BigDecimal depositAmount, final BigDecimal depositAmountCompleted,
final BigDecimal totalPaidInAdvance, final BigDecimal totalPaidLate, final boolean obligationsMet,
final Date obligationsMetOnDate) {
this.account = account;
this.installmentNumber = installmentNumber;
this.fromDate = fromDate;
this.dueDate = dueDate;
this.depositAmount = defaultToNullIfZero(depositAmount);
this.depositAmountCompleted = depositAmountCompleted;
this.totalPaidInAdvance = totalPaidInAdvance;
this.totalPaidLate = totalPaidLate;
this.obligationsMet = obligationsMet;
this.obligationsMetOnDate = obligationsMetOnDate;
}
public static RecurringDepositScheduleInstallment from(final RecurringDepositAccount account, final Integer installmentNumber,
final Date fromDate, final Date dueDate, final BigDecimal depositAmount, final BigDecimal depositAmountCompleted,
final BigDecimal totalPaidInAdvance, final BigDecimal totalPaidLate, final boolean obligationsMet,
final Date obligationsMetOnDate) {
return new RecurringDepositScheduleInstallment(account, installmentNumber, fromDate, dueDate, depositAmount,
depositAmountCompleted, totalPaidInAdvance, totalPaidLate, obligationsMet, obligationsMetOnDate);
}
public static RecurringDepositScheduleInstallment installment(final RecurringDepositAccount account, final Integer installmentNumber,
final Date dueDate, final BigDecimal depositAmount) {
final Date fromDate = null;
final BigDecimal depositAmountCompleted = null;
final BigDecimal totalPaidInAdvance = null;
final BigDecimal totalPaidLate = null;
final boolean obligationsMet = false;
final Date obligationsMetOnDate = null;
return new RecurringDepositScheduleInstallment(account, installmentNumber, fromDate, dueDate, depositAmount,
depositAmountCompleted, totalPaidInAdvance, totalPaidLate, obligationsMet, obligationsMetOnDate);
}
private BigDecimal defaultToNullIfZero(final BigDecimal value) {
BigDecimal result = value;
if (BigDecimal.ZERO.compareTo(value) == 0) {
result = null;
}
return result;
}
public boolean isObligationsMet() {
return this.obligationsMet;
}
public boolean isNotFullyPaidOff() {
return !this.obligationsMet;
}
public boolean isPrincipalNotCompleted(final MonetaryCurrency currency) {
return !isPrincipalCompleted(currency);
}
public boolean isPrincipalCompleted(final MonetaryCurrency currency) {
return getDepositAmountOutstanding(currency).isZero();
}
public Money getDepositAmountOutstanding(final MonetaryCurrency currency) {
final Money depositAmountAccountedFor = getDepositAmountCompleted(currency);
return getDepositAmount(currency).minus(depositAmountAccountedFor);
}
public Money getDepositAmountCompleted(final MonetaryCurrency currency) {
return Money.of(currency, this.depositAmountCompleted);
}
public Money getDepositAmount(final MonetaryCurrency currency) {
return Money.of(currency, this.depositAmount);
}
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();
Money depositAmountPortionOfTransaction = Money.zero(currency);
final Money depositAmount = getDepositAmountOutstanding(currency);
if (transactionAmountRemaining.isGreaterThanOrEqualTo(depositAmount)) {
this.depositAmountCompleted = getDepositAmountCompleted(currency).plus(depositAmount).getAmount();
depositAmountPortionOfTransaction = depositAmountPortionOfTransaction.plus(depositAmount);
} else {
this.depositAmountCompleted = getDepositAmountCompleted(currency).plus(transactionAmountRemaining).getAmount();
depositAmountPortionOfTransaction = depositAmountPortionOfTransaction.plus(transactionAmountRemaining);
}
this.depositAmountCompleted = defaultToNullIfZero(this.depositAmountCompleted);
checkIfInstallmentObligationsAreMet(transactionDate, currency);
trackAdvanceAndLateTotalsForInstallment(transactionDate, currency, depositAmountPortionOfTransaction);
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)) {
this.totalPaidInAdvance = asMoney(this.totalPaidInAdvance, currency).plus(amountPaidInInstallment).getAmount();
} else if (isLatePayment(transactionDate)) {
this.totalPaidLate = asMoney(this.totalPaidLate, currency).plus(amountPaidInInstallment).getAmount();
}
}
private boolean isInAdvance(final LocalDate transactionDate) {
return transactionDate.isBefore(dueDate());
}
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(){
this.depositAmountCompleted = null;
this.totalPaidInAdvance = null;
this.totalPaidLate = null;
this.obligationsMet = false;
this.obligationsMetOnDate = null;
}
}
@@ -82,6 +82,7 @@ import org.mifosplatform.portfolio.savings.SavingsPostingInterestPeriodType;
import org.mifosplatform.portfolio.savings.data.SavingsAccountTransactionDTO;
import org.mifosplatform.portfolio.savings.domain.interest.PostingPeriod;
import org.mifosplatform.portfolio.savings.exception.InsufficientAccountBalanceException;
import org.mifosplatform.portfolio.savings.exception.SavingsAccountTransactionNotFoundException;
import org.mifosplatform.portfolio.savings.exception.SavingsActivityPriorToClientTransferException;
import org.mifosplatform.portfolio.savings.exception.SavingsTransferTransactionsCannotBeUndoneException;
import org.mifosplatform.portfolio.savings.service.SavingsEnumerations;
@@ -583,13 +584,16 @@ public class SavingsAccount extends AbstractPersistable<Long> {
if (isTransactionsModified) {
accountTransactionsSorted = retreiveListOfTransactions();
}
// loop over transactions in reverse
resetAccountTransactionsEndOfDayBalances(accountTransactionsSorted, interestPostingUpToDate);
}
protected void resetAccountTransactionsEndOfDayBalances(final List<SavingsAccountTransaction> accountTransactionsSorted, final LocalDate interestPostingUpToDate) {
// loop over transactions in reverse
LocalDate endOfBalanceDate = interestPostingUpToDate;
for (int i = accountTransactionsSorted.size() - 1; i >= 0; i--) {
final SavingsAccountTransaction transaction = accountTransactionsSorted.get(i);
if (transaction.isNotReversed() && !transaction.isInterestPostingAndNotReversed()) {
transaction.updateCumulativeBalanceAndDates(this.currency, endOfBalanceDate);
// this transactions transaction date is end of balance date for
// previous transaction.
endOfBalanceDate = transaction.transactionLocalDate().minusDays(1);
@@ -598,11 +602,12 @@ public class SavingsAccount extends AbstractPersistable<Long> {
}
public SavingsAccountTransaction deposit(final SavingsAccountTransactionDTO transactionDTO) {
final String resourceTypeName = depositAccountType().resourceName();
if (isNotActive()) {
final String defaultUserMessage = "Transaction is not allowed. Account is not active.";
final ApiParameterError error = ApiParameterError.parameterError("error.msg.savingsaccount.transaction.account.is.not.active",
defaultUserMessage, "transactionDate", transactionDTO.getTransactionDate().toString(transactionDTO.getFormatter()));
final ApiParameterError error = ApiParameterError.parameterError("error.msg." + resourceTypeName
+ ".transaction.account.is.not.active", defaultUserMessage, "transactionDate", transactionDTO.getTransactionDate()
.toString(transactionDTO.getFormatter()));
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
dataValidationErrors.add(error);
@@ -612,7 +617,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
if (isDateInTheFuture(transactionDTO.getTransactionDate())) {
final String defaultUserMessage = "Transaction date cannot be in the future.";
final ApiParameterError error = ApiParameterError.parameterError("error.msg.savingsaccount.transaction.in.the.future",
final ApiParameterError error = ApiParameterError.parameterError("error.msg." + resourceTypeName + ".transaction.in.the.future",
defaultUserMessage, "transactionDate", transactionDTO.getTransactionDate().toString(transactionDTO.getFormatter()));
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
@@ -625,8 +630,8 @@ public class SavingsAccount extends AbstractPersistable<Long> {
final Object[] defaultUserArgs = Arrays.asList(transactionDTO.getTransactionDate().toString(transactionDTO.getFormatter()),
getActivationLocalDate().toString(transactionDTO.getFormatter())).toArray();
final String defaultUserMessage = "Transaction date cannot be before accounts activation date.";
final ApiParameterError error = ApiParameterError.parameterError("error.msg.savingsaccount.transaction.before.activation.date",
defaultUserMessage, "transactionDate", defaultUserArgs);
final ApiParameterError error = ApiParameterError.parameterError("error.msg." + resourceTypeName
+ ".transaction.before.activation.date", defaultUserMessage, "transactionDate", defaultUserArgs);
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
dataValidationErrors.add(error);
@@ -785,7 +790,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
//
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
.resource(SAVINGS_ACCOUNT_RESOURCE_NAME + transactionAction);
.resource(depositAccountType().resourceName() + transactionAction);
if (this.allowOverdraft) {
Money limit = runningBalance.zero();
@@ -803,7 +808,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
}
}
private boolean isAccountLocked(final LocalDate transactionDate) {
protected boolean isAccountLocked(final LocalDate transactionDate) {
boolean isLocked = false;
final boolean accountHasLockedInSetting = this.lockedInUntilDate != null;
if (accountHasLockedInSetting) {
@@ -1308,24 +1313,20 @@ public class SavingsAccount extends AbstractPersistable<Long> {
}
}
if (transactionToUndo == null) {
// throw non found exception
} else {
validateAttemptToUndoTransferRelatedTransactions(transactionToUndo);
validateActivityNotBeforeClientOrGroupTransferDate(SavingsEvent.SAVINGS_UNDO_TRANSACTION,
transactionToUndo.transactionLocalDate());
transactionToUndo.reverse();
if (transactionToUndo.isChargeTransaction() || transactionToUndo.isWaiveCharge()) {
// undo charge
final Set<SavingsAccountChargePaidBy> chargesPaidBy = transactionToUndo.getSavingsAccountChargesPaid();
for (final SavingsAccountChargePaidBy savingsAccountChargePaidBy : chargesPaidBy) {
final SavingsAccountCharge chargeToUndo = savingsAccountChargePaidBy.getSavingsAccountCharge();
if (transactionToUndo.isChargeTransaction()) {
chargeToUndo.undoPayment(this.getCurrency(), transactionToUndo.getAmount(this.getCurrency()));
} else if (transactionToUndo.isWaiveCharge()) {
chargeToUndo.undoWaiver(this.getCurrency(), transactionToUndo.getAmount(this.getCurrency()));
}
if (transactionToUndo == null) { throw new SavingsAccountTransactionNotFoundException(this.getId(), transactionId); }
validateAttemptToUndoTransferRelatedTransactions(transactionToUndo);
validateActivityNotBeforeClientOrGroupTransferDate(SavingsEvent.SAVINGS_UNDO_TRANSACTION, transactionToUndo.transactionLocalDate());
transactionToUndo.reverse();
if (transactionToUndo.isChargeTransaction() || transactionToUndo.isWaiveCharge()) {
// undo charge
final Set<SavingsAccountChargePaidBy> chargesPaidBy = transactionToUndo.getSavingsAccountChargesPaid();
for (final SavingsAccountChargePaidBy savingsAccountChargePaidBy : chargesPaidBy) {
final SavingsAccountCharge chargeToUndo = savingsAccountChargePaidBy.getSavingsAccountCharge();
if (transactionToUndo.isChargeTransaction()) {
chargeToUndo.undoPayment(this.getCurrency(), transactionToUndo.getAmount(this.getCurrency()));
} else if (transactionToUndo.isWaiveCharge()) {
chargeToUndo.undoWaiver(this.getCurrency(), transactionToUndo.getAmount(this.getCurrency()));
}
}
}
@@ -1478,7 +1479,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
.resource(SAVINGS_ACCOUNT_RESOURCE_NAME + SavingsApiConstants.activateAction);
.resource(depositAccountType().resourceName() + SavingsApiConstants.activateAction);
final SavingsAccountStatusType currentStatus = SavingsAccountStatusType.fromInt(this.status);
if (!SavingsAccountStatusType.APPROVED.hasStateOf(currentStatus)) {
@@ -2043,4 +2044,10 @@ public class SavingsAccount extends AbstractPersistable<Long> {
protected boolean isTransferInterestToOtherAccount() {
return false;
}
public boolean accountSubmittedAndActivationOnSameDate() {
if (getSubmittedOnLocalDate() == null || getActivationLocalDate() == null) { return false; }
return getActivationLocalDate().isEqual(getSubmittedOnLocalDate());
}
}
@@ -5,8 +5,8 @@
*/
package org.mifosplatform.portfolio.savings.domain;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.accountNoParamName;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.SAVINGS_ACCOUNT_RESOURCE_NAME;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.accountNoParamName;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.allowOverdraftParamName;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.clientIdParamName;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.externalIdParamName;
@@ -215,7 +215,7 @@ public class SavingsProduct extends AbstractPersistable<Long> {
}
public BigDecimal nominalAnnualInterestRate() {
return Money.of(this.currency, this.nominalAnnualInterestRate).getAmount();
return this.nominalAnnualInterestRate;
}
public SavingsCompoundingInterestPeriodType interestCompoundingPeriodType() {
@@ -6,7 +6,6 @@ import java.math.RoundingMode;
import org.joda.time.LocalDate;
import org.mifosplatform.infrastructure.core.domain.LocalDateInterval;
import org.mifosplatform.infrastructure.core.service.DateUtils;
import org.mifosplatform.organisation.monetary.domain.Money;
public class EndOfDayBalance {
@@ -118,6 +118,8 @@ public class MonthlyCompoundingPeriod implements CompoundingPeriod {
// break;
case INVALID:
break;
default:
break;
}
interestEarned = interestEarned.add(interestOnBalanceUnrounded);
@@ -14,18 +14,18 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
public class CloseDepositAccountCommandHandler implements NewCommandSourceHandler {
public class ActivateFixedDepositAccountCommandHandler implements NewCommandSourceHandler {
private final DepositAccountWritePlatformService depositAccountWritePlatformService;
@Autowired
public CloseDepositAccountCommandHandler(final DepositAccountWritePlatformService depositAccountWritePlatformService) {
public ActivateFixedDepositAccountCommandHandler(final DepositAccountWritePlatformService depositAccountWritePlatformService) {
this.depositAccountWritePlatformService = depositAccountWritePlatformService;
}
@Transactional
@Override
public CommandProcessingResult processCommand(final JsonCommand command) {
return this.depositAccountWritePlatformService.close(command.entityId(), command, command.depositAccounttype());
return this.depositAccountWritePlatformService.activateFDAccount(command.entityId(), command);
}
}
@@ -14,18 +14,18 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
public class CalculateInterestDepositAccountCommandHandler implements NewCommandSourceHandler {
public class ActivateRecurringDepositAccountCommandHandler implements NewCommandSourceHandler {
private final DepositAccountWritePlatformService depositAccountWritePlatformService;
@Autowired
public CalculateInterestDepositAccountCommandHandler(final DepositAccountWritePlatformService depositAccountWritePlatformService) {
public ActivateRecurringDepositAccountCommandHandler(final DepositAccountWritePlatformService depositAccountWritePlatformService) {
this.depositAccountWritePlatformService = depositAccountWritePlatformService;
}
@Transactional
@Override
public CommandProcessingResult processCommand(final JsonCommand command) {
return this.depositAccountWritePlatformService.calculateInterest(command.entityId(), command.depositAccounttype());
return this.depositAccountWritePlatformService.activateRDAccount(command.entityId(), command);
}
}
@@ -0,0 +1,32 @@
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.mifosplatform.portfolio.savings.handler;
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
import org.mifosplatform.infrastructure.core.api.JsonCommand;
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
import org.mifosplatform.portfolio.savings.DepositAccountType;
import org.mifosplatform.portfolio.savings.service.DepositAccountWritePlatformService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
public class CalculateInterestFixedDepositAccountCommandHandler implements NewCommandSourceHandler {
private final DepositAccountWritePlatformService depositAccountWritePlatformService;
@Autowired
public CalculateInterestFixedDepositAccountCommandHandler(final DepositAccountWritePlatformService depositAccountWritePlatformService) {
this.depositAccountWritePlatformService = depositAccountWritePlatformService;
}
@Transactional
@Override
public CommandProcessingResult processCommand(final JsonCommand command) {
return this.depositAccountWritePlatformService.calculateInterest(command.entityId(), DepositAccountType.FIXED_DEPOSIT);
}
}
@@ -0,0 +1,32 @@
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.mifosplatform.portfolio.savings.handler;
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
import org.mifosplatform.infrastructure.core.api.JsonCommand;
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
import org.mifosplatform.portfolio.savings.DepositAccountType;
import org.mifosplatform.portfolio.savings.service.DepositAccountWritePlatformService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
public class CalculateInterestRecurringDepositAccountCommandHandler implements NewCommandSourceHandler {
private final DepositAccountWritePlatformService depositAccountWritePlatformService;
@Autowired
public CalculateInterestRecurringDepositAccountCommandHandler(final DepositAccountWritePlatformService depositAccountWritePlatformService) {
this.depositAccountWritePlatformService = depositAccountWritePlatformService;
}
@Transactional
@Override
public CommandProcessingResult processCommand(final JsonCommand command) {
return this.depositAccountWritePlatformService.calculateInterest(command.entityId(), DepositAccountType.RECURRING_DEPOSIT);
}
}
@@ -14,18 +14,18 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
public class DepositAccountDepositCommandHandler implements NewCommandSourceHandler {
public class CloseFixedDepositAccountCommandHandler implements NewCommandSourceHandler {
private final DepositAccountWritePlatformService depositAccountWritePlatformService;
@Autowired
public DepositAccountDepositCommandHandler(final DepositAccountWritePlatformService depositAccountWritePlatformService) {
public CloseFixedDepositAccountCommandHandler(final DepositAccountWritePlatformService depositAccountWritePlatformService) {
this.depositAccountWritePlatformService = depositAccountWritePlatformService;
}
@Transactional
@Override
public CommandProcessingResult processCommand(final JsonCommand command) {
return this.depositAccountWritePlatformService.deposit(command.entityId(), command, command.depositAccounttype());
return this.depositAccountWritePlatformService.closeFDAccount(command.entityId(), command);
}
}

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