Added support to mandatory savings

This commit is contained in:
ashok-conflux
2014-05-24 21:47:11 +05:30
parent b2131b52a7
commit 2f8278331e
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; package org.mifosplatform.commands.domain;
import org.mifosplatform.portfolio.savings.DepositAccountType;
public class CommandWrapper { public class CommandWrapper {
@@ -28,8 +27,6 @@ public class CommandWrapper {
@SuppressWarnings("unused") @SuppressWarnings("unused")
private Long templateId; 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) { 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); 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, 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 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, final String json, final String transactionId, final Long productId, final Long templateId) {
DepositAccountType depositAccountType) {
this.commandId = null; this.commandId = null;
this.officeId = officeId; this.officeId = officeId;
@@ -87,8 +83,6 @@ public class CommandWrapper {
this.transactionId = transactionId; this.transactionId = transactionId;
this.productId = productId; this.productId = productId;
this.templateId = templateId; this.templateId = templateId;
this.interestRatechartId = interestRatechartId;
this.depositAccountType = depositAccountType;
} }
private CommandWrapper(final Long commandId, final String actionName, final String entityName, final Long resourceId, 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"); return this.entityName.equalsIgnoreCase("CACHE");
} }
public Long interestRatechartId() {
return this.interestRatechartId;
}
// Begin - Deposit product // Begin - Deposit product
public boolean isFixedDepositProductResource() { public boolean isFixedDepositProductResource() {
return this.entityName.equalsIgnoreCase("FIXEDDEPOSITPRODUCT"); return this.entityName.equalsIgnoreCase("FIXEDDEPOSITPRODUCT");
@@ -737,53 +727,101 @@ public class CommandWrapper {
// Begin - Deposit accounts // Begin - Deposit accounts
public boolean isDepositAccountResource() { public boolean isDepositAccountResource() {
return this.entityName.equalsIgnoreCase("FIXEDDEPOSITACCOUNT") || this.entityName.equalsIgnoreCase("RECURRINGDEPOSITACCOUNT"); return isFixedDepositAccountResource() || isRecurringDepositAccountResource();
} }
public boolean isRejectionOfDepositAccountApplication() { public boolean isFixedDepositAccountResource() {
return this.actionName.equalsIgnoreCase("REJECT") && isDepositAccountResource(); return this.entityName.equalsIgnoreCase("FIXEDDEPOSITACCOUNT");
} }
public boolean isWithdrawFromDepositAccountApplicationByApplicant() { public boolean isRecurringDepositAccountResource() {
return this.actionName.equalsIgnoreCase("WITHDRAW") && isDepositAccountResource(); return this.entityName.equalsIgnoreCase("RECURRINGDEPOSITACCOUNT");
} }
public boolean isApprovalOfDepositAccountApplication() { public boolean isFixedDepositAccountCreate() {
return this.actionName.equalsIgnoreCase("APPROVE") && isDepositAccountResource(); 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() { public boolean isUndoApprovalOfFixedDepositAccountApplication() {
return this.actionName.equalsIgnoreCase("APPROVALUNDO") && isDepositAccountResource(); return this.actionName.equalsIgnoreCase("APPROVALUNDO") && isFixedDepositAccountResource();
}
public boolean isUndoApprovalOfRecurringDepositAccountApplication() {
return this.actionName.equalsIgnoreCase("APPROVALUNDO") && isRecurringDepositAccountResource();
} }
//Account transaction actions //Account transaction actions
public boolean isDepositAccountDeposit() { public boolean isDeposit() {
return this.actionName.equalsIgnoreCase("DEPOSIT") && isDepositAccountResource(); return this.actionName.equalsIgnoreCase("DEPOSIT");
} }
public boolean isDepositAccountWithdrawal() { public boolean isWithdrawal() {
return this.actionName.equalsIgnoreCase("WITHDRAWAL") && isDepositAccountResource(); return this.actionName.equalsIgnoreCase("WITHDRAWAL");
} }
public boolean isDepositAccountActivation() { public boolean isActivation() {
return this.actionName.equalsIgnoreCase("ACTIVATE") && isDepositAccountResource(); return this.actionName.equalsIgnoreCase("ACTIVATE");
} }
public boolean isDepositAccountInterestCalculation() { public boolean isInterestCalculation() {
return this.actionName.equalsIgnoreCase("CALCULATEINTEREST") && isDepositAccountResource(); return this.actionName.equalsIgnoreCase("CALCULATEINTEREST");
} }
public boolean isDepositAccountInterestPosting() { public boolean isInterestPosting() {
return this.actionName.equalsIgnoreCase("POSTINTEREST") && isDepositAccountResource(); return this.actionName.equalsIgnoreCase("POSTINTEREST");
} }
public boolean isDepositAccountUndoTransaction() { public boolean isUndoTransaction() {
return this.actionName.equalsIgnoreCase("UNDOTRANSACTION") && isDepositAccountResource(); return this.actionName.equalsIgnoreCase("UNDOTRANSACTION");
} }
public boolean isAdjustDeopsitAccountTransaction() { public boolean isAdjustTransaction() {
return this.actionName.equalsIgnoreCase("ADJUSTTRANSACTION") && isDepositAccountResource(); return this.actionName.equalsIgnoreCase("ADJUSTTRANSACTION");
} }
public boolean isDepositAccountClose() { public boolean isDepositAccountClose() {
@@ -795,8 +833,4 @@ public class CommandWrapper {
} }
// End - Deposit accounts // End - Deposit accounts
public DepositAccountType depositAccountType(){
return this.depositAccountType;
}
} }
@@ -6,7 +6,6 @@
package org.mifosplatform.commands.service; package org.mifosplatform.commands.service;
import org.mifosplatform.commands.domain.CommandWrapper; import org.mifosplatform.commands.domain.CommandWrapper;
import org.mifosplatform.portfolio.savings.DepositAccountType;
public class CommandWrapperBuilder { public class CommandWrapperBuilder {
@@ -24,13 +23,11 @@ public class CommandWrapperBuilder {
private String transactionId; private String transactionId;
private Long productId; private Long productId;
private Long templateId; private Long templateId;
private Long interestRatechartId;
private DepositAccountType depositAccountType;
public CommandWrapper build() { public CommandWrapper build() {
return new CommandWrapper(this.officeId, this.groupId, this.clientId, this.loanId, this.savingsId, this.actionName, 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.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) { public CommandWrapperBuilder withLoanId(final Long withLoanId) {
@@ -1185,7 +1182,7 @@ public class CommandWrapperBuilder {
this.actionName = "CREATE"; this.actionName = "CREATE";
this.entityName = "CHARTSLAB"; this.entityName = "CHARTSLAB";
this.entityId = null; this.entityId = null;
this.interestRatechartId = chartId; this.subentityId = chartId; //refer to chart id
this.href = "/interestratechart/" + chartId + "/chartdetails/template"; this.href = "/interestratechart/" + chartId + "/chartdetails/template";
return this; return this;
} }
@@ -1194,7 +1191,7 @@ public class CommandWrapperBuilder {
this.actionName = "UPDATE"; this.actionName = "UPDATE";
this.entityName = "CHARTSLAB"; this.entityName = "CHARTSLAB";
this.entityId = chartSlabId; this.entityId = chartSlabId;
this.interestRatechartId = chartId; this.subentityId = chartId;//refers parent chart
this.href = "/interestratechart/" + chartId + "/chartdetails/" + chartSlabId; this.href = "/interestratechart/" + chartId + "/chartdetails/" + chartSlabId;
return this; return this;
} }
@@ -1203,7 +1200,7 @@ public class CommandWrapperBuilder {
this.actionName = "DELETE"; this.actionName = "DELETE";
this.entityName = "CHARTSLAB"; this.entityName = "CHARTSLAB";
this.entityId = chartSlabId; this.entityId = chartSlabId;
this.interestRatechartId = chartId; this.subentityId = chartId;//refers parent chart
this.href = "/interestratechart/" + chartId + "/chartdetails/" + chartSlabId; this.href = "/interestratechart/" + chartId + "/chartdetails/" + chartSlabId;
return this; return this;
} }
@@ -1698,7 +1695,6 @@ public class CommandWrapperBuilder {
this.actionName = "CREATE"; this.actionName = "CREATE";
this.entityName = "FIXEDDEPOSITACCOUNT"; this.entityName = "FIXEDDEPOSITACCOUNT";
this.entityId = null; this.entityId = null;
this.depositAccountType = DepositAccountType.FIXED_DEPOSIT;
this.href = "/fixeddepositaccounts/template"; this.href = "/fixeddepositaccounts/template";
return this; return this;
} }
@@ -1707,7 +1703,6 @@ public class CommandWrapperBuilder {
this.actionName = "UPDATE"; this.actionName = "UPDATE";
this.entityName = "FIXEDDEPOSITACCOUNT"; this.entityName = "FIXEDDEPOSITACCOUNT";
this.entityId = accountId; this.entityId = accountId;
this.depositAccountType = DepositAccountType.FIXED_DEPOSIT;
this.href = "/fixeddepositaccounts/" + accountId; this.href = "/fixeddepositaccounts/" + accountId;
return this; return this;
} }
@@ -1716,7 +1711,6 @@ public class CommandWrapperBuilder {
this.actionName = "DELETE"; this.actionName = "DELETE";
this.entityName = "FIXEDDEPOSITACCOUNT"; this.entityName = "FIXEDDEPOSITACCOUNT";
this.entityId = accountId; this.entityId = accountId;
this.depositAccountType = DepositAccountType.FIXED_DEPOSIT;
this.href = "/fixeddepositaccounts/" + accountId; this.href = "/fixeddepositaccounts/" + accountId;
return this; return this;
} }
@@ -1726,7 +1720,6 @@ public class CommandWrapperBuilder {
this.entityName = "FIXEDDEPOSITACCOUNT"; this.entityName = "FIXEDDEPOSITACCOUNT";
this.entityId = accountId; this.entityId = accountId;
this.savingsId = accountId; this.savingsId = accountId;
this.depositAccountType = DepositAccountType.FIXED_DEPOSIT;
this.href = "/fixeddepositaccounts/" + accountId + "?command=reject"; this.href = "/fixeddepositaccounts/" + accountId + "?command=reject";
return this; return this;
} }
@@ -1736,7 +1729,6 @@ public class CommandWrapperBuilder {
this.entityName = "FIXEDDEPOSITACCOUNT"; this.entityName = "FIXEDDEPOSITACCOUNT";
this.entityId = accountId; this.entityId = accountId;
this.savingsId = accountId; this.savingsId = accountId;
this.depositAccountType = DepositAccountType.FIXED_DEPOSIT;
this.href = "/fixeddepositaccounts/" + accountId + "?command=withdrawnByApplicant"; this.href = "/fixeddepositaccounts/" + accountId + "?command=withdrawnByApplicant";
return this; return this;
} }
@@ -1746,7 +1738,6 @@ public class CommandWrapperBuilder {
this.entityName = "FIXEDDEPOSITACCOUNT"; this.entityName = "FIXEDDEPOSITACCOUNT";
this.entityId = accountId; this.entityId = accountId;
this.savingsId = accountId; this.savingsId = accountId;
this.depositAccountType = DepositAccountType.FIXED_DEPOSIT;
this.href = "/fixeddepositaccounts/" + accountId + "?command=approve"; this.href = "/fixeddepositaccounts/" + accountId + "?command=approve";
return this; return this;
} }
@@ -1756,7 +1747,6 @@ public class CommandWrapperBuilder {
this.entityName = "FIXEDDEPOSITACCOUNT"; this.entityName = "FIXEDDEPOSITACCOUNT";
this.entityId = accountId; this.entityId = accountId;
this.savingsId = accountId; this.savingsId = accountId;
this.depositAccountType = DepositAccountType.FIXED_DEPOSIT;
this.href = "/fixeddepositaccounts/" + accountId + "?command=undoapproval"; this.href = "/fixeddepositaccounts/" + accountId + "?command=undoapproval";
return this; return this;
} }
@@ -1766,7 +1756,6 @@ public class CommandWrapperBuilder {
this.entityName = "FIXEDDEPOSITACCOUNT"; this.entityName = "FIXEDDEPOSITACCOUNT";
this.savingsId = accountId; this.savingsId = accountId;
this.entityId = accountId; this.entityId = accountId;
this.depositAccountType = DepositAccountType.FIXED_DEPOSIT;
this.href = "/fixeddepositaccounts/" + accountId + "?command=activate"; this.href = "/fixeddepositaccounts/" + accountId + "?command=activate";
return this; return this;
} }
@@ -1776,7 +1765,6 @@ public class CommandWrapperBuilder {
this.entityName = "FIXEDDEPOSITACCOUNT"; this.entityName = "FIXEDDEPOSITACCOUNT";
this.entityId = accountId; this.entityId = accountId;
this.savingsId = accountId; this.savingsId = accountId;
this.depositAccountType = DepositAccountType.FIXED_DEPOSIT;
this.href = "/fixeddepositaccounts/" + accountId + "?command=close"; this.href = "/fixeddepositaccounts/" + accountId + "?command=close";
return this; return this;
} }
@@ -1786,7 +1774,6 @@ public class CommandWrapperBuilder {
this.entityName = "FIXEDDEPOSITACCOUNT"; this.entityName = "FIXEDDEPOSITACCOUNT";
this.entityId = accountId; this.entityId = accountId;
this.savingsId = accountId; this.savingsId = accountId;
this.depositAccountType = DepositAccountType.FIXED_DEPOSIT;
this.href = "/fixeddepositaccounts/" + accountId + "?command=prematureClose"; this.href = "/fixeddepositaccounts/" + accountId + "?command=prematureClose";
return this; return this;
} }
@@ -1796,7 +1783,6 @@ public class CommandWrapperBuilder {
this.entityName = "FIXEDDEPOSITACCOUNT"; this.entityName = "FIXEDDEPOSITACCOUNT";
this.savingsId = accountId; this.savingsId = accountId;
this.entityId = accountId; this.entityId = accountId;
this.depositAccountType = DepositAccountType.FIXED_DEPOSIT;
this.href = "/fixeddepositaccounts/" + accountId + "?command=calculateInterest"; this.href = "/fixeddepositaccounts/" + accountId + "?command=calculateInterest";
return this; return this;
} }
@@ -1806,7 +1792,6 @@ public class CommandWrapperBuilder {
this.entityName = "FIXEDDEPOSITACCOUNT"; this.entityName = "FIXEDDEPOSITACCOUNT";
this.savingsId = accountId; this.savingsId = accountId;
this.entityId = accountId; this.entityId = accountId;
this.depositAccountType = DepositAccountType.FIXED_DEPOSIT;
this.href = "/fixeddepositaccounts/" + accountId + "?command=postInterest"; this.href = "/fixeddepositaccounts/" + accountId + "?command=postInterest";
return this; return this;
} }
@@ -1815,7 +1800,6 @@ public class CommandWrapperBuilder {
this.actionName = "DEPOSIT"; this.actionName = "DEPOSIT";
this.entityName = "FIXEDDEPOSITACCOUNT"; this.entityName = "FIXEDDEPOSITACCOUNT";
this.savingsId = accountId; this.savingsId = accountId;
this.depositAccountType = DepositAccountType.FIXED_DEPOSIT;
this.entityId = accountId; this.entityId = accountId;
this.href = "/fixeddepositaccounts/" + accountId + "/transactions?command=deposit"; this.href = "/fixeddepositaccounts/" + accountId + "/transactions?command=deposit";
return this; return this;
@@ -1825,7 +1809,6 @@ public class CommandWrapperBuilder {
this.actionName = "WITHDRAWAL"; this.actionName = "WITHDRAWAL";
this.entityName = "FIXEDDEPOSITACCOUNT"; this.entityName = "FIXEDDEPOSITACCOUNT";
this.savingsId = accountId; this.savingsId = accountId;
this.depositAccountType = DepositAccountType.FIXED_DEPOSIT;
this.entityId = accountId; this.entityId = accountId;
this.href = "/fixeddepositaccounts/" + accountId + "/transactions?command=withdrawal"; this.href = "/fixeddepositaccounts/" + accountId + "/transactions?command=withdrawal";
return this; return this;
@@ -1835,7 +1818,6 @@ public class CommandWrapperBuilder {
this.actionName = "CREATE"; this.actionName = "CREATE";
this.entityName = "RECURRINGDEPOSITACCOUNT"; this.entityName = "RECURRINGDEPOSITACCOUNT";
this.entityId = null; this.entityId = null;
this.depositAccountType = DepositAccountType.RECURRING_DEPOSIT;
this.href = "/recurringdepositaccounts/template"; this.href = "/recurringdepositaccounts/template";
return this; return this;
} }
@@ -1844,7 +1826,6 @@ public class CommandWrapperBuilder {
this.actionName = "UPDATE"; this.actionName = "UPDATE";
this.entityName = "RECURRINGDEPOSITACCOUNT"; this.entityName = "RECURRINGDEPOSITACCOUNT";
this.entityId = accountId; this.entityId = accountId;
this.depositAccountType = DepositAccountType.RECURRING_DEPOSIT;
this.href = "/recurringdepositaccounts/" + accountId; this.href = "/recurringdepositaccounts/" + accountId;
return this; return this;
} }
@@ -1853,7 +1834,6 @@ public class CommandWrapperBuilder {
this.actionName = "DEPOSIT"; this.actionName = "DEPOSIT";
this.entityName = "RECURRINGDEPOSITACCOUNT"; this.entityName = "RECURRINGDEPOSITACCOUNT";
this.savingsId = accountId; this.savingsId = accountId;
this.depositAccountType = DepositAccountType.RECURRING_DEPOSIT;
this.entityId = accountId; this.entityId = accountId;
this.href = "/recurringdepositaccounts/" + accountId + "/transactions?command=deposit"; this.href = "/recurringdepositaccounts/" + accountId + "/transactions?command=deposit";
return this; return this;
@@ -1863,7 +1843,6 @@ public class CommandWrapperBuilder {
this.actionName = "WITHDRAWAL"; this.actionName = "WITHDRAWAL";
this.entityName = "RECURRINGDEPOSITACCOUNT"; this.entityName = "RECURRINGDEPOSITACCOUNT";
this.savingsId = accountId; this.savingsId = accountId;
this.depositAccountType = DepositAccountType.RECURRING_DEPOSIT;
this.entityId = accountId; this.entityId = accountId;
this.href = "/recurringdepositaccounts/" + accountId + "/transactions?command=withdrawal"; this.href = "/recurringdepositaccounts/" + accountId + "/transactions?command=withdrawal";
return this; return this;
@@ -1874,7 +1853,6 @@ public class CommandWrapperBuilder {
this.entityName = "RECURRINGDEPOSITACCOUNT"; this.entityName = "RECURRINGDEPOSITACCOUNT";
this.savingsId = accountId; this.savingsId = accountId;
this.entityId = accountId; this.entityId = accountId;
this.depositAccountType = DepositAccountType.RECURRING_DEPOSIT;
this.subentityId = transactionId; this.subentityId = transactionId;
this.transactionId = transactionId.toString(); this.transactionId = transactionId.toString();
this.href = "/recurringdepositaccounts/" + accountId + "/transactions/" + transactionId + "?command=modify"; this.href = "/recurringdepositaccounts/" + accountId + "/transactions/" + transactionId + "?command=modify";
@@ -1886,7 +1864,6 @@ public class CommandWrapperBuilder {
this.entityName = "RECURRINGDEPOSITACCOUNT"; this.entityName = "RECURRINGDEPOSITACCOUNT";
this.savingsId = accountId; this.savingsId = accountId;
this.entityId = accountId; this.entityId = accountId;
this.depositAccountType = DepositAccountType.RECURRING_DEPOSIT;
this.subentityId = transactionId; this.subentityId = transactionId;
this.transactionId = transactionId.toString(); this.transactionId = transactionId.toString();
this.href = "/recurringdepositaccounts/" + accountId + "/transactions/" + transactionId + "?command=undo"; this.href = "/recurringdepositaccounts/" + accountId + "/transactions/" + transactionId + "?command=undo";
@@ -1897,7 +1874,6 @@ public class CommandWrapperBuilder {
this.actionName = "DELETE"; this.actionName = "DELETE";
this.entityName = "RECURRINGDEPOSITACCOUNT"; this.entityName = "RECURRINGDEPOSITACCOUNT";
this.entityId = accountId; this.entityId = accountId;
this.depositAccountType = DepositAccountType.RECURRING_DEPOSIT;
this.href = "/recurringdepositaccounts/" + accountId; this.href = "/recurringdepositaccounts/" + accountId;
return this; return this;
} }
@@ -1907,7 +1883,6 @@ public class CommandWrapperBuilder {
this.entityName = "RECURRINGDEPOSITACCOUNT"; this.entityName = "RECURRINGDEPOSITACCOUNT";
this.entityId = accountId; this.entityId = accountId;
this.savingsId = accountId; this.savingsId = accountId;
this.depositAccountType = DepositAccountType.RECURRING_DEPOSIT;
this.href = "/recurringdepositaccounts/" + accountId + "?command=reject"; this.href = "/recurringdepositaccounts/" + accountId + "?command=reject";
return this; return this;
} }
@@ -1917,7 +1892,6 @@ public class CommandWrapperBuilder {
this.entityName = "RECURRINGDEPOSITACCOUNT"; this.entityName = "RECURRINGDEPOSITACCOUNT";
this.entityId = accountId; this.entityId = accountId;
this.savingsId = accountId; this.savingsId = accountId;
this.depositAccountType = DepositAccountType.RECURRING_DEPOSIT;
this.href = "/recurringdepositaccounts/" + accountId + "?command=withdrawnByApplicant"; this.href = "/recurringdepositaccounts/" + accountId + "?command=withdrawnByApplicant";
return this; return this;
} }
@@ -1927,7 +1901,6 @@ public class CommandWrapperBuilder {
this.entityName = "RECURRINGDEPOSITACCOUNT"; this.entityName = "RECURRINGDEPOSITACCOUNT";
this.entityId = accountId; this.entityId = accountId;
this.savingsId = accountId; this.savingsId = accountId;
this.depositAccountType = DepositAccountType.RECURRING_DEPOSIT;
this.href = "/recurringdepositaccounts/" + accountId + "?command=approve"; this.href = "/recurringdepositaccounts/" + accountId + "?command=approve";
return this; return this;
} }
@@ -1937,7 +1910,6 @@ public class CommandWrapperBuilder {
this.entityName = "RECURRINGDEPOSITACCOUNT"; this.entityName = "RECURRINGDEPOSITACCOUNT";
this.entityId = accountId; this.entityId = accountId;
this.savingsId = accountId; this.savingsId = accountId;
this.depositAccountType = DepositAccountType.RECURRING_DEPOSIT;
this.href = "/recurringdepositaccounts/" + accountId + "?command=undoapproval"; this.href = "/recurringdepositaccounts/" + accountId + "?command=undoapproval";
return this; return this;
} }
@@ -1947,7 +1919,6 @@ public class CommandWrapperBuilder {
this.entityName = "RECURRINGDEPOSITACCOUNT"; this.entityName = "RECURRINGDEPOSITACCOUNT";
this.savingsId = accountId; this.savingsId = accountId;
this.entityId = accountId; this.entityId = accountId;
this.depositAccountType = DepositAccountType.RECURRING_DEPOSIT;
this.href = "/recurringdepositaccounts/" + accountId + "?command=activate"; this.href = "/recurringdepositaccounts/" + accountId + "?command=activate";
return this; return this;
} }
@@ -1957,7 +1928,6 @@ public class CommandWrapperBuilder {
this.entityName = "RECURRINGDEPOSITACCOUNT"; this.entityName = "RECURRINGDEPOSITACCOUNT";
this.entityId = accountId; this.entityId = accountId;
this.savingsId = accountId; this.savingsId = accountId;
this.depositAccountType = DepositAccountType.RECURRING_DEPOSIT;
this.href = "/recurringdepositaccounts/" + accountId + "?command=close"; this.href = "/recurringdepositaccounts/" + accountId + "?command=close";
return this; return this;
} }
@@ -1967,7 +1937,6 @@ public class CommandWrapperBuilder {
this.entityName = "RECURRINGDEPOSITACCOUNT"; this.entityName = "RECURRINGDEPOSITACCOUNT";
this.entityId = accountId; this.entityId = accountId;
this.savingsId = accountId; this.savingsId = accountId;
this.depositAccountType = DepositAccountType.RECURRING_DEPOSIT;
this.href = "/recurringdepositaccounts/" + accountId + "?command=prematureClose"; this.href = "/recurringdepositaccounts/" + accountId + "?command=prematureClose";
return this; return this;
} }
@@ -1977,7 +1946,6 @@ public class CommandWrapperBuilder {
this.entityName = "RECURRINGDEPOSITACCOUNT"; this.entityName = "RECURRINGDEPOSITACCOUNT";
this.savingsId = accountId; this.savingsId = accountId;
this.entityId = accountId; this.entityId = accountId;
this.depositAccountType = DepositAccountType.RECURRING_DEPOSIT;
this.href = "/recurringdepositaccounts/" + accountId + "?command=calculateInterest"; this.href = "/recurringdepositaccounts/" + accountId + "?command=calculateInterest";
return this; return this;
} }
@@ -1987,7 +1955,6 @@ public class CommandWrapperBuilder {
this.entityName = "RECURRINGDEPOSITACCOUNT"; this.entityName = "RECURRINGDEPOSITACCOUNT";
this.savingsId = accountId; this.savingsId = accountId;
this.entityId = accountId; this.entityId = accountId;
this.depositAccountType = DepositAccountType.RECURRING_DEPOSIT;
this.href = "/recurringdepositaccounts/" + accountId + "?command=postInterest"; this.href = "/recurringdepositaccounts/" + accountId + "?command=postInterest";
return this; return this;
} }
@@ -68,8 +68,7 @@ public class PortfolioCommandSourceWritePlatformServiceImpl implements Portfolio
final JsonElement parsedCommand = this.fromApiJsonHelper.parse(json); final JsonElement parsedCommand = this.fromApiJsonHelper.parse(json);
final JsonCommand command = JsonCommand.from(json, parsedCommand, this.fromApiJsonHelper, wrapper.getEntityName(), final JsonCommand command = JsonCommand.from(json, parsedCommand, this.fromApiJsonHelper, wrapper.getEntityName(),
wrapper.getEntityId(), wrapper.getSubentityId(), wrapper.getGroupId(), wrapper.getClientId(), wrapper.getLoanId(), wrapper.getEntityId(), wrapper.getSubentityId(), wrapper.getGroupId(), wrapper.getClientId(), wrapper.getLoanId(),
wrapper.getSavingsId(), wrapper.getTransactionId(), wrapper.getHref(), wrapper.getProductId(), wrapper.getSavingsId(), wrapper.getTransactionId(), wrapper.getHref(), wrapper.getProductId());
wrapper.interestRatechartId(), wrapper.depositAccountType());
result = this.processAndLogCommandService.processAndLogCommand(wrapper, command, isApprovedByChecker); result = this.processAndLogCommandService.processAndLogCommand(wrapper, command, isApprovedByChecker);
} catch (final RollbackTransactionAsCommandIsNotApprovedByCheckerException e) { } catch (final RollbackTransactionAsCommandIsNotApprovedByCheckerException e) {
@@ -503,43 +503,87 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
} else { } else {
throw new UnsupportedCommandException(wrapper.commandName()); throw new UnsupportedCommandException(wrapper.commandName());
} }
} else if (wrapper.isDepositAccountResource()) { } else if (wrapper.isFixedDepositAccountResource()) {
if (wrapper.isCreate()) { if (wrapper.isCreate()) {
handler = this.applicationContext handler = this.applicationContext.getBean("fixedDepositAccountApplicationSubmittalCommandHandler",
.getBean("depositAccountApplicationSubmittalCommandHandler", NewCommandSourceHandler.class); NewCommandSourceHandler.class);
} else if (wrapper.isUpdate()) { }else if (wrapper.isUpdate()) {
handler = this.applicationContext.getBean("depositAccountApplicationModificationCommandHandler", handler = this.applicationContext.getBean("fixedDepositAccountApplicationModificationCommandHandler",
NewCommandSourceHandler.class); NewCommandSourceHandler.class);
} else if (wrapper.isDelete()) { } else if (wrapper.isDelete()) {
handler = this.applicationContext.getBean("depositAccountApplicationDeletionCommandHandler", NewCommandSourceHandler.class); handler = this.applicationContext.getBean("fixedDepositAccountApplicationDeletionCommandHandler",
} else if (wrapper.isRejectionOfDepositAccountApplication()) {
handler = this.applicationContext.getBean("depositAccountApplicationRejectedCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isWithdrawFromDepositAccountApplicationByApplicant()) {
handler = this.applicationContext.getBean("depositAccountApplicationWithdrawnByApplicantCommandHandler",
NewCommandSourceHandler.class); NewCommandSourceHandler.class);
} else if (wrapper.isApprovalOfDepositAccountApplication()) { } else if (wrapper.isRejectionOfFixedDepositAccountApplication()) {
handler = this.applicationContext.getBean("depositAccountApplicationApprovalCommandHandler", NewCommandSourceHandler.class); handler = this.applicationContext.getBean("fixedDepositAccountApplicationRejectedCommandHandler",
} else if (wrapper.isUndoApprovalOfDepositAccountApplication()) {
handler = this.applicationContext.getBean("depositAccountApplicationApprovalUndoCommandHandler",
NewCommandSourceHandler.class); NewCommandSourceHandler.class);
} else if (wrapper.isDepositAccountDeposit()) { } else if (wrapper.isWithdrawFixedDepositAccountApplicationByApplicant()) {
handler = this.applicationContext.getBean("depositAccountDepositCommandHandler", NewCommandSourceHandler.class); handler = this.applicationContext.getBean("fixedDepositAccountApplicationWithdrawnByApplicantCommandHandler",
} else if (wrapper.isDepositAccountWithdrawal()) { NewCommandSourceHandler.class);
handler = this.applicationContext.getBean("withdrawDepositAccountCommandHandler", NewCommandSourceHandler.class); } else if (wrapper.isApprovalOfFixedDepositAccountApplication()) {
} else if (wrapper.isDepositAccountActivation()) { handler = this.applicationContext.getBean("fixedDepositAccountApplicationApprovalCommandHandler", NewCommandSourceHandler.class);
handler = this.applicationContext.getBean("activateDepositAccountCommandHandler", NewCommandSourceHandler.class); } else if (wrapper.isUndoApprovalOfFixedDepositAccountApplication()) {
} else if (wrapper.isDepositAccountInterestCalculation()) { handler = this.applicationContext.getBean("fixedDepositAccountApplicationApprovalUndoCommandHandler",
handler = this.applicationContext.getBean("calculateInterestDepositAccountCommandHandler", NewCommandSourceHandler.class); NewCommandSourceHandler.class);
} else if (wrapper.isDepositAccountInterestPosting()) { } else if (wrapper.isDeposit()) {
handler = this.applicationContext.getBean("postInterestDepositAccountCommandHandler", NewCommandSourceHandler.class); handler = this.applicationContext.getBean("fixedDepositAccountDepositCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isDepositAccountUndoTransaction()) { } else if (wrapper.isWithdrawal()) {
handler = this.applicationContext.getBean("undoTransactionDepositAccountCommandHandler", NewCommandSourceHandler.class); handler = this.applicationContext.getBean("withdrawalFixedDepositAccountCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isAdjustDeopsitAccountTransaction()) { } else if (wrapper.isActivation()) {
handler = this.applicationContext.getBean("depositTransactionAdjustmentCommandHandler", NewCommandSourceHandler.class); 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()) { } else if (wrapper.isDepositAccountClose()) {
handler = this.applicationContext.getBean("closeDepositAccountCommandHandler", NewCommandSourceHandler.class); handler = this.applicationContext.getBean("closeFixedDepositAccountCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isDepositAccountPrematureClose()) { } 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 { } else {
throw new UnsupportedCommandException(wrapper.commandName()); throw new UnsupportedCommandException(wrapper.commandName());
} }
@@ -34,4 +34,8 @@ public interface ConfigurationDomainService {
Long retrievePasswordLiveTime(); Long retrievePasswordLiveTime();
Long retrieveGraceOnPenaltyPostingPeriod(); Long retrieveGraceOnPenaltyPostingPeriod();
Long ageLimitForSeniorCitizen();
Long ageLimitForChildren();
} }
@@ -135,4 +135,19 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService
final GlobalConfigurationProperty property = this.globalConfigurationRepository.findOneByNameWithNotFoundDetection(propertyName); final GlobalConfigurationProperty property = this.globalConfigurationRepository.findOneByNameWithNotFoundDetection(propertyName);
return property.getValue(); 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.BasicPasswordEncodablePlatformUser;
import org.mifosplatform.infrastructure.security.domain.PlatformUser; import org.mifosplatform.infrastructure.security.domain.PlatformUser;
import org.mifosplatform.infrastructure.security.service.PlatformPasswordEncoder; import org.mifosplatform.infrastructure.security.service.PlatformPasswordEncoder;
import org.mifosplatform.portfolio.savings.DepositAccountType;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
@@ -49,35 +48,28 @@ public final class JsonCommand {
private final String transactionId; private final String transactionId;
private final String url; private final String url;
private final Long productId; 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, 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 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 loanId, final Long savingsId, final String transactionId, final String url, final Long productId) {
final Long interestRateChartId, final DepositAccountType depositAccountType) {
return new JsonCommand(null, jsonCommand, parsedCommand, fromApiJsonHelper, entityName, resourceId, subresourceId, groupId, 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, 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 FromJsonHelper fromApiJsonHelper, final String entityName, final Long resourceId, final Long subresourceId,
final String url, final Long productId) { 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, 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, 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 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 groupId, final Long clientId, final Long loanId, final Long savingsId, final String transactionId, final String url,
final Long productId) { final Long productId) {
final Long interestRateChartId = null;
final DepositAccountType depositAccountType = null;
return new JsonCommand(commandId, jsonCommand, parsedCommand, fromApiJsonHelper, entityName, resourceId, subresourceId, groupId, 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); final String jsonCommand = command.fromApiJsonHelper.toJson(parsedCommand);
return new JsonCommand(command.commandId, jsonCommand, parsedCommand, command.fromApiJsonHelper, command.entityName, return new JsonCommand(command.commandId, jsonCommand, parsedCommand, command.fromApiJsonHelper, command.entityName,
command.resourceId, command.subresourceId, command.groupId, command.clientId, command.loanId, command.savingsId, 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, public JsonCommand(final Long commandId, final String jsonCommand, final JsonElement parsedCommand,
final FromJsonHelper fromApiJsonHelper, final String entityName, final Long resourceId, final Long subresourceId, final FromJsonHelper fromApiJsonHelper, final String entityName, final Long resourceId, final Long subresourceId,
final Long groupId, final Long clientId, final Long loanId, final Long savingsId, final String transactionId, final String url, 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.commandId = commandId;
this.jsonCommand = jsonCommand; this.jsonCommand = jsonCommand;
@@ -107,8 +99,6 @@ public final class JsonCommand {
this.transactionId = transactionId; this.transactionId = transactionId;
this.url = url; this.url = url;
this.productId = productId; this.productId = productId;
this.interestRateChartId = interestRateChartId;
this.depositAccountType = depositAccountType;
} }
public String json() { public String json() {
@@ -503,12 +493,5 @@ public final class JsonCommand {
public void checkForUnsupportedParameters(final Type typeOfMap, final String json, final Set<String> requestDataParameters) { public void checkForUnsupportedParameters(final Type typeOfMap, final String json, final Set<String> requestDataParameters) {
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, 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 noteText;
private final String txnExternalId; private final String txnExternalId;
private final Loan loan; private final Loan loan;
private final SavingsAccount savingsAccount; private final SavingsAccount toSavingsAccount;
private final SavingsAccount fromSavingsAccount;
public AccountTransferDTO(final LocalDate transactionDate, final BigDecimal transactionAmount, public AccountTransferDTO(final LocalDate transactionDate, final BigDecimal transactionAmount,
final PortfolioAccountType fromAccountType, final PortfolioAccountType toAccountType, final Long fromAccountId, final PortfolioAccountType fromAccountType, final PortfolioAccountType toAccountType, final Long fromAccountId,
final Long toAccountId, final String description, final Locale locale, final DateTimeFormatter fmt, final Long toAccountId, final String description, final Locale locale, final DateTimeFormatter fmt,
final PaymentDetail paymentDetail, final Integer fromTransferType, final Integer toTransferType, final Long chargeId, final PaymentDetail paymentDetail, final Integer fromTransferType, final Integer toTransferType, final Long chargeId,
Integer loanInstallmentNumber, Integer transferType, final AccountTransferDetails accountTransferDetails, 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.transactionDate = transactionDate;
this.transactionAmount = transactionAmount; this.transactionAmount = transactionAmount;
this.fromAccountType = fromAccountType; this.fromAccountType = fromAccountType;
@@ -59,7 +60,8 @@ public class AccountTransferDTO {
this.noteText = noteText; this.noteText = noteText;
this.txnExternalId = txnExternalId; this.txnExternalId = txnExternalId;
this.loan = loan; this.loan = loan;
this.savingsAccount = savingsAccount; this.toSavingsAccount = toSavingsAccount;
this.fromSavingsAccount = fromSavingsAccount;
} }
public LocalDate getTransactionDate() { public LocalDate getTransactionDate() {
@@ -138,8 +140,12 @@ public class AccountTransferDTO {
return this.loan; return this.loan;
} }
public SavingsAccount getSavingsAccount() { public SavingsAccount getToSavingsAccount() {
return this.savingsAccount; 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") @Table(name = "m_portfolio_account_associations")
public class AccountAssociations extends AbstractPersistable<Long> { public class AccountAssociations extends AbstractPersistable<Long> {
@SuppressWarnings("unused")
@ManyToOne @ManyToOne
@JoinColumn(name = "loan_account_id", nullable = true) @JoinColumn(name = "loan_account_id", nullable = true)
private Loan loanAccount; private Loan loanAccount;
@SuppressWarnings("unused")
@ManyToOne @ManyToOne
@JoinColumn(name = "savings_account_id", nullable = true) @JoinColumn(name = "savings_account_id", nullable = true)
private SavingsAccount savingsAccount; private SavingsAccount savingsAccount;
@SuppressWarnings("unused")
@ManyToOne @ManyToOne
@JoinColumn(name = "linked_loan_account_id", nullable = true) @JoinColumn(name = "linked_loan_account_id", nullable = true)
private Loan linkedLoanAccount; private Loan linkedLoanAccount;
@@ -86,6 +86,10 @@ public class AccountTransferEnumerations {
optionData = new EnumOptionData(AccountTransferType.CHARGE_PAYMENT.getValue().longValue(), optionData = new EnumOptionData(AccountTransferType.CHARGE_PAYMENT.getValue().longValue(),
AccountTransferType.CHARGE_PAYMENT.getCode(), "Charge Payment"); AccountTransferType.CHARGE_PAYMENT.getCode(), "Charge Payment");
break; break;
case INTEREST_TRANSFER:
optionData = new EnumOptionData(AccountTransferType.INTEREST_TRANSFER.getValue().longValue(),
AccountTransferType.INTEREST_TRANSFER.getCode(), "Interest Transfer");
break;
} }
} }
return optionData; return optionData;
@@ -274,11 +274,15 @@ public class AccountTransfersWritePlatformServiceImpl implements AccountTransfer
SavingsAccount fromSavingsAccount = null; SavingsAccount fromSavingsAccount = null;
SavingsAccount toSavingsAccount = null; SavingsAccount toSavingsAccount = null;
if (accountTransferDetails == null) { if (accountTransferDetails == null) {
fromSavingsAccount = this.savingsAccountAssembler.assembleFrom(accountTransferDTO.getFromAccountId()); if (accountTransferDTO.getFromSavingsAccount() == null) {
if (accountTransferDTO.getSavingsAccount() == null) { fromSavingsAccount = this.savingsAccountAssembler.assembleFrom(accountTransferDTO.getFromAccountId());
}else{
fromSavingsAccount = accountTransferDTO.getFromSavingsAccount();
}
if (accountTransferDTO.getToSavingsAccount() == null) {
toSavingsAccount = this.savingsAccountAssembler.assembleFrom(accountTransferDTO.getToAccountId()); toSavingsAccount = this.savingsAccountAssembler.assembleFrom(accountTransferDTO.getToAccountId());
} else { } else {
toSavingsAccount = accountTransferDTO.getSavingsAccount(); toSavingsAccount = accountTransferDTO.getToSavingsAccount();
} }
} else { } else {
fromSavingsAccount = accountTransferDetails.fromSavingsAccount(); 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.common.domain.PeriodFrequencyType;
import org.mifosplatform.portfolio.loanaccount.loanschedule.domain.DefaultScheduledDateGenerator; import org.mifosplatform.portfolio.loanaccount.loanschedule.domain.DefaultScheduledDateGenerator;
import org.mifosplatform.portfolio.loanaccount.loanschedule.domain.ScheduledDateGenerator; import org.mifosplatform.portfolio.loanaccount.loanschedule.domain.ScheduledDateGenerator;
import org.mifosplatform.portfolio.savings.domain.SavingsAccount;
import org.mifosplatform.portfolio.savings.exception.InsufficientAccountBalanceException; import org.mifosplatform.portfolio.savings.exception.InsufficientAccountBalanceException;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -213,11 +214,12 @@ public class StandingInstructionWritePlatformServiceImpl implements StandingInst
if (isDueForTransfer && transactionAmount != null && transactionAmount.compareTo(BigDecimal.ZERO) > 0) { if (isDueForTransfer && transactionAmount != null && transactionAmount.compareTo(BigDecimal.ZERO) > 0) {
final AccountTransferDetails accountTransferDetails = this.accountTransferDetailRepository.findOne(data.accountDetailId()); final AccountTransferDetails accountTransferDetails = this.accountTransferDetailRepository.findOne(data.accountDetailId());
final SavingsAccount fromSavingsAccount = null;
accountTransferDetails.accountTransferStandingInstruction().updateLatsRunDate(transactionDate.toDate()); accountTransferDetails.accountTransferStandingInstruction().updateLatsRunDate(transactionDate.toDate());
AccountTransferDTO accountTransferDTO = new AccountTransferDTO(transactionDate, transactionAmount, data.fromAccountType(), AccountTransferDTO accountTransferDTO = new AccountTransferDTO(transactionDate, transactionAmount, data.fromAccountType(),
data.toAccountType(), data.fromAccount().accountId(), data.toAccount().accountId(), data.name() data.toAccountType(), data.fromAccount().accountId(), data.toAccount().accountId(), data.name()
+ " Standing instruction trasfer ", null, null, null, null, data.toTransferType(), null, null, data + " 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()); transferAmount(sb, accountTransferDTO, data.getId());
} }
} }
@@ -236,6 +236,9 @@ public class CalendarsApiResource {
case LOANS: case LOANS:
resourceDetails.withLoanId(entityId); resourceDetails.withLoanId(entityId);
break; break;
case SAVINGS:
resourceDetails.withSavingsId(entityId);
break;
case INVALID: case INVALID:
break; break;
} }
@@ -326,4 +326,12 @@ public class CalendarData {
compareDate); } compareDate); }
return false; 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; 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) { public static Calendar fromJson(final JsonCommand command) {
// final Long entityId = command.getSupportedEntityId(); // final Long entityId = command.getSupportedEntityId();
@@ -301,6 +318,25 @@ public class Calendar extends AbstractAuditableCustom<AppUser, Long> {
return actualChanges; 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() { public String getTitle() {
return this.title; return this.title;
@@ -419,29 +455,38 @@ public class Calendar extends AbstractAuditableCustom<AppUser, Long> {
} }
if (repeating) { if (repeating) {
final StringBuilder recurrenceBuilder = new StringBuilder(200);
final Integer frequency = command.integerValueOfParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.FREQUENCY.getValue()); final Integer frequency = command.integerValueOfParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.FREQUENCY.getValue());
final CalendarFrequencyType frequencyType = CalendarFrequencyType.fromInt(frequency); final CalendarFrequencyType frequencyType = CalendarFrequencyType.fromInt(frequency);
recurrenceBuilder.append("FREQ=");
recurrenceBuilder.append(frequencyType.toString().toUpperCase());
final Integer interval = command.integerValueOfParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.INTERVAL.getValue()); final Integer interval = command.integerValueOfParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.INTERVAL.getValue());
if (interval > 1) { Integer repeatsOnDay = null;
recurrenceBuilder.append(";INTERVAL=");
recurrenceBuilder.append(interval);
}
if (frequencyType.isWeekly()) { if (frequencyType.isWeekly()) {
final Integer repeatsOnDay = command.integerValueOfParameterNamed(CALENDAR_SUPPORTED_PARAMETERS.REPEATS_ON_DAY.getValue()); 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());
}
} }
return recurrenceBuilder.toString();
return constructRecurrence(frequencyType, interval, repeatsOnDay);
} }
return ""; 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) { public boolean isValidRecurringDate(final LocalDate compareDate) {
if (isBetweenStartAndEndDate(compareDate)) { return CalendarUtils.isValidRedurringDate(getRecurrence(), getStartDateLocalDate(), if (isBetweenStartAndEndDate(compareDate)) { return CalendarUtils.isValidRedurringDate(getRecurrence(), getStartDateLocalDate(),
@@ -11,7 +11,7 @@ import java.util.Map;
public enum CalendarEntityType { public enum CalendarEntityType {
INVALID(0, "calendarEntityType.invalid"), CLIENTS(1, "calendarEntityType.clients"), GROUPS(2, "calendarEntityType.groups"), LOANS(3, 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 Integer value;
private final String code; private final String code;
@@ -126,5 +126,17 @@ public enum CalendarEntityType {
public static CalendarEntityType getEntityType(String entityType) { public static CalendarEntityType getEntityType(String entityType) {
return entityNameToEnumMap.get(entityType.toLowerCase()); 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.HashMap;
import java.util.Map; import java.util.Map;
import org.mifosplatform.portfolio.common.domain.PeriodFrequencyType;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
public enum CalendarFrequencyType { public enum CalendarFrequencyType {
@@ -84,4 +85,44 @@ public enum CalendarFrequencyType {
public boolean isInvalid() { public boolean isInvalid() {
return this.value.equals(CalendarFrequencyType.INVALID.value); 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; package org.mifosplatform.portfolio.calendar.domain;
import javax.persistence.CascadeType;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
@@ -17,7 +18,7 @@ import org.springframework.data.jpa.domain.AbstractPersistable;
@Table(name = "m_calendar_instance") @Table(name = "m_calendar_instance")
public class CalendarInstance extends AbstractPersistable<Long> { public class CalendarInstance extends AbstractPersistable<Long> {
@ManyToOne @ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "calendar_id", nullable = false) @JoinColumn(name = "calendar_id", nullable = false)
private Calendar calendar; 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); return new CalendarInstance(calendar, entityId, entityTypeId);
} }
@@ -8,17 +8,28 @@ package org.mifosplatform.portfolio.calendar.domain;
import java.util.Collection; import java.util.Collection;
import java.util.List; 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.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param; import org.springframework.data.repository.query.Param;
import ch.qos.logback.core.net.server.Client;
public interface CalendarInstanceRepository extends JpaRepository<CalendarInstance, Long>, JpaSpecificationExecutor<CalendarInstance> { public interface CalendarInstanceRepository extends JpaRepository<CalendarInstance, Long>, JpaSpecificationExecutor<CalendarInstance> {
CalendarInstance findByCalendarIdAndEntityIdAndEntityTypeId(Long calendarId, Long entityId, Integer entityTypeId); CalendarInstance findByCalendarIdAndEntityIdAndEntityTypeId(Long calendarId, Long entityId, Integer entityTypeId);
Collection<CalendarInstance> findByEntityIdAndEntityTypeId(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); CalendarInstance findByEntityIdAndEntityTypeIdAndCalendarTypeId(Long entityId, Integer entityTypeId, Integer calendarTypeId);
@Query("from CalendarInstance ci where ci.entityId = :loanId and ci.entityTypeId = :entityTypeId") @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); this.calendarRepository.save(newCalendar);
final CalendarInstance newCalendarInstance = CalendarInstance.fromJson(newCalendar, entityId, entityTypeId); final CalendarInstance newCalendarInstance = CalendarInstance.from(newCalendar, entityId, entityTypeId);
this.calendarInstanceRepository.save(newCalendarInstance); this.calendarInstanceRepository.save(newCalendarInstance);
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
@@ -65,11 +65,9 @@ final public class ClientData implements Comparable<ClientData> {
// template // template
private final Collection<OfficeData> officeOptions; private final Collection<OfficeData> officeOptions;
private final Collection<StaffData> staffOptions; private final Collection<StaffData> staffOptions;
@SuppressWarnings("unused")
private final Collection<CodeValueData> closureReasons; private final Collection<CodeValueData> closureReasons;
private final Collection<SavingsProductData> savingProductOptions; private final Collection<SavingsProductData> savingProductOptions;
private final Collection<SavingsAccountData> savingAccountOptions; private final Collection<SavingsAccountData> savingAccountOptions;
@SuppressWarnings("unused")
private final Collection<CodeValueData> genderOptions; private final Collection<CodeValueData> genderOptions;
public static ClientData template(final Long officeId, final LocalDate joinedDate, final Collection<OfficeData> officeOptions, 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.transferToOfficeId, clientData.transferToOfficeName, clientData.id, clientData.firstname, clientData.middlename,
clientData.lastname, clientData.fullname, clientData.displayName, clientData.externalId, clientData.mobileNo, clientData.lastname, clientData.fullname, clientData.displayName, clientData.externalId, clientData.mobileNo,
clientData.dateOfBirth, clientData.gender, clientData.activationDate, clientData.imageId, clientData.staffId, 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, templateData.savingProductOptions, clientData.savingsProductId, clientData.savingsProductName, clientData.savingsAccountId,
clientData.savingAccountOptions); clientData.savingAccountOptions);
@@ -32,6 +32,7 @@ import org.apache.commons.lang.StringUtils;
import org.hibernate.annotations.LazyCollection; import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption; import org.hibernate.annotations.LazyCollectionOption;
import org.joda.time.LocalDate; import org.joda.time.LocalDate;
import org.joda.time.Years;
import org.joda.time.format.DateTimeFormatter; import org.joda.time.format.DateTimeFormatter;
import org.mifosplatform.infrastructure.codes.domain.CodeValue; import org.mifosplatform.infrastructure.codes.domain.CodeValue;
import org.mifosplatform.infrastructure.core.api.JsonCommand; 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.organisation.staff.domain.Staff;
import org.mifosplatform.portfolio.client.api.ClientApiConstants; import org.mifosplatform.portfolio.client.api.ClientApiConstants;
import org.mifosplatform.portfolio.group.domain.Group; 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.SavingsAccount;
import org.mifosplatform.portfolio.savings.domain.SavingsProduct; import org.mifosplatform.portfolio.savings.domain.SavingsProduct;
import org.mifosplatform.useradministration.domain.AppUser; import org.mifosplatform.useradministration.domain.AppUser;
@@ -157,6 +159,9 @@ public final class Client extends AbstractPersistable<Long> {
@JoinColumn(name = "default_savings_account", nullable = true) @JoinColumn(name = "default_savings_account", nullable = true)
private SavingsAccount savingsAccount; private SavingsAccount savingsAccount;
@Transient
private ClientIncentiveAttributes incentiveAttributes;
public static Client createNew(final AppUser currentUser, final Office clientOffice, final Group clientParentGroup, final Staff staff, 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) { final SavingsProduct savingsProduct, final CodeValue gender, final JsonCommand command) {
@@ -272,7 +277,7 @@ public final class Client extends AbstractPersistable<Long> {
this.savingsProduct = savingsProduct; this.savingsProduct = savingsProduct;
this.savingsAccount = savingsAccount; this.savingsAccount = savingsAccount;
if(gender != null){ if (gender != null) {
this.gender = gender; this.gender = gender;
} }
if (dateOfBirth != null) { if (dateOfBirth != null) {
@@ -692,4 +697,41 @@ public final class Client extends AbstractPersistable<Long> {
public void updateSavingsAccount(SavingsAccount savingsAccount) { public void updateSavingsAccount(SavingsAccount savingsAccount) {
this.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 actualDisbursementDateParamName = "actualDisbursementDate";
public static final String bulkRepaymentTransactionsParamName = "bulkRepaymentTransactions"; public static final String bulkRepaymentTransactionsParamName = "bulkRepaymentTransactions";
public static final String bulkDisbursementTransactionsParamName = "bulkDisbursementTransactions"; public static final String bulkDisbursementTransactionsParamName = "bulkDisbursementTransactions";
public static final String bulkSavingsDueTransactionsParamName = "bulkSavingsDueTransactions";
public static final String noteParamName = "note"; public static final String noteParamName = "note";
public static final String calendarIdParamName = "calendarId"; public static final String calendarIdParamName = "calendarId";
@@ -29,9 +30,10 @@ public class CollectionSheetConstants {
public static final String attendanceTypeParamName = "attendanceType"; public static final String attendanceTypeParamName = "attendanceType";
public static final String loanIdParamName = "loanId"; public static final String loanIdParamName = "loanId";
public static final String savingsIdParamName = "savingsId";
public static final String transactionAmountParamName = "transactionAmount"; public static final String transactionAmountParamName = "transactionAmount";
public static final Set<String> COLLECTIONSHEET_REQUEST_DATA_PARAMETERS = new HashSet<String>(Arrays.asList(localeParamName, public static final Set<String> COLLECTIONSHEET_REQUEST_DATA_PARAMETERS = new HashSet<String>(Arrays.asList(localeParamName,
dateFormatParamName, transactionDateParamName, actualDisbursementDateParamName, bulkRepaymentTransactionsParamName, 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.attendanceTypeParamName;
import static org.mifosplatform.portfolio.collectionsheet.CollectionSheetConstants.bulkDisbursementTransactionsParamName; import static org.mifosplatform.portfolio.collectionsheet.CollectionSheetConstants.bulkDisbursementTransactionsParamName;
import static org.mifosplatform.portfolio.collectionsheet.CollectionSheetConstants.bulkRepaymentTransactionsParamName; 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.calendarIdParamName;
import static org.mifosplatform.portfolio.collectionsheet.CollectionSheetConstants.clientIdParamName; import static org.mifosplatform.portfolio.collectionsheet.CollectionSheetConstants.clientIdParamName;
import static org.mifosplatform.portfolio.collectionsheet.CollectionSheetConstants.clientsAttendanceParamName; import static org.mifosplatform.portfolio.collectionsheet.CollectionSheetConstants.clientsAttendanceParamName;
import static org.mifosplatform.portfolio.collectionsheet.CollectionSheetConstants.loanIdParamName; 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.noteParamName;
import static org.mifosplatform.portfolio.collectionsheet.CollectionSheetConstants.transactionAmountParamName; import static org.mifosplatform.portfolio.collectionsheet.CollectionSheetConstants.transactionAmountParamName;
import static org.mifosplatform.portfolio.collectionsheet.CollectionSheetConstants.transactionDateParamName; import static org.mifosplatform.portfolio.collectionsheet.CollectionSheetConstants.transactionDateParamName;
@@ -80,6 +82,8 @@ public class CollectionSheetTransactionDataValidator {
validateDisbursementTransactions(element, baseDataValidator); validateDisbursementTransactions(element, baseDataValidator);
validateRepaymentTransactions(element, baseDataValidator); validateRepaymentTransactions(element, baseDataValidator);
validateSavingsDueTransactions(element, baseDataValidator);
throwExceptionIfValidationWarningsExist(dataValidationErrors); 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) { private void throwExceptionIfValidationWarningsExist(final List<ApiParameterError> dataValidationErrors) {
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); } if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
} }
} }
@@ -18,21 +18,50 @@ public class JLGClientData {
private final Long clientId; private final Long clientId;
private final String clientName; private final String clientName;
private Collection<LoanDueData> loans; private Collection<LoanDueData> loans;
private Collection<SavingsDueData> savings;
@SuppressWarnings("unused") @SuppressWarnings("unused")
private final EnumOptionData attendanceType; 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) { final EnumOptionData attendanceType) {
this.clientId = clientId; this.clientId = clientId;
this.clientName = clientName; this.clientName = clientName;
this.loans = loans; this.loans = loans;
this.attendanceType = attendanceType; 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.clientId = clientId;
this.clientName = clientName; this.clientName = clientName;
this.loans = null; this.loans = loans;
this.savings = savings;
this.attendanceType = attendanceType; this.attendanceType = attendanceType;
} }
@@ -51,4 +80,24 @@ public class JLGClientData {
public void setLoans(final Collection<LoanDueData> loans) { public void setLoans(final Collection<LoanDueData> loans) {
this.loans = 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.joda.time.LocalDate;
import org.mifosplatform.infrastructure.core.data.EnumOptionData; import org.mifosplatform.infrastructure.core.data.EnumOptionData;
import org.mifosplatform.portfolio.loanproduct.data.LoanProductData; import org.mifosplatform.portfolio.loanproduct.data.LoanProductData;
import org.mifosplatform.portfolio.savings.data.SavingsProductData;
/** /**
* Immutable data object for join liability group's collection sheet. * Immutable data object for join liability group's collection sheet.
@@ -19,14 +20,27 @@ public class JLGCollectionSheetData {
private final LocalDate dueDate; private final LocalDate dueDate;
private final Collection<LoanProductData> loanProducts; private final Collection<LoanProductData> loanProducts;
private final Collection<JLGGroupData> groups;
@SuppressWarnings("unused") @SuppressWarnings("unused")
private final Collection<SavingsProductData> savingsProducts;
private final Collection<JLGGroupData> groups;
private final List<EnumOptionData> attendanceTypeOptions; 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) { 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.loanProducts = loanProducts;
this.savingsProducts = savingsProducts;
this.groups = groups; this.groups = groups;
this.attendanceTypeOptions = attendanceTypeOptions; this.attendanceTypeOptions = attendanceTypeOptions;
} }
@@ -42,4 +56,5 @@ public class JLGCollectionSheetData {
public Collection<LoanProductData> getLoanProducts() { public Collection<LoanProductData> getLoanProducts() {
return this.loanProducts; return this.loanProducts;
} }
} }
@@ -153,12 +153,12 @@ public class JLGCollectionSheetFlatData {
} }
public JLGClientData getClientData() { public JLGClientData getClientData() {
return new JLGClientData(this.clientId, this.clientName, this.attendanceType); return JLGClientData.withAttendance(this.clientId, this.clientName, this.attendanceType);
} }
public JLGGroupData getJLGGroupData() { 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 final String levelName;
private Collection<JLGClientData> clients; private Collection<JLGClientData> clients;
public JLGGroupData(final Long groupId, final String groupName, final Long staffId, final String staffName, final Long levelId, public static JLGGroupData instance(final Long groupId, final String groupName, final Long staffId, final String staffName, final Long levelId,
final String levelName) { 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.groupId = groupId;
this.groupName = groupName; this.groupName = groupName;
this.staffId = staffId; this.staffId = staffId;
this.staffName = staffName; this.staffName = staffName;
this.levelId = levelId; this.levelId = levelId;
this.levelName = levelName; this.levelName = levelName;
this.clients = clients;
} }
public Long getGroupId() { public Long getGroupId() {
@@ -62,4 +72,15 @@ public class JLGGroupData {
public void setClients(final Collection<JLGClientData> clients) { public void setClients(final Collection<JLGClientData> clients) {
this.clients = 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.JLGCollectionSheetFlatData;
import org.mifosplatform.portfolio.collectionsheet.data.JLGGroupData; import org.mifosplatform.portfolio.collectionsheet.data.JLGGroupData;
import org.mifosplatform.portfolio.collectionsheet.data.LoanDueData; 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.collectionsheet.serialization.CollectionSheetGenerateCommandFromApiJsonDeserializer;
import org.mifosplatform.portfolio.group.data.CenterData; import org.mifosplatform.portfolio.group.data.CenterData;
import org.mifosplatform.portfolio.group.data.GroupGeneralData; 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.loanproduct.data.LoanProductData;
import org.mifosplatform.portfolio.meeting.attendance.service.AttendanceDropdownReadPlatformService; import org.mifosplatform.portfolio.meeting.attendance.service.AttendanceDropdownReadPlatformService;
import org.mifosplatform.portfolio.meeting.attendance.service.AttendanceEnumerations; import org.mifosplatform.portfolio.meeting.attendance.service.AttendanceEnumerations;
import org.mifosplatform.portfolio.savings.data.SavingsProductData;
import org.mifosplatform.useradministration.domain.AppUser; import org.mifosplatform.useradministration.domain.AppUser;
import org.springframework.beans.factory.annotation.Autowired; 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.RowMapper;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
@@ -61,6 +65,7 @@ public class CollectionSheetReadPlatformServiceImpl implements CollectionSheetRe
private final CollectionSheetGenerateCommandFromApiJsonDeserializer collectionSheetGenerateCommandFromApiJsonDeserializer; private final CollectionSheetGenerateCommandFromApiJsonDeserializer collectionSheetGenerateCommandFromApiJsonDeserializer;
private final CalendarRepositoryWrapper calendarRepositoryWrapper; private final CalendarRepositoryWrapper calendarRepositoryWrapper;
private final AttendanceDropdownReadPlatformService attendanceDropdownReadPlatformService; private final AttendanceDropdownReadPlatformService attendanceDropdownReadPlatformService;
final MandatorySavingsCollectionsheetExtractor mandatorySavingsExtractor = new MandatorySavingsCollectionsheetExtractor();
@Autowired @Autowired
public CollectionSheetReadPlatformServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource, public CollectionSheetReadPlatformServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource,
@@ -162,7 +167,7 @@ public class CollectionSheetReadPlatformServiceImpl implements CollectionSheetRe
jlgGroupsData.add(jlgGroupData); jlgGroupsData.add(jlgGroupData);
} }
jlgCollectionSheetData = new JLGCollectionSheetData(dueDate, loanProducts, jlgGroupsData, jlgCollectionSheetData = JLGCollectionSheetData.instance(dueDate, loanProducts, jlgGroupsData,
this.attendanceDropdownReadPlatformService.retrieveAttendanceTypeOptions()); this.attendanceDropdownReadPlatformService.retrieveAttendanceTypeOptions());
} }
@@ -296,8 +301,6 @@ public class CollectionSheetReadPlatformServiceImpl implements CollectionSheetRe
final JLGCollectionSheetFaltDataMapper mapper = new JLGCollectionSheetFaltDataMapper(); final JLGCollectionSheetFaltDataMapper mapper = new JLGCollectionSheetFaltDataMapper();
final StringBuilder sql = new StringBuilder(mapper.collectionSheetSchema(false));
// entityType should be center if it's within a center // entityType should be center if it's within a center
final CalendarEntityType entityType = (group.isChildGroup()) ? CalendarEntityType.CENTERS : CalendarEntityType.GROUPS; 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("groupId", group.getId()).addValue("officeHierarchy", officeHierarchy)
.addValue("entityTypeId", entityType.getValue()); .addValue("entityTypeId", entityType.getValue());
final Collection<JLGCollectionSheetFlatData> collectionSheetFlatDatas = this.namedParameterjdbcTemplate.query(sql.toString(), final Collection<JLGCollectionSheetFlatData> collectionSheetFlatDatas = this.namedParameterjdbcTemplate.query(
namedParameters, mapper); 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 @Override
@@ -337,6 +411,204 @@ public class CollectionSheetReadPlatformServiceImpl implements CollectionSheetRe
final Collection<JLGCollectionSheetFlatData> collectionSheetFlatDatas = this.namedParameterjdbcTemplate.query(sql.toString(), final Collection<JLGCollectionSheetFlatData> collectionSheetFlatDatas = this.namedParameterjdbcTemplate.query(sql.toString(),
namedParameters, mapper); 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; package org.mifosplatform.portfolio.collectionsheet.service;
import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; 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.collectionsheet.serialization.CollectionSheetBulkRepaymentCommandFromApiJsonDeserializer;
import org.mifosplatform.portfolio.loanaccount.service.LoanWritePlatformService; import org.mifosplatform.portfolio.loanaccount.service.LoanWritePlatformService;
import org.mifosplatform.portfolio.meeting.service.MeetingWritePlatformService; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -30,18 +34,23 @@ public class CollectionSheetWritePlatformServiceJpaRepositoryImpl implements Col
private final CollectionSheetBulkDisbursalCommandFromApiJsonDeserializer bulkDisbursalCommandFromApiJsonDeserializer; private final CollectionSheetBulkDisbursalCommandFromApiJsonDeserializer bulkDisbursalCommandFromApiJsonDeserializer;
private final CollectionSheetTransactionDataValidator transactionDataValidator; private final CollectionSheetTransactionDataValidator transactionDataValidator;
private final MeetingWritePlatformService meetingWritePlatformService; private final MeetingWritePlatformService meetingWritePlatformService;
private final DepositAccountAssembler accountAssembler;
private final DepositAccountWritePlatformService accountWritePlatformService;
@Autowired @Autowired
public CollectionSheetWritePlatformServiceJpaRepositoryImpl(final LoanWritePlatformService loanWritePlatformService, public CollectionSheetWritePlatformServiceJpaRepositoryImpl(final LoanWritePlatformService loanWritePlatformService,
final CollectionSheetBulkRepaymentCommandFromApiJsonDeserializer bulkRepaymentCommandFromApiJsonDeserializer, final CollectionSheetBulkRepaymentCommandFromApiJsonDeserializer bulkRepaymentCommandFromApiJsonDeserializer,
final CollectionSheetBulkDisbursalCommandFromApiJsonDeserializer bulkDisbursalCommandFromApiJsonDeserializer, final CollectionSheetBulkDisbursalCommandFromApiJsonDeserializer bulkDisbursalCommandFromApiJsonDeserializer,
final CollectionSheetTransactionDataValidator transactionDataValidator, final CollectionSheetTransactionDataValidator transactionDataValidator,
final MeetingWritePlatformService meetingWritePlatformService) { final MeetingWritePlatformService meetingWritePlatformService, final DepositAccountAssembler accountAssembler,
final DepositAccountWritePlatformService accountWritePlatformService) {
this.loanWritePlatformService = loanWritePlatformService; this.loanWritePlatformService = loanWritePlatformService;
this.bulkRepaymentCommandFromApiJsonDeserializer = bulkRepaymentCommandFromApiJsonDeserializer; this.bulkRepaymentCommandFromApiJsonDeserializer = bulkRepaymentCommandFromApiJsonDeserializer;
this.bulkDisbursalCommandFromApiJsonDeserializer = bulkDisbursalCommandFromApiJsonDeserializer; this.bulkDisbursalCommandFromApiJsonDeserializer = bulkDisbursalCommandFromApiJsonDeserializer;
this.transactionDataValidator = transactionDataValidator; this.transactionDataValidator = transactionDataValidator;
this.meetingWritePlatformService = meetingWritePlatformService; this.meetingWritePlatformService = meetingWritePlatformService;
this.accountAssembler = accountAssembler;
this.accountWritePlatformService = accountWritePlatformService;
} }
@Override @Override
@@ -61,6 +70,8 @@ public class CollectionSheetWritePlatformServiceJpaRepositoryImpl implements Col
changes.putAll(updateBulkReapayments(command)); changes.putAll(updateBulkReapayments(command));
changes.putAll(updateBulkDisbursals(command)); changes.putAll(updateBulkDisbursals(command));
changes.putAll(updateBulkMandatorySavingsDuePayments(command));
this.meetingWritePlatformService.updateCollectionSheetAttendance(command); this.meetingWritePlatformService.updateCollectionSheetAttendance(command);
@@ -86,4 +97,21 @@ public class CollectionSheetWritePlatformServiceJpaRepositoryImpl implements Col
changes.putAll(this.loanWritePlatformService.bulkLoanDisbursal(command, bulkDisbursalCommand, false)); changes.putAll(this.loanWritePlatformService.bulkLoanDisbursal(command, bulkDisbursalCommand, false));
return changes; 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; package org.mifosplatform.portfolio.common.domain;
import java.util.ArrayList;
import java.util.List;
public enum PeriodFrequencyType { public enum PeriodFrequencyType {
DAYS(0, "periodFrequencyType.days"), // DAYS(0, "periodFrequencyType.days"), //
@@ -57,4 +60,19 @@ public enum PeriodFrequencyType {
public boolean isYearly() { public boolean isYearly() {
return this.value.equals(PeriodFrequencyType.MONTHS.getValue()); 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 descriptionParamName = "description";
public static final String fromDateParamName = "fromDate"; public static final String fromDateParamName = "fromDate";
public static final String endDateParamName = "endDate"; public static final String endDateParamName = "endDate";
public static final String savingsProductIdParamName = "savingsProductId"; public static final String productIdParamName = "productId";
public static final String savingsProductNameParamName = "savingsProductName"; public static final String productNameParamName = "productName";
// interest rate chart Slabs parameters // interest rate chart Slabs parameters
public static final String periodTypeParamName = "periodType"; // public static final String periodTypeParamName = "periodType";
public static final String fromPeriodParamName = "fromPeriod"; // public static final String fromPeriodParamName = "fromPeriod";
public static final String toPeriodParamName = "toPeriod"; // public static final String toPeriodParamName = "toPeriod";
public static final String amountRangeFromParamName = "amountRangeFrom"; // public static final String amountRangeFromParamName = "amountRangeFrom";
public static final String amountRangeToParamName = "amountRangeTo"; // public static final String amountRangeToParamName = "amountRangeTo";
public static final String annualInterestRateParamName = "annualInterestRate"; // 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 // associations
public static final String chartSlabs = "chartSlabs"; public static final String chartSlabs = "chartSlabs";
@@ -47,7 +50,7 @@ public class InterestRateChartApiConstants {
public static final String deleteParamName = "delete"; public static final String deleteParamName = "delete";
public static final Set<String> INTERESTRATE_CHART_CREATE_REQUEST_DATA_PARAMETERS = new HashSet<String>(Arrays.asList(localeParamName, 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)); chartSlabs));
public static final Set<String> INTERESTRATE_CHART_UPDATE_REQUEST_DATA_PARAMETERS = new HashSet<String>(Arrays.asList(localeParamName, 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 amountRangeFromParamName = "amountRangeFrom";
public static final String amountRangeToParamName = "amountRangeTo"; public static final String amountRangeToParamName = "amountRangeTo";
public static final String annualInterestRateParamName = "annualInterestRate"; 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 // associations
public static final Set<String> INTERESTRATE_CHART_SLAB_CREATE_REQUEST_DATA_PARAMETERS = new HashSet<String>(Arrays.asList( public static final Set<String> INTERESTRATE_CHART_SLAB_CREATE_REQUEST_DATA_PARAMETERS = new HashSet<String>(Arrays.asList(
localeParamName, idParamName, descriptionParamName, periodTypeParamName, fromPeriodParamName, toPeriodParamName, 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( public static final Set<String> INTERESTRATE_CHART_SLAB_UPDATE_REQUEST_DATA_PARAMETERS = new HashSet<String>(Arrays.asList(
localeParamName, idParamName, descriptionParamName, periodTypeParamName, fromPeriodParamName, toPeriodParamName, 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, public static final Set<String> INTERESTRATE_CHART_SLAB_RESPONSE_DATA_PARAMETERS = new HashSet<String>(Arrays.asList(localeParamName,
idParamName, descriptionParamName, periodTypeParamName, fromPeriodParamName, toPeriodParamName, amountRangeFromParamName, idParamName, descriptionParamName, periodTypeParamName, fromPeriodParamName, toPeriodParamName, amountRangeFromParamName,
amountRangeToParamName, annualInterestRateParamName, currencyCodeParamName)); amountRangeToParamName, annualInterestRateParamName, interestRateForFemaleParamName, interestRateForChildrenParamName,
interestRateForSeniorCitizenParamName, currencyCodeParamName));
} }
@@ -64,9 +64,10 @@ public class InterestRateChartSlabsApiResource {
@Path("template") @Path("template")
@Consumes({ MediaType.APPLICATION_JSON }) @Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON })
public String template() { public String template(@Context final UriInfo uriInfo) {
// TODO: implement InterestRateChartSlabData chartSlab = this.interestRateChartSlabReadPlatformService.retrieveTemplate();
return null; final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
return this.toApiJsonSerializer.serialize(settings, chartSlab, INTERESTRATE_CHART_SLAB_RESPONSE_DATA_PARAMETERS);
} }
@GET @GET
@@ -6,6 +6,7 @@
package org.mifosplatform.portfolio.interestratechart.api; package org.mifosplatform.portfolio.interestratechart.api;
import java.util.Collection; import java.util.Collection;
import java.util.Set;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE; 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.domain.CommandWrapper;
import org.mifosplatform.commands.service.CommandWrapperBuilder; import org.mifosplatform.commands.service.CommandWrapperBuilder;
import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService; 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.api.ApiRequestParameterHelper;
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult; import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
import org.mifosplatform.infrastructure.core.serialization.ApiRequestJsonSerializationSettings; 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) { public String retrieveOne(@PathParam("chartId") final Long chartId, @Context final UriInfo uriInfo) {
this.context.authenticatedUser().validateHasReadPermission(InterestRateChartApiConstants.INTERESTRATE_CHART_RESOURCE_NAME); 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()); final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
if (settings.isTemplate()) { if (settings.isTemplate()) {
chartData = this.chartReadPlatformService.retrieveWithTemplate(chartData); 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 String description;
private final LocalDate fromDate; private final LocalDate fromDate;
private final LocalDate endDate; private final LocalDate endDate;
private final Long savingsProductId; private final Long productId;
private final String savingsProductName; private final String productName;
// associations // associations
private Set<InterestRateChartSlabData> chartSlabs; private Set<InterestRateChartSlabData> chartSlabs;
@@ -32,8 +32,9 @@ public class InterestRateChartData {
private Collection<EnumOptionData> periodTypes; private Collection<EnumOptionData> periodTypes;
public static InterestRateChartData instance(Long id, String name, String description, LocalDate fromDate, LocalDate endDate, 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; Collection<EnumOptionData> periodTypes = null;
Set<InterestRateChartSlabData> chartSlabs = null;
return new InterestRateChartData(id, name, description, fromDate, endDate, savingsProductId, savingsProductName, chartSlabs, return new InterestRateChartData(id, name, description, fromDate, endDate, savingsProductId, savingsProductName, chartSlabs,
periodTypes); periodTypes);
} }
@@ -41,14 +42,14 @@ public class InterestRateChartData {
public static InterestRateChartData withSlabs(InterestRateChartData interestRateChartData, public static InterestRateChartData withSlabs(InterestRateChartData interestRateChartData,
Set<InterestRateChartSlabData> chartSlabs) { Set<InterestRateChartSlabData> chartSlabs) {
return new InterestRateChartData(interestRateChartData.id, interestRateChartData.name, interestRateChartData.description, return new InterestRateChartData(interestRateChartData.id, interestRateChartData.name, interestRateChartData.description,
interestRateChartData.fromDate, interestRateChartData.endDate, interestRateChartData.savingsProductId, interestRateChartData.fromDate, interestRateChartData.endDate, interestRateChartData.productId,
interestRateChartData.savingsProductName, chartSlabs, interestRateChartData.periodTypes); interestRateChartData.productName, chartSlabs, interestRateChartData.periodTypes);
} }
public static InterestRateChartData withTemplate(InterestRateChartData interestRateChartData, Collection<EnumOptionData> periodTypes) { public static InterestRateChartData withTemplate(InterestRateChartData interestRateChartData, Collection<EnumOptionData> periodTypes) {
return new InterestRateChartData(interestRateChartData.id, interestRateChartData.name, interestRateChartData.description, return new InterestRateChartData(interestRateChartData.id, interestRateChartData.name, interestRateChartData.description,
interestRateChartData.fromDate, interestRateChartData.endDate, interestRateChartData.savingsProductId, interestRateChartData.fromDate, interestRateChartData.endDate, interestRateChartData.productId,
interestRateChartData.savingsProductName, interestRateChartData.chartSlabs, periodTypes); interestRateChartData.productName, interestRateChartData.chartSlabs, periodTypes);
} }
public static InterestRateChartData template(Collection<EnumOptionData> periodTypes) { public static InterestRateChartData template(Collection<EnumOptionData> periodTypes) {
@@ -73,8 +74,8 @@ public class InterestRateChartData {
this.fromDate = fromDate; this.fromDate = fromDate;
this.endDate = endDate; this.endDate = endDate;
this.chartSlabs = chartSlabs; this.chartSlabs = chartSlabs;
this.savingsProductId = savingsProductId; this.productId = savingsProductId;
this.savingsProductName = savingsProductName; this.productName = savingsProductName;
this.periodTypes = periodTypes; 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.fromDateParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.idParamName; import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.idParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.nameParamName; 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.lang.reflect.Type;
import java.util.ArrayList; import java.util.ArrayList;
@@ -112,9 +112,9 @@ public class InterestRateChartDataValidator {
final JsonElement element = this.fromApiJsonHelper.parse(json); final JsonElement element = this.fromApiJsonHelper.parse(json);
if (this.fromApiJsonHelper.parameterExists(savingsProductIdParamName, element)) { if (this.fromApiJsonHelper.parameterExists(productIdParamName, element)) {
final Long savingsProductId = this.fromApiJsonHelper.extractLongNamed(savingsProductIdParamName, element); final Long savingsProductId = this.fromApiJsonHelper.extractLongNamed(productIdParamName, element);
baseDataValidator.reset().parameter(savingsProductIdParamName).value(savingsProductId).notNull().integerGreaterThanZero(); baseDataValidator.reset().parameter(productIdParamName).value(savingsProductId).notNull().integerGreaterThanZero();
} }
if (this.fromApiJsonHelper.parameterExists(nameParamName, element)) { if (this.fromApiJsonHelper.parameterExists(nameParamName, element)) {
@@ -24,25 +24,52 @@ public class InterestRateChartSlabData {
private final BigDecimal amountRangeFrom; private final BigDecimal amountRangeFrom;
private final BigDecimal amountRangeTo; private final BigDecimal amountRangeTo;
private final BigDecimal annualInterestRate; private final BigDecimal annualInterestRate;
private final BigDecimal interestRateForFemale;
private final BigDecimal interestRateForChildren;
private final BigDecimal interestRateForSeniorCitizen;
private final CurrencyData currency; private final CurrencyData currency;
// template // template
private Collection<EnumOptionData> periodTypes; private final Collection<EnumOptionData> periodTypes;
public static InterestRateChartSlabData instance(Long id, String description, EnumOptionData periodType, Integer fromPeriod, public static InterestRateChartSlabData instance(final Long id, final String description, final EnumOptionData periodType,
Integer toPeriod, BigDecimal amountRangeFrom, BigDecimal amountRangeTo, BigDecimal annualInterestRate, CurrencyData currency) { final Integer fromPeriod, final Integer toPeriod, final BigDecimal amountRangeFrom, final BigDecimal amountRangeTo,
Collection<EnumOptionData> periodTypes = null; 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, return new InterestRateChartSlabData(id, description, periodType, fromPeriod, toPeriod, amountRangeFrom, amountRangeTo,
annualInterestRate, currency, periodTypes); annualInterestRate, interestRateForFemale, interestRateForChildren, interestRateForSeniorCitizen, 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);
} }
private InterestRateChartSlabData(Long id, String description, EnumOptionData periodType, Integer fromPeriod, Integer toPeriod, public static InterestRateChartSlabData withTemplate(final InterestRateChartSlabData chartSlab,
BigDecimal amountRangeFrom, BigDecimal amountRangeTo, BigDecimal annualInterestRate, CurrencyData currency, Collection<EnumOptionData> periodTypes) { 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.id = id;
this.description = description; this.description = description;
this.periodType = periodType; this.periodType = periodType;
@@ -51,51 +78,59 @@ public class InterestRateChartSlabData {
this.amountRangeFrom = amountRangeFrom; this.amountRangeFrom = amountRangeFrom;
this.amountRangeTo = amountRangeTo; this.amountRangeTo = amountRangeTo;
this.annualInterestRate = annualInterestRate; this.annualInterestRate = annualInterestRate;
this.interestRateForFemale = interestRateForFemale;
this.interestRateForChildren = interestRateForChildren;
this.interestRateForSeniorCitizen = interestRateForSeniorCitizen;
this.currency = currency; this.currency = currency;
this.periodTypes = periodTypes; this.periodTypes = periodTypes;
} }
public String description() { public String description() {
return this.description; return this.description;
} }
public EnumOptionData periodType() { public EnumOptionData periodType() {
return this.periodType; return this.periodType;
} }
public Integer fromPeriod() { public Integer fromPeriod() {
return this.fromPeriod; return this.fromPeriod;
} }
public Integer toPeriod() { public Integer toPeriod() {
return this.toPeriod; return this.toPeriod;
} }
public BigDecimal amountRangeFrom() { public BigDecimal amountRangeFrom() {
return this.amountRangeFrom; return this.amountRangeFrom;
} }
public BigDecimal amountRangeTo() { public BigDecimal amountRangeTo() {
return this.amountRangeTo; return this.amountRangeTo;
} }
public BigDecimal annualInterestRate() { public BigDecimal annualInterestRate() {
return this.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() { public CurrencyData currency() {
return this.currency; return this.currency;
} }
public Collection<EnumOptionData> periodTypes() { public Collection<EnumOptionData> periodTypes() {
return this.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.currencyCodeParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.descriptionParamName; import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.descriptionParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.fromPeriodParamName; 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.periodTypeParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.toPeriodParamName; 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.InvalidJsonException;
import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException;
import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -61,17 +64,16 @@ public class InterestRateChartSlabDataValidator {
final JsonElement element = this.fromApiJsonHelper.parse(json); final JsonElement element = this.fromApiJsonHelper.parse(json);
final JsonObject objectElement = element.getAsJsonObject(); final JsonObject objectElement = element.getAsJsonObject();
final Locale locale = this.fromApiJsonHelper.extractLocaleParameter(objectElement); final Locale locale = this.fromApiJsonHelper.extractLocaleParameter(objectElement);
final String currencyCode = this.fromApiJsonHelper.extractStringNamed(currencyCodeParamName, element); final String currencyCode = this.fromApiJsonHelper.extractStringNamed(currencyCodeParamName, element);
baseDataValidator.reset().parameter(currencyCodeParamName).value(currencyCode).notBlank().notExceedingLengthOf(3); baseDataValidator.reset().parameter(currencyCodeParamName).value(currencyCode).notBlank().notExceedingLengthOf(3);
validateChartSlabsCreate(element, baseDataValidator, locale); validateChartSlabsCreate(element, baseDataValidator, locale);
throwExceptionIfValidationWarningsExist(dataValidationErrors); throwExceptionIfValidationWarningsExist(dataValidationErrors);
} }
public void validateChartSlabsCreate(final JsonElement element, final DataValidatorBuilder baseDataValidator, final Locale locale) { public void validateChartSlabsCreate(final JsonElement element, final DataValidatorBuilder baseDataValidator, final Locale locale) {
if (this.fromApiJsonHelper.parameterExists(descriptionParamName, element)) { if (this.fromApiJsonHelper.parameterExists(descriptionParamName, element)) {
final String description = this.fromApiJsonHelper.extractStringNamed(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); final Integer periodType = this.fromApiJsonHelper.extractIntegerNamed(periodTypeParamName, element, locale);
baseDataValidator.reset().parameter(periodTypeParamName).value(periodType).notNull() baseDataValidator.reset().parameter(periodTypeParamName).value(periodType).notNull()
.isOneOfTheseValues(InterestRateChartPeriodType.integerValues()); .isOneOfTheseValues(PeriodFrequencyType.integerValues());
Integer toPeriod = null; Integer toPeriod = null;
@@ -117,6 +119,25 @@ public class InterestRateChartSlabDataValidator {
final BigDecimal annualInterestRate = this.fromApiJsonHelper.extractBigDecimalNamed(annualInterestRateParamName, element, locale); final BigDecimal annualInterestRate = this.fromApiJsonHelper.extractBigDecimalNamed(annualInterestRateParamName, element, locale);
baseDataValidator.reset().parameter(annualInterestRateParamName).value(annualInterestRate).notNull().zeroOrPositiveAmount(); 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) { 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) { public void validateChartSlabsUpdate(final JsonElement element, final DataValidatorBuilder baseDataValidator, final Locale locale) {
if (this.fromApiJsonHelper.parameterExists(descriptionParamName, element)) { if (this.fromApiJsonHelper.parameterExists(descriptionParamName, element)) {
final String description = this.fromApiJsonHelper.extractStringNamed(descriptionParamName, element); final String description = this.fromApiJsonHelper.extractStringNamed(descriptionParamName, element);
@@ -148,7 +168,7 @@ public class InterestRateChartSlabDataValidator {
if (this.fromApiJsonHelper.parameterExists(periodTypeParamName, element)) { if (this.fromApiJsonHelper.parameterExists(periodTypeParamName, element)) {
final Integer periodType = this.fromApiJsonHelper.extractIntegerNamed(periodTypeParamName, element, locale); final Integer periodType = this.fromApiJsonHelper.extractIntegerNamed(periodTypeParamName, element, locale);
baseDataValidator.reset().parameter(periodTypeParamName).value(periodType).notNull() baseDataValidator.reset().parameter(periodTypeParamName).value(periodType).notNull()
.isOneOfTheseValues(InterestRateChartPeriodType.integerValues()); .isOneOfTheseValues(PeriodFrequencyType.integerValues());
} }
Integer fromPeriod = null; Integer fromPeriod = null;
@@ -192,6 +212,24 @@ public class InterestRateChartSlabDataValidator {
locale); locale);
baseDataValidator.reset().parameter(annualInterestRateParamName).value(annualInterestRate).notNull().zeroOrPositiveAmount(); 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)) { if (this.fromApiJsonHelper.parameterExists(currencyCodeParamName, element)) {
final String currencyCode = this.fromApiJsonHelper.extractStringNamed(currencyCodeParamName, element); final String currencyCode = this.fromApiJsonHelper.extractStringNamed(currencyCodeParamName, element);
@@ -6,15 +6,18 @@
package org.mifosplatform.portfolio.interestratechart.domain; package org.mifosplatform.portfolio.interestratechart.domain;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.INTERESTRATE_CHART_RESOURCE_NAME; 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.InterestRateChartSlabApiConstants.amountRangeFromParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.amountRangeToParamName; import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.amountRangeToParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.annualInterestRateParamName; import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.annualInterestRateParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.deleteParamName; import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.deleteParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.descriptionParamName; 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.idParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.periodTypeParamName; import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.interestRateForChildrenParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.toPeriodParamName; 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.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
@@ -202,8 +205,12 @@ public class InterestRateChart extends AbstractPersistable<Long> {
final BigDecimal amountRangeTo = chartSlabsCommand.bigDecimalValueOfParameterNamed(amountRangeToParamName); final BigDecimal amountRangeTo = chartSlabsCommand.bigDecimalValueOfParameterNamed(amountRangeToParamName);
final BigDecimal annualInterestRate = chartSlabsCommand final BigDecimal annualInterestRate = chartSlabsCommand
.bigDecimalValueOfParameterNamed(annualInterestRateParamName); .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, 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); final InterestRateChartSlab chartSlab = InterestRateChartSlab.createNew(slabFields, this);
chartSlab.slabFields().validateChartSlabPlatformRules(chartSlabsCommand, baseDataValidator); chartSlab.slabFields().validateChartSlabPlatformRules(chartSlabsCommand, baseDataValidator);
this.addChartSlab(chartSlab); this.addChartSlab(chartSlab);
@@ -84,7 +84,7 @@ public class InterestRateChartFields {
this.fromDate = newValue.toDate(); this.fromDate = newValue.toDate();
} }
if (command.isChangeInLocalDateParameterNamed(endDateParamName, getFromDateAsLocalDate())) { if (command.isChangeInLocalDateParameterNamed(endDateParamName, getEndDateAsLocalDate())) {
final LocalDate newValue = command.localDateValueOfParameterNamed(endDateParamName); final LocalDate newValue = command.localDateValueOfParameterNamed(endDateParamName);
final String newValueAsString = command.stringValueOfParameterNamed(endDateParamName); final String newValueAsString = command.stringValueOfParameterNamed(endDateParamName);
actualChanges.put(endDateParamName, newValueAsString); actualChanges.put(endDateParamName, newValueAsString);
@@ -135,7 +135,7 @@ public class InterestRateChartFields {
final LocalDateInterval thisInterval = LocalDateInterval.create(thisFromDate, thisEndDate); final LocalDateInterval thisInterval = LocalDateInterval.create(thisFromDate, thisEndDate);
final LocalDateInterval thatInterval = LocalDateInterval.create(thatFromDate, thatEndDate); final LocalDateInterval thatInterval = LocalDateInterval.create(thatFromDate, thatEndDate);
if(thisInterval.containsPortionOf(thatInterval) || thisInterval.contains(thatInterval)){ if(thisInterval.containsPortionOf(thatInterval) || thatInterval.containsPortionOf(thisInterval)){
return true; return true;
} }
return false;// no overlapping return false;// no overlapping
@@ -5,13 +5,16 @@
*/ */
package org.mifosplatform.portfolio.interestratechart.domain; package org.mifosplatform.portfolio.interestratechart.domain;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.amountRangeFromParamName; import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.amountRangeFromParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.amountRangeToParamName; import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.amountRangeToParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.annualInterestRateParamName; import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.annualInterestRateParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.descriptionParamName; import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.interestRateForFemaleParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.fromPeriodParamName; import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.interestRateForChildrenParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.periodTypeParamName; import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.interestRateForSeniorCitizenParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.toPeriodParamName; 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.math.BigDecimal;
import java.util.Map; import java.util.Map;
@@ -52,6 +55,15 @@ public class InterestRateChartSlabFields {
@Column(name = "annual_interest_rate", scale = 6, precision = 19, nullable = false) @Column(name = "annual_interest_rate", scale = 6, precision = 19, nullable = false)
private BigDecimal annualInterestRate; 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) @Column(name = "currency_code", nullable = false)
private String currencyCode; private String currencyCode;
@@ -59,15 +71,18 @@ public class InterestRateChartSlabFields {
// //
} }
public static InterestRateChartSlabFields createNew(String description, final SavingsPeriodFrequencyType periodFrequencyType, public static InterestRateChartSlabFields createNew(final String description, final SavingsPeriodFrequencyType periodFrequencyType,
Integer fromPeriod, Integer toPeriod, BigDecimal amountRangeFrom, BigDecimal amountRangeTo, BigDecimal annualInterestRate, final Integer fromPeriod, final Integer toPeriod, final BigDecimal amountRangeFrom, final BigDecimal amountRangeTo,
String currencyCode) { final BigDecimal annualInterestRate, final BigDecimal interestRateForFemale, final BigDecimal interestRateForChildren,
final BigDecimal interestRateForSeniorCitizen, final String currencyCode) {
return new InterestRateChartSlabFields(description, periodFrequencyType, fromPeriod, toPeriod, amountRangeFrom, amountRangeTo, 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, private InterestRateChartSlabFields(final String description, final SavingsPeriodFrequencyType periodFrequencyType,
Integer toPeriod, BigDecimal amountRangeFrom, BigDecimal amountRangeTo, BigDecimal annualInterestRate, String currencyCode) { 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.description = description;
this.periodType = (periodFrequencyType == null) ? null : periodFrequencyType.getValue(); this.periodType = (periodFrequencyType == null) ? null : periodFrequencyType.getValue();
this.fromPeriod = fromPeriod; this.fromPeriod = fromPeriod;
@@ -75,10 +90,13 @@ public class InterestRateChartSlabFields {
this.amountRangeFrom = amountRangeFrom; this.amountRangeFrom = amountRangeFrom;
this.amountRangeTo = amountRangeTo; this.amountRangeTo = amountRangeTo;
this.annualInterestRate = annualInterestRate; this.annualInterestRate = annualInterestRate;
this.interestRateForFemale = interestRateForFemale;
this.interestRateForChildren = interestRateForChildren;
this.interestRateForSeniorCitizen = interestRateForSeniorCitizen;
this.currencyCode = currencyCode; 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)) { if (command.isChangeInStringParameterNamed(descriptionParamName, this.description)) {
final String newValue = command.stringValueOfParameterNamed(descriptionParamName); final String newValue = command.stringValueOfParameterNamed(descriptionParamName);
@@ -86,52 +104,70 @@ public class InterestRateChartSlabFields {
this.description = newValue; this.description = newValue;
} }
if (command.isChangeInIntegerParameterNamed(periodTypeParamName, periodType)) { if (command.isChangeInIntegerParameterNamed(periodTypeParamName, this.periodType)) {
final Integer newValue = command.integerValueOfParameterNamed(periodTypeParamName); final Integer newValue = command.integerValueOfParameterNamed(periodTypeParamName);
actualChanges.put(periodTypeParamName, newValue); actualChanges.put(periodTypeParamName, newValue);
this.periodType = newValue; this.periodType = newValue;
} }
if (command.isChangeInIntegerParameterNamed(fromPeriodParamName, fromPeriod)) { if (command.isChangeInIntegerParameterNamed(fromPeriodParamName, this.fromPeriod)) {
final Integer newValue = command.integerValueOfParameterNamed(fromPeriodParamName); final Integer newValue = command.integerValueOfParameterNamed(fromPeriodParamName);
actualChanges.put(fromPeriodParamName, newValue); actualChanges.put(fromPeriodParamName, newValue);
this.fromPeriod = newValue; this.fromPeriod = newValue;
} }
if (command.isChangeInIntegerParameterNamed(toPeriodParamName, toPeriod)) { if (command.isChangeInIntegerParameterNamed(toPeriodParamName, this.toPeriod)) {
final Integer newValue = command.integerValueOfParameterNamed(toPeriodParamName); final Integer newValue = command.integerValueOfParameterNamed(toPeriodParamName);
actualChanges.put(toPeriodParamName, newValue); actualChanges.put(toPeriodParamName, newValue);
this.toPeriod = newValue; this.toPeriod = newValue;
} }
if (command.isChangeInBigDecimalParameterNamed(amountRangeFromParamName, amountRangeFrom)) { if (command.isChangeInBigDecimalParameterNamed(amountRangeFromParamName, this.amountRangeFrom)) {
final BigDecimal newValue = command.bigDecimalValueOfParameterNamed(amountRangeFromParamName); final BigDecimal newValue = command.bigDecimalValueOfParameterNamed(amountRangeFromParamName);
actualChanges.put(amountRangeFromParamName, newValue); actualChanges.put(amountRangeFromParamName, newValue);
this.amountRangeFrom = newValue; this.amountRangeFrom = newValue;
} }
if (command.isChangeInBigDecimalParameterNamed(amountRangeToParamName, amountRangeTo)) { if (command.isChangeInBigDecimalParameterNamed(amountRangeToParamName, this.amountRangeTo)) {
final BigDecimal newValue = command.bigDecimalValueOfParameterNamed(amountRangeToParamName); final BigDecimal newValue = command.bigDecimalValueOfParameterNamed(amountRangeToParamName);
actualChanges.put(amountRangeToParamName, newValue); actualChanges.put(amountRangeToParamName, newValue);
this.amountRangeTo = newValue; this.amountRangeTo = newValue;
} }
if (command.isChangeInBigDecimalParameterNamed(annualInterestRateParamName, annualInterestRate)) { if (command.isChangeInBigDecimalParameterNamed(annualInterestRateParamName, this.annualInterestRate)) {
final BigDecimal newValue = command.bigDecimalValueOfParameterNamed(annualInterestRateParamName); final BigDecimal newValue = command.bigDecimalValueOfParameterNamed(annualInterestRateParamName);
actualChanges.put(annualInterestRateParamName, newValue); actualChanges.put(annualInterestRateParamName, newValue);
this.annualInterestRate = 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) { public void validateChartSlabPlatformRules(final JsonCommand chartSlabsCommand, final DataValidatorBuilder baseDataValidator) {
if (this.isFromPeriodGreaterThanToPeriod()) { if (isFromPeriodGreaterThanToPeriod()) {
final Integer fromPeriod = chartSlabsCommand.integerValueOfParameterNamed(fromPeriodParamName); final Integer fromPeriod = chartSlabsCommand.integerValueOfParameterNamed(fromPeriodParamName);
baseDataValidator.parameter(fromPeriodParamName).value(fromPeriod).failWithCode("from.period.is.greater.than.to.period"); baseDataValidator.parameter(fromPeriodParamName).value(fromPeriod).failWithCode("from.period.is.greater.than.to.period");
} }
if (this.isAmountRangeFromGreaterThanTo()) { if (isAmountRangeFromGreaterThanTo()) {
final BigDecimal amountRangeFrom = chartSlabsCommand.bigDecimalValueOfParameterNamed(amountRangeFromParamName); final BigDecimal amountRangeFrom = chartSlabsCommand.bigDecimalValueOfParameterNamed(amountRangeFromParamName);
baseDataValidator.parameter(amountRangeFromParamName).value(amountRangeFrom) baseDataValidator.parameter(amountRangeFromParamName).value(amountRangeFrom)
.failWithCode("amount.range.from.is.greater.than.amount.range.to"); .failWithCode("amount.range.from.is.greater.than.amount.range.to");
@@ -140,7 +176,7 @@ public class InterestRateChartSlabFields {
public boolean isFromPeriodGreaterThanToPeriod() { public boolean isFromPeriodGreaterThanToPeriod() {
boolean isGreater = false; boolean isGreater = false;
if (this.toPeriod != null && fromPeriod.compareTo(this.toPeriod) > 1) { if (this.toPeriod != null && this.fromPeriod.compareTo(this.toPeriod) > 1) {
isGreater = true; isGreater = true;
} }
return isGreater; return isGreater;
@@ -166,7 +202,7 @@ public class InterestRateChartSlabFields {
return this.toPeriod; return this.toPeriod;
} }
public boolean isPeriodOverlapping(InterestRateChartSlabFields that) { public boolean isPeriodOverlapping(final InterestRateChartSlabFields that) {
if (that.toPeriod == null) { if (that.toPeriod == null) {
if (this.toPeriod == null) { return true; } if (this.toPeriod == null) { return true; }
return that.fromPeriod <= this.toPeriod; return that.fromPeriod <= this.toPeriod;
@@ -187,9 +223,21 @@ public class InterestRateChartSlabFields {
return this.annualInterestRate; 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) { public Integer depositPeriod(final LocalDate periodStartDate, final LocalDate periodEndDate) {
Integer actualDepositPeriod = 0; Integer actualDepositPeriod = 0;
final SavingsPeriodFrequencyType periodFrequencyType = SavingsPeriodFrequencyType.fromInt(this.periodType()); final SavingsPeriodFrequencyType periodFrequencyType = SavingsPeriodFrequencyType.fromInt(periodType());
switch (periodFrequencyType) { switch (periodFrequencyType) {
case DAYS: case DAYS:
actualDepositPeriod = Days.daysBetween(periodStartDate, periodEndDate).getDays(); actualDepositPeriod = Days.daysBetween(periodStartDate, periodEndDate).getDays();
@@ -216,7 +264,9 @@ public class InterestRateChartSlabFields {
returnValue = depositAmount.compareTo(amountRangeFrom) >= 0 && depositAmount.compareTo(amountRangeTo) <= 0; returnValue = depositAmount.compareTo(amountRangeFrom) >= 0 && depositAmount.compareTo(amountRangeTo) <= 0;
} else if (amountRangeFrom != null) { } else if (amountRangeFrom != null) {
returnValue = depositAmount.compareTo(amountRangeFrom) >= 0; 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; return returnValue;
} }
@@ -24,6 +24,7 @@ public class DeleteInterestRateChartSlabCommandHandler implements NewCommandSour
@Override @Override
public CommandProcessingResult processCommand(final JsonCommand command) { 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 @Override
public CommandProcessingResult processCommand(final JsonCommand command) { 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 java.util.Collection;
import org.mifosplatform.infrastructure.core.data.EnumOptionData; 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; import org.springframework.stereotype.Service;
@Service @Service
@@ -16,7 +16,7 @@ public class InterestRateChartDropdownReadPlatformServiceImpl implements Interes
@Override @Override
public Collection<EnumOptionData> retrievePeriodTypeOptions() { 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 java.util.List;
import org.mifosplatform.infrastructure.core.data.EnumOptionData; import org.mifosplatform.infrastructure.core.data.EnumOptionData;
import org.mifosplatform.portfolio.interestratechart.InterestRateChartPeriodType; import org.mifosplatform.portfolio.common.domain.PeriodFrequencyType;
public class InterestRateChartEnumerations { public class InterestRateChartEnumerations {
public static EnumOptionData periodType(final Integer type) { public static EnumOptionData periodType(final Integer type) {
return periodType(InterestRateChartPeriodType.fromInt(type)); return periodType(PeriodFrequencyType.fromInt(type));
} }
public static EnumOptionData periodType(final InterestRateChartPeriodType type) { public static EnumOptionData periodType(final PeriodFrequencyType type) {
EnumOptionData optionData = new EnumOptionData(InterestRateChartPeriodType.INVALID.getValue().longValue(), EnumOptionData optionData = new EnumOptionData(PeriodFrequencyType.INVALID.getValue().longValue(),
InterestRateChartPeriodType.INVALID.getCode(), "Invalid"); PeriodFrequencyType.INVALID.getCode(), "Invalid");
switch (type) { switch (type) {
case INVALID: case INVALID:
break; break;
case DAYS: case DAYS:
optionData = new EnumOptionData(InterestRateChartPeriodType.DAYS.getValue().longValue(), optionData = new EnumOptionData(PeriodFrequencyType.DAYS.getValue().longValue(),
InterestRateChartPeriodType.DAYS.getCode(), "Days"); PeriodFrequencyType.DAYS.getCode(), "Days");
break; break;
case WEEKS: case WEEKS:
optionData = new EnumOptionData(InterestRateChartPeriodType.WEEKS.getValue().longValue(), optionData = new EnumOptionData(PeriodFrequencyType.WEEKS.getValue().longValue(),
InterestRateChartPeriodType.WEEKS.getCode(), "Weeks"); PeriodFrequencyType.WEEKS.getCode(), "Weeks");
break; break;
case MONTHS: case MONTHS:
optionData = new EnumOptionData(InterestRateChartPeriodType.MONTHS.getValue().longValue(), optionData = new EnumOptionData(PeriodFrequencyType.MONTHS.getValue().longValue(),
InterestRateChartPeriodType.MONTHS.getCode(), "Months"); PeriodFrequencyType.MONTHS.getCode(), "Months");
break; break;
case YEARS: case YEARS:
optionData = new EnumOptionData(InterestRateChartPeriodType.YEARS.getValue().longValue(), optionData = new EnumOptionData(PeriodFrequencyType.YEARS.getValue().longValue(),
InterestRateChartPeriodType.YEARS.getCode(), "Years"); PeriodFrequencyType.YEARS.getCode(), "Years");
break; break;
} }
return optionData; 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>(); final List<EnumOptionData> optionDatas = new ArrayList<EnumOptionData>();
for (final InterestRateChartPeriodType periodType : periodTypes) { for (final PeriodFrequencyType periodType : periodTypes) {
if (!periodType.isInvalid()) { if (!periodType.isInvalid()) {
optionDatas.add(periodType(periodType)); optionDatas.add(periodType(periodType));
} }
@@ -47,13 +47,6 @@ public class InterestRateChartReadPlatformServiceImpl implements InterestRateCha
this.chartDropdownReadPlatformService = chartDropdownReadPlatformService; this.chartDropdownReadPlatformService = chartDropdownReadPlatformService;
} }
/*
* @Override public Collection<InterestRateChartData> retrieveAll(Long
* productId) {
*
* // TODO return null; }
*/
@Override @Override
public InterestRateChartData retrieveOne(Long chartId) { public InterestRateChartData retrieveOne(Long chartId) {
try { 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 @Override
public Collection<InterestRateChartData> retrieveAllWithSlabs(Long productId) { public Collection<InterestRateChartData> retrieveAllWithSlabs(Long productId) {
this.context.authenticatedUser(); 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.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.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.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.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("curr.display_symbol as currencyDisplaySymbol, curr.decimal_places as currencyDigits, curr.currency_multiplesof as inMultiplesOf, ")
.append("sp.id as savingsProductId, sp.name as savingsProductName ") .append("sp.id as savingsProductId, sp.name as savingsProductName ")
@@ -198,7 +185,7 @@ public class InterestRateChartReadPlatformServiceImpl implements InterestRateCha
final StringBuilder sqlBuilder = new StringBuilder(400); final StringBuilder sqlBuilder = new StringBuilder(400);
sqlBuilder.append("irc.id as ircId, irc.name as ircName, irc.description as ircDescription, ") 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("sp.id as savingsProductId, sp.name as savingsProductName ").append("from ")
.append("m_interest_rate_chart irc ") .append("m_interest_rate_chart irc ")
.append("left join m_deposit_product_interest_rate_chart dpirc on irc.id=dpirc.interest_rate_chart_id ") .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 String description = rs.getString("ircDescription");
final LocalDate fromDate = JdbcSupport.getLocalDate(rs, "ircFromDate"); final LocalDate fromDate = JdbcSupport.getLocalDate(rs, "ircFromDate");
final LocalDate endDate = JdbcSupport.getLocalDate(rs, "ircEndDate"); 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"); 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.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.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.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.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("curr.display_symbol as currencyDisplaySymbol, curr.decimal_places as currencyDigits, curr.currency_multiplesof as inMultiplesOf ")
.append("from ").append("m_interest_rate_slab ircd ") .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 amountRangeFrom = rs.getBigDecimal("ircdAmountRangeFrom");
final BigDecimal amountRangeTo = rs.getBigDecimal("ircdAmountRangeTo"); final BigDecimal amountRangeTo = rs.getBigDecimal("ircdAmountRangeTo");
final BigDecimal annualInterestRate = rs.getBigDecimal("ircdAnnualInterestRate"); 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 // currency Slabs
final String currencyCode = rs.getString("currencyCode"); final String currencyCode = rs.getString("currencyCode");
@@ -272,7 +264,7 @@ public class InterestRateChartReadPlatformServiceImpl implements InterestRateCha
currencyDisplaySymbol, currencyNameCode); currencyDisplaySymbol, currencyNameCode);
return InterestRateChartSlabData.instance(id, description, periodType, fromPeriod, toPeriod, amountRangeFrom, amountRangeTo, 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; package org.mifosplatform.portfolio.interestratechart.service;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.amountRangeFromParamName; import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.amountRangeFromParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.amountRangeToParamName; import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.amountRangeToParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.annualInterestRateParamName; 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.chartSlabs;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.descriptionParamName; 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.periodTypeParamName; import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.periodTypeParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.toPeriodParamName; 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.INTERESTRATE_CHART_SLAB_RESOURCE_NAME;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartSlabApiConstants.currencyCodeParamName; 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.InterestRateChart;
import org.mifosplatform.portfolio.interestratechart.domain.InterestRateChartSlab; import org.mifosplatform.portfolio.interestratechart.domain.InterestRateChartSlab;
import org.mifosplatform.portfolio.interestratechart.domain.InterestRateChartSlabFields; import org.mifosplatform.portfolio.interestratechart.domain.InterestRateChartSlabFields;
import org.mifosplatform.portfolio.interestratechart.exception.InterestRateChartSlabNotFoundException;
import org.mifosplatform.portfolio.savings.SavingsPeriodFrequencyType; import org.mifosplatform.portfolio.savings.SavingsPeriodFrequencyType;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -64,7 +68,7 @@ public class InterestRateChartSlabAssembler {
final Locale locale = this.fromApiJsonHelper.extractLocaleParameter(elementObject); final Locale locale = this.fromApiJsonHelper.extractLocaleParameter(elementObject);
final String currencyCode = command.stringValueOfParameterNamed(currencyCodeParamName); 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); 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 amountRangeFrom = this.fromApiJsonHelper.extractBigDecimalNamed(amountRangeFromParamName, element, locale);
final BigDecimal amountRangeTo = this.fromApiJsonHelper.extractBigDecimalNamed(amountRangeToParamName, element, locale); final BigDecimal amountRangeTo = this.fromApiJsonHelper.extractBigDecimalNamed(amountRangeToParamName, element, locale);
final BigDecimal annualInterestRate = this.fromApiJsonHelper.extractBigDecimalNamed(annualInterestRateParamName, 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, 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); return InterestRateChartSlab.createNew(slabFields, interestRateChart);
} }
@@ -100,6 +108,9 @@ public class InterestRateChartSlabAssembler {
public InterestRateChartSlab assembleFrom(final Long chartSlabId, final Long chartId) { public InterestRateChartSlab assembleFrom(final Long chartSlabId, final Long chartId) {
final InterestRateChart chart = this.interestRateChartRepositoryWrapper.findOneWithNotFoundDetection(chartId); final InterestRateChart chart = this.interestRateChartRepositoryWrapper.findOneWithNotFoundDetection(chartId);
final InterestRateChartSlab interestRateChartSlab = chart.findChartSlab(chartSlabId); final InterestRateChartSlab interestRateChartSlab = chart.findChartSlab(chartSlabId);
if (interestRateChartSlab == null) throw new InterestRateChartSlabNotFoundException(chartSlabId, chartId);
return interestRateChartSlab; return interestRateChartSlab;
} }
@@ -16,4 +16,6 @@ public interface InterestRateChartSlabReadPlatformService {
InterestRateChartSlabData retrieveOne(Long chartId, Long chartSlabId); InterestRateChartSlabData retrieveOne(Long chartId, Long chartSlabId);
InterestRateChartSlabData retrieveWithTemplate(InterestRateChartSlabData chartSlab); InterestRateChartSlabData retrieveWithTemplate(InterestRateChartSlabData chartSlab);
InterestRateChartSlabData retrieveTemplate();
} }
@@ -62,6 +62,11 @@ public class InterestRateChartSlabReadPlatformServiceImpl implements InterestRat
return InterestRateChartSlabData.withTemplate(chartSlab, this.chartDropdownReadPlatformService.retrievePeriodTypeOptions()); 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 static final class InterestRateChartSlabsMapper implements RowMapper<InterestRateChartSlabData> {
private final String schemaSql; 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.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.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.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.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("curr.display_symbol as currencyDisplaySymbol, curr.decimal_places as currencyDigits, curr.currency_multiplesof as inMultiplesOf ")
.append("from ").append("m_interest_rate_slab ircd ") .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 amountRangeFrom = rs.getBigDecimal("ircdAmountRangeFrom");
final BigDecimal amountRangeTo = rs.getBigDecimal("ircdAmountRangeTo"); final BigDecimal amountRangeTo = rs.getBigDecimal("ircdAmountRangeTo");
final BigDecimal annualInterestRate = rs.getBigDecimal("ircdAnnualInterestRate"); 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 // currency Slabs
final String currencyCode = rs.getString("currencyCode"); final String currencyCode = rs.getString("currencyCode");
@@ -112,7 +122,7 @@ public class InterestRateChartSlabReadPlatformServiceImpl implements InterestRat
currencyDisplaySymbol, currencyNameCode); currencyDisplaySymbol, currencyNameCode);
return InterestRateChartSlabData.instance(id, description, periodType, fromPeriod, toPeriod, amountRangeFrom, amountRangeTo, 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); final InterestRateChartSlab interestRateChartSlab = this.interestRateChartSlabAssembler.assembleFrom(command);
this.chartSlabRepository.saveAndFlush(interestRateChartSlab); this.chartSlabRepository.save(interestRateChartSlab);
final Long interestRateChartId = interestRateChartSlab.getId(); 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.note.domain.NoteRepository;
import org.mifosplatform.portfolio.paymentdetail.domain.PaymentDetail; import org.mifosplatform.portfolio.paymentdetail.domain.PaymentDetail;
import org.mifosplatform.portfolio.paymentdetail.service.PaymentDetailWritePlatformService; import org.mifosplatform.portfolio.paymentdetail.service.PaymentDetailWritePlatformService;
import org.mifosplatform.portfolio.savings.domain.SavingsAccount;
import org.mifosplatform.portfolio.savings.exception.InsufficientAccountBalanceException; import org.mifosplatform.portfolio.savings.exception.InsufficientAccountBalanceException;
import org.mifosplatform.useradministration.domain.AppUser; import org.mifosplatform.useradministration.domain.AppUser;
import org.slf4j.Logger; import org.slf4j.Logger;
@@ -319,10 +320,11 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale); final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale);
for (final Map.Entry<Long, BigDecimal> entrySet : disBuLoanCharges.entrySet()) { for (final Map.Entry<Long, BigDecimal> entrySet : disBuLoanCharges.entrySet()) {
final PortfolioAccountData savingAccountData = this.accountAssociationsReadPlatformService.retriveLoanAssociation(loanId); final PortfolioAccountData savingAccountData = this.accountAssociationsReadPlatformService.retriveLoanAssociation(loanId);
final SavingsAccount fromSavingsAccount = null;
final AccountTransferDTO accountTransferDTO = new AccountTransferDTO(actualDisbursementDate, entrySet.getValue(), final AccountTransferDTO accountTransferDTO = new AccountTransferDTO(actualDisbursementDate, entrySet.getValue(),
PortfolioAccountType.SAVINGS, PortfolioAccountType.LOAN, savingAccountData.accountId(), loanId, "Loan Charge Payment", PortfolioAccountType.SAVINGS, PortfolioAccountType.LOAN, savingAccountData.accountId(), loanId, "Loan Charge Payment",
locale, fmt, null, null, LoanTransactionType.REPAYMENT_AT_DISBURSEMENT.getValue(), entrySet.getKey(), null, 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); this.accountTransfersWritePlatformService.transferFunds(accountTransferDTO);
} }
@@ -491,10 +493,12 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
for (final Map.Entry<Long, BigDecimal> entrySet : disBuLoanCharges.entrySet()) { for (final Map.Entry<Long, BigDecimal> entrySet : disBuLoanCharges.entrySet()) {
final PortfolioAccountData savingAccountData = this.accountAssociationsReadPlatformService.retriveLoanAssociation(loan final PortfolioAccountData savingAccountData = this.accountAssociationsReadPlatformService.retriveLoanAssociation(loan
.getId()); .getId());
final SavingsAccount fromSavingsAccount = null;
final AccountTransferDTO accountTransferDTO = new AccountTransferDTO(actualDisbursementDate, entrySet.getValue(), final AccountTransferDTO accountTransferDTO = new AccountTransferDTO(actualDisbursementDate, entrySet.getValue(),
PortfolioAccountType.SAVINGS, PortfolioAccountType.LOAN, savingAccountData.accountId(), loan.getId(), PortfolioAccountType.SAVINGS, PortfolioAccountType.LOAN, savingAccountData.accountId(), loan.getId(),
"Loan Charge Payment", locale, fmt, null, null, LoanTransactionType.REPAYMENT_AT_DISBURSEMENT.getValue(), "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); 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"; final String errorMessage = "Charge with id:" + loanChargeId + " requires linked savings account for payment";
throw new LinkedAccountRequiredException("loanCharge.pay", errorMessage, loanChargeId); throw new LinkedAccountRequiredException("loanCharge.pay", errorMessage, loanChargeId);
} }
final SavingsAccount fromSavingsAccount = null;
final AccountTransferDTO accountTransferDTO = new AccountTransferDTO(transactionDate, amount, PortfolioAccountType.SAVINGS, final AccountTransferDTO accountTransferDTO = new AccountTransferDTO(transactionDate, amount, PortfolioAccountType.SAVINGS,
PortfolioAccountType.LOAN, portfolioAccountData.accountId(), loanId, "Loan Charge Payment", locale, fmt, null, null, PortfolioAccountType.LOAN, portfolioAccountData.accountId(), loanId, "Loan Charge Payment", locale, fmt, null, null,
LoanTransactionType.CHARGE_PAYMENT.getValue(), loanChargeId, loanInstallmentNumber, 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); this.accountTransfersWritePlatformService.transferFunds(accountTransferDTO);
return new CommandProcessingResultBuilder() // 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"; 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()); throw new LinkedAccountRequiredException("loan.disburse.to.savings", errorMessage, loan.getId());
} }
final SavingsAccount fromSavingsAccount = null;
final AccountTransferDTO accountTransferDTO = new AccountTransferDTO(transactionDate, amount.getAmount(), final AccountTransferDTO accountTransferDTO = new AccountTransferDTO(transactionDate, amount.getAmount(),
PortfolioAccountType.LOAN, PortfolioAccountType.SAVINGS, loan.getId(), portfolioAccountData.accountId(), PortfolioAccountType.LOAN, PortfolioAccountType.SAVINGS, loan.getId(), portfolioAccountData.accountId(),
"Loan Disbursement", locale, fmt, paymentDetail, LoanTransactionType.DISBURSEMENT.getValue(), null, null, null, "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); this.accountTransfersWritePlatformService.transferFunds(accountTransferDTO);
} }
@@ -1307,23 +1312,25 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
portfolioAccountData = this.accountAssociationsReadPlatformService.retriveLoanAssociation(chargeData portfolioAccountData = this.accountAssociationsReadPlatformService.retriveLoanAssociation(chargeData
.getLoanId()); .getLoanId());
} }
final SavingsAccount fromSavingsAccount = null;
final AccountTransferDTO accountTransferDTO = new AccountTransferDTO(new LocalDate(), final AccountTransferDTO accountTransferDTO = new AccountTransferDTO(new LocalDate(),
installmentChargeData.getAmountOutstanding(), PortfolioAccountType.SAVINGS, PortfolioAccountType.LOAN, installmentChargeData.getAmountOutstanding(), PortfolioAccountType.SAVINGS, PortfolioAccountType.LOAN,
portfolioAccountData.accountId(), chargeData.getLoanId(), "Loan Charge Payment", null, null, null, portfolioAccountData.accountId(), chargeData.getLoanId(), "Loan Charge Payment", null, null, null,
null, LoanTransactionType.CHARGE_PAYMENT.getValue(), chargeData.getId(), null, LoanTransactionType.CHARGE_PAYMENT.getValue(), chargeData.getId(),
installmentChargeData.getInstallmentNumber(), AccountTransferType.CHARGE_PAYMENT.getValue(), null, installmentChargeData.getInstallmentNumber(), AccountTransferType.CHARGE_PAYMENT.getValue(), null,
null, null, null, null); null, null, null, null, fromSavingsAccount);
transferFeeCharge(sb, accountTransferDTO); transferFeeCharge(sb, accountTransferDTO);
} }
} }
} else if (chargeData.getDueDate() != null && !chargeData.getDueDate().isAfter(new LocalDate())) { } else if (chargeData.getDueDate() != null && !chargeData.getDueDate().isAfter(new LocalDate())) {
final PortfolioAccountData portfolioAccountData = this.accountAssociationsReadPlatformService final PortfolioAccountData portfolioAccountData = this.accountAssociationsReadPlatformService
.retriveLoanAssociation(chargeData.getLoanId()); .retriveLoanAssociation(chargeData.getLoanId());
final SavingsAccount fromSavingsAccount = null;
final AccountTransferDTO accountTransferDTO = new AccountTransferDTO(new LocalDate(), final AccountTransferDTO accountTransferDTO = new AccountTransferDTO(new LocalDate(),
chargeData.getAmountOutstanding(), PortfolioAccountType.SAVINGS, PortfolioAccountType.LOAN, chargeData.getAmountOutstanding(), PortfolioAccountType.SAVINGS, PortfolioAccountType.LOAN,
portfolioAccountData.accountId(), chargeData.getLoanId(), "Loan Charge Payment", null, null, null, null, portfolioAccountData.accountId(), chargeData.getLoanId(), "Loan Charge Payment", null, null, null, null,
LoanTransactionType.CHARGE_PAYMENT.getValue(), chargeData.getId(), 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); transferFeeCharge(sb, accountTransferDTO);
} }
} }
@@ -1812,7 +1819,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final JsonElement parsedCommand = this.fromApiJsonHelper.parse(overdueInstallment.toString()); final JsonElement parsedCommand = this.fromApiJsonHelper.parse(overdueInstallment.toString());
final JsonCommand command = JsonCommand.from(overdueInstallment.toString(), parsedCommand, this.fromApiJsonHelper, 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(), applyChargeToOverdueLoanInstallment(overdueInstallment.getLoanId(), overdueInstallment.getChargeId(),
overdueInstallment.getPeriodNumber(), command); 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"; final String errorMessage = "Charge with id:" + loanChargeId + " requires linked savings account for payment";
throw new LinkedAccountRequiredException("loanCharge.pay", errorMessage, loanChargeId); throw new LinkedAccountRequiredException("loanCharge.pay", errorMessage, loanChargeId);
} }
final SavingsAccount fromSavingsAccount = null;
final AccountTransferDTO accountTransferDTO = new AccountTransferDTO(transactionDate, amount, PortfolioAccountType.SAVINGS, final AccountTransferDTO accountTransferDTO = new AccountTransferDTO(transactionDate, amount, PortfolioAccountType.SAVINGS,
PortfolioAccountType.LOAN, portfolioAccountData.accountId(), loanId, "Loan Charge Payment", locale, fmt, null, null, PortfolioAccountType.LOAN, portfolioAccountData.accountId(), loanId, "Loan Charge Payment", locale, fmt, null, null,
LoanTransactionType.CHARGE_PAYMENT.getValue(), loanChargeId, loanInstallmentNumber, 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); this.accountTransfersWritePlatformService.transferFunds(accountTransferDTO);
return transaction; return transaction;
@@ -247,6 +247,9 @@ public class MeetingsApiResource {
case LOANS: case LOANS:
resourceDetails.withLoanId(entityId); resourceDetails.withLoanId(entityId);
break; break;
case SAVINGS:
resourceDetails.withSavingsId(entityId);
break;
case INVALID: case INVALID:
break; break;
} }
@@ -97,10 +97,6 @@ public class DepositsApiConstants {
public static final String bankNumberParamName = "bankNumber"; public static final String bankNumberParamName = "bankNumber";
// Preclosure parameters // 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 preClosurePenalApplicableParamName = "preClosurePenalApplicable";
public static final String preClosurePenalInterestParamName = "preClosurePenalInterest"; public static final String preClosurePenalInterestParamName = "preClosurePenalInterest";
public static final String preClosurePenalInterestOnTypeIdParamName = "preClosurePenalInterestOnTypeId"; public static final String preClosurePenalInterestOnTypeIdParamName = "preClosurePenalInterestOnTypeId";
@@ -125,12 +121,14 @@ public class DepositsApiConstants {
public static final String depositPeriodFrequencyIdParamName = "depositPeriodFrequencyId"; public static final String depositPeriodFrequencyIdParamName = "depositPeriodFrequencyId";
// recurring parameters // recurring parameters
public static final String recurringDepositAmountParamName = "recurringDepositAmount"; public static final String mandatoryRecommendedDepositAmountParamName = "mandatoryRecommendedDepositAmount";
public static final String recurringDepositType = "recurringDepositType"; public static final String isMandatoryDepositParamName = "isMandatoryDeposit";
public static final String recurringDepositFrequencyType = "recurringDepositFrequencyType"; public static final String allowWithdrawalParamName = "allowWithdrawal";
public static final String recurringDepositFrequencyParamName = "recurringDepositFrequency"; public static final String adjustAdvanceTowardsFuturePaymentsParamName = "adjustAdvanceTowardsFuturePayments";
public static final String recurringDepositTypeIdParamName = "recurringDepositTypeId";
public static final String recurringDepositFrequencyTypeIdParamName = "recurringDepositFrequencyTypeId"; public static final String recurringFrequencyTypeParamName = "recurringFrequencyType";
public static final String recurringFrequencyParamName = "recurringFrequency";
public static final String isCalendarInheritedParamName = "isCalendarInherited";
// transaction parameters // transaction parameters
public static final String transactionDateParamName = "transactionDate"; public static final String transactionDateParamName = "transactionDate";
@@ -206,14 +204,10 @@ public class DepositsApiConstants {
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.PENALTY_INCOME_ACCOUNT_MAPPING.getValue(), chartsParamName)); SAVINGS_PRODUCT_ACCOUNTING_PARAMS.PENALTY_INCOME_ACCOUNT_MAPPING.getValue(), chartsParamName));
private static final Set<String> PRECLOSURE_REQUEST_DATA_PARAMETERS = new HashSet<String>(Arrays.asList( private static final Set<String> PRECLOSURE_REQUEST_DATA_PARAMETERS = new HashSet<String>(Arrays.asList(
interestFreePeriodApplicableParamName, interestFreeFromPeriodParamName, interestFreeToPeriodParamName, preClosurePenalApplicableParamName, preClosurePenalInterestParamName, preClosurePenalInterestOnTypeIdParamName));
interestFreePeriodFrequencyTypeIdParamName, preClosurePenalApplicableParamName, preClosurePenalInterestParamName,
preClosurePenalInterestOnTypeIdParamName));
private static final Set<String> PRECLOSURE_RESPONSE_DATA_PARAMETERS = new HashSet<String>(Arrays.asList( private static final Set<String> PRECLOSURE_RESPONSE_DATA_PARAMETERS = new HashSet<String>(Arrays.asList(
interestFreePeriodApplicableParamName, interestFreeFromPeriodParamName, interestFreeToPeriodParamName, preClosurePenalApplicableParamName, preClosurePenalInterestParamName, preClosurePenalInterestOnType));
interestFreePeriodFrequencyType, preClosurePenalApplicableParamName, preClosurePenalInterestParamName,
preClosurePenalInterestOnType));
private static final Set<String> DEPOSIT_TERM_REQUEST_DATA_PARAMETERS = new HashSet<String>(Arrays.asList(minDepositTermParamName, private static final Set<String> DEPOSIT_TERM_REQUEST_DATA_PARAMETERS = new HashSet<String>(Arrays.asList(minDepositTermParamName,
maxDepositTermParamName, minDepositTermTypeIdParamName, maxDepositTermTypeIdParamName, inMultiplesOfDepositTermParamName, maxDepositTermParamName, minDepositTermTypeIdParamName, maxDepositTermTypeIdParamName, inMultiplesOfDepositTermParamName,
@@ -224,11 +218,14 @@ public class DepositsApiConstants {
inMultiplesOfDepositTermType, depositAmountParamName, depositMinAmountParamName, depositMaxAmountParamName)); inMultiplesOfDepositTermType, depositAmountParamName, depositMinAmountParamName, depositMaxAmountParamName));
private static final Set<String> RECURRING_DETAILS_REQUEST_DATA_PARAMETERS = new HashSet<String>(Arrays.asList( private static final Set<String> RECURRING_DETAILS_REQUEST_DATA_PARAMETERS = new HashSet<String>(Arrays.asList(
recurringDepositAmountParamName, recurringDepositTypeIdParamName, recurringDepositFrequencyTypeIdParamName, mandatoryRecommendedDepositAmountParamName, isMandatoryDepositParamName, allowWithdrawalParamName,
recurringDepositFrequencyParamName)); adjustAdvanceTowardsFuturePaymentsParamName, recurringFrequencyTypeParamName, recurringFrequencyParamName,
isCalendarInheritedParamName));
private static final Set<String> RECURRING_DETAILS_RESPONSE_DATA_PARAMETERS = new HashSet<String>(Arrays.asList( 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>( public static final Set<String> DEPOSIT_PRECLOSURE_CALCULATION_REQUEST_DATA_PARAMETERS = new HashSet<String>(
Arrays.asList(preMatureCloseOnDateParamName)); Arrays.asList(preMatureCloseOnDateParamName));
@@ -44,6 +44,7 @@ import org.mifosplatform.organisation.monetary.data.CurrencyData;
import org.mifosplatform.organisation.monetary.service.CurrencyReadPlatformService; import org.mifosplatform.organisation.monetary.service.CurrencyReadPlatformService;
import org.mifosplatform.portfolio.charge.data.ChargeData; import org.mifosplatform.portfolio.charge.data.ChargeData;
import org.mifosplatform.portfolio.charge.service.ChargeReadPlatformService; 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.data.InterestRateChartData;
import org.mifosplatform.portfolio.interestratechart.service.InterestRateChartReadPlatformService; import org.mifosplatform.portfolio.interestratechart.service.InterestRateChartReadPlatformService;
import org.mifosplatform.portfolio.paymentdetail.PaymentDetailConstants; import org.mifosplatform.portfolio.paymentdetail.PaymentDetailConstants;
@@ -69,7 +70,7 @@ import org.springframework.util.CollectionUtils;
public class FixedDepositProductsApiResource { public class FixedDepositProductsApiResource {
private final DepositProductReadPlatformService depositProductReadPlatformService; private final DepositProductReadPlatformService depositProductReadPlatformService;
private final SavingsDropdownReadPlatformService dropdownReadPlatformService; private final SavingsDropdownReadPlatformService savingsDropdownReadPlatformService;
private final CurrencyReadPlatformService currencyReadPlatformService; private final CurrencyReadPlatformService currencyReadPlatformService;
private final PlatformSecurityContext context; private final PlatformSecurityContext context;
private final DefaultToApiJsonSerializer<FixedDepositProductData> toApiJsonSerializer; private final DefaultToApiJsonSerializer<FixedDepositProductData> toApiJsonSerializer;
@@ -82,10 +83,11 @@ public class FixedDepositProductsApiResource {
private final InterestRateChartReadPlatformService chartReadPlatformService; private final InterestRateChartReadPlatformService chartReadPlatformService;
private final InterestRateChartReadPlatformService interestRateChartReadPlatformService; private final InterestRateChartReadPlatformService interestRateChartReadPlatformService;
private final DepositsDropdownReadPlatformService depositsDropdownReadPlatformService; private final DepositsDropdownReadPlatformService depositsDropdownReadPlatformService;
private final DropdownReadPlatformService dropdownReadPlatformService;
@Autowired @Autowired
public FixedDepositProductsApiResource(final DepositProductReadPlatformService depositProductReadPlatformService, public FixedDepositProductsApiResource(final DepositProductReadPlatformService depositProductReadPlatformService,
final SavingsDropdownReadPlatformService dropdownReadPlatformService, final SavingsDropdownReadPlatformService savingsDropdownReadPlatformService,
final CurrencyReadPlatformService currencyReadPlatformService, final PlatformSecurityContext context, final CurrencyReadPlatformService currencyReadPlatformService, final PlatformSecurityContext context,
final DefaultToApiJsonSerializer<FixedDepositProductData> toApiJsonSerializer, final DefaultToApiJsonSerializer<FixedDepositProductData> toApiJsonSerializer,
final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService, final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService,
@@ -94,9 +96,10 @@ public class FixedDepositProductsApiResource {
final ProductToGLAccountMappingReadPlatformService accountMappingReadPlatformService, final ProductToGLAccountMappingReadPlatformService accountMappingReadPlatformService,
final ChargeReadPlatformService chargeReadPlatformService, final InterestRateChartReadPlatformService chartReadPlatformService, final ChargeReadPlatformService chargeReadPlatformService, final InterestRateChartReadPlatformService chartReadPlatformService,
final InterestRateChartReadPlatformService interestRateChartReadPlatformService, final InterestRateChartReadPlatformService interestRateChartReadPlatformService,
final DepositsDropdownReadPlatformService depositsDropdownReadPlatformService) { final DepositsDropdownReadPlatformService depositsDropdownReadPlatformService,
final DropdownReadPlatformService dropdownReadPlatformService) {
this.depositProductReadPlatformService = depositProductReadPlatformService; this.depositProductReadPlatformService = depositProductReadPlatformService;
this.dropdownReadPlatformService = dropdownReadPlatformService; this.savingsDropdownReadPlatformService = savingsDropdownReadPlatformService;
this.currencyReadPlatformService = currencyReadPlatformService; this.currencyReadPlatformService = currencyReadPlatformService;
this.context = context; this.context = context;
this.toApiJsonSerializer = toApiJsonSerializer; this.toApiJsonSerializer = toApiJsonSerializer;
@@ -109,6 +112,7 @@ public class FixedDepositProductsApiResource {
this.chartReadPlatformService = chartReadPlatformService; this.chartReadPlatformService = chartReadPlatformService;
this.interestRateChartReadPlatformService = interestRateChartReadPlatformService; this.interestRateChartReadPlatformService = interestRateChartReadPlatformService;
this.depositsDropdownReadPlatformService = depositsDropdownReadPlatformService; this.depositsDropdownReadPlatformService = depositsDropdownReadPlatformService;
this.dropdownReadPlatformService = dropdownReadPlatformService;
} }
@POST @POST
@@ -231,22 +235,23 @@ public class FixedDepositProductsApiResource {
currency = new ArrayList<CurrencyData>(currencyOptions).get(0); currency = new ArrayList<CurrencyData>(currencyOptions).get(0);
} }
final Collection<EnumOptionData> interestCompoundingPeriodTypeOptions = this.dropdownReadPlatformService final Collection<EnumOptionData> interestCompoundingPeriodTypeOptions = this.savingsDropdownReadPlatformService
.retrieveCompoundingInterestPeriodTypeOptions(); .retrieveCompoundingInterestPeriodTypeOptions();
final Collection<EnumOptionData> interestPostingPeriodTypeOptions = this.dropdownReadPlatformService final Collection<EnumOptionData> interestPostingPeriodTypeOptions = this.savingsDropdownReadPlatformService
.retrieveInterestPostingPeriodTypeOptions(); .retrieveInterestPostingPeriodTypeOptions();
final Collection<EnumOptionData> interestCalculationTypeOptions = this.dropdownReadPlatformService final Collection<EnumOptionData> interestCalculationTypeOptions = this.savingsDropdownReadPlatformService
.retrieveInterestCalculationTypeOptions(); .retrieveInterestCalculationTypeOptions();
final Collection<EnumOptionData> interestCalculationDaysInYearTypeOptions = this.dropdownReadPlatformService final Collection<EnumOptionData> interestCalculationDaysInYearTypeOptions = this.savingsDropdownReadPlatformService
.retrieveInterestCalculationDaysInYearTypeOptions(); .retrieveInterestCalculationDaysInYearTypeOptions();
final Collection<EnumOptionData> lockinPeriodFrequencyTypeOptions = this.dropdownReadPlatformService final Collection<EnumOptionData> lockinPeriodFrequencyTypeOptions = this.savingsDropdownReadPlatformService
.retrieveLockinPeriodFrequencyTypeOptions(); .retrieveLockinPeriodFrequencyTypeOptions();
final Collection<EnumOptionData> withdrawalFeeTypeOptions = this.dropdownReadPlatformService.retrievewithdrawalFeeTypeOptions(); final Collection<EnumOptionData> withdrawalFeeTypeOptions = this.savingsDropdownReadPlatformService
.retrievewithdrawalFeeTypeOptions();
final Collection<CodeValueData> paymentTypeOptions = this.codeValueReadPlatformService final Collection<CodeValueData> paymentTypeOptions = this.codeValueReadPlatformService
.retrieveCodeValuesByCode(PaymentDetailConstants.paymentTypeCodeName); .retrieveCodeValuesByCode(PaymentDetailConstants.paymentTypeCodeName);
@@ -260,13 +265,7 @@ public class FixedDepositProductsApiResource {
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions = this.depositsDropdownReadPlatformService final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions = this.depositsDropdownReadPlatformService
.retrievePreClosurePenalInterestOnTypeOptions(); .retrievePreClosurePenalInterestOnTypeOptions();
final Collection<EnumOptionData> interestFreePeriodTypeOptions = this.depositsDropdownReadPlatformService final Collection<EnumOptionData> periodFrequencyTypeOptions = this.dropdownReadPlatformService.retrievePeriodFrequencyTypeOptions();
.retrieveInterestFreePeriodFrequencyTypeOptions();
final Collection<EnumOptionData> depositTermTypeOptions = this.depositsDropdownReadPlatformService.retrieveDepositTermTypeOptions();
final Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions = this.depositsDropdownReadPlatformService
.retrieveInMultiplesOfDepositTermTypeOptions();
// charges // charges
final boolean feeChargesOnly = true; final boolean feeChargesOnly = true;
@@ -285,16 +284,14 @@ public class FixedDepositProductsApiResource {
interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions, interestCalculationTypeOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions, interestCalculationTypeOptions,
interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions,
paymentTypeOptions, accountingRuleOptions, accountingMappingOptions, chargeOptions, penaltyOptions, chartTemplate, paymentTypeOptions, accountingRuleOptions, accountingMappingOptions, chargeOptions, penaltyOptions, chartTemplate,
interestFreePeriodTypeOptions, preClosurePenalInterestOnTypeOptions, depositTermTypeOptions, preClosurePenalInterestOnTypeOptions, periodFrequencyTypeOptions);
inMultiplesOfDepositTermTypeOptions);
} else { } else {
fixedDepositProductToReturn = FixedDepositProductData.template(currency, interestCompoundingPeriodType, fixedDepositProductToReturn = FixedDepositProductData.template(currency, interestCompoundingPeriodType,
interestPostingPeriodType, interestCalculationType, interestCalculationDaysInYearType, accountingRule, currencyOptions, interestPostingPeriodType, interestCalculationType, interestCalculationDaysInYearType, accountingRule, currencyOptions,
interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions, interestCalculationTypeOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions, interestCalculationTypeOptions,
interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions,
paymentTypeOptions, accountingRuleOptions, accountingMappingOptions, chargeOptions, penaltyOptions, chartTemplate, paymentTypeOptions, accountingRuleOptions, accountingMappingOptions, chargeOptions, penaltyOptions, chartTemplate,
interestFreePeriodTypeOptions, preClosurePenalInterestOnTypeOptions, depositTermTypeOptions, preClosurePenalInterestOnTypeOptions, periodFrequencyTypeOptions);
inMultiplesOfDepositTermTypeOptions);
} }
return fixedDepositProductToReturn; return fixedDepositProductToReturn;
@@ -90,7 +90,7 @@ public class RecurringDepositAccountTransactionsApiResource {
savingsAccount = this.depositAccountReadPlatformService savingsAccount = this.depositAccountReadPlatformService
.retrieveRecurringAccountDepositTransactionTemplate(recurringDepositAccountId); .retrieveRecurringAccountDepositTransactionTemplate(recurringDepositAccountId);
} else if (is(commandParam, "withdrawal")) { } else if (is(commandParam, "withdrawal")) {
//
} else { } else {
throw new UnrecognizedQueryParamException("command", commandParam, new Object[] { "deposit", "withdrawal" }); throw new UnrecognizedQueryParamException("command", commandParam, new Object[] { "deposit", "withdrawal" });
} }
@@ -168,7 +168,7 @@ public class RecurringDepositAccountTransactionsApiResource {
CommandProcessingResult result = null; CommandProcessingResult result = null;
if (is(commandParam, DepositsApiConstants.COMMAND_UNDO_TRANSACTION)) { 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); result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
} else if (is(commandParam, DepositsApiConstants.COMMAND_ADJUST_TRANSACTION)) { } else if (is(commandParam, DepositsApiConstants.COMMAND_ADJUST_TRANSACTION)) {
final CommandWrapper commandRequest = builder.adjustRecurringAccountTransaction(recurringDepositAccountId, transactionId).build(); final CommandWrapper commandRequest = builder.adjustRecurringAccountTransaction(recurringDepositAccountId, transactionId).build();
@@ -44,6 +44,7 @@ import org.mifosplatform.organisation.monetary.data.CurrencyData;
import org.mifosplatform.organisation.monetary.service.CurrencyReadPlatformService; import org.mifosplatform.organisation.monetary.service.CurrencyReadPlatformService;
import org.mifosplatform.portfolio.charge.data.ChargeData; import org.mifosplatform.portfolio.charge.data.ChargeData;
import org.mifosplatform.portfolio.charge.service.ChargeReadPlatformService; 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.data.InterestRateChartData;
import org.mifosplatform.portfolio.interestratechart.service.InterestRateChartReadPlatformService; import org.mifosplatform.portfolio.interestratechart.service.InterestRateChartReadPlatformService;
import org.mifosplatform.portfolio.paymentdetail.PaymentDetailConstants; import org.mifosplatform.portfolio.paymentdetail.PaymentDetailConstants;
@@ -69,7 +70,7 @@ import org.springframework.util.CollectionUtils;
public class RecurringDepositProductsApiResource { public class RecurringDepositProductsApiResource {
private final DepositProductReadPlatformService depositProductReadPlatformService; private final DepositProductReadPlatformService depositProductReadPlatformService;
private final SavingsDropdownReadPlatformService dropdownReadPlatformService; private final SavingsDropdownReadPlatformService savingsDropdownReadPlatformService;
private final CurrencyReadPlatformService currencyReadPlatformService; private final CurrencyReadPlatformService currencyReadPlatformService;
private final PlatformSecurityContext context; private final PlatformSecurityContext context;
private final DefaultToApiJsonSerializer<RecurringDepositProductData> toApiJsonSerializer; private final DefaultToApiJsonSerializer<RecurringDepositProductData> toApiJsonSerializer;
@@ -82,10 +83,11 @@ public class RecurringDepositProductsApiResource {
private final InterestRateChartReadPlatformService chartReadPlatformService; private final InterestRateChartReadPlatformService chartReadPlatformService;
private final InterestRateChartReadPlatformService interestRateChartReadPlatformService; private final InterestRateChartReadPlatformService interestRateChartReadPlatformService;
private final DepositsDropdownReadPlatformService depositsDropdownReadPlatformService; private final DepositsDropdownReadPlatformService depositsDropdownReadPlatformService;
private final DropdownReadPlatformService dropdownReadPlatformService;
@Autowired @Autowired
public RecurringDepositProductsApiResource(final DepositProductReadPlatformService depositProductReadPlatformService, public RecurringDepositProductsApiResource(final DepositProductReadPlatformService depositProductReadPlatformService,
final SavingsDropdownReadPlatformService dropdownReadPlatformService, final SavingsDropdownReadPlatformService savingsDropdownReadPlatformService,
final CurrencyReadPlatformService currencyReadPlatformService, final PlatformSecurityContext context, final CurrencyReadPlatformService currencyReadPlatformService, final PlatformSecurityContext context,
final DefaultToApiJsonSerializer<RecurringDepositProductData> toApiJsonSerializer, final DefaultToApiJsonSerializer<RecurringDepositProductData> toApiJsonSerializer,
final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService, final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService,
@@ -94,9 +96,10 @@ public class RecurringDepositProductsApiResource {
final ProductToGLAccountMappingReadPlatformService accountMappingReadPlatformService, final ProductToGLAccountMappingReadPlatformService accountMappingReadPlatformService,
final ChargeReadPlatformService chargeReadPlatformService, final InterestRateChartReadPlatformService chartReadPlatformService, final ChargeReadPlatformService chargeReadPlatformService, final InterestRateChartReadPlatformService chartReadPlatformService,
final InterestRateChartReadPlatformService interestRateChartReadPlatformService, final InterestRateChartReadPlatformService interestRateChartReadPlatformService,
final DepositsDropdownReadPlatformService depositsDropdownReadPlatformService) { final DepositsDropdownReadPlatformService depositsDropdownReadPlatformService,
final DropdownReadPlatformService dropdownReadPlatformService) {
this.depositProductReadPlatformService = depositProductReadPlatformService; this.depositProductReadPlatformService = depositProductReadPlatformService;
this.dropdownReadPlatformService = dropdownReadPlatformService; this.savingsDropdownReadPlatformService = savingsDropdownReadPlatformService;
this.currencyReadPlatformService = currencyReadPlatformService; this.currencyReadPlatformService = currencyReadPlatformService;
this.context = context; this.context = context;
this.toApiJsonSerializer = toApiJsonSerializer; this.toApiJsonSerializer = toApiJsonSerializer;
@@ -109,6 +112,7 @@ public class RecurringDepositProductsApiResource {
this.chartReadPlatformService = chartReadPlatformService; this.chartReadPlatformService = chartReadPlatformService;
this.interestRateChartReadPlatformService = interestRateChartReadPlatformService; this.interestRateChartReadPlatformService = interestRateChartReadPlatformService;
this.depositsDropdownReadPlatformService = depositsDropdownReadPlatformService; this.depositsDropdownReadPlatformService = depositsDropdownReadPlatformService;
this.dropdownReadPlatformService = dropdownReadPlatformService;
} }
@POST @POST
@@ -232,22 +236,23 @@ public class RecurringDepositProductsApiResource {
currency = new ArrayList<CurrencyData>(currencyOptions).get(0); currency = new ArrayList<CurrencyData>(currencyOptions).get(0);
} }
final Collection<EnumOptionData> interestCompoundingPeriodTypeOptions = this.dropdownReadPlatformService final Collection<EnumOptionData> interestCompoundingPeriodTypeOptions = this.savingsDropdownReadPlatformService
.retrieveCompoundingInterestPeriodTypeOptions(); .retrieveCompoundingInterestPeriodTypeOptions();
final Collection<EnumOptionData> interestPostingPeriodTypeOptions = this.dropdownReadPlatformService final Collection<EnumOptionData> interestPostingPeriodTypeOptions = this.savingsDropdownReadPlatformService
.retrieveInterestPostingPeriodTypeOptions(); .retrieveInterestPostingPeriodTypeOptions();
final Collection<EnumOptionData> interestCalculationTypeOptions = this.dropdownReadPlatformService final Collection<EnumOptionData> interestCalculationTypeOptions = this.savingsDropdownReadPlatformService
.retrieveInterestCalculationTypeOptions(); .retrieveInterestCalculationTypeOptions();
final Collection<EnumOptionData> interestCalculationDaysInYearTypeOptions = this.dropdownReadPlatformService final Collection<EnumOptionData> interestCalculationDaysInYearTypeOptions = this.savingsDropdownReadPlatformService
.retrieveInterestCalculationDaysInYearTypeOptions(); .retrieveInterestCalculationDaysInYearTypeOptions();
final Collection<EnumOptionData> lockinPeriodFrequencyTypeOptions = this.dropdownReadPlatformService final Collection<EnumOptionData> lockinPeriodFrequencyTypeOptions = this.savingsDropdownReadPlatformService
.retrieveLockinPeriodFrequencyTypeOptions(); .retrieveLockinPeriodFrequencyTypeOptions();
final Collection<EnumOptionData> withdrawalFeeTypeOptions = this.dropdownReadPlatformService.retrievewithdrawalFeeTypeOptions(); final Collection<EnumOptionData> withdrawalFeeTypeOptions = this.savingsDropdownReadPlatformService
.retrievewithdrawalFeeTypeOptions();
final Collection<CodeValueData> paymentTypeOptions = this.codeValueReadPlatformService final Collection<CodeValueData> paymentTypeOptions = this.codeValueReadPlatformService
.retrieveCodeValuesByCode(PaymentDetailConstants.paymentTypeCodeName); .retrieveCodeValuesByCode(PaymentDetailConstants.paymentTypeCodeName);
@@ -257,8 +262,6 @@ public class RecurringDepositProductsApiResource {
.retrieveAccountMappingOptionsForSavingsProducts(); .retrieveAccountMappingOptionsForSavingsProducts();
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions = this.depositsDropdownReadPlatformService final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions = this.depositsDropdownReadPlatformService
.retrievePreClosurePenalInterestOnTypeOptions(); .retrievePreClosurePenalInterestOnTypeOptions();
final Collection<EnumOptionData> interestFreePeriodTypeOptions = this.depositsDropdownReadPlatformService
.retrieveInterestFreePeriodFrequencyTypeOptions();
// charges // charges
final boolean feeChargesOnly = true; final boolean feeChargesOnly = true;
@@ -268,15 +271,7 @@ public class RecurringDepositProductsApiResource {
Collection<ChargeData> penaltyOptions = this.chargeReadPlatformService.retrieveSavingsAccountApplicablePenalties(); Collection<ChargeData> penaltyOptions = this.chargeReadPlatformService.retrieveSavingsAccountApplicablePenalties();
penaltyOptions = CollectionUtils.isEmpty(penaltyOptions) ? null : penaltyOptions; penaltyOptions = CollectionUtils.isEmpty(penaltyOptions) ? null : penaltyOptions;
Collection<EnumOptionData> recurringDepositTypeOptions = this.depositsDropdownReadPlatformService final Collection<EnumOptionData> periodFrequencyTypeOptions = this.dropdownReadPlatformService.retrievePeriodFrequencyTypeOptions();
.retrieveRecurringDepositTypeOptions();
Collection<EnumOptionData> recurringDepositFrequencyTypeOptions = this.depositsDropdownReadPlatformService
.retrieveRecurringDepositFrequencyTypeOptions();
final Collection<EnumOptionData> depositTermTypeOptions = this.depositsDropdownReadPlatformService.retrieveDepositTermTypeOptions();
final Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions = this.depositsDropdownReadPlatformService
.retrieveInMultiplesOfDepositTermTypeOptions();
// interest rate chart template // interest rate chart template
final InterestRateChartData chartTemplate = this.interestRateChartReadPlatformService.template(); final InterestRateChartData chartTemplate = this.interestRateChartReadPlatformService.template();
@@ -287,16 +282,14 @@ public class RecurringDepositProductsApiResource {
interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions, interestCalculationTypeOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions, interestCalculationTypeOptions,
interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions,
paymentTypeOptions, accountingRuleOptions, accountingMappingOptions, chargeOptions, penaltyOptions, chartTemplate, paymentTypeOptions, accountingRuleOptions, accountingMappingOptions, chargeOptions, penaltyOptions, chartTemplate,
interestFreePeriodTypeOptions, preClosurePenalInterestOnTypeOptions, recurringDepositTypeOptions, preClosurePenalInterestOnTypeOptions, periodFrequencyTypeOptions);
recurringDepositFrequencyTypeOptions, depositTermTypeOptions, inMultiplesOfDepositTermTypeOptions);
} else { } else {
recurringDepositProductToReturn = RecurringDepositProductData.template(currency, interestCompoundingPeriodType, recurringDepositProductToReturn = RecurringDepositProductData.template(currency, interestCompoundingPeriodType,
interestPostingPeriodType, interestCalculationType, interestCalculationDaysInYearType, accountingRule, currencyOptions, interestPostingPeriodType, interestCalculationType, interestCalculationDaysInYearType, accountingRule, currencyOptions,
interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions, interestCalculationTypeOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions, interestCalculationTypeOptions,
interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions,
paymentTypeOptions, accountingRuleOptions, accountingMappingOptions, chargeOptions, penaltyOptions, chartTemplate, paymentTypeOptions, accountingRuleOptions, accountingMappingOptions, chargeOptions, penaltyOptions, chartTemplate,
interestFreePeriodTypeOptions, preClosurePenalInterestOnTypeOptions, recurringDepositTypeOptions, preClosurePenalInterestOnTypeOptions, periodFrequencyTypeOptions);
recurringDepositFrequencyTypeOptions, depositTermTypeOptions, inMultiplesOfDepositTermTypeOptions);
} }
return recurringDepositProductToReturn; return recurringDepositProductToReturn;
@@ -29,8 +29,8 @@ public class DepositAccountData {
protected final String groupName; protected final String groupName;
protected final Long clientId; protected final Long clientId;
protected final String clientName; protected final String clientName;
protected final Long savingsProductId; protected final Long depositProductId;
protected final String savingsProductName; protected final String depositProductName;
protected final Long fieldOfficerId; protected final Long fieldOfficerId;
protected final String fieldOfficerName; protected final String fieldOfficerName;
protected final SavingsAccountStatusEnumData status; protected final SavingsAccountStatusEnumData status;
@@ -177,8 +177,8 @@ public class DepositAccountData {
this.groupName = groupName; this.groupName = groupName;
this.clientId = clientId; this.clientId = clientId;
this.clientName = clientName; this.clientName = clientName;
this.savingsProductId = productId; this.depositProductId = productId;
this.savingsProductName = productName; this.depositProductName = productName;
this.fieldOfficerId = fieldofficerId; this.fieldOfficerId = fieldofficerId;
this.fieldOfficerName = fieldofficerName; this.fieldOfficerName = fieldofficerName;
this.status = status; this.status = status;
@@ -244,7 +244,7 @@ public class DepositAccountData {
} }
public Long productId() { public Long productId() {
return this.savingsProductId; return this.depositProductId;
} }
public CurrencyData currency() { public CurrencyData currency() {
@@ -5,16 +5,17 @@
*/ */
package org.mifosplatform.portfolio.savings.data; 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.depositAmountParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.depositPeriodFrequencyIdParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.depositPeriodFrequencyIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.depositPeriodParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.depositPeriodParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.inMultiplesOfDepositTermParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.inMultiplesOfDepositTermParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.inMultiplesOfDepositTermTypeIdParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.inMultiplesOfDepositTermTypeIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.interestFreeFromPeriodParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.isCalendarInheritedParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.interestFreePeriodApplicableParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.isMandatoryDepositParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.interestFreePeriodFrequencyTypeIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.interestFreeToPeriodParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.linkedAccountParamName; 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.maxDepositTermParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.maxDepositTermTypeIdParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.maxDepositTermTypeIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.minDepositTermParamName; 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.preClosurePenalApplicableParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.preClosurePenalInterestOnTypeIdParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.preClosurePenalInterestOnTypeIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.preClosurePenalInterestParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.preClosurePenalInterestParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.recurringDepositFrequencyParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.recurringFrequencyParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.recurringDepositFrequencyTypeIdParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.recurringFrequencyTypeParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.recurringDepositTypeIdParamName;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.accountNoParamName; import static org.mifosplatform.portfolio.savings.SavingsApiConstants.accountNoParamName;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.amountParamName; import static org.mifosplatform.portfolio.savings.SavingsApiConstants.amountParamName;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.chargeIdParamName; 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.InvalidJsonException;
import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException;
import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper; 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.DepositAccountType;
import org.mifosplatform.portfolio.savings.DepositsApiConstants; import org.mifosplatform.portfolio.savings.DepositsApiConstants;
import org.mifosplatform.portfolio.savings.PreClosurePenalInterestOnType; import org.mifosplatform.portfolio.savings.PreClosurePenalInterestOnType;
import org.mifosplatform.portfolio.savings.RecurringDepositType;
import org.mifosplatform.portfolio.savings.SavingsCompoundingInterestPeriodType; import org.mifosplatform.portfolio.savings.SavingsCompoundingInterestPeriodType;
import org.mifosplatform.portfolio.savings.SavingsInterestCalculationDaysInYearType; import org.mifosplatform.portfolio.savings.SavingsInterestCalculationDaysInYearType;
import org.mifosplatform.portfolio.savings.SavingsInterestCalculationType; import org.mifosplatform.portfolio.savings.SavingsInterestCalculationType;
@@ -93,7 +92,7 @@ public class DepositAccountDataValidator {
this.productDataValidator = productDataValidator; this.productDataValidator = productDataValidator;
} }
private void validateFixedDepositForSubmit(final String json) { public void validateFixedDepositForSubmit(final String json) {
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); } if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType(); final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
@@ -113,7 +112,7 @@ public class DepositAccountDataValidator {
throwExceptionIfValidationWarningsExist(dataValidationErrors); throwExceptionIfValidationWarningsExist(dataValidationErrors);
} }
private void validateFixedDepositForUpdate(final String json) { public void validateFixedDepositForUpdate(final String json) {
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); } if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType(); final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
@@ -133,7 +132,7 @@ public class DepositAccountDataValidator {
throwExceptionIfValidationWarningsExist(dataValidationErrors); throwExceptionIfValidationWarningsExist(dataValidationErrors);
} }
private void validateRecurringDepositForSubmit(final String json) { public void validateRecurringDepositForSubmit(final String json) {
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); } if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType(); final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
@@ -154,7 +153,7 @@ public class DepositAccountDataValidator {
throwExceptionIfValidationWarningsExist(dataValidationErrors); throwExceptionIfValidationWarningsExist(dataValidationErrors);
} }
private void validateRecurringDepositForUpdate(final String json) { public void validateRecurringDepositForUpdate(final String json) {
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); } if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType(); final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
@@ -253,13 +252,16 @@ public class DepositAccountDataValidator {
baseDataValidator.reset().parameter(minRequiredOpeningBalanceParamName).value(minOpeningBalance).zeroOrPositiveAmount(); baseDataValidator.reset().parameter(minRequiredOpeningBalanceParamName).value(minOpeningBalance).zeroOrPositiveAmount();
} }
boolean isLockinPeriodFrequencyValidated = false;
boolean isLockinPeriodFrequencyTypeValidated = false;
if (this.fromApiJsonHelper.parameterExists(lockinPeriodFrequencyParamName, element)) { if (this.fromApiJsonHelper.parameterExists(lockinPeriodFrequencyParamName, element)) {
isLockinPeriodFrequencyValidated = true;
final Integer lockinPeriodFrequency = this.fromApiJsonHelper.extractIntegerWithLocaleNamed(lockinPeriodFrequencyParamName, final Integer lockinPeriodFrequency = this.fromApiJsonHelper.extractIntegerWithLocaleNamed(lockinPeriodFrequencyParamName,
element); element);
baseDataValidator.reset().parameter(lockinPeriodFrequencyParamName).value(lockinPeriodFrequency).integerZeroOrGreater(); baseDataValidator.reset().parameter(lockinPeriodFrequencyParamName).value(lockinPeriodFrequency).integerZeroOrGreater();
if (lockinPeriodFrequency != null) { if (lockinPeriodFrequency != null) {
isLockinPeriodFrequencyTypeValidated = true;
final Integer lockinPeriodFrequencyType = this.fromApiJsonHelper.extractIntegerSansLocaleNamed( final Integer lockinPeriodFrequencyType = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(
lockinPeriodFrequencyTypeParamName, element); lockinPeriodFrequencyTypeParamName, element);
baseDataValidator.reset().parameter(lockinPeriodFrequencyTypeParamName).value(lockinPeriodFrequencyType).notNull() 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( final Integer lockinPeriodFrequencyType = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(
lockinPeriodFrequencyTypeParamName, element); lockinPeriodFrequencyTypeParamName, element);
baseDataValidator.reset().parameter(lockinPeriodFrequencyTypeParamName).value(lockinPeriodFrequencyType).inMinMaxRange(0, 3); baseDataValidator.reset().parameter(lockinPeriodFrequencyTypeParamName).value(lockinPeriodFrequencyType).inMinMaxRange(0, 3);
if (lockinPeriodFrequencyType != null) { if (lockinPeriodFrequencyType != null && !isLockinPeriodFrequencyValidated) {
final Integer lockinPeriodFrequency = this.fromApiJsonHelper.extractIntegerWithLocaleNamed(lockinPeriodFrequencyParamName, final Integer lockinPeriodFrequency = this.fromApiJsonHelper.extractIntegerWithLocaleNamed(lockinPeriodFrequencyParamName,
element); element);
baseDataValidator.reset().parameter(lockinPeriodFrequencyParamName).value(lockinPeriodFrequency).notNull() baseDataValidator.reset().parameter(lockinPeriodFrequencyParamName).value(lockinPeriodFrequency).notNull()
@@ -425,31 +427,6 @@ public class DepositAccountDataValidator {
} }
private void validatePreClosureDetailForSubmit(final JsonElement element, final DataValidatorBuilder baseDataValidator) { 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)) { if (fromApiJsonHelper.parameterExists(preClosurePenalApplicableParamName, element)) {
final boolean preClosurePenalApplicable = fromApiJsonHelper.extractBooleanNamed(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) { private void validateRecurringDetailForSubmit(final JsonElement element, final DataValidatorBuilder baseDataValidator) {
if (fromApiJsonHelper.parameterExists(recurringDepositTypeIdParamName, element)) {
final Integer rdTypeId = fromApiJsonHelper.extractIntegerSansLocaleNamed(recurringDepositTypeIdParamName, element); final BigDecimal mandatoryRecommendedDepositAmount = fromApiJsonHelper.extractBigDecimalWithLocaleNamed(mandatoryRecommendedDepositAmountParamName, element);
baseDataValidator.reset().parameter(recurringDepositTypeIdParamName).value(rdTypeId).notNull() baseDataValidator.reset().parameter(mandatoryRecommendedDepositAmountParamName).value(mandatoryRecommendedDepositAmount).notNull().positiveAmount();
.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)) { if (this.fromApiJsonHelper.parameterExists(allowWithdrawalParamName, element)) {
final Integer rdFrequency = fromApiJsonHelper.extractIntegerSansLocaleNamed(recurringDepositFrequencyParamName, element); final Boolean allowWithdrawal = this.fromApiJsonHelper.extractBooleanNamed(allowWithdrawalParamName, element);
baseDataValidator.reset().parameter(recurringDepositFrequencyParamName).value(rdFrequency).notNull().integerGreaterThanZero(); baseDataValidator.reset().parameter(allowWithdrawalParamName).value(allowWithdrawal).ignoreIfNull().validateForBooleanValue();
} }
if (fromApiJsonHelper.parameterExists(recurringDepositFrequencyTypeIdParamName, element)) { if (this.fromApiJsonHelper.parameterExists(adjustAdvanceTowardsFuturePaymentsParamName, element)) {
final Integer rdFrequencyTypeId = fromApiJsonHelper.extractIntegerSansLocaleNamed(recurringDepositFrequencyTypeIdParamName, final Boolean adjustAdvanceTowardsFuturePayments = this.fromApiJsonHelper.extractBooleanNamed(
element); adjustAdvanceTowardsFuturePaymentsParamName, element);
baseDataValidator.reset().parameter(recurringDepositFrequencyTypeIdParamName).value(rdFrequencyTypeId).notNull() baseDataValidator.reset().parameter(adjustAdvanceTowardsFuturePaymentsParamName).value(adjustAdvanceTowardsFuturePayments)
.isOneOfTheseValues(SavingsPeriodFrequencyType.integerValues()); .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) { 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()) { if (this.fromApiJsonHelper.parameterExists(adjustAdvanceTowardsFuturePaymentsParamName, element)) {
this.validateFixedDepositForSubmit(json); final Boolean adjustAdvanceTowardsFuturePayments = this.fromApiJsonHelper.extractBooleanNamed(
} else if (depositAccountType.isRecurringDeposit()) { adjustAdvanceTowardsFuturePaymentsParamName, element);
this.validateRecurringDepositForSubmit(json); baseDataValidator.reset().parameter(adjustAdvanceTowardsFuturePaymentsParamName).value(adjustAdvanceTowardsFuturePayments)
} else { .ignoreIfNull().validateForBooleanValue();
// FIXME: AA handle unsupported deposit account type }
// throw unsupported account type exception
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) { private void throwExceptionIfValidationWarningsExist(final List<ApiParameterError> dataValidationErrors) {
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); } if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
} }
@@ -25,34 +25,47 @@ public class DepositAccountInterestRateChartSlabData {
private final BigDecimal amountRangeFrom; private final BigDecimal amountRangeFrom;
private final BigDecimal amountRangeTo; private final BigDecimal amountRangeTo;
private final BigDecimal annualInterestRate; private final BigDecimal annualInterestRate;
private final BigDecimal interestRateForFemale;
private final BigDecimal interestRateForChildren;
private final BigDecimal interestRateForSeniorCitizen;
private final CurrencyData currency; private final CurrencyData currency;
// associations // associations
// template // template
@SuppressWarnings("unused") @SuppressWarnings("unused")
private Collection<EnumOptionData> periodTypes; private final Collection<EnumOptionData> periodTypes;
public static DepositAccountInterestRateChartSlabData instance(Long id, String description, EnumOptionData periodType, Integer fromPeriod, public static DepositAccountInterestRateChartSlabData instance(final Long id, final String description,
Integer toPeriod, BigDecimal amountRangeFrom, BigDecimal amountRangeTo, BigDecimal annualInterestRate, CurrencyData currency) { final EnumOptionData periodType, final Integer fromPeriod, final Integer toPeriod, final BigDecimal amountRangeFrom,
Collection<EnumOptionData> periodTypes = null; final BigDecimal amountRangeTo, final BigDecimal annualInterestRate, final BigDecimal interestRateForFemale,
return new DepositAccountInterestRateChartSlabData(id, description, periodType, fromPeriod, toPeriod, amountRangeFrom, amountRangeTo, final BigDecimal interestRateForChildren, final BigDecimal interestRateForSeniorCitizen, final CurrencyData currency) {
annualInterestRate, currency, periodTypes); final Collection<EnumOptionData> periodTypes = null;
} return new DepositAccountInterestRateChartSlabData(id, description, periodType, fromPeriod, toPeriod, amountRangeFrom,
amountRangeTo, annualInterestRate, interestRateForFemale, interestRateForChildren, interestRateForSeniorCitizen, currency,
public static DepositAccountInterestRateChartSlabData from(InterestRateChartSlabData chartSlabData) { periodTypes);
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);
} }
private DepositAccountInterestRateChartSlabData(Long id, String description, EnumOptionData periodType, Integer fromPeriod, Integer toPeriod, public static DepositAccountInterestRateChartSlabData from(final InterestRateChartSlabData chartSlabData) {
BigDecimal amountRangeFrom, BigDecimal amountRangeTo, BigDecimal annualInterestRate, CurrencyData currency, Collection<EnumOptionData> periodTypes) { 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.id = id;
this.description = description; this.description = description;
this.periodType = periodType; this.periodType = periodType;
@@ -61,6 +74,9 @@ public class DepositAccountInterestRateChartSlabData {
this.amountRangeFrom = amountRangeFrom; this.amountRangeFrom = amountRangeFrom;
this.amountRangeTo = amountRangeTo; this.amountRangeTo = amountRangeTo;
this.annualInterestRate = annualInterestRate; this.annualInterestRate = annualInterestRate;
this.interestRateForFemale = interestRateForFemale;
this.interestRateForChildren = interestRateForChildren;
this.interestRateForSeniorCitizen = interestRateForSeniorCitizen;
this.currency = currency; this.currency = currency;
this.periodTypes = periodTypes; this.periodTypes = periodTypes;
} }
@@ -159,7 +159,7 @@ public class DepositAccountTransactionDataValidator {
if (accountOnClosureType.isTransferToSavings()) { if (accountOnClosureType.isTransferToSavings()) {
final Long toSavingsAccountId = this.fromApiJsonHelper.extractLongNamed(toSavingsAccountIdParamName, element); final Long toSavingsAccountId = this.fromApiJsonHelper.extractLongNamed(toSavingsAccountIdParamName, element);
baseDataValidator.reset().parameter(toSavingsAccountIdParamName).value(toSavingsAccountId) baseDataValidator.reset().parameter(toSavingsAccountIdParamName).value(toSavingsAccountId)
.cantBeBlankWhenParameterProvidedIs(onAccountClosureIdParamName, onAccountClosureId); .cantBeBlankWhenParameterProvidedIs(onAccountClosureIdParamName, DepositAccountOnClosureType.fromInt(onAccountClosureId).getCode());
} else if (accountOnClosureType.isReinvest() && isPreMatureClose) { } else if (accountOnClosureType.isReinvest() && isPreMatureClose) {
baseDataValidator.reset().parameter(onAccountClosureIdParamName).value(onAccountClosureId) baseDataValidator.reset().parameter(onAccountClosureIdParamName).value(onAccountClosureId)
.failWithCode("reinvest.not.allowed", "Re-Invest is not supported for account pre mature close"); .failWithCode("reinvest.not.allowed", "Re-Invest is not supported for account pre mature close");
@@ -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.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_REQUEST_DATA_PARAMETERS;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.RECURRING_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.chartsParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.depositAmountParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.depositAmountParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.depositMaxAmountParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.depositMaxAmountParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.depositMinAmountParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.depositMinAmountParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.inMultiplesOfDepositTermParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.inMultiplesOfDepositTermParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.inMultiplesOfDepositTermTypeIdParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.inMultiplesOfDepositTermTypeIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.interestFreeFromPeriodParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.isMandatoryDepositParamName;
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.maxDepositTermParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.maxDepositTermParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.maxDepositTermTypeIdParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.maxDepositTermTypeIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.minDepositTermParamName; 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.preClosurePenalApplicableParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.preClosurePenalInterestOnTypeIdParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.preClosurePenalInterestOnTypeIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.preClosurePenalInterestParamName; 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.currencyCodeParamName;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.descriptionParamName; import static org.mifosplatform.portfolio.savings.SavingsApiConstants.descriptionParamName;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.digitsAfterDecimalParamName; 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.InvalidJsonException;
import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException;
import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper; import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper;
import org.mifosplatform.portfolio.interestratechart.InterestRateChartPeriodType;
import org.mifosplatform.portfolio.interestratechart.data.InterestRateChartDataValidator; import org.mifosplatform.portfolio.interestratechart.data.InterestRateChartDataValidator;
import org.mifosplatform.portfolio.savings.PreClosurePenalInterestOnType; import org.mifosplatform.portfolio.savings.PreClosurePenalInterestOnType;
import org.mifosplatform.portfolio.savings.RecurringDepositType;
import org.mifosplatform.portfolio.savings.SavingsCompoundingInterestPeriodType; import org.mifosplatform.portfolio.savings.SavingsCompoundingInterestPeriodType;
import org.mifosplatform.portfolio.savings.SavingsInterestCalculationDaysInYearType; import org.mifosplatform.portfolio.savings.SavingsInterestCalculationDaysInYearType;
import org.mifosplatform.portfolio.savings.SavingsInterestCalculationType; import org.mifosplatform.portfolio.savings.SavingsInterestCalculationType;
@@ -321,32 +315,6 @@ public class DepositProductDataValidator {
} }
public void validatePreClosureDetailForCreate(JsonElement element, DataValidatorBuilder baseDataValidator) { 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)) { if (fromApiJsonHelper.parameterExists(preClosurePenalApplicableParamName, element)) {
final boolean preClosurePenalApplicable = fromApiJsonHelper.extractBooleanNamed(preClosurePenalApplicableParamName, element); final boolean preClosurePenalApplicable = fromApiJsonHelper.extractBooleanNamed(preClosurePenalApplicableParamName, element);
@@ -369,7 +337,7 @@ public class DepositProductDataValidator {
public void validateDepositTermDeatilForCreate(JsonElement element, DataValidatorBuilder baseDataValidator) { public void validateDepositTermDeatilForCreate(JsonElement element, DataValidatorBuilder baseDataValidator) {
final Integer minTerm = fromApiJsonHelper.extractIntegerSansLocaleNamed(minDepositTermParamName, element); 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)) { if (fromApiJsonHelper.parameterExists(maxDepositTermParamName, element)) {
final Integer maxTerm = fromApiJsonHelper.extractIntegerSansLocaleNamed(maxDepositTermParamName, element); final Integer maxTerm = fromApiJsonHelper.extractIntegerSansLocaleNamed(maxDepositTermParamName, element);
@@ -546,33 +514,6 @@ public class DepositProductDataValidator {
} }
public void validatePreClosureDetailForUpdate(JsonElement element, DataValidatorBuilder baseDataValidator) { 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)) { if (fromApiJsonHelper.parameterExists(preClosurePenalApplicableParamName, element)) {
final Boolean preClosurePenalApplicable = fromApiJsonHelper.extractBooleanNamed(preClosurePenalApplicableParamName, element); final Boolean preClosurePenalApplicable = fromApiJsonHelper.extractBooleanNamed(preClosurePenalApplicableParamName, element);
baseDataValidator.reset().parameter(preClosurePenalApplicableParamName).value(preClosurePenalApplicable).notNull(); baseDataValidator.reset().parameter(preClosurePenalApplicableParamName).value(preClosurePenalApplicable).notNull();
@@ -711,37 +652,34 @@ public class DepositProductDataValidator {
public void validateRecurringDetailForCreate(JsonElement element, DataValidatorBuilder baseDataValidator) { public void validateRecurringDetailForCreate(JsonElement element, DataValidatorBuilder baseDataValidator) {
final Integer rdTypeId = fromApiJsonHelper.extractIntegerSansLocaleNamed(recurringDepositTypeIdParamName, element); final Boolean isMandatoryDeposit = this.fromApiJsonHelper.extractBooleanNamed(isMandatoryDepositParamName, element);
baseDataValidator.reset().parameter(recurringDepositTypeIdParamName).value(rdTypeId).notNull() baseDataValidator.reset().parameter(isMandatoryDepositParamName).value(isMandatoryDeposit).ignoreIfNull().validateForBooleanValue();
.isOneOfTheseValues(RecurringDepositType.integerValues()); final Boolean allowWithdrawal = this.fromApiJsonHelper.extractBooleanNamed(allowWithdrawalParamName, element);
baseDataValidator.reset().parameter(allowWithdrawalParamName).value(allowWithdrawal).ignoreIfNull().validateForBooleanValue();
final Integer rdFrequency = fromApiJsonHelper.extractIntegerSansLocaleNamed(recurringDepositFrequencyParamName, element); final Boolean adjustAdvanceTowardsFuturePayments = this.fromApiJsonHelper.extractBooleanNamed(
baseDataValidator.reset().parameter(recurringDepositFrequencyParamName).value(rdFrequency).notNull().integerGreaterThanZero(); adjustAdvanceTowardsFuturePaymentsParamName, element);
baseDataValidator.reset().parameter(adjustAdvanceTowardsFuturePaymentsParamName).value(adjustAdvanceTowardsFuturePayments)
final Integer rdFrequencyTypeId = fromApiJsonHelper .ignoreIfNull().validateForBooleanValue();
.extractIntegerSansLocaleNamed(recurringDepositFrequencyTypeIdParamName, element);
baseDataValidator.reset().parameter(recurringDepositFrequencyTypeIdParamName).value(rdFrequencyTypeId).notNull()
.isOneOfTheseValues(SavingsPeriodFrequencyType.integerValues());
} }
public void validateRecurringDepositUpdate(JsonElement element, DataValidatorBuilder baseDataValidator) { public void validateRecurringDepositUpdate(JsonElement element, DataValidatorBuilder baseDataValidator) {
if (fromApiJsonHelper.parameterExists(recurringDepositTypeIdParamName, element)) { if (this.fromApiJsonHelper.parameterExists(isMandatoryDepositParamName, element)) {
final Integer rdTypeId = fromApiJsonHelper.extractIntegerSansLocaleNamed(recurringDepositTypeIdParamName, element); final Boolean isMandatoryDeposit = this.fromApiJsonHelper.extractBooleanNamed(isMandatoryDepositParamName, element);
baseDataValidator.reset().parameter(recurringDepositTypeIdParamName).value(rdTypeId).notNull() baseDataValidator.reset().parameter(isMandatoryDepositParamName).value(isMandatoryDeposit).ignoreIfNull()
.isOneOfTheseValues(RecurringDepositType.integerValues()); .validateForBooleanValue();
} }
if (fromApiJsonHelper.parameterExists(recurringDepositFrequencyParamName, element)) { if (this.fromApiJsonHelper.parameterExists(allowWithdrawalParamName, element)) {
final Integer rdFrequency = fromApiJsonHelper.extractIntegerSansLocaleNamed(recurringDepositFrequencyParamName, element); final Boolean allowWithdrawal = this.fromApiJsonHelper.extractBooleanNamed(allowWithdrawalParamName, element);
baseDataValidator.reset().parameter(recurringDepositFrequencyParamName).value(rdFrequency).notNull().integerGreaterThanZero(); baseDataValidator.reset().parameter(allowWithdrawalParamName).value(allowWithdrawal).ignoreIfNull().validateForBooleanValue();
} }
if (fromApiJsonHelper.parameterExists(recurringDepositFrequencyTypeIdParamName, element)) { if (this.fromApiJsonHelper.parameterExists(adjustAdvanceTowardsFuturePaymentsParamName, element)) {
final Integer rdFrequencyTypeId = fromApiJsonHelper.extractIntegerSansLocaleNamed(recurringDepositFrequencyTypeIdParamName, final Boolean adjustAdvanceTowardsFuturePayments = this.fromApiJsonHelper.extractBooleanNamed(
element); adjustAdvanceTowardsFuturePaymentsParamName, element);
baseDataValidator.reset().parameter(recurringDepositFrequencyTypeIdParamName).value(rdFrequencyTypeId).notNull() baseDataValidator.reset().parameter(adjustAdvanceTowardsFuturePaymentsParamName).value(adjustAdvanceTowardsFuturePayments)
.isOneOfTheseValues(SavingsPeriodFrequencyType.integerValues()); .ignoreIfNull().validateForBooleanValue();
} }
} }
@@ -25,11 +25,6 @@ import org.mifosplatform.portfolio.savings.service.SavingsEnumerations;
*/ */
public class FixedDepositAccountData extends DepositAccountData { public class FixedDepositAccountData extends DepositAccountData {
// additional fields
private boolean interestFreePeriodApplicable;
private Integer interestFreeFromPeriod;
private Integer interestFreeToPeriod;
private EnumOptionData interestFreePeriodFrequencyType;
private boolean preClosurePenalApplicable; private boolean preClosurePenalApplicable;
private BigDecimal preClosurePenalInterest; private BigDecimal preClosurePenalInterest;
private EnumOptionData preClosurePenalInterestOnType; private EnumOptionData preClosurePenalInterestOnType;
@@ -51,32 +46,25 @@ public class FixedDepositAccountData extends DepositAccountData {
private final PortfolioAccountData linkedAccount; private final PortfolioAccountData linkedAccount;
private final Boolean transferInterestToSavings; private final Boolean transferInterestToSavings;
private Collection<EnumOptionData> interestFreePeriodTypeOptions;
private Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions; private Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions;
private Collection<EnumOptionData> depositTermTypeOptions; private Collection<EnumOptionData> periodFrequencyTypeOptions;
private Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions;
private Collection<EnumOptionData> depositPeriodFrequencyOptions;
private Collection<SavingsAccountData> savingsAccounts; private Collection<SavingsAccountData> savingsAccounts;
// for account close // for account close
private Collection<EnumOptionData> onAccountClosureOptions; private Collection<EnumOptionData> onAccountClosureOptions;
private Collection<CodeValueData> paymentTypeOptions; private Collection<CodeValueData> paymentTypeOptions;
public static FixedDepositAccountData instance(final DepositAccountData depositAccountData, final boolean interestFreePeriodApplicable, public static FixedDepositAccountData instance(final DepositAccountData depositAccountData, final boolean preClosurePenalApplicable,
final Integer interestFreeFromPeriod, final Integer interestFreeToPeriod, final EnumOptionData interestFreePeriodFrequencyType, final BigDecimal preClosurePenalInterest, final EnumOptionData preClosurePenalInterestOnType, final Integer minDepositTerm,
final boolean preClosurePenalApplicable, final BigDecimal preClosurePenalInterest, final Integer maxDepositTerm, final EnumOptionData minDepositTermType, final EnumOptionData maxDepositTermType,
final EnumOptionData preClosurePenalInterestOnType, final Integer minDepositTerm, final Integer maxDepositTerm, final Integer inMultiplesOfDepositTerm, final EnumOptionData inMultiplesOfDepositTermType, final BigDecimal depositAmount,
final EnumOptionData minDepositTermType, final EnumOptionData maxDepositTermType, final Integer inMultiplesOfDepositTerm, final BigDecimal maturityAmount, final LocalDate maturityDate, final Integer depositPeriod,
final EnumOptionData inMultiplesOfDepositTermType, final BigDecimal depositAmount, final BigDecimal maturityAmount, final EnumOptionData depositPeriodFrequency, final EnumOptionData onAccountClosure, final Boolean transferInterestToSavings) {
final LocalDate maturityDate, final Integer depositPeriod, final EnumOptionData depositPeriodFrequency,
final EnumOptionData onAccountClosure, final Boolean transferInterestToSavings) {
final PortfolioAccountData linkedAccount = null; final PortfolioAccountData linkedAccount = null;
final Collection<EnumOptionData> interestFreePeriodTypeOptions = null;
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions = null; final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions = null;
final Collection<EnumOptionData> depositTermTypeOptions = null; final Collection<EnumOptionData> periodFrequencyTypeOptions = null;
final Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions = null;
final Collection<EnumOptionData> depositPeriodFrequencyOptions = null;
final EnumOptionData depositType = SavingsEnumerations.depositType(DepositAccountType.FIXED_DEPOSIT.getValue()); final EnumOptionData depositType = SavingsEnumerations.depositType(DepositAccountType.FIXED_DEPOSIT.getValue());
final Collection<EnumOptionData> onAccountClosureOptions = null; final Collection<EnumOptionData> onAccountClosureOptions = null;
final Collection<CodeValueData> paymentTypeOptions = null; final Collection<CodeValueData> paymentTypeOptions = null;
@@ -84,7 +72,7 @@ public class FixedDepositAccountData extends DepositAccountData {
return new FixedDepositAccountData(depositAccountData.id, depositAccountData.accountNo, depositAccountData.externalId, return new FixedDepositAccountData(depositAccountData.id, depositAccountData.accountNo, depositAccountData.externalId,
depositAccountData.groupId, depositAccountData.groupName, depositAccountData.clientId, depositAccountData.clientName, 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.fieldOfficerName, depositAccountData.status, depositAccountData.timeline, depositAccountData.currency,
depositAccountData.nominalAnnualInterestRate, depositAccountData.interestCompoundingPeriodType, depositAccountData.nominalAnnualInterestRate, depositAccountData.interestCompoundingPeriodType,
depositAccountData.interestPostingPeriodType, depositAccountData.interestCalculationType, depositAccountData.interestPostingPeriodType, depositAccountData.interestCalculationType,
@@ -96,19 +84,17 @@ public class FixedDepositAccountData extends DepositAccountData {
depositAccountData.interestCalculationTypeOptions, depositAccountData.interestCalculationDaysInYearTypeOptions, depositAccountData.interestCalculationTypeOptions, depositAccountData.interestCalculationDaysInYearTypeOptions,
depositAccountData.lockinPeriodFrequencyTypeOptions, depositAccountData.withdrawalFeeTypeOptions, depositAccountData.lockinPeriodFrequencyTypeOptions, depositAccountData.withdrawalFeeTypeOptions,
depositAccountData.charges, depositAccountData.chargeOptions, depositAccountData.accountChart, depositAccountData.charges, depositAccountData.chargeOptions, depositAccountData.accountChart,
depositAccountData.chartTemplate, interestFreePeriodApplicable, interestFreeFromPeriod, interestFreeToPeriod, depositAccountData.chartTemplate, preClosurePenalApplicable, preClosurePenalInterest, preClosurePenalInterestOnType,
interestFreePeriodFrequencyType, preClosurePenalApplicable, preClosurePenalInterest, preClosurePenalInterestOnType, preClosurePenalInterestOnTypeOptions, minDepositTerm, maxDepositTerm, minDepositTermType, maxDepositTermType,
interestFreePeriodTypeOptions, preClosurePenalInterestOnTypeOptions, minDepositTerm, maxDepositTerm, minDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType, depositAmount, maturityAmount, maturityDate, depositPeriod,
maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType, depositAmount, maturityAmount, maturityDate, depositPeriodFrequency, periodFrequencyTypeOptions, depositType, onAccountClosure, onAccountClosureOptions,
depositPeriod, depositPeriodFrequency, depositTermTypeOptions, inMultiplesOfDepositTermTypeOptions, paymentTypeOptions, savingsAccountDatas, linkedAccount, transferInterestToSavings);
depositPeriodFrequencyOptions, depositType, onAccountClosure, onAccountClosureOptions, paymentTypeOptions,
savingsAccountDatas, linkedAccount, transferInterestToSavings);
} }
public static FixedDepositAccountData withInterestChart(final FixedDepositAccountData account, public static FixedDepositAccountData withInterestChart(final FixedDepositAccountData account,
final DepositAccountInterestRateChartData accountChart) { final DepositAccountInterestRateChartData accountChart) {
return new FixedDepositAccountData(account.id, account.accountNo, account.externalId, account.groupId, account.groupName, 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.fieldOfficerName, account.status, account.timeline, account.currency, account.nominalAnnualInterestRate,
account.interestCompoundingPeriodType, account.interestPostingPeriodType, account.interestCalculationType, account.interestCompoundingPeriodType, account.interestPostingPeriodType, account.interestCalculationType,
account.interestCalculationDaysInYearType, account.minRequiredOpeningBalance, account.lockinPeriodFrequency, account.interestCalculationDaysInYearType, account.minRequiredOpeningBalance, account.lockinPeriodFrequency,
@@ -117,15 +103,12 @@ public class FixedDepositAccountData extends DepositAccountData {
account.interestPostingPeriodTypeOptions, account.interestCalculationTypeOptions, account.interestPostingPeriodTypeOptions, account.interestCalculationTypeOptions,
account.interestCalculationDaysInYearTypeOptions, account.lockinPeriodFrequencyTypeOptions, account.interestCalculationDaysInYearTypeOptions, account.lockinPeriodFrequencyTypeOptions,
account.withdrawalFeeTypeOptions, account.charges, account.chargeOptions, accountChart, account.chartTemplate, account.withdrawalFeeTypeOptions, account.charges, account.chargeOptions, accountChart, account.chartTemplate,
account.interestFreePeriodApplicable, account.interestFreeFromPeriod, account.interestFreeToPeriod, account.preClosurePenalApplicable, account.preClosurePenalInterest, account.preClosurePenalInterestOnType,
account.interestFreePeriodFrequencyType, account.preClosurePenalApplicable, account.preClosurePenalInterest, account.preClosurePenalInterestOnTypeOptions, account.minDepositTerm, account.maxDepositTerm, account.minDepositTermType,
account.preClosurePenalInterestOnType, account.interestFreePeriodTypeOptions, account.preClosurePenalInterestOnTypeOptions, account.maxDepositTermType, account.inMultiplesOfDepositTerm, account.inMultiplesOfDepositTermType, account.depositAmount,
account.minDepositTerm, account.maxDepositTerm, account.minDepositTermType, account.maxDepositTermType, account.maturityAmount, account.maturityDate, account.depositPeriod, account.depositPeriodFrequency,
account.inMultiplesOfDepositTerm, account.inMultiplesOfDepositTermType, account.depositAmount, account.maturityAmount, account.periodFrequencyTypeOptions, account.depositType, account.onAccountClosure, account.onAccountClosureOptions,
account.maturityDate, account.depositPeriod, account.depositPeriodFrequency, account.depositTermTypeOptions, account.paymentTypeOptions, account.savingsAccounts, account.linkedAccount, account.transferInterestToSavings);
account.inMultiplesOfDepositTermTypeOptions, account.depositTermTypeOptions, account.depositType, account.onAccountClosure,
account.onAccountClosureOptions, account.paymentTypeOptions, account.savingsAccounts, account.linkedAccount,
account.transferInterestToSavings);
} }
public static FixedDepositAccountData associationsAndTemplate(final FixedDepositAccountData account, FixedDepositAccountData template, 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, 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.fieldOfficerName, account.status, account.timeline, account.currency, account.nominalAnnualInterestRate,
account.interestCompoundingPeriodType, account.interestPostingPeriodType, account.interestCalculationType, account.interestCompoundingPeriodType, account.interestPostingPeriodType, account.interestCalculationType,
account.interestCalculationDaysInYearType, account.minRequiredOpeningBalance, account.lockinPeriodFrequency, account.interestCalculationDaysInYearType, account.minRequiredOpeningBalance, account.lockinPeriodFrequency,
@@ -146,15 +129,12 @@ public class FixedDepositAccountData extends DepositAccountData {
template.interestPostingPeriodTypeOptions, template.interestCalculationTypeOptions, template.interestPostingPeriodTypeOptions, template.interestCalculationTypeOptions,
template.interestCalculationDaysInYearTypeOptions, template.lockinPeriodFrequencyTypeOptions, template.interestCalculationDaysInYearTypeOptions, template.lockinPeriodFrequencyTypeOptions,
template.withdrawalFeeTypeOptions, charges, template.chargeOptions, account.accountChart, account.chartTemplate, template.withdrawalFeeTypeOptions, charges, template.chargeOptions, account.accountChart, account.chartTemplate,
account.interestFreePeriodApplicable, account.interestFreeFromPeriod, account.interestFreeToPeriod, account.preClosurePenalApplicable, account.preClosurePenalInterest, account.preClosurePenalInterestOnType,
account.interestFreePeriodFrequencyType, account.preClosurePenalApplicable, account.preClosurePenalInterest,
account.preClosurePenalInterestOnType, template.interestFreePeriodTypeOptions,
template.preClosurePenalInterestOnTypeOptions, account.minDepositTerm, account.maxDepositTerm, account.minDepositTermType, template.preClosurePenalInterestOnTypeOptions, account.minDepositTerm, account.maxDepositTerm, account.minDepositTermType,
account.maxDepositTermType, account.inMultiplesOfDepositTerm, account.inMultiplesOfDepositTermType, account.depositAmount, account.maxDepositTermType, account.inMultiplesOfDepositTerm, account.inMultiplesOfDepositTermType, account.depositAmount,
account.maturityAmount, account.maturityDate, account.depositPeriod, account.depositPeriodFrequency, account.maturityAmount, account.maturityDate, account.depositPeriod, account.depositPeriodFrequency,
template.depositTermTypeOptions, template.inMultiplesOfDepositTermTypeOptions, template.depositPeriodFrequencyOptions, template.periodFrequencyTypeOptions, account.depositType, account.onAccountClosure, account.onAccountClosureOptions,
account.depositType, account.onAccountClosure, account.onAccountClosureOptions, account.paymentTypeOptions, account.paymentTypeOptions, template.savingsAccounts, linkedAccount, account.transferInterestToSavings);
template.savingsAccounts, linkedAccount, account.transferInterestToSavings);
} }
public static FixedDepositAccountData withTemplateOptions(final FixedDepositAccountData account, public static FixedDepositAccountData withTemplateOptions(final FixedDepositAccountData account,
@@ -165,13 +145,12 @@ public class FixedDepositAccountData extends DepositAccountData {
final Collection<EnumOptionData> interestCalculationDaysInYearTypeOptions, final Collection<EnumOptionData> interestCalculationDaysInYearTypeOptions,
final Collection<EnumOptionData> lockinPeriodFrequencyTypeOptions, final Collection<EnumOptionData> withdrawalFeeTypeOptions, final Collection<EnumOptionData> lockinPeriodFrequencyTypeOptions, final Collection<EnumOptionData> withdrawalFeeTypeOptions,
final Collection<SavingsAccountTransactionData> transactions, final Collection<SavingsAccountChargeData> charges, final Collection<SavingsAccountTransactionData> transactions, final Collection<SavingsAccountChargeData> charges,
final Collection<ChargeData> chargeOptions, final Collection<EnumOptionData> interestFreePeriodTypeOptions, final Collection<ChargeData> chargeOptions, final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions,
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions, final Collection<EnumOptionData> depositTermTypeOptions, final Collection<EnumOptionData> periodFrequencyTypeOptions, final Collection<SavingsAccountData> savingsAccounts) {
final Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions,
final Collection<EnumOptionData> depositPeriodFrequencyOptions, final Collection<SavingsAccountData> savingsAccounts) {
return new FixedDepositAccountData(account.id, account.accountNo, account.externalId, account.groupId, account.groupName, 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.fieldOfficerName, account.status, account.timeline, account.currency, account.nominalAnnualInterestRate,
account.interestCompoundingPeriodType, account.interestPostingPeriodType, account.interestCalculationType, account.interestCompoundingPeriodType, account.interestPostingPeriodType, account.interestCalculationType,
account.interestCalculationDaysInYearType, account.minRequiredOpeningBalance, account.lockinPeriodFrequency, account.interestCalculationDaysInYearType, account.minRequiredOpeningBalance, account.lockinPeriodFrequency,
@@ -179,15 +158,12 @@ public class FixedDepositAccountData extends DepositAccountData {
fieldOfficerOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions, fieldOfficerOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions,
interestCalculationTypeOptions, interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, interestCalculationTypeOptions, interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions,
withdrawalFeeTypeOptions, charges, chargeOptions, account.accountChart, account.chartTemplate, withdrawalFeeTypeOptions, charges, chargeOptions, account.accountChart, account.chartTemplate,
account.interestFreePeriodApplicable, account.interestFreeFromPeriod, account.interestFreeToPeriod, account.preClosurePenalApplicable, account.preClosurePenalInterest, account.preClosurePenalInterestOnType,
account.interestFreePeriodFrequencyType, account.preClosurePenalApplicable, account.preClosurePenalInterest, preClosurePenalInterestOnTypeOptions, account.minDepositTerm, account.maxDepositTerm, account.minDepositTermType,
account.preClosurePenalInterestOnType, interestFreePeriodTypeOptions, preClosurePenalInterestOnTypeOptions, account.maxDepositTermType, account.inMultiplesOfDepositTerm, account.inMultiplesOfDepositTermType, account.depositAmount,
account.minDepositTerm, account.maxDepositTerm, account.minDepositTermType, account.maxDepositTermType, account.maturityAmount, account.maturityDate, account.depositPeriod, account.depositPeriodFrequency,
account.inMultiplesOfDepositTerm, account.inMultiplesOfDepositTermType, account.depositAmount, account.maturityAmount, periodFrequencyTypeOptions, account.depositType, account.onAccountClosure, account.onAccountClosureOptions,
account.maturityDate, account.depositPeriod, account.depositPeriodFrequency, depositTermTypeOptions, account.paymentTypeOptions, savingsAccounts, account.linkedAccount, account.transferInterestToSavings);
inMultiplesOfDepositTermTypeOptions, depositPeriodFrequencyOptions, 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, 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 accountChart = null;
final DepositAccountInterestRateChartData chartTemplate = 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 boolean preClosurePenalApplicable = false;
final BigDecimal preClosurePenalInterest = null; final BigDecimal preClosurePenalInterest = null;
final EnumOptionData preClosurePenalInterestOnType = null; final EnumOptionData preClosurePenalInterestOnType = null;
@@ -250,12 +222,9 @@ public class FixedDepositAccountData extends DepositAccountData {
final EnumOptionData onAccountClosure = null; final EnumOptionData onAccountClosure = null;
final PortfolioAccountData linkedAccount = null; final PortfolioAccountData linkedAccount = null;
final Boolean transferInterestToSavings = null; final Boolean transferInterestToSavings = null;
final Collection<EnumOptionData> interestFreePeriodTypeOptions = null;
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions = null; final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions = null;
final Collection<EnumOptionData> depositTermTypeOptions = null; final Collection<EnumOptionData> periodFrequencyTypeOptions = null;
final Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions = null;
final Collection<EnumOptionData> depositPeriodFrequencyOptions = null;
final EnumOptionData depositType = SavingsEnumerations.depositType(DepositAccountType.FIXED_DEPOSIT.getValue()); final EnumOptionData depositType = SavingsEnumerations.depositType(DepositAccountType.FIXED_DEPOSIT.getValue());
final Collection<EnumOptionData> onAccountClosureOptions = null; final Collection<EnumOptionData> onAccountClosureOptions = null;
final Collection<CodeValueData> paymentTypeOptions = null; final Collection<CodeValueData> paymentTypeOptions = null;
@@ -267,14 +236,11 @@ public class FixedDepositAccountData extends DepositAccountData {
lockinPeriodFrequency, lockinPeriodFrequencyType, withdrawalFeeForTransfers, summary, transactions, productOptions, lockinPeriodFrequency, lockinPeriodFrequencyType, withdrawalFeeForTransfers, summary, transactions, productOptions,
fieldOfficerOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions, fieldOfficerOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions,
interestCalculationTypeOptions, interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, interestCalculationTypeOptions, interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions,
withdrawalFeeTypeOptions, charges, chargeOptions, accountChart, chartTemplate, interestFreePeriodApplicable, withdrawalFeeTypeOptions, charges, chargeOptions, accountChart, chartTemplate, preClosurePenalApplicable,
interestFreeFromPeriod, interestFreeToPeriod, interestFreePeriodFrequencyType, preClosurePenalApplicable, preClosurePenalInterest, preClosurePenalInterestOnType, preClosurePenalInterestOnTypeOptions, minDepositTerm,
preClosurePenalInterest, preClosurePenalInterestOnType, interestFreePeriodTypeOptions, maxDepositTerm, minDepositTermType, maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType,
preClosurePenalInterestOnTypeOptions, minDepositTerm, maxDepositTerm, minDepositTermType, maxDepositTermType, depositAmount, maturityAmount, maturityDate, depositPeriod, depositPeriodFrequency, periodFrequencyTypeOptions,
inMultiplesOfDepositTerm, inMultiplesOfDepositTermType, depositAmount, maturityAmount, maturityDate, depositPeriod, depositType, onAccountClosure, onAccountClosureOptions, paymentTypeOptions, savingsAccountDatas, linkedAccount, transferInterestToSavings);
depositPeriodFrequency, depositTermTypeOptions, inMultiplesOfDepositTermTypeOptions, depositPeriodFrequencyOptions,
depositType, onAccountClosure, onAccountClosureOptions, paymentTypeOptions, savingsAccountDatas, linkedAccount,
transferInterestToSavings);
} }
public static FixedDepositAccountData preClosureDetails(final Long accountId, BigDecimal maturityAmount, public static FixedDepositAccountData preClosureDetails(final Long accountId, BigDecimal maturityAmount,
@@ -305,7 +271,6 @@ public class FixedDepositAccountData extends DepositAccountData {
final boolean withdrawalFeeForTransfers = false; final boolean withdrawalFeeForTransfers = false;
final SavingsAccountSummaryData summary = null; final SavingsAccountSummaryData summary = null;
final Collection<SavingsAccountTransactionData> transactions = null; final Collection<SavingsAccountTransactionData> transactions = null;
final Collection<DepositProductData> productOptions = null; final Collection<DepositProductData> productOptions = null;
final Collection<StaffData> fieldOfficerOptions = null; final Collection<StaffData> fieldOfficerOptions = null;
final Collection<EnumOptionData> interestCompoundingPeriodTypeOptions = null; final Collection<EnumOptionData> interestCompoundingPeriodTypeOptions = null;
@@ -320,10 +285,6 @@ public class FixedDepositAccountData extends DepositAccountData {
final DepositAccountInterestRateChartData accountChart = null; final DepositAccountInterestRateChartData accountChart = null;
final DepositAccountInterestRateChartData chartTemplate = 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 boolean preClosurePenalApplicable = false;
final BigDecimal preClosurePenalInterest = null; final BigDecimal preClosurePenalInterest = null;
final EnumOptionData preClosurePenalInterestOnType = null; final EnumOptionData preClosurePenalInterestOnType = null;
@@ -340,11 +301,9 @@ public class FixedDepositAccountData extends DepositAccountData {
final EnumOptionData onAccountClosure = null; final EnumOptionData onAccountClosure = null;
final Boolean transferInterestToSavings = null; final Boolean transferInterestToSavings = null;
final Collection<EnumOptionData> interestFreePeriodTypeOptions = null;
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions = null; final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions = null;
final Collection<EnumOptionData> depositTermTypeOptions = null; final Collection<EnumOptionData> periodFrequencyTypeOptions = null;
final Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions = null;
final Collection<EnumOptionData> depositPeriodFrequencyOptions = null;
final EnumOptionData depositType = SavingsEnumerations.depositType(DepositAccountType.FIXED_DEPOSIT.getValue()); final EnumOptionData depositType = SavingsEnumerations.depositType(DepositAccountType.FIXED_DEPOSIT.getValue());
final PortfolioAccountData linkedAccount = null; final PortfolioAccountData linkedAccount = null;
@@ -354,14 +313,11 @@ public class FixedDepositAccountData extends DepositAccountData {
lockinPeriodFrequency, lockinPeriodFrequencyType, withdrawalFeeForTransfers, summary, transactions, productOptions, lockinPeriodFrequency, lockinPeriodFrequencyType, withdrawalFeeForTransfers, summary, transactions, productOptions,
fieldOfficerOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions, fieldOfficerOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions,
interestCalculationTypeOptions, interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, interestCalculationTypeOptions, interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions,
withdrawalFeeTypeOptions, charges, chargeOptions, accountChart, chartTemplate, interestFreePeriodApplicable, withdrawalFeeTypeOptions, charges, chargeOptions, accountChart, chartTemplate, preClosurePenalApplicable,
interestFreeFromPeriod, interestFreeToPeriod, interestFreePeriodFrequencyType, preClosurePenalApplicable, preClosurePenalInterest, preClosurePenalInterestOnType, preClosurePenalInterestOnTypeOptions, minDepositTerm,
preClosurePenalInterest, preClosurePenalInterestOnType, interestFreePeriodTypeOptions, maxDepositTerm, minDepositTermType, maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType,
preClosurePenalInterestOnTypeOptions, minDepositTerm, maxDepositTerm, minDepositTermType, maxDepositTermType, depositAmount, maturityAmount, maturityDate, depositPeriod, depositPeriodFrequency, periodFrequencyTypeOptions,
inMultiplesOfDepositTerm, inMultiplesOfDepositTermType, depositAmount, maturityAmount, maturityDate, depositPeriod, depositType, onAccountClosure, onAccountClosureOptions, paymentTypeOptions, savingsAccountDatas, linkedAccount, transferInterestToSavings);
depositPeriodFrequency, depositTermTypeOptions, inMultiplesOfDepositTermTypeOptions, depositPeriodFrequencyOptions,
depositType, onAccountClosure, onAccountClosureOptions, paymentTypeOptions, savingsAccountDatas, linkedAccount,
transferInterestToSavings);
} }
public static FixedDepositAccountData withClosureTemplateDetails(final FixedDepositAccountData account, public static FixedDepositAccountData withClosureTemplateDetails(final FixedDepositAccountData account,
@@ -369,7 +325,7 @@ public class FixedDepositAccountData extends DepositAccountData {
final Collection<SavingsAccountData> savingsAccountDatas) { final Collection<SavingsAccountData> savingsAccountDatas) {
return new FixedDepositAccountData(account.id, account.accountNo, account.externalId, account.groupId, account.groupName, 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.fieldOfficerName, account.status, account.timeline, account.currency, account.nominalAnnualInterestRate,
account.interestCompoundingPeriodType, account.interestPostingPeriodType, account.interestCalculationType, account.interestCompoundingPeriodType, account.interestPostingPeriodType, account.interestCalculationType,
account.interestCalculationDaysInYearType, account.minRequiredOpeningBalance, account.lockinPeriodFrequency, account.interestCalculationDaysInYearType, account.minRequiredOpeningBalance, account.lockinPeriodFrequency,
@@ -378,15 +334,13 @@ public class FixedDepositAccountData extends DepositAccountData {
account.interestPostingPeriodTypeOptions, account.interestCalculationTypeOptions, account.interestPostingPeriodTypeOptions, account.interestCalculationTypeOptions,
account.interestCalculationDaysInYearTypeOptions, account.lockinPeriodFrequencyTypeOptions, account.interestCalculationDaysInYearTypeOptions, account.lockinPeriodFrequencyTypeOptions,
account.withdrawalFeeTypeOptions, account.charges, account.chargeOptions, account.accountChart, account.chartTemplate, account.withdrawalFeeTypeOptions, account.charges, account.chargeOptions, account.accountChart, account.chartTemplate,
account.interestFreePeriodApplicable, account.interestFreeFromPeriod, account.interestFreeToPeriod, account.preClosurePenalApplicable, account.preClosurePenalInterest, account.preClosurePenalInterestOnType,
account.interestFreePeriodFrequencyType, account.preClosurePenalApplicable, account.preClosurePenalInterest, account.preClosurePenalInterestOnTypeOptions, account.minDepositTerm, account.maxDepositTerm, account.minDepositTermType,
account.preClosurePenalInterestOnType, account.interestFreePeriodTypeOptions, account.preClosurePenalInterestOnTypeOptions, account.maxDepositTermType, account.inMultiplesOfDepositTerm, account.inMultiplesOfDepositTermType, account.depositAmount,
account.minDepositTerm, account.maxDepositTerm, account.minDepositTermType, account.maxDepositTermType, account.maturityAmount, account.maturityDate, account.depositPeriod, account.depositPeriodFrequency,
account.inMultiplesOfDepositTerm, account.inMultiplesOfDepositTermType, account.depositAmount, account.maturityAmount, account.periodFrequencyTypeOptions, account.depositType, account.onAccountClosure, onAccountClosureOptions,
account.maturityDate, account.depositPeriod, account.depositPeriodFrequency, account.depositTermTypeOptions, paymentTypeOptions, savingsAccountDatas, account.linkedAccount, account.transferInterestToSavings);
account.inMultiplesOfDepositTermTypeOptions, account.depositPeriodFrequencyOptions, 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, 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<EnumOptionData> lockinPeriodFrequencyTypeOptions, final Collection<EnumOptionData> withdrawalFeeTypeOptions,
final Collection<SavingsAccountChargeData> charges, final Collection<ChargeData> chargeOptions, final Collection<SavingsAccountChargeData> charges, final Collection<ChargeData> chargeOptions,
final DepositAccountInterestRateChartData accountChart, final DepositAccountInterestRateChartData chartTemplate, final DepositAccountInterestRateChartData accountChart, final DepositAccountInterestRateChartData chartTemplate,
final boolean interestFreePeriodApplicable, final Integer interestFreeFromPeriod, final Integer interestFreeToPeriod, final boolean preClosurePenalApplicable, final BigDecimal preClosurePenalInterest,
final EnumOptionData interestFreePeriodFrequencyType, final boolean preClosurePenalApplicable, final EnumOptionData preClosurePenalInterestOnType, final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions,
final BigDecimal preClosurePenalInterest, final EnumOptionData preClosurePenalInterestOnType, final Integer minDepositTerm, final Integer maxDepositTerm, final EnumOptionData minDepositTermType,
final Collection<EnumOptionData> interestFreePeriodTypeOptions, final EnumOptionData maxDepositTermType, final Integer inMultiplesOfDepositTerm,
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions, final Integer minDepositTerm, final EnumOptionData inMultiplesOfDepositTermType, final BigDecimal depositAmount, final BigDecimal maturityAmount,
final Integer maxDepositTerm, final EnumOptionData minDepositTermType, final EnumOptionData maxDepositTermType, final LocalDate maturityDate, final Integer depositPeriod, final EnumOptionData depositPeriodFrequency,
final Integer inMultiplesOfDepositTerm, final EnumOptionData inMultiplesOfDepositTermType, final BigDecimal depositAmount, final Collection<EnumOptionData> periodFrequencyTypeOptions, final EnumOptionData depositType,
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 EnumOptionData onAccountClosure, final Collection<EnumOptionData> onAccountClosureOptions, final EnumOptionData onAccountClosure, final Collection<EnumOptionData> onAccountClosureOptions,
final Collection<CodeValueData> paymentTypeOptions, final Collection<SavingsAccountData> savingsAccountDatas, final Collection<CodeValueData> paymentTypeOptions, final Collection<SavingsAccountData> savingsAccountDatas,
final PortfolioAccountData linkedAccount, final Boolean transferInterestToSavings) { final PortfolioAccountData linkedAccount, final Boolean transferInterestToSavings) {
@@ -429,11 +379,6 @@ public class FixedDepositAccountData extends DepositAccountData {
interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, charges, interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, charges,
chargeOptions, accountChart, chartTemplate, depositType); chargeOptions, accountChart, chartTemplate, depositType);
// fixed deposit additional fields
this.interestFreePeriodApplicable = interestFreePeriodApplicable;
this.interestFreeFromPeriod = interestFreeFromPeriod;
this.interestFreeToPeriod = interestFreeToPeriod;
this.interestFreePeriodFrequencyType = interestFreePeriodFrequencyType;
this.preClosurePenalApplicable = preClosurePenalApplicable; this.preClosurePenalApplicable = preClosurePenalApplicable;
this.preClosurePenalInterest = preClosurePenalInterest; this.preClosurePenalInterest = preClosurePenalInterest;
this.preClosurePenalInterestOnType = preClosurePenalInterestOnType; this.preClosurePenalInterestOnType = preClosurePenalInterestOnType;
@@ -453,11 +398,8 @@ public class FixedDepositAccountData extends DepositAccountData {
this.transferInterestToSavings = transferInterestToSavings; this.transferInterestToSavings = transferInterestToSavings;
// template // template
this.interestFreePeriodTypeOptions = interestFreePeriodTypeOptions;
this.preClosurePenalInterestOnTypeOptions = preClosurePenalInterestOnTypeOptions; this.preClosurePenalInterestOnTypeOptions = preClosurePenalInterestOnTypeOptions;
this.depositTermTypeOptions = depositTermTypeOptions; this.periodFrequencyTypeOptions = periodFrequencyTypeOptions;
this.inMultiplesOfDepositTermTypeOptions = inMultiplesOfDepositTermTypeOptions;
this.depositPeriodFrequencyOptions = depositPeriodFrequencyOptions;
// account close template options // account close template options
this.onAccountClosureOptions = onAccountClosureOptions; this.onAccountClosureOptions = onAccountClosureOptions;
@@ -25,10 +25,6 @@ import org.mifosplatform.portfolio.interestratechart.data.InterestRateChartData;
public class FixedDepositProductData extends DepositProductData { public class FixedDepositProductData extends DepositProductData {
// additional fields // additional fields
private boolean interestFreePeriodApplicable;
private Integer interestFreeFromPeriod;
private Integer interestFreeToPeriod;
protected EnumOptionData interestFreePeriodFrequencyType;
private boolean preClosurePenalApplicable; private boolean preClosurePenalApplicable;
protected BigDecimal preClosurePenalInterest; protected BigDecimal preClosurePenalInterest;
protected EnumOptionData preClosurePenalInterestOnType; protected EnumOptionData preClosurePenalInterestOnType;
@@ -42,10 +38,8 @@ public class FixedDepositProductData extends DepositProductData {
protected BigDecimal depositAmount; protected BigDecimal depositAmount;
protected BigDecimal maxDepositAmount; protected BigDecimal maxDepositAmount;
private Collection<EnumOptionData> interestFreePeriodTypeOptions;
private Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions; private Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions;
private Collection<EnumOptionData> depositTermTypeOptions; private Collection<EnumOptionData> periodFrequencyTypeOptions;
private Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions;
public static FixedDepositProductData template(final CurrencyData currency, final EnumOptionData interestCompoundingPeriodType, public static FixedDepositProductData template(final CurrencyData currency, final EnumOptionData interestCompoundingPeriodType,
final EnumOptionData interestPostingPeriodType, final EnumOptionData interestCalculationType, final EnumOptionData interestPostingPeriodType, final EnumOptionData interestCalculationType,
@@ -58,9 +52,8 @@ public class FixedDepositProductData extends DepositProductData {
final Collection<CodeValueData> paymentTypeOptions, final Collection<EnumOptionData> accountingRuleOptions, final Collection<CodeValueData> paymentTypeOptions, final Collection<EnumOptionData> accountingRuleOptions,
final Map<String, List<GLAccountData>> accountingMappingOptions, final Collection<ChargeData> chargeOptions, final Map<String, List<GLAccountData>> accountingMappingOptions, final Collection<ChargeData> chargeOptions,
final Collection<ChargeData> penaltyOptions, final InterestRateChartData chartTemplate, final Collection<ChargeData> penaltyOptions, final InterestRateChartData chartTemplate,
final Collection<EnumOptionData> interestFreePeriodTypes, final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions,
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions, final Collection<EnumOptionData> depositTermTypeOptions, final Collection<EnumOptionData> periodFrequencyTypeOptions) {
final Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions) {
final Long id = null; final Long id = null;
final String name = null; final String name = null;
@@ -75,10 +68,7 @@ public class FixedDepositProductData extends DepositProductData {
final Collection<ChargeToGLAccountMapper> feeToIncomeAccountMappings = null; final Collection<ChargeToGLAccountMapper> feeToIncomeAccountMappings = null;
final Collection<ChargeToGLAccountMapper> penaltyToIncomeAccountMappings = null; final Collection<ChargeToGLAccountMapper> penaltyToIncomeAccountMappings = null;
final Collection<InterestRateChartData> interestRateCharts = 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 boolean preClosurePenalApplicable = false;
final BigDecimal preClosurePenalInterest = null; final BigDecimal preClosurePenalInterest = null;
final EnumOptionData preClosurePenalInterestOnType = null; final EnumOptionData preClosurePenalInterestOnType = null;
@@ -98,11 +88,10 @@ public class FixedDepositProductData extends DepositProductData {
currencyOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions, interestCalculationTypeOptions, currencyOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions, interestCalculationTypeOptions,
interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, paymentTypeOptions, interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, paymentTypeOptions,
accountingRuleOptions, accountingMappingOptions, charges, chargeOptions, penaltyOptions, feeToIncomeAccountMappings, accountingRuleOptions, accountingMappingOptions, charges, chargeOptions, penaltyOptions, feeToIncomeAccountMappings,
penaltyToIncomeAccountMappings, interestRateCharts, chartTemplate, interestFreePeriodApplicable, interestFreeFromPeriod, penaltyToIncomeAccountMappings, interestRateCharts, chartTemplate, preClosurePenalApplicable, preClosurePenalInterest,
interestFreeToPeriod, interestFreePeriodFrequencyType, preClosurePenalApplicable, preClosurePenalInterest, preClosurePenalInterestOnType, preClosurePenalInterestOnTypeOptions, minDepositTerm, maxDepositTerm, minDepositTermType,
preClosurePenalInterestOnType, interestFreePeriodTypes, preClosurePenalInterestOnTypeOptions, minDepositTerm, maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType, minDepositAmount, depositAmount,
maxDepositTerm, minDepositTermType, maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType, maxDepositAmount, periodFrequencyTypeOptions);
minDepositAmount, depositAmount, maxDepositAmount, depositTermTypeOptions, inMultiplesOfDepositTermTypeOptions);
} }
public static FixedDepositProductData withCharges(final FixedDepositProductData existingProduct, final Collection<ChargeData> charges) { 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, existingProduct.paymentTypeOptions, existingProduct.accountingRuleOptions, existingProduct.accountingMappingOptions,
charges, existingProduct.chargeOptions, existingProduct.penaltyOptions, existingProduct.feeToIncomeAccountMappings, charges, existingProduct.chargeOptions, existingProduct.penaltyOptions, existingProduct.feeToIncomeAccountMappings,
existingProduct.penaltyToIncomeAccountMappings, existingProduct.interestRateCharts, existingProduct.chartTemplate, existingProduct.penaltyToIncomeAccountMappings, existingProduct.interestRateCharts, existingProduct.chartTemplate,
existingProduct.interestFreePeriodApplicable, existingProduct.interestFreeFromPeriod, existingProduct.interestFreeToPeriod, existingProduct.preClosurePenalApplicable, existingProduct.preClosurePenalInterest,
existingProduct.interestFreePeriodFrequencyType, existingProduct.preClosurePenalApplicable, existingProduct.preClosurePenalInterestOnType, existingProduct.preClosurePenalInterestOnTypeOptions,
existingProduct.preClosurePenalInterest, existingProduct.preClosurePenalInterestOnType,
existingProduct.interestFreePeriodTypeOptions, existingProduct.preClosurePenalInterestOnTypeOptions,
existingProduct.minDepositTerm, existingProduct.maxDepositTerm, existingProduct.minDepositTermType, existingProduct.minDepositTerm, existingProduct.maxDepositTerm, existingProduct.minDepositTermType,
existingProduct.maxDepositTermType, existingProduct.inMultiplesOfDepositTerm, existingProduct.inMultiplesOfDepositTermType, existingProduct.maxDepositTermType, existingProduct.inMultiplesOfDepositTerm, existingProduct.inMultiplesOfDepositTermType,
existingProduct.minDepositAmount, existingProduct.depositAmount, existingProduct.maxDepositAmount, 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 Collection<CodeValueData> paymentTypeOptions, final Collection<EnumOptionData> accountingRuleOptions,
final Map<String, List<GLAccountData>> accountingMappingOptions, final Collection<ChargeData> chargeOptions, final Map<String, List<GLAccountData>> accountingMappingOptions, final Collection<ChargeData> chargeOptions,
final Collection<ChargeData> penaltyOptions, final InterestRateChartData chartTemplate, final Collection<ChargeData> penaltyOptions, final InterestRateChartData chartTemplate,
final Collection<EnumOptionData> interestFreePeriodTypes, final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions,
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions, final Collection<EnumOptionData> depositTermTypeOptions, final Collection<EnumOptionData> periodFrequencyTypeOptions) {
final Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions) {
return new FixedDepositProductData(existingProduct.id, existingProduct.name, existingProduct.shortName, return new FixedDepositProductData(existingProduct.id, existingProduct.name, existingProduct.shortName,
existingProduct.description, existingProduct.currency, existingProduct.nominalAnnualInterestRate, existingProduct.description, existingProduct.currency, existingProduct.nominalAnnualInterestRate,
@@ -156,14 +142,12 @@ public class FixedDepositProductData extends DepositProductData {
interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, paymentTypeOptions, interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, paymentTypeOptions,
accountingRuleOptions, accountingMappingOptions, existingProduct.charges, chargeOptions, penaltyOptions, accountingRuleOptions, accountingMappingOptions, existingProduct.charges, chargeOptions, penaltyOptions,
existingProduct.feeToIncomeAccountMappings, existingProduct.penaltyToIncomeAccountMappings, existingProduct.feeToIncomeAccountMappings, existingProduct.penaltyToIncomeAccountMappings,
existingProduct.interestRateCharts, chartTemplate, existingProduct.interestFreePeriodApplicable, existingProduct.interestRateCharts, chartTemplate, existingProduct.preClosurePenalApplicable,
existingProduct.interestFreeFromPeriod, existingProduct.interestFreeToPeriod, existingProduct.preClosurePenalInterest, existingProduct.preClosurePenalInterestOnType,
existingProduct.interestFreePeriodFrequencyType, existingProduct.preClosurePenalApplicable,
existingProduct.preClosurePenalInterest, existingProduct.preClosurePenalInterestOnType, interestFreePeriodTypes,
preClosurePenalInterestOnTypeOptions, existingProduct.minDepositTerm, existingProduct.maxDepositTerm, preClosurePenalInterestOnTypeOptions, existingProduct.minDepositTerm, existingProduct.maxDepositTerm,
existingProduct.minDepositTermType, existingProduct.maxDepositTermType, existingProduct.inMultiplesOfDepositTerm, existingProduct.minDepositTermType, existingProduct.maxDepositTermType, existingProduct.inMultiplesOfDepositTerm,
existingProduct.inMultiplesOfDepositTermType, existingProduct.minDepositAmount, existingProduct.depositAmount, existingProduct.inMultiplesOfDepositTermType, existingProduct.minDepositAmount, existingProduct.depositAmount,
existingProduct.maxDepositAmount, depositTermTypeOptions, inMultiplesOfDepositTermTypeOptions); existingProduct.maxDepositAmount, periodFrequencyTypeOptions);
} }
public static FixedDepositProductData withAccountingDetails(final FixedDepositProductData existingProduct, public static FixedDepositProductData withAccountingDetails(final FixedDepositProductData existingProduct,
@@ -195,23 +179,19 @@ public class FixedDepositProductData extends DepositProductData {
lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, paymentTypeOptions, accountingRuleOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, paymentTypeOptions, accountingRuleOptions,
accountingMappingOptions, existingProduct.charges, chargeOptions, penaltyOptions, feeToIncomeAccountMappings, accountingMappingOptions, existingProduct.charges, chargeOptions, penaltyOptions, feeToIncomeAccountMappings,
penaltyToIncomeAccountMappings, existingProduct.interestRateCharts, existingProduct.chartTemplate, penaltyToIncomeAccountMappings, existingProduct.interestRateCharts, existingProduct.chartTemplate,
existingProduct.interestFreePeriodApplicable, existingProduct.interestFreeFromPeriod, existingProduct.interestFreeToPeriod, existingProduct.preClosurePenalApplicable, existingProduct.preClosurePenalInterest,
existingProduct.interestFreePeriodFrequencyType, existingProduct.preClosurePenalApplicable, existingProduct.preClosurePenalInterestOnType, existingProduct.preClosurePenalInterestOnTypeOptions,
existingProduct.preClosurePenalInterest, existingProduct.preClosurePenalInterestOnType,
existingProduct.interestFreePeriodTypeOptions, existingProduct.preClosurePenalInterestOnTypeOptions,
existingProduct.minDepositTerm, existingProduct.maxDepositTerm, existingProduct.minDepositTermType, existingProduct.minDepositTerm, existingProduct.maxDepositTerm, existingProduct.minDepositTermType,
existingProduct.maxDepositTermType, existingProduct.inMultiplesOfDepositTerm, existingProduct.inMultiplesOfDepositTermType, existingProduct.maxDepositTermType, existingProduct.inMultiplesOfDepositTerm, existingProduct.inMultiplesOfDepositTermType,
existingProduct.minDepositAmount, existingProduct.depositAmount, existingProduct.maxDepositAmount, existingProduct.minDepositAmount, existingProduct.depositAmount, existingProduct.maxDepositAmount,
existingProduct.depositTermTypeOptions, existingProduct.inMultiplesOfDepositTermTypeOptions); existingProduct.periodFrequencyTypeOptions);
} }
public static FixedDepositProductData instance(final DepositProductData depositProductData, final boolean interestFreePeriodApplicable, public static FixedDepositProductData instance(final DepositProductData depositProductData, final boolean preClosurePenalApplicable,
final Integer interestFreeFromPeriod, final Integer interestFreeToPeriod, final EnumOptionData interestFreePeriodFrequencyType, final BigDecimal preClosurePenalInterest, final EnumOptionData preClosurePenalInterestOnType, final Integer minDepositTerm,
final boolean preClosurePenalApplicable, final BigDecimal preClosurePenalInterest, final Integer maxDepositTerm, final EnumOptionData minDepositTermType, final EnumOptionData maxDepositTermType,
final EnumOptionData preClosurePenalInterestOnType, final Integer minDepositTerm, final Integer maxDepositTerm, final Integer inMultiplesOfDepositTerm, final EnumOptionData inMultiplesOfDepositTermType, final BigDecimal minDepositAmount,
final EnumOptionData minDepositTermType, final EnumOptionData maxDepositTermType, final Integer inMultiplesOfDepositTerm, final BigDecimal depositAmount, final BigDecimal maxDepositAmount) {
final EnumOptionData inMultiplesOfDepositTermType, final BigDecimal minDepositAmount, final BigDecimal depositAmount,
final BigDecimal maxDepositAmount) {
final Map<String, Object> accountingMappings = null; final Map<String, Object> accountingMappings = null;
final Collection<PaymentTypeToGLAccountMapper> paymentChannelToFundSourceMappings = null; final Collection<PaymentTypeToGLAccountMapper> paymentChannelToFundSourceMappings = null;
@@ -233,10 +213,8 @@ public class FixedDepositProductData extends DepositProductData {
final Collection<ChargeToGLAccountMapper> penaltyToIncomeAccountMappings = null; final Collection<ChargeToGLAccountMapper> penaltyToIncomeAccountMappings = null;
final Collection<InterestRateChartData> interestRateCharts = null; final Collection<InterestRateChartData> interestRateCharts = null;
final InterestRateChartData chartTemplate = null; final InterestRateChartData chartTemplate = null;
final Collection<EnumOptionData> interestFreePeriodTypes = null;
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions = null; final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions = null;
final Collection<EnumOptionData> depositTermTypeOptions = null; final Collection<EnumOptionData> periodFrequencyTypeOptions = null;
final Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions = null;
return new FixedDepositProductData(depositProductData.id, depositProductData.name, depositProductData.shortName, return new FixedDepositProductData(depositProductData.id, depositProductData.name, depositProductData.shortName,
depositProductData.description, depositProductData.currency, depositProductData.nominalAnnualInterestRate, depositProductData.description, depositProductData.currency, depositProductData.nominalAnnualInterestRate,
@@ -247,11 +225,10 @@ public class FixedDepositProductData extends DepositProductData {
interestPostingPeriodTypeOptions, interestCalculationTypeOptions, interestCalculationDaysInYearTypeOptions, interestPostingPeriodTypeOptions, interestCalculationTypeOptions, interestCalculationDaysInYearTypeOptions,
lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, paymentTypeOptions, accountingRuleOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, paymentTypeOptions, accountingRuleOptions,
accountingMappingOptions, charges, chargeOptions, penaltyOptions, feeToIncomeAccountMappings, accountingMappingOptions, charges, chargeOptions, penaltyOptions, feeToIncomeAccountMappings,
penaltyToIncomeAccountMappings, interestRateCharts, chartTemplate, interestFreePeriodApplicable, interestFreeFromPeriod, penaltyToIncomeAccountMappings, interestRateCharts, chartTemplate, preClosurePenalApplicable, preClosurePenalInterest,
interestFreeToPeriod, interestFreePeriodFrequencyType, preClosurePenalApplicable, preClosurePenalInterest, preClosurePenalInterestOnType, preClosurePenalInterestOnTypeOptions, minDepositTerm, maxDepositTerm, minDepositTermType,
preClosurePenalInterestOnType, interestFreePeriodTypes, preClosurePenalInterestOnTypeOptions, minDepositTerm, maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType, minDepositAmount, depositAmount,
maxDepositTerm, minDepositTermType, maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType, maxDepositAmount, periodFrequencyTypeOptions);
minDepositAmount, depositAmount, maxDepositAmount, depositTermTypeOptions, inMultiplesOfDepositTermTypeOptions);
} }
public static FixedDepositProductData lookup(final Long id, final String name) { 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<ChargeToGLAccountMapper> penaltyToIncomeAccountMappings = null;
final Collection<InterestRateChartData> interestRateCharts = null; final Collection<InterestRateChartData> interestRateCharts = null;
final InterestRateChartData chartTemplate = 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 boolean preClosurePenalApplicable = false;
final BigDecimal preClosurePenalInterest = null; final BigDecimal preClosurePenalInterest = null;
final EnumOptionData preClosurePenalInterestOnType = null; final EnumOptionData preClosurePenalInterestOnType = null;
final Collection<EnumOptionData> interestFreePeriodTypes = null;
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions = null; final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions = null;
final Integer minDepositTerm = null; final Integer minDepositTerm = null;
final Integer maxDepositTerm = null; final Integer maxDepositTerm = null;
@@ -305,8 +277,7 @@ public class FixedDepositProductData extends DepositProductData {
final BigDecimal minDepositAmount = null; final BigDecimal minDepositAmount = null;
final BigDecimal depositAmount = null; final BigDecimal depositAmount = null;
final BigDecimal maxDepositAmount = null; final BigDecimal maxDepositAmount = null;
final Collection<EnumOptionData> depositTermTypeOptions = null; final Collection<EnumOptionData> periodFrequencyTypeOptions = null;
final Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions = null;
return new FixedDepositProductData(id, name, shortName, description, currency, nominalAnnualInterestRate, return new FixedDepositProductData(id, name, shortName, description, currency, nominalAnnualInterestRate,
interestCompoundingPeriodType, interestPostingPeriodType, interestCalculationType, interestCalculationDaysInYearType, interestCompoundingPeriodType, interestPostingPeriodType, interestCalculationType, interestCalculationDaysInYearType,
@@ -314,11 +285,10 @@ public class FixedDepositProductData extends DepositProductData {
currencyOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions, interestCalculationTypeOptions, currencyOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions, interestCalculationTypeOptions,
interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, paymentTypeOptions, interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, paymentTypeOptions,
accountingRuleOptions, accountingMappingOptions, charges, chargeOptions, penaltyOptions, feeToIncomeAccountMappings, accountingRuleOptions, accountingMappingOptions, charges, chargeOptions, penaltyOptions, feeToIncomeAccountMappings,
penaltyToIncomeAccountMappings, interestRateCharts, chartTemplate, interestFreePeriodApplicable, interestFreeFromPeriod, penaltyToIncomeAccountMappings, interestRateCharts, chartTemplate, preClosurePenalApplicable, preClosurePenalInterest,
interestFreeToPeriod, interestFreePeriodFrequencyType, preClosurePenalApplicable, preClosurePenalInterest, preClosurePenalInterestOnType, preClosurePenalInterestOnTypeOptions, minDepositTerm, maxDepositTerm, minDepositTermType,
preClosurePenalInterestOnType, interestFreePeriodTypes, preClosurePenalInterestOnTypeOptions, minDepositTerm, maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType, minDepositAmount, depositAmount,
maxDepositTerm, minDepositTermType, maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType, maxDepositAmount, periodFrequencyTypeOptions);
minDepositAmount, depositAmount, maxDepositAmount, depositTermTypeOptions, inMultiplesOfDepositTermTypeOptions);
} }
public static FixedDepositProductData withInterestChart(final FixedDepositProductData existingProduct, public static FixedDepositProductData withInterestChart(final FixedDepositProductData existingProduct,
@@ -335,15 +305,13 @@ public class FixedDepositProductData extends DepositProductData {
existingProduct.paymentTypeOptions, existingProduct.accountingRuleOptions, existingProduct.accountingMappingOptions, existingProduct.paymentTypeOptions, existingProduct.accountingRuleOptions, existingProduct.accountingMappingOptions,
existingProduct.charges, existingProduct.chargeOptions, existingProduct.penaltyOptions, existingProduct.charges, existingProduct.chargeOptions, existingProduct.penaltyOptions,
existingProduct.feeToIncomeAccountMappings, existingProduct.penaltyToIncomeAccountMappings, interestRateCharts, existingProduct.feeToIncomeAccountMappings, existingProduct.penaltyToIncomeAccountMappings, interestRateCharts,
existingProduct.chartTemplate, existingProduct.interestFreePeriodApplicable, existingProduct.interestFreeFromPeriod, existingProduct.chartTemplate, existingProduct.preClosurePenalApplicable, existingProduct.preClosurePenalInterest,
existingProduct.interestFreeToPeriod, existingProduct.interestFreePeriodFrequencyType, existingProduct.preClosurePenalInterestOnType, existingProduct.preClosurePenalInterestOnTypeOptions,
existingProduct.preClosurePenalApplicable, existingProduct.preClosurePenalInterest, existingProduct.minDepositTerm, existingProduct.maxDepositTerm, existingProduct.minDepositTermType,
existingProduct.preClosurePenalInterestOnType, existingProduct.interestFreePeriodTypeOptions, existingProduct.maxDepositTermType, existingProduct.inMultiplesOfDepositTerm, existingProduct.inMultiplesOfDepositTermType,
existingProduct.preClosurePenalInterestOnTypeOptions, existingProduct.minDepositTerm, existingProduct.maxDepositTerm, existingProduct.minDepositAmount, existingProduct.depositAmount, existingProduct.maxDepositAmount,
existingProduct.minDepositTermType, existingProduct.maxDepositTermType, existingProduct.inMultiplesOfDepositTerm, existingProduct.periodFrequencyTypeOptions);
existingProduct.inMultiplesOfDepositTermType, existingProduct.minDepositAmount, existingProduct.depositAmount,
existingProduct.maxDepositAmount, existingProduct.depositTermTypeOptions,
existingProduct.inMultiplesOfDepositTermTypeOptions);
} }
private FixedDepositProductData(final Long id, final String name, final String shortName, final String description, 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> feeToIncomeAccountMappings,
final Collection<ChargeToGLAccountMapper> penaltyToIncomeAccountMappings, final Collection<ChargeToGLAccountMapper> penaltyToIncomeAccountMappings,
final Collection<InterestRateChartData> interestRateCharts, final InterestRateChartData chartTemplate, final Collection<InterestRateChartData> interestRateCharts, final InterestRateChartData chartTemplate,
final boolean interestFreePeriodApplicable, final Integer interestFreeFromPeriod, final Integer interestFreeToPeriod, final boolean preClosurePenalApplicable, final BigDecimal preClosurePenalInterest,
final EnumOptionData interestFreePeriodFrequencyType, final boolean preClosurePenalApplicable, final EnumOptionData preClosurePenalInterestOnType, final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions,
final BigDecimal preClosurePenalInterest, final EnumOptionData preClosurePenalInterestOnType, final Integer minDepositTerm, final Integer maxDepositTerm, final EnumOptionData minDepositTermType,
final Collection<EnumOptionData> interestFreePeriodTypeOptions, final EnumOptionData maxDepositTermType, final Integer inMultiplesOfDepositTerm,
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions, final Integer minDepositTerm, final EnumOptionData inMultiplesOfDepositTermType, final BigDecimal minDepositAmount, final BigDecimal depositAmount,
final Integer maxDepositTerm, final EnumOptionData minDepositTermType, final EnumOptionData maxDepositTermType, final BigDecimal maxDepositAmount, final Collection<EnumOptionData> periodFrequencyTypeOptions) {
final Integer inMultiplesOfDepositTerm, final EnumOptionData inMultiplesOfDepositTermType,
final BigDecimal minDepositAmount, final BigDecimal depositAmount, final BigDecimal maxDepositAmount,
final Collection<EnumOptionData> depositTermTypeOptions, Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions) {
super(id, name, shortName, description, currency, nominalAnnualInterestRate, interestCompoundingPeriodType, super(id, name, shortName, description, currency, nominalAnnualInterestRate, interestCompoundingPeriodType,
interestPostingPeriodType, interestCalculationType, interestCalculationDaysInYearType, lockinPeriodFrequency, interestPostingPeriodType, interestCalculationType, interestCalculationDaysInYearType, lockinPeriodFrequency,
@@ -383,10 +348,6 @@ public class FixedDepositProductData extends DepositProductData {
penaltyToIncomeAccountMappings, interestRateCharts, chartTemplate); penaltyToIncomeAccountMappings, interestRateCharts, chartTemplate);
// fixed deposit additional fields // fixed deposit additional fields
this.interestFreePeriodApplicable = interestFreePeriodApplicable;
this.interestFreeFromPeriod = interestFreeFromPeriod;
this.interestFreeToPeriod = interestFreeToPeriod;
this.interestFreePeriodFrequencyType = interestFreePeriodFrequencyType;
this.preClosurePenalApplicable = preClosurePenalApplicable; this.preClosurePenalApplicable = preClosurePenalApplicable;
this.preClosurePenalInterest = preClosurePenalInterest; this.preClosurePenalInterest = preClosurePenalInterest;
this.preClosurePenalInterestOnType = preClosurePenalInterestOnType; this.preClosurePenalInterestOnType = preClosurePenalInterestOnType;
@@ -401,10 +362,8 @@ public class FixedDepositProductData extends DepositProductData {
this.maxDepositAmount = maxDepositAmount; this.maxDepositAmount = maxDepositAmount;
// template // template
this.interestFreePeriodTypeOptions = interestFreePeriodTypeOptions;
this.preClosurePenalInterestOnTypeOptions = preClosurePenalInterestOnTypeOptions; this.preClosurePenalInterestOnTypeOptions = preClosurePenalInterestOnTypeOptions;
this.depositTermTypeOptions = depositTermTypeOptions; this.periodFrequencyTypeOptions = periodFrequencyTypeOptions;
this.inMultiplesOfDepositTermTypeOptions = inMultiplesOfDepositTermTypeOptions;
} }
} }
@@ -25,73 +25,65 @@ import org.mifosplatform.portfolio.savings.service.SavingsEnumerations;
public class RecurringDepositAccountData extends DepositAccountData { public class RecurringDepositAccountData extends DepositAccountData {
// additional fields // additional fields
private boolean interestFreePeriodApplicable; private final boolean preClosurePenalApplicable;
private Integer interestFreeFromPeriod; private final BigDecimal preClosurePenalInterest;
private Integer interestFreeToPeriod; private final EnumOptionData preClosurePenalInterestOnType;
private EnumOptionData interestFreePeriodFrequencyType; private final Integer minDepositTerm;
private boolean preClosurePenalApplicable; private final Integer maxDepositTerm;
private BigDecimal preClosurePenalInterest; private final EnumOptionData minDepositTermType;
private EnumOptionData preClosurePenalInterestOnType; private final EnumOptionData maxDepositTermType;
private Integer minDepositTerm; private final Integer inMultiplesOfDepositTerm;
private Integer maxDepositTerm; private final EnumOptionData inMultiplesOfDepositTermType;
private EnumOptionData minDepositTermType; private final BigDecimal depositAmount;
private EnumOptionData maxDepositTermType; private final BigDecimal maturityAmount;
private Integer inMultiplesOfDepositTerm; private final LocalDate maturityDate;
private EnumOptionData inMultiplesOfDepositTermType; private final Integer depositPeriod;
private BigDecimal depositAmount; private final EnumOptionData depositPeriodFrequency;
private BigDecimal maturityAmount; private final BigDecimal mandatoryRecommendedDepositAmount;
private LocalDate maturityDate; private final BigDecimal totalOverdueAmount;
private Integer depositPeriod; private final Integer noOfOverdueInstallments;
private EnumOptionData depositPeriodFrequency; private final boolean isMandatoryDeposit;
private BigDecimal recurringDepositAmount; private final boolean allowWithdrawal;
private EnumOptionData recurringDepositType; private final boolean adjustAdvanceTowardsFuturePayments;
private Integer recurringDepositFrequency; private final LocalDate expectedFirstDepositOnDate;
private EnumOptionData recurringDepositFrequencyType; private final boolean isCalendarInherited;
private LocalDate expectedFirstDepositOnDate; private final Integer recurringFrequency;
private final EnumOptionData recurringFrequencyType;
// used for account close // used for account close
private EnumOptionData onAccountClosure; private final EnumOptionData onAccountClosure;
private Collection<EnumOptionData> interestFreePeriodTypeOptions; private final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions;
private Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions; private final Collection<EnumOptionData> periodFrequencyTypeOptions;
private Collection<EnumOptionData> recurringDepositTypeOptions; private final Collection<SavingsAccountData> savingsAccounts;
private Collection<EnumOptionData> recurringDepositFrequencyTypeOptions;
private Collection<EnumOptionData> depositTermTypeOptions;
private Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions;
private Collection<EnumOptionData> depositPeriodFrequencyOptions;
private Collection<SavingsAccountData> savingsAccounts;
// for account close // for account close
private Collection<EnumOptionData> onAccountClosureOptions; private final Collection<EnumOptionData> onAccountClosureOptions;
private Collection<CodeValueData> paymentTypeOptions; private final Collection<CodeValueData> paymentTypeOptions;
public static RecurringDepositAccountData instance(final DepositAccountData depositAccountData, public static RecurringDepositAccountData instance(final DepositAccountData depositAccountData,
final boolean interestFreePeriodApplicable, final Integer interestFreeFromPeriod, final Integer interestFreeToPeriod, final boolean preClosurePenalApplicable, final BigDecimal preClosurePenalInterest,
final EnumOptionData interestFreePeriodFrequencyType, final boolean preClosurePenalApplicable, final EnumOptionData preClosurePenalInterestOnType, final Integer minDepositTerm, final Integer maxDepositTerm,
final BigDecimal preClosurePenalInterest, final EnumOptionData preClosurePenalInterestOnType, final Integer minDepositTerm, final EnumOptionData minDepositTermType, final EnumOptionData maxDepositTermType, final Integer inMultiplesOfDepositTerm,
final Integer maxDepositTerm, final EnumOptionData minDepositTermType, final EnumOptionData maxDepositTermType, final EnumOptionData inMultiplesOfDepositTermType, final BigDecimal depositAmount, final BigDecimal maturityAmount,
final Integer inMultiplesOfDepositTerm, final EnumOptionData inMultiplesOfDepositTermType, final BigDecimal depositAmount, final LocalDate maturityDate, final Integer depositPeriod, final EnumOptionData depositPeriodFrequency,
final BigDecimal maturityAmount, final LocalDate maturityDate, final Integer depositPeriod, final BigDecimal mandatoryRecommendedDepositAmount, final EnumOptionData onAccountClosure,
final EnumOptionData depositPeriodFrequency, final BigDecimal recurringDepositAmount, final LocalDate expectedFirstDepositOnDate, final BigDecimal totalOverdueAmount, final Integer noOfOverdueInstallments,
final EnumOptionData recurringDepositType, final Integer recurringDepositFrequency, final boolean isMandatoryDeposit, final boolean allowWithdrawal, final boolean adjustAdvanceTowardsFuturePayments, final boolean isCalendarInherited) {
final EnumOptionData recurringDepositFrequencyType, final EnumOptionData onAccountClosure,
final LocalDate expectedFirstDepositOnDate) {
final Collection<EnumOptionData> interestFreePeriodTypeOptions = null;
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions = null; final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions = null;
final Collection<EnumOptionData> depositTermTypeOptions = null; final Collection<EnumOptionData> periodFrequencyTypeOptions = null;
final Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions = null;
final Collection<EnumOptionData> recurringDepositTypeOptions = null;
final Collection<EnumOptionData> recurringDepositFrequencyTypeOptions = null;
final Collection<EnumOptionData> depositPeriodFrequencyOptions = null;
final EnumOptionData depositType = SavingsEnumerations.depositType(DepositAccountType.FIXED_DEPOSIT.getValue()); final EnumOptionData depositType = SavingsEnumerations.depositType(DepositAccountType.FIXED_DEPOSIT.getValue());
final Collection<EnumOptionData> onAccountClosureOptions = null; final Collection<EnumOptionData> onAccountClosureOptions = null;
final Collection<CodeValueData> paymentTypeOptions = null; final Collection<CodeValueData> paymentTypeOptions = null;
final Collection<SavingsAccountData> savingsAccountDatas = null; final Collection<SavingsAccountData> savingsAccountDatas = null;
final Integer recurringFrequency = null;
final EnumOptionData recurringFrequencyType = null;
return new RecurringDepositAccountData(depositAccountData.id, depositAccountData.accountNo, depositAccountData.externalId, return new RecurringDepositAccountData(depositAccountData.id, depositAccountData.accountNo, depositAccountData.externalId,
depositAccountData.groupId, depositAccountData.groupName, depositAccountData.clientId, depositAccountData.clientName, 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.fieldOfficerName, depositAccountData.status, depositAccountData.timeline, depositAccountData.currency,
depositAccountData.nominalAnnualInterestRate, depositAccountData.interestCompoundingPeriodType, depositAccountData.nominalAnnualInterestRate, depositAccountData.interestCompoundingPeriodType,
depositAccountData.interestPostingPeriodType, depositAccountData.interestCalculationType, depositAccountData.interestPostingPeriodType, depositAccountData.interestCalculationType,
@@ -103,20 +95,18 @@ public class RecurringDepositAccountData extends DepositAccountData {
depositAccountData.interestCalculationTypeOptions, depositAccountData.interestCalculationDaysInYearTypeOptions, depositAccountData.interestCalculationTypeOptions, depositAccountData.interestCalculationDaysInYearTypeOptions,
depositAccountData.lockinPeriodFrequencyTypeOptions, depositAccountData.withdrawalFeeTypeOptions, depositAccountData.lockinPeriodFrequencyTypeOptions, depositAccountData.withdrawalFeeTypeOptions,
depositAccountData.charges, depositAccountData.chargeOptions, depositAccountData.accountChart, depositAccountData.charges, depositAccountData.chargeOptions, depositAccountData.accountChart,
depositAccountData.chartTemplate, interestFreePeriodApplicable, interestFreeFromPeriod, interestFreeToPeriod, depositAccountData.chartTemplate, preClosurePenalApplicable, preClosurePenalInterest, preClosurePenalInterestOnType,
interestFreePeriodFrequencyType, preClosurePenalApplicable, preClosurePenalInterest, preClosurePenalInterestOnType, preClosurePenalInterestOnTypeOptions, minDepositTerm, maxDepositTerm, minDepositTermType, maxDepositTermType,
interestFreePeriodTypeOptions, preClosurePenalInterestOnTypeOptions, minDepositTerm, maxDepositTerm, minDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType, depositAmount, maturityAmount, maturityDate, depositPeriod,
maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType, depositAmount, maturityAmount, maturityDate, depositPeriodFrequency, mandatoryRecommendedDepositAmount, periodFrequencyTypeOptions, depositType, onAccountClosure,
depositPeriod, depositPeriodFrequency, recurringDepositAmount, depositTermTypeOptions, inMultiplesOfDepositTermTypeOptions, onAccountClosureOptions, paymentTypeOptions, savingsAccountDatas, expectedFirstDepositOnDate, totalOverdueAmount,
recurringDepositType, recurringDepositFrequency, recurringDepositFrequencyType, recurringDepositTypeOptions, noOfOverdueInstallments, isMandatoryDeposit, allowWithdrawal, adjustAdvanceTowardsFuturePayments, isCalendarInherited, recurringFrequency, recurringFrequencyType);
recurringDepositFrequencyTypeOptions, depositPeriodFrequencyOptions, depositType, onAccountClosure,
onAccountClosureOptions, paymentTypeOptions, savingsAccountDatas, expectedFirstDepositOnDate);
} }
public static RecurringDepositAccountData withInterestChart(final RecurringDepositAccountData account, public static RecurringDepositAccountData withInterestChartAndRecurringDetails(final RecurringDepositAccountData account,
final DepositAccountInterestRateChartData accountChart) { final DepositAccountInterestRateChartData accountChart, final Integer recurringFrequency, final EnumOptionData recurringFrequencyType) {
return new RecurringDepositAccountData(account.id, account.accountNo, account.externalId, account.groupId, account.groupName, 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.fieldOfficerName, account.status, account.timeline, account.currency, account.nominalAnnualInterestRate,
account.interestCompoundingPeriodType, account.interestPostingPeriodType, account.interestCalculationType, account.interestCompoundingPeriodType, account.interestPostingPeriodType, account.interestCalculationType,
account.interestCalculationDaysInYearType, account.minRequiredOpeningBalance, account.lockinPeriodFrequency, account.interestCalculationDaysInYearType, account.minRequiredOpeningBalance, account.lockinPeriodFrequency,
@@ -125,17 +115,15 @@ public class RecurringDepositAccountData extends DepositAccountData {
account.interestPostingPeriodTypeOptions, account.interestCalculationTypeOptions, account.interestPostingPeriodTypeOptions, account.interestCalculationTypeOptions,
account.interestCalculationDaysInYearTypeOptions, account.lockinPeriodFrequencyTypeOptions, account.interestCalculationDaysInYearTypeOptions, account.lockinPeriodFrequencyTypeOptions,
account.withdrawalFeeTypeOptions, account.charges, account.chargeOptions, accountChart, account.chartTemplate, account.withdrawalFeeTypeOptions, account.charges, account.chargeOptions, accountChart, account.chartTemplate,
account.interestFreePeriodApplicable, account.interestFreeFromPeriod, account.interestFreeToPeriod, account.preClosurePenalApplicable, account.preClosurePenalInterest, account.preClosurePenalInterestOnType,
account.interestFreePeriodFrequencyType, account.preClosurePenalApplicable, account.preClosurePenalInterest, account.preClosurePenalInterestOnTypeOptions, account.minDepositTerm, account.maxDepositTerm, account.minDepositTermType,
account.preClosurePenalInterestOnType, account.interestFreePeriodTypeOptions, account.preClosurePenalInterestOnTypeOptions, account.maxDepositTermType, account.inMultiplesOfDepositTerm, account.inMultiplesOfDepositTermType, account.depositAmount,
account.minDepositTerm, account.maxDepositTerm, account.minDepositTermType, account.maxDepositTermType, account.maturityAmount, account.maturityDate, account.depositPeriod, account.depositPeriodFrequency,
account.inMultiplesOfDepositTerm, account.inMultiplesOfDepositTermType, account.depositAmount, account.maturityAmount, account.mandatoryRecommendedDepositAmount, account.periodFrequencyTypeOptions, account.depositType,
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.onAccountClosure, account.onAccountClosureOptions, account.paymentTypeOptions, account.savingsAccounts, 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, public static RecurringDepositAccountData withTemplateOptions(final RecurringDepositAccountData account,
@@ -153,24 +141,17 @@ public class RecurringDepositAccountData extends DepositAccountData {
final Collection<EnumOptionData> withdrawalFeeTypeOptions = null; final Collection<EnumOptionData> withdrawalFeeTypeOptions = null;
final Collection<ChargeData> chargeOptions = null; final Collection<ChargeData> chargeOptions = null;
final Collection<EnumOptionData> interestFreePeriodTypeOptions = null;
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions = null; final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions = null;
final Collection<EnumOptionData> depositTermTypeOptions = null; final Collection<EnumOptionData> periodFrequencyTypeOptions = null;
final Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions = null;
final Collection<EnumOptionData> recurringDepositTypeOptions = null;
final Collection<EnumOptionData> recurringDepositFrequencyTypeOptions = null;
final Collection<EnumOptionData> depositPeriodFrequencyOptions = null;
return withTemplateOptions(account, productOptions, fieldOfficerOptions, interestCompoundingPeriodTypeOptions, return withTemplateOptions(account, productOptions, fieldOfficerOptions, interestCompoundingPeriodTypeOptions,
interestPostingPeriodTypeOptions, interestCalculationTypeOptions, interestCalculationDaysInYearTypeOptions, interestPostingPeriodTypeOptions, interestCalculationTypeOptions, interestCalculationDaysInYearTypeOptions,
lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, transactions, charges, chargeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, transactions, charges, chargeOptions,
interestFreePeriodTypeOptions, preClosurePenalInterestOnTypeOptions, depositTermTypeOptions, preClosurePenalInterestOnTypeOptions, periodFrequencyTypeOptions);
inMultiplesOfDepositTermTypeOptions, recurringDepositTypeOptions, recurringDepositFrequencyTypeOptions,
depositPeriodFrequencyOptions);
} }
return new RecurringDepositAccountData(account.id, account.accountNo, account.externalId, account.groupId, account.groupName, 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.fieldOfficerName, account.status, account.timeline, account.currency, account.nominalAnnualInterestRate,
account.interestCompoundingPeriodType, account.interestPostingPeriodType, account.interestCalculationType, account.interestCompoundingPeriodType, account.interestPostingPeriodType, account.interestCalculationType,
account.interestCalculationDaysInYearType, account.minRequiredOpeningBalance, account.lockinPeriodFrequency, account.interestCalculationDaysInYearType, account.minRequiredOpeningBalance, account.lockinPeriodFrequency,
@@ -179,17 +160,15 @@ public class RecurringDepositAccountData extends DepositAccountData {
template.interestPostingPeriodTypeOptions, template.interestCalculationTypeOptions, template.interestPostingPeriodTypeOptions, template.interestCalculationTypeOptions,
template.interestCalculationDaysInYearTypeOptions, template.lockinPeriodFrequencyTypeOptions, template.interestCalculationDaysInYearTypeOptions, template.lockinPeriodFrequencyTypeOptions,
template.withdrawalFeeTypeOptions, charges, template.chargeOptions, account.accountChart, account.chartTemplate, template.withdrawalFeeTypeOptions, charges, template.chargeOptions, account.accountChart, account.chartTemplate,
account.interestFreePeriodApplicable, account.interestFreeFromPeriod, account.interestFreeToPeriod, account.preClosurePenalApplicable, account.preClosurePenalInterest, account.preClosurePenalInterestOnType,
account.interestFreePeriodFrequencyType, account.preClosurePenalApplicable, account.preClosurePenalInterest,
account.preClosurePenalInterestOnType, template.interestFreePeriodTypeOptions,
template.preClosurePenalInterestOnTypeOptions, account.minDepositTerm, account.maxDepositTerm, account.minDepositTermType, template.preClosurePenalInterestOnTypeOptions, account.minDepositTerm, account.maxDepositTerm, account.minDepositTermType,
account.maxDepositTermType, account.inMultiplesOfDepositTerm, account.inMultiplesOfDepositTermType, account.depositAmount, account.maxDepositTermType, account.inMultiplesOfDepositTerm, account.inMultiplesOfDepositTermType, account.depositAmount,
account.maturityAmount, account.maturityDate, account.depositPeriod, account.depositPeriodFrequency, account.maturityAmount, account.maturityDate, account.depositPeriod, account.depositPeriodFrequency,
account.recurringDepositAmount, template.depositTermTypeOptions, template.inMultiplesOfDepositTermTypeOptions, account.mandatoryRecommendedDepositAmount, template.periodFrequencyTypeOptions, account.depositType,
account.recurringDepositType, account.recurringDepositFrequency, account.recurringDepositFrequencyType, account.onAccountClosure, account.onAccountClosureOptions, account.paymentTypeOptions, account.savingsAccounts,
template.recurringDepositTypeOptions, template.recurringDepositFrequencyTypeOptions, account.expectedFirstDepositOnDate, account.totalOverdueAmount, account.noOfOverdueInstallments,
template.depositPeriodFrequencyOptions, account.depositType, account.onAccountClosure, account.onAccountClosureOptions, account.isMandatoryDeposit, account.allowWithdrawal, account.adjustAdvanceTowardsFuturePayments,
account.paymentTypeOptions, account.savingsAccounts, account.expectedFirstDepositOnDate); account.isCalendarInherited, account.recurringFrequency, account.recurringFrequencyType);
} }
@@ -201,15 +180,11 @@ public class RecurringDepositAccountData extends DepositAccountData {
final Collection<EnumOptionData> interestCalculationDaysInYearTypeOptions, final Collection<EnumOptionData> interestCalculationDaysInYearTypeOptions,
final Collection<EnumOptionData> lockinPeriodFrequencyTypeOptions, final Collection<EnumOptionData> withdrawalFeeTypeOptions, final Collection<EnumOptionData> lockinPeriodFrequencyTypeOptions, final Collection<EnumOptionData> withdrawalFeeTypeOptions,
final Collection<SavingsAccountTransactionData> transactions, final Collection<SavingsAccountChargeData> charges, final Collection<SavingsAccountTransactionData> transactions, final Collection<SavingsAccountChargeData> charges,
final Collection<ChargeData> chargeOptions, final Collection<EnumOptionData> interestFreePeriodTypeOptions, final Collection<ChargeData> chargeOptions, final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions,
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions, final Collection<EnumOptionData> depositTermTypeOptions, final Collection<EnumOptionData> periodFrequencyTypeOptions) {
final Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions,
final Collection<EnumOptionData> recurringDepositTypeOptions,
final Collection<EnumOptionData> recurringDepositFrequencyTypeOptions,
final Collection<EnumOptionData> depositPeriodFrequencyOptions) {
return new RecurringDepositAccountData(account.id, account.accountNo, account.externalId, account.groupId, account.groupName, 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.fieldOfficerName, account.status, account.timeline, account.currency, account.nominalAnnualInterestRate,
account.interestCompoundingPeriodType, account.interestPostingPeriodType, account.interestCalculationType, account.interestCompoundingPeriodType, account.interestPostingPeriodType, account.interestCalculationType,
account.interestCalculationDaysInYearType, account.minRequiredOpeningBalance, account.lockinPeriodFrequency, account.interestCalculationDaysInYearType, account.minRequiredOpeningBalance, account.lockinPeriodFrequency,
@@ -217,16 +192,15 @@ public class RecurringDepositAccountData extends DepositAccountData {
fieldOfficerOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions, fieldOfficerOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions,
interestCalculationTypeOptions, interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, interestCalculationTypeOptions, interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions,
withdrawalFeeTypeOptions, charges, chargeOptions, account.accountChart, account.chartTemplate, withdrawalFeeTypeOptions, charges, chargeOptions, account.accountChart, account.chartTemplate,
account.interestFreePeriodApplicable, account.interestFreeFromPeriod, account.interestFreeToPeriod, account.preClosurePenalApplicable, account.preClosurePenalInterest, account.preClosurePenalInterestOnType,
account.interestFreePeriodFrequencyType, account.preClosurePenalApplicable, account.preClosurePenalInterest, preClosurePenalInterestOnTypeOptions, account.minDepositTerm, account.maxDepositTerm, account.minDepositTermType,
account.preClosurePenalInterestOnType, interestFreePeriodTypeOptions, preClosurePenalInterestOnTypeOptions, account.maxDepositTermType, account.inMultiplesOfDepositTerm, account.inMultiplesOfDepositTermType, account.depositAmount,
account.minDepositTerm, account.maxDepositTerm, account.minDepositTermType, account.maxDepositTermType, account.maturityAmount, account.maturityDate, account.depositPeriod, account.depositPeriodFrequency,
account.inMultiplesOfDepositTerm, account.inMultiplesOfDepositTermType, account.depositAmount, account.maturityAmount, account.mandatoryRecommendedDepositAmount, periodFrequencyTypeOptions, account.depositType, account.onAccountClosure,
account.maturityDate, account.depositPeriod, account.depositPeriodFrequency, account.recurringDepositAmount, account.onAccountClosureOptions, account.paymentTypeOptions, account.savingsAccounts, account.expectedFirstDepositOnDate,
depositTermTypeOptions, inMultiplesOfDepositTermTypeOptions, account.recurringDepositType, account.totalOverdueAmount, account.noOfOverdueInstallments, account.isMandatoryDeposit, account.allowWithdrawal,
account.recurringDepositFrequency, account.recurringDepositFrequencyType, recurringDepositTypeOptions, account.adjustAdvanceTowardsFuturePayments, account.isCalendarInherited, account.recurringFrequency,
recurringDepositFrequencyTypeOptions, depositPeriodFrequencyOptions, account.depositType, account.onAccountClosure, account.recurringFrequencyType);
account.onAccountClosureOptions, account.paymentTypeOptions, account.savingsAccounts, account.expectedFirstDepositOnDate);
} }
public static RecurringDepositAccountData withClientTemplate(final Long clientId, final String clientName, final Long groupId, 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 accountChart = null;
final DepositAccountInterestRateChartData chartTemplate = 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 boolean preClosurePenalApplicable = false;
final BigDecimal preClosurePenalInterest = null; final BigDecimal preClosurePenalInterest = null;
final EnumOptionData preClosurePenalInterestOnType = null; final EnumOptionData preClosurePenalInterestOnType = null;
@@ -286,45 +256,46 @@ public class RecurringDepositAccountData extends DepositAccountData {
final LocalDate maturityDate = null; final LocalDate maturityDate = null;
final Integer depositPeriod = null; final Integer depositPeriod = null;
final EnumOptionData depositPeriodFrequency = null; final EnumOptionData depositPeriodFrequency = null;
final BigDecimal recurringDepositAmount = null; final BigDecimal mandatoryRecommendedDepositAmount = null;
final EnumOptionData onAccountClosure = null; final EnumOptionData onAccountClosure = null;
final Collection<EnumOptionData> interestFreePeriodTypeOptions = null;
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions = null; final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions = null;
final Collection<EnumOptionData> depositTermTypeOptions = null; final Collection<EnumOptionData> periodFrequencyTypeOptions = 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 EnumOptionData depositType = SavingsEnumerations.depositType(DepositAccountType.RECURRING_DEPOSIT.getValue()); final EnumOptionData depositType = SavingsEnumerations.depositType(DepositAccountType.RECURRING_DEPOSIT.getValue());
final Collection<EnumOptionData> onAccountClosureOptions = null; final Collection<EnumOptionData> onAccountClosureOptions = null;
final Collection<CodeValueData> paymentTypeOptions = null; final Collection<CodeValueData> paymentTypeOptions = null;
final Collection<SavingsAccountData> savingsAccountDatas = null; final Collection<SavingsAccountData> savingsAccountDatas = null;
final LocalDate expectedFirstDepositOnDate = 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, return new RecurringDepositAccountData(id, accountNo, externalId, groupId, groupName, clientId, clientName, productId, productName,
fieldOfficerId, fieldOfficerName, status, timeline, currency, nominalAnnualInterestRate, interestPeriodType, fieldOfficerId, fieldOfficerName, status, timeline, currency, nominalAnnualInterestRate, interestPeriodType,
interestPostingPeriodType, interestCalculationType, interestCalculationDaysInYearType, minRequiredOpeningBalance, interestPostingPeriodType, interestCalculationType, interestCalculationDaysInYearType, minRequiredOpeningBalance,
lockinPeriodFrequency, lockinPeriodFrequencyType, withdrawalFeeForTransfers, summary, transactions, productOptions, lockinPeriodFrequency, lockinPeriodFrequencyType, withdrawalFeeForTransfers, summary, transactions, productOptions,
fieldOfficerOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions, fieldOfficerOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions,
interestCalculationTypeOptions, interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, interestCalculationTypeOptions, interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions,
withdrawalFeeTypeOptions, charges, chargeOptions, accountChart, chartTemplate, interestFreePeriodApplicable, withdrawalFeeTypeOptions, charges, chargeOptions, accountChart, chartTemplate, preClosurePenalApplicable,
interestFreeFromPeriod, interestFreeToPeriod, interestFreePeriodFrequencyType, preClosurePenalApplicable, preClosurePenalInterest, preClosurePenalInterestOnType, preClosurePenalInterestOnTypeOptions, minDepositTerm,
preClosurePenalInterest, preClosurePenalInterestOnType, interestFreePeriodTypeOptions, maxDepositTerm, minDepositTermType, maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType,
preClosurePenalInterestOnTypeOptions, minDepositTerm, maxDepositTerm, minDepositTermType, maxDepositTermType, depositAmount, maturityAmount, maturityDate, depositPeriod, depositPeriodFrequency, mandatoryRecommendedDepositAmount,
inMultiplesOfDepositTerm, inMultiplesOfDepositTermType, depositAmount, maturityAmount, maturityDate, depositPeriod, periodFrequencyTypeOptions, depositType, onAccountClosure, onAccountClosureOptions, paymentTypeOptions,
depositPeriodFrequency, recurringDepositAmount, depositTermTypeOptions, inMultiplesOfDepositTermTypeOptions, savingsAccountDatas, expectedFirstDepositOnDate, totalOverdueAmount, noOfOverdueInstallments, isMandatoryDeposit,
recurringDepositType, recurringDepositFrequency, recurringDepositFrequencyType, recurringDepositTypeOptions, allowWithdrawal, adjustAdvanceTowardsFuturePayments, isCalendarInherited, recurringFrequency, recurringFrequencyType);
recurringDepositFrequencyTypeOptions, depositPeriodFrequencyOptions, depositType, onAccountClosure,
onAccountClosureOptions, paymentTypeOptions, savingsAccountDatas, expectedFirstDepositOnDate);
} }
public static RecurringDepositAccountData preClosureDetails(final Long accountId, BigDecimal maturityAmount, public static RecurringDepositAccountData preClosureDetails(final Long accountId, final BigDecimal maturityAmount,
final Collection<EnumOptionData> onAccountClosureOptions, final Collection<CodeValueData> paymentTypeOptions, final Collection<SavingsAccountData> savingsAccountDatas) { final Collection<EnumOptionData> onAccountClosureOptions, final Collection<CodeValueData> paymentTypeOptions,
final Collection<SavingsAccountData> savingsAccountDatas) {
final String accountNo = null; final String accountNo = null;
final String externalId = null; final String externalId = null;
@@ -361,10 +332,6 @@ public class RecurringDepositAccountData extends DepositAccountData {
final DepositAccountInterestRateChartData accountChart = null; final DepositAccountInterestRateChartData accountChart = null;
final DepositAccountInterestRateChartData chartTemplate = 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 boolean preClosurePenalApplicable = false;
final BigDecimal preClosurePenalInterest = null; final BigDecimal preClosurePenalInterest = null;
final EnumOptionData preClosurePenalInterestOnType = null; final EnumOptionData preClosurePenalInterestOnType = null;
@@ -378,20 +345,10 @@ public class RecurringDepositAccountData extends DepositAccountData {
final LocalDate maturityDate = null; final LocalDate maturityDate = null;
final Integer depositPeriod = null; final Integer depositPeriod = null;
final EnumOptionData depositPeriodFrequency = null; final EnumOptionData depositPeriodFrequency = null;
final BigDecimal recurringDepositAmount = null; final BigDecimal mandatoryRecommendedDepositAmount = null;
final EnumOptionData onAccountClosure = null; final EnumOptionData onAccountClosure = null;
final Collection<EnumOptionData> interestFreePeriodTypeOptions = null;
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions = null; final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions = null;
final Collection<EnumOptionData> depositTermTypeOptions = null; final Collection<EnumOptionData> periodFrequencyTypeOptions = 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 EnumOptionData depositType = SavingsEnumerations.depositType(DepositAccountType.RECURRING_DEPOSIT.getValue()); final EnumOptionData depositType = SavingsEnumerations.depositType(DepositAccountType.RECURRING_DEPOSIT.getValue());
final Long groupId = null; final Long groupId = null;
@@ -400,28 +357,36 @@ public class RecurringDepositAccountData extends DepositAccountData {
final String clientName = null; final String clientName = null;
final LocalDate expectedFirstDepositOnDate = 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, return new RecurringDepositAccountData(accountId, accountNo, externalId, groupId, groupName, clientId, clientName, productId,
productName, fieldOfficerId, fieldOfficerName, status, timeline, currency, nominalAnnualInterestRate, interestPeriodType, productName, fieldOfficerId, fieldOfficerName, status, timeline, currency, nominalAnnualInterestRate, interestPeriodType,
interestPostingPeriodType, interestCalculationType, interestCalculationDaysInYearType, minRequiredOpeningBalance, interestPostingPeriodType, interestCalculationType, interestCalculationDaysInYearType, minRequiredOpeningBalance,
lockinPeriodFrequency, lockinPeriodFrequencyType, withdrawalFeeForTransfers, summary, transactions, productOptions, lockinPeriodFrequency, lockinPeriodFrequencyType, withdrawalFeeForTransfers, summary, transactions, productOptions,
fieldOfficerOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions, fieldOfficerOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions,
interestCalculationTypeOptions, interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, interestCalculationTypeOptions, interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions,
withdrawalFeeTypeOptions, charges, chargeOptions, accountChart, chartTemplate, interestFreePeriodApplicable, withdrawalFeeTypeOptions, charges, chargeOptions, accountChart, chartTemplate, preClosurePenalApplicable,
interestFreeFromPeriod, interestFreeToPeriod, interestFreePeriodFrequencyType, preClosurePenalApplicable, preClosurePenalInterest, preClosurePenalInterestOnType, preClosurePenalInterestOnTypeOptions, minDepositTerm,
preClosurePenalInterest, preClosurePenalInterestOnType, interestFreePeriodTypeOptions, maxDepositTerm, minDepositTermType, maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType,
preClosurePenalInterestOnTypeOptions, minDepositTerm, maxDepositTerm, minDepositTermType, maxDepositTermType, depositAmount, maturityAmount, maturityDate, depositPeriod, depositPeriodFrequency, mandatoryRecommendedDepositAmount,
inMultiplesOfDepositTerm, inMultiplesOfDepositTermType, depositAmount, maturityAmount, maturityDate, depositPeriod, periodFrequencyTypeOptions, depositType, onAccountClosure, onAccountClosureOptions, paymentTypeOptions,
depositPeriodFrequency, recurringDepositAmount, depositTermTypeOptions, inMultiplesOfDepositTermTypeOptions, savingsAccountDatas, expectedFirstDepositOnDate, totalOverdueAmount, noOfOverdueInstallments, isMandatoryDeposit,
recurringDepositType, recurringDepositFrequency, recurringDepositFrequencyType, recurringDepositTypeOptions, allowWithdrawal, adjustAdvanceTowardsFuturePayments, isCalendarInherited, recurringFrequency, recurringFrequencyType);
recurringDepositFrequencyTypeOptions, depositPeriodFrequencyOptions, depositType, onAccountClosure,
onAccountClosureOptions, paymentTypeOptions, savingsAccountDatas, expectedFirstDepositOnDate);
} }
public static RecurringDepositAccountData withClosureTemplateDetails(final RecurringDepositAccountData account, 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, 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.fieldOfficerName, account.status, account.timeline, account.currency, account.nominalAnnualInterestRate,
account.interestCompoundingPeriodType, account.interestPostingPeriodType, account.interestCalculationType, account.interestCompoundingPeriodType, account.interestPostingPeriodType, account.interestCalculationType,
account.interestCalculationDaysInYearType, account.minRequiredOpeningBalance, account.lockinPeriodFrequency, account.interestCalculationDaysInYearType, account.minRequiredOpeningBalance, account.lockinPeriodFrequency,
@@ -430,17 +395,15 @@ public class RecurringDepositAccountData extends DepositAccountData {
account.interestPostingPeriodTypeOptions, account.interestCalculationTypeOptions, account.interestPostingPeriodTypeOptions, account.interestCalculationTypeOptions,
account.interestCalculationDaysInYearTypeOptions, account.lockinPeriodFrequencyTypeOptions, account.interestCalculationDaysInYearTypeOptions, account.lockinPeriodFrequencyTypeOptions,
account.withdrawalFeeTypeOptions, account.charges, account.chargeOptions, account.accountChart, account.chartTemplate, account.withdrawalFeeTypeOptions, account.charges, account.chargeOptions, account.accountChart, account.chartTemplate,
account.interestFreePeriodApplicable, account.interestFreeFromPeriod, account.interestFreeToPeriod, account.preClosurePenalApplicable, account.preClosurePenalInterest, account.preClosurePenalInterestOnType,
account.interestFreePeriodFrequencyType, account.preClosurePenalApplicable, account.preClosurePenalInterest, account.preClosurePenalInterestOnTypeOptions, account.minDepositTerm, account.maxDepositTerm, account.minDepositTermType,
account.preClosurePenalInterestOnType, account.interestFreePeriodTypeOptions, account.preClosurePenalInterestOnTypeOptions, account.maxDepositTermType, account.inMultiplesOfDepositTerm, account.inMultiplesOfDepositTermType, account.depositAmount,
account.minDepositTerm, account.maxDepositTerm, account.minDepositTermType, account.maxDepositTermType, account.maturityAmount, account.maturityDate, account.depositPeriod, account.depositPeriodFrequency,
account.inMultiplesOfDepositTerm, account.inMultiplesOfDepositTermType, account.depositAmount, account.maturityAmount, account.mandatoryRecommendedDepositAmount, account.periodFrequencyTypeOptions, account.depositType,
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.onAccountClosure, onAccountClosureOptions, paymentTypeOptions, savingsAccountDatas, 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, 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<EnumOptionData> lockinPeriodFrequencyTypeOptions, final Collection<EnumOptionData> withdrawalFeeTypeOptions,
final Collection<SavingsAccountChargeData> charges, final Collection<ChargeData> chargeOptions, final Collection<SavingsAccountChargeData> charges, final Collection<ChargeData> chargeOptions,
final DepositAccountInterestRateChartData accountChart, final DepositAccountInterestRateChartData chartTemplate, final DepositAccountInterestRateChartData accountChart, final DepositAccountInterestRateChartData chartTemplate,
final boolean interestFreePeriodApplicable, final Integer interestFreeFromPeriod, final Integer interestFreeToPeriod, final boolean preClosurePenalApplicable, final BigDecimal preClosurePenalInterest,
final EnumOptionData interestFreePeriodFrequencyType, final boolean preClosurePenalApplicable, final EnumOptionData preClosurePenalInterestOnType, final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions,
final BigDecimal preClosurePenalInterest, final EnumOptionData preClosurePenalInterestOnType, final Integer minDepositTerm, final Integer maxDepositTerm, final EnumOptionData minDepositTermType,
final Collection<EnumOptionData> interestFreePeriodTypeOptions, final EnumOptionData maxDepositTermType, final Integer inMultiplesOfDepositTerm,
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions, final Integer minDepositTerm, final EnumOptionData inMultiplesOfDepositTermType, final BigDecimal depositAmount, final BigDecimal maturityAmount,
final Integer maxDepositTerm, final EnumOptionData minDepositTermType, final EnumOptionData maxDepositTermType, final LocalDate maturityDate, final Integer depositPeriod, final EnumOptionData depositPeriodFrequency,
final Integer inMultiplesOfDepositTerm, final EnumOptionData inMultiplesOfDepositTermType, final BigDecimal depositAmount, final BigDecimal mandatoryRecommendedDepositAmount, final Collection<EnumOptionData> periodFrequencyTypeOptions,
final BigDecimal maturityAmount, final LocalDate maturityDate, final Integer depositPeriod, final EnumOptionData depositType, final EnumOptionData onAccountClosure,
final EnumOptionData depositPeriodFrequency, final BigDecimal recurringDepositAmount, final Collection<EnumOptionData> onAccountClosureOptions, final Collection<CodeValueData> paymentTypeOptions,
final Collection<EnumOptionData> depositTermTypeOptions, Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions, final Collection<SavingsAccountData> savingsAccountDatas, final LocalDate expectedFirstDepositOnDate,
final EnumOptionData recurringDepositType, final Integer recurringDepositFrequency, final BigDecimal totalOverdueAmount, final Integer noOfOverdueInstallments, final boolean isMandatoryDeposit,
final EnumOptionData recurringDepositFrequencyType, final Collection<EnumOptionData> recurringDepositTypeOptions, final boolean allowWithdrawal, final boolean adjustAdvanceTowardsFuturePayments, final boolean isCalendarInherited,
final Collection<EnumOptionData> recurringDepositFrequencyTypeOptions, final Integer recurringFrequency, final EnumOptionData recurringFrequencyType) {
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) {
super(id, accountNo, externalId, groupId, groupName, clientId, clientName, productId, productName, fieldofficerId, super(id, accountNo, externalId, groupId, groupName, clientId, clientName, productId, productName, fieldofficerId,
fieldofficerName, status, timeline, currency, nominalAnnualInterestRate, interestPeriodType, interestPostingPeriodType, fieldofficerName, status, timeline, currency, nominalAnnualInterestRate, interestPeriodType, interestPostingPeriodType,
@@ -486,10 +445,6 @@ public class RecurringDepositAccountData extends DepositAccountData {
interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, charges, interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, charges,
chargeOptions, accountChart, chartTemplate, depositType); chargeOptions, accountChart, chartTemplate, depositType);
this.interestFreePeriodApplicable = interestFreePeriodApplicable;
this.interestFreeFromPeriod = interestFreeFromPeriod;
this.interestFreeToPeriod = interestFreeToPeriod;
this.interestFreePeriodFrequencyType = interestFreePeriodFrequencyType;
this.preClosurePenalApplicable = preClosurePenalApplicable; this.preClosurePenalApplicable = preClosurePenalApplicable;
this.preClosurePenalInterest = preClosurePenalInterest; this.preClosurePenalInterest = preClosurePenalInterest;
this.preClosurePenalInterestOnType = preClosurePenalInterestOnType; this.preClosurePenalInterestOnType = preClosurePenalInterestOnType;
@@ -504,20 +459,20 @@ public class RecurringDepositAccountData extends DepositAccountData {
this.maturityDate = maturityDate; this.maturityDate = maturityDate;
this.depositPeriod = depositPeriod; this.depositPeriod = depositPeriod;
this.depositPeriodFrequency = depositPeriodFrequency; this.depositPeriodFrequency = depositPeriodFrequency;
this.recurringDepositAmount = recurringDepositAmount;
this.recurringDepositFrequencyType = recurringDepositFrequencyType;
this.recurringDepositFrequency = recurringDepositFrequency;
this.recurringDepositType = recurringDepositType;
this.expectedFirstDepositOnDate = expectedFirstDepositOnDate; 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.preClosurePenalInterestOnTypeOptions = preClosurePenalInterestOnTypeOptions;
this.recurringDepositTypeOptions = recurringDepositTypeOptions; this.periodFrequencyTypeOptions = periodFrequencyTypeOptions;
this.recurringDepositFrequencyTypeOptions = recurringDepositFrequencyTypeOptions;
this.depositTermTypeOptions = depositTermTypeOptions;
this.inMultiplesOfDepositTermTypeOptions = inMultiplesOfDepositTermTypeOptions;
this.depositPeriodFrequencyOptions = depositPeriodFrequencyOptions;
this.onAccountClosure = onAccountClosure; this.onAccountClosure = onAccountClosure;
this.savingsAccounts = savingsAccountDatas; this.savingsAccounts = savingsAccountDatas;
@@ -24,10 +24,6 @@ import org.mifosplatform.portfolio.interestratechart.data.InterestRateChartData;
*/ */
public class RecurringDepositProductData extends DepositProductData { public class RecurringDepositProductData extends DepositProductData {
private boolean interestFreePeriodApplicable;
private Integer interestFreeFromPeriod;
private Integer interestFreeToPeriod;
protected EnumOptionData interestFreePeriodFrequencyType;
private boolean preClosurePenalApplicable; private boolean preClosurePenalApplicable;
private BigDecimal preClosurePenalInterest; private BigDecimal preClosurePenalInterest;
private EnumOptionData preClosurePenalInterestOnType; private EnumOptionData preClosurePenalInterestOnType;
@@ -37,19 +33,15 @@ public class RecurringDepositProductData extends DepositProductData {
private EnumOptionData maxDepositTermType; private EnumOptionData maxDepositTermType;
private Integer inMultiplesOfDepositTerm; private Integer inMultiplesOfDepositTerm;
private EnumOptionData inMultiplesOfDepositTermType; private EnumOptionData inMultiplesOfDepositTermType;
private EnumOptionData recurringDepositType;
private Integer recurringDepositFrequency;
private EnumOptionData recurringDepositFrequencyType;
private BigDecimal minDepositAmount; private BigDecimal minDepositAmount;
private BigDecimal depositAmount; private BigDecimal depositAmount;
private BigDecimal maxDepositAmount; private BigDecimal maxDepositAmount;
private boolean isMandatoryDeposit;
private boolean allowWithdrawal;
private boolean adjustAdvanceTowardsFuturePayments;
private Collection<EnumOptionData> interestFreePeriodTypeOptions;
private Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions; private Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions;
private Collection<EnumOptionData> recurringDepositTypeOptions; private Collection<EnumOptionData> periodFrequencyTypeOptions;
private Collection<EnumOptionData> recurringDepositFrequencyTypeOptions;
private Collection<EnumOptionData> depositTermTypeOptions;
private Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions;
public static RecurringDepositProductData template(final CurrencyData currency, final EnumOptionData interestCompoundingPeriodType, public static RecurringDepositProductData template(final CurrencyData currency, final EnumOptionData interestCompoundingPeriodType,
final EnumOptionData interestPostingPeriodType, final EnumOptionData interestCalculationType, final EnumOptionData interestPostingPeriodType, final EnumOptionData interestCalculationType,
@@ -62,11 +54,8 @@ public class RecurringDepositProductData extends DepositProductData {
final Collection<CodeValueData> paymentTypeOptions, final Collection<EnumOptionData> accountingRuleOptions, final Collection<CodeValueData> paymentTypeOptions, final Collection<EnumOptionData> accountingRuleOptions,
final Map<String, List<GLAccountData>> accountingMappingOptions, final Collection<ChargeData> chargeOptions, final Map<String, List<GLAccountData>> accountingMappingOptions, final Collection<ChargeData> chargeOptions,
final Collection<ChargeData> penaltyOptions, final InterestRateChartData chartTemplate, final Collection<ChargeData> penaltyOptions, final InterestRateChartData chartTemplate,
final Collection<EnumOptionData> interestFreePeriodTypes,
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions, final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions,
final Collection<EnumOptionData> recurringDepositTypeOptions, final Collection<EnumOptionData> periodFrequencyTypeOptions) {
final Collection<EnumOptionData> recurringDepositFrequencyTypeOptions, final Collection<EnumOptionData> depositTermTypeOptions,
final Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions) {
final Long id = null; final Long id = null;
final String name = null; final String name = null;
@@ -83,16 +72,12 @@ public class RecurringDepositProductData extends DepositProductData {
final Collection<ChargeToGLAccountMapper> feeToIncomeAccountMappings = null; final Collection<ChargeToGLAccountMapper> feeToIncomeAccountMappings = null;
final Collection<ChargeToGLAccountMapper> penaltyToIncomeAccountMappings = null; final Collection<ChargeToGLAccountMapper> penaltyToIncomeAccountMappings = null;
final Collection<InterestRateChartData> interestRateCharts = 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 boolean preClosurePenalApplicable = false;
final BigDecimal preClosurePenalInterest = null; final BigDecimal preClosurePenalInterest = null;
final EnumOptionData preClosurePenalInterestOnType = null; final EnumOptionData preClosurePenalInterestOnType = null;
final EnumOptionData recurringDepositType = null; final boolean isMandatoryDeposit = false;
final Integer recurringDepositFrequency = null; final boolean allowWithdrawal = false;
final EnumOptionData recurringDepositFrequencyType = null; final boolean adjustAdvanceTowardsFuturePayments = false;
final Integer minDepositTerm = null; final Integer minDepositTerm = null;
final Integer maxDepositTerm = null; final Integer maxDepositTerm = null;
final EnumOptionData minDepositTermType = null; final EnumOptionData minDepositTermType = null;
@@ -102,20 +87,17 @@ public class RecurringDepositProductData extends DepositProductData {
final BigDecimal minDepositAmount = null; final BigDecimal minDepositAmount = null;
final BigDecimal depositAmount = null; final BigDecimal depositAmount = null;
final BigDecimal maxDepositAmount = null; final BigDecimal maxDepositAmount = null;
return new RecurringDepositProductData(id, name, shortName, description, currency, nominalAnnualInterestRate, return new RecurringDepositProductData(id, name, shortName, description, currency, nominalAnnualInterestRate,
interestCompoundingPeriodType, interestPostingPeriodType, interestCalculationType, interestCalculationDaysInYearType, interestCompoundingPeriodType, interestPostingPeriodType, interestCalculationType, interestCalculationDaysInYearType,
lockinPeriodFrequency, lockinPeriodFrequencyType, accountingRule, accountingMappings, paymentChannelToFundSourceMappings, lockinPeriodFrequency, lockinPeriodFrequencyType, accountingRule, accountingMappings, paymentChannelToFundSourceMappings,
currencyOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions, interestCalculationTypeOptions, currencyOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions, interestCalculationTypeOptions,
interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, paymentTypeOptions, interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, paymentTypeOptions,
accountingRuleOptions, accountingMappingOptions, charges, chargeOptions, penaltyOptions, feeToIncomeAccountMappings, accountingRuleOptions, accountingMappingOptions, charges, chargeOptions, penaltyOptions, feeToIncomeAccountMappings,
penaltyToIncomeAccountMappings, interestRateCharts, chartTemplate, interestFreePeriodApplicable, interestFreeFromPeriod, penaltyToIncomeAccountMappings, interestRateCharts, chartTemplate, preClosurePenalApplicable, preClosurePenalInterest,
interestFreeToPeriod, interestFreePeriodFrequencyType, preClosurePenalApplicable, preClosurePenalInterest, preClosurePenalInterestOnType, preClosurePenalInterestOnTypeOptions, minDepositTerm, maxDepositTerm, minDepositTermType,
preClosurePenalInterestOnType, interestFreePeriodTypes, preClosurePenalInterestOnTypeOptions, minDepositTerm, maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType, isMandatoryDeposit, allowWithdrawal,
maxDepositTerm, minDepositTermType, maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType, recurringDepositType, adjustAdvanceTowardsFuturePayments, periodFrequencyTypeOptions, minDepositAmount, depositAmount, maxDepositAmount);
recurringDepositFrequency, recurringDepositFrequencyType, recurringDepositTypeOptions,
recurringDepositFrequencyTypeOptions, depositTermTypeOptions, inMultiplesOfDepositTermTypeOptions,
minDepositAmount, depositAmount, maxDepositAmount);
} }
public static RecurringDepositProductData withCharges(final RecurringDepositProductData existingProduct, public static RecurringDepositProductData withCharges(final RecurringDepositProductData existingProduct,
@@ -132,17 +114,13 @@ public class RecurringDepositProductData extends DepositProductData {
existingProduct.paymentTypeOptions, existingProduct.accountingRuleOptions, existingProduct.accountingMappingOptions, existingProduct.paymentTypeOptions, existingProduct.accountingRuleOptions, existingProduct.accountingMappingOptions,
charges, existingProduct.chargeOptions, existingProduct.penaltyOptions, existingProduct.feeToIncomeAccountMappings, charges, existingProduct.chargeOptions, existingProduct.penaltyOptions, existingProduct.feeToIncomeAccountMappings,
existingProduct.penaltyToIncomeAccountMappings, existingProduct.interestRateCharts, existingProduct.chartTemplate, existingProduct.penaltyToIncomeAccountMappings, existingProduct.interestRateCharts, existingProduct.chartTemplate,
existingProduct.interestFreePeriodApplicable, existingProduct.interestFreeFromPeriod, existingProduct.interestFreeToPeriod, existingProduct.preClosurePenalApplicable, existingProduct.preClosurePenalInterest,
existingProduct.interestFreePeriodFrequencyType, existingProduct.preClosurePenalApplicable, existingProduct.preClosurePenalInterestOnType, existingProduct.preClosurePenalInterestOnTypeOptions,
existingProduct.preClosurePenalInterest, existingProduct.preClosurePenalInterestOnType,
existingProduct.interestFreePeriodTypeOptions, existingProduct.preClosurePenalInterestOnTypeOptions,
existingProduct.minDepositTerm, existingProduct.maxDepositTerm, existingProduct.minDepositTermType, existingProduct.minDepositTerm, existingProduct.maxDepositTerm, existingProduct.minDepositTermType,
existingProduct.maxDepositTermType, existingProduct.inMultiplesOfDepositTerm, existingProduct.inMultiplesOfDepositTermType, existingProduct.maxDepositTermType, existingProduct.inMultiplesOfDepositTerm, existingProduct.inMultiplesOfDepositTermType,
existingProduct.recurringDepositType, existingProduct.recurringDepositFrequency, existingProduct.isMandatoryDeposit, existingProduct.allowWithdrawal, existingProduct.adjustAdvanceTowardsFuturePayments,
existingProduct.recurringDepositFrequencyType, existingProduct.recurringDepositTypeOptions, existingProduct.periodFrequencyTypeOptions, existingProduct.minDepositAmount, existingProduct.depositAmount,
existingProduct.recurringDepositFrequencyTypeOptions, existingProduct.depositTermTypeOptions, existingProduct.maxDepositAmount);
existingProduct.inMultiplesOfDepositTermTypeOptions, existingProduct.minDepositAmount,
existingProduct.depositAmount, existingProduct.maxDepositAmount);
} }
/** /**
@@ -159,11 +137,8 @@ public class RecurringDepositProductData extends DepositProductData {
final Collection<CodeValueData> paymentTypeOptions, final Collection<EnumOptionData> accountingRuleOptions, final Collection<CodeValueData> paymentTypeOptions, final Collection<EnumOptionData> accountingRuleOptions,
final Map<String, List<GLAccountData>> accountingMappingOptions, final Collection<ChargeData> chargeOptions, final Map<String, List<GLAccountData>> accountingMappingOptions, final Collection<ChargeData> chargeOptions,
final Collection<ChargeData> penaltyOptions, final InterestRateChartData chartTemplate, final Collection<ChargeData> penaltyOptions, final InterestRateChartData chartTemplate,
final Collection<EnumOptionData> interestFreePeriodTypes,
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions, final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions,
final Collection<EnumOptionData> recurringDepositTypeOptions, final Collection<EnumOptionData> periodFrequencyTypeOptions) {
final Collection<EnumOptionData> recurringDepositFrequencyTypeOptions, final Collection<EnumOptionData> depositTermTypeOptions,
final Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions) {
return new RecurringDepositProductData(existingProduct.id, existingProduct.name, existingProduct.shortName, return new RecurringDepositProductData(existingProduct.id, existingProduct.name, existingProduct.shortName,
existingProduct.description, existingProduct.currency, existingProduct.nominalAnnualInterestRate, existingProduct.description, existingProduct.currency, existingProduct.nominalAnnualInterestRate,
@@ -175,16 +150,14 @@ public class RecurringDepositProductData extends DepositProductData {
interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, paymentTypeOptions, interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, paymentTypeOptions,
accountingRuleOptions, accountingMappingOptions, existingProduct.charges, chargeOptions, penaltyOptions, accountingRuleOptions, accountingMappingOptions, existingProduct.charges, chargeOptions, penaltyOptions,
existingProduct.feeToIncomeAccountMappings, existingProduct.penaltyToIncomeAccountMappings, existingProduct.feeToIncomeAccountMappings, existingProduct.penaltyToIncomeAccountMappings,
existingProduct.interestRateCharts, chartTemplate, existingProduct.interestFreePeriodApplicable, existingProduct.interestRateCharts, chartTemplate, existingProduct.preClosurePenalApplicable,
existingProduct.interestFreeFromPeriod, existingProduct.interestFreeToPeriod, existingProduct.preClosurePenalInterest, existingProduct.preClosurePenalInterestOnType,
existingProduct.interestFreePeriodFrequencyType, existingProduct.preClosurePenalApplicable,
existingProduct.preClosurePenalInterest, existingProduct.preClosurePenalInterestOnType, interestFreePeriodTypes,
preClosurePenalInterestOnTypeOptions, existingProduct.minDepositTerm, existingProduct.maxDepositTerm, preClosurePenalInterestOnTypeOptions, existingProduct.minDepositTerm, existingProduct.maxDepositTerm,
existingProduct.minDepositTermType, existingProduct.maxDepositTermType, existingProduct.inMultiplesOfDepositTerm, existingProduct.minDepositTermType, existingProduct.maxDepositTermType, existingProduct.inMultiplesOfDepositTerm,
existingProduct.inMultiplesOfDepositTermType, existingProduct.recurringDepositType, existingProduct.inMultiplesOfDepositTermType, existingProduct.isMandatoryDeposit, existingProduct.allowWithdrawal,
existingProduct.recurringDepositFrequency, existingProduct.recurringDepositFrequencyType, recurringDepositTypeOptions, existingProduct.adjustAdvanceTowardsFuturePayments, periodFrequencyTypeOptions, existingProduct.minDepositAmount,
recurringDepositFrequencyTypeOptions, depositTermTypeOptions, inMultiplesOfDepositTermTypeOptions, existingProduct.minDepositAmount,
existingProduct.depositAmount, existingProduct.maxDepositAmount); existingProduct.depositAmount, existingProduct.maxDepositAmount);
} }
public static RecurringDepositProductData withAccountingDetails(final RecurringDepositProductData existingProduct, public static RecurringDepositProductData withAccountingDetails(final RecurringDepositProductData existingProduct,
@@ -216,28 +189,21 @@ public class RecurringDepositProductData extends DepositProductData {
lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, paymentTypeOptions, accountingRuleOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, paymentTypeOptions, accountingRuleOptions,
accountingMappingOptions, existingProduct.charges, chargeOptions, penaltyOptions, feeToIncomeAccountMappings, accountingMappingOptions, existingProduct.charges, chargeOptions, penaltyOptions, feeToIncomeAccountMappings,
penaltyToIncomeAccountMappings, existingProduct.interestRateCharts, existingProduct.chartTemplate, penaltyToIncomeAccountMappings, existingProduct.interestRateCharts, existingProduct.chartTemplate,
existingProduct.interestFreePeriodApplicable, existingProduct.interestFreeFromPeriod, existingProduct.interestFreeToPeriod, existingProduct.preClosurePenalApplicable, existingProduct.preClosurePenalInterest,
existingProduct.interestFreePeriodFrequencyType, existingProduct.preClosurePenalApplicable, existingProduct.preClosurePenalInterestOnType, existingProduct.preClosurePenalInterestOnTypeOptions,
existingProduct.preClosurePenalInterest, existingProduct.preClosurePenalInterestOnType,
existingProduct.interestFreePeriodTypeOptions, existingProduct.preClosurePenalInterestOnTypeOptions,
existingProduct.minDepositTerm, existingProduct.maxDepositTerm, existingProduct.minDepositTermType, existingProduct.minDepositTerm, existingProduct.maxDepositTerm, existingProduct.minDepositTermType,
existingProduct.maxDepositTermType, existingProduct.inMultiplesOfDepositTerm, existingProduct.inMultiplesOfDepositTermType, existingProduct.maxDepositTermType, existingProduct.inMultiplesOfDepositTerm, existingProduct.inMultiplesOfDepositTermType,
existingProduct.recurringDepositType, existingProduct.recurringDepositFrequency, existingProduct.isMandatoryDeposit, existingProduct.allowWithdrawal, existingProduct.adjustAdvanceTowardsFuturePayments,
existingProduct.recurringDepositFrequencyType, existingProduct.recurringDepositTypeOptions, existingProduct.periodFrequencyTypeOptions, existingProduct.minDepositAmount, existingProduct.depositAmount,
existingProduct.recurringDepositFrequencyTypeOptions, existingProduct.depositTermTypeOptions, existingProduct.maxDepositAmount);
existingProduct.inMultiplesOfDepositTermTypeOptions, existingProduct.minDepositAmount,
existingProduct.depositAmount, existingProduct.maxDepositAmount);
} }
public static RecurringDepositProductData instance(final DepositProductData depositProductData, public static RecurringDepositProductData instance(final DepositProductData depositProductData,
final boolean interestFreePeriodApplicable, final Integer interestFreeFromPeriod, final Integer interestFreeToPeriod, final boolean preClosurePenalApplicable, final BigDecimal preClosurePenalInterest,
final EnumOptionData interestFreePeriodFrequencyType, final boolean preClosurePenalApplicable, final EnumOptionData preClosurePenalInterestOnType, final Integer minDepositTerm, final Integer maxDepositTerm,
final BigDecimal preClosurePenalInterest, final EnumOptionData preClosurePenalInterestOnType, final Integer minDepositTerm, final EnumOptionData minDepositTermType, final EnumOptionData maxDepositTermType, final Integer inMultiplesOfDepositTerm,
final Integer maxDepositTerm, final EnumOptionData minDepositTermType, final EnumOptionData maxDepositTermType, final EnumOptionData inMultiplesOfDepositTermType, final boolean isMandatoryDeposit, boolean allowWithdrawal,
final Integer inMultiplesOfDepositTerm, final EnumOptionData inMultiplesOfDepositTermType, boolean adjustAdvanceTowardsFuturePayments, final BigDecimal minDepositAmount, final BigDecimal depositAmount,
final EnumOptionData recurringDepositType, final Integer recurringDepositFrequency,
final EnumOptionData recurringDepositFrequencyType,
final BigDecimal minDepositAmount,final BigDecimal depositAmount,
final BigDecimal maxDepositAmount) { final BigDecimal maxDepositAmount) {
final Map<String, Object> accountingMappings = null; final Map<String, Object> accountingMappings = null;
@@ -260,12 +226,8 @@ public class RecurringDepositProductData extends DepositProductData {
final Collection<ChargeToGLAccountMapper> penaltyToIncomeAccountMappings = null; final Collection<ChargeToGLAccountMapper> penaltyToIncomeAccountMappings = null;
final Collection<InterestRateChartData> interestRateCharts = null; final Collection<InterestRateChartData> interestRateCharts = null;
final InterestRateChartData chartTemplate = null; final InterestRateChartData chartTemplate = null;
final Collection<EnumOptionData> interestFreePeriodTypes = null;
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions = null; final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions = null;
final Collection<EnumOptionData> recurringDepositTypeOptions = null; final Collection<EnumOptionData> periodFrequencyTypeOptions = null;
final Collection<EnumOptionData> recurringDepositFrequencyTypeOptions = null;
final Collection<EnumOptionData> depositTermTypeOptions = null;
final Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions = null;
return new RecurringDepositProductData(depositProductData.id, depositProductData.name, depositProductData.shortName, return new RecurringDepositProductData(depositProductData.id, depositProductData.name, depositProductData.shortName,
depositProductData.description, depositProductData.currency, depositProductData.nominalAnnualInterestRate, depositProductData.description, depositProductData.currency, depositProductData.nominalAnnualInterestRate,
@@ -276,13 +238,10 @@ public class RecurringDepositProductData extends DepositProductData {
interestPostingPeriodTypeOptions, interestCalculationTypeOptions, interestCalculationDaysInYearTypeOptions, interestPostingPeriodTypeOptions, interestCalculationTypeOptions, interestCalculationDaysInYearTypeOptions,
lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, paymentTypeOptions, accountingRuleOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, paymentTypeOptions, accountingRuleOptions,
accountingMappingOptions, charges, chargeOptions, penaltyOptions, feeToIncomeAccountMappings, accountingMappingOptions, charges, chargeOptions, penaltyOptions, feeToIncomeAccountMappings,
penaltyToIncomeAccountMappings, interestRateCharts, chartTemplate, interestFreePeriodApplicable, interestFreeFromPeriod, penaltyToIncomeAccountMappings, interestRateCharts, chartTemplate, preClosurePenalApplicable, preClosurePenalInterest,
interestFreeToPeriod, interestFreePeriodFrequencyType, preClosurePenalApplicable, preClosurePenalInterest, preClosurePenalInterestOnType, preClosurePenalInterestOnTypeOptions, minDepositTerm, maxDepositTerm, minDepositTermType,
preClosurePenalInterestOnType, interestFreePeriodTypes, preClosurePenalInterestOnTypeOptions, minDepositTerm, maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType, isMandatoryDeposit, allowWithdrawal,
maxDepositTerm, minDepositTermType, maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType, adjustAdvanceTowardsFuturePayments, periodFrequencyTypeOptions, minDepositAmount, depositAmount, maxDepositAmount);
recurringDepositType, recurringDepositFrequency, recurringDepositFrequencyType, recurringDepositTypeOptions,
recurringDepositFrequencyTypeOptions, depositTermTypeOptions, inMultiplesOfDepositTermTypeOptions,
minDepositAmount, depositAmount, maxDepositAmount);
} }
public static RecurringDepositProductData lookup(final Long id, final String name) { 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<ChargeToGLAccountMapper> penaltyToIncomeAccountMappings = null;
final Collection<InterestRateChartData> interestRateCharts = null; final Collection<InterestRateChartData> interestRateCharts = null;
final InterestRateChartData chartTemplate = 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 boolean preClosurePenalApplicable = false;
final BigDecimal preClosurePenalInterest = null; final BigDecimal preClosurePenalInterest = null;
final EnumOptionData preClosurePenalInterestOnType = null; final EnumOptionData preClosurePenalInterestOnType = null;
final Collection<EnumOptionData> interestFreePeriodTypes = null;
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions = null; final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions = null;
final EnumOptionData recurringDepositType = null; final boolean isMandatoryDeposit = false;
final Integer recurringDepositFrequency = null; final boolean allowWithdrawal = false;
final EnumOptionData recurringDepositFrequencyType = null; final boolean adjustAdvanceTowardsFuturePayments = false;
final Collection<EnumOptionData> recurringDepositTypeOptions = null;
final Collection<EnumOptionData> recurringDepositFrequencyTypeOptions = null;
final Integer minDepositTerm = null; final Integer minDepositTerm = null;
final Integer maxDepositTerm = null; final Integer maxDepositTerm = null;
final EnumOptionData minDepositTermType = null; final EnumOptionData minDepositTermType = null;
final EnumOptionData maxDepositTermType = null; final EnumOptionData maxDepositTermType = null;
final Integer inMultiplesOfDepositTerm = null; final Integer inMultiplesOfDepositTerm = null;
final EnumOptionData inMultiplesOfDepositTermType = null; final EnumOptionData inMultiplesOfDepositTermType = null;
final Collection<EnumOptionData> depositTermTypeOptions = null; final Collection<EnumOptionData> periodFrequencyTypeOptions = null;
final Collection<EnumOptionData> inMultiplesOfDepositTermTypeOptions = null;
final BigDecimal minDepositAmount = null; final BigDecimal minDepositAmount = null;
final BigDecimal depositAmount = null; final BigDecimal depositAmount = null;
final BigDecimal maxDepositAmount = null; final BigDecimal maxDepositAmount = null;
@@ -352,13 +303,10 @@ public class RecurringDepositProductData extends DepositProductData {
currencyOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions, interestCalculationTypeOptions, currencyOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions, interestCalculationTypeOptions,
interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, paymentTypeOptions, interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, paymentTypeOptions,
accountingRuleOptions, accountingMappingOptions, charges, chargeOptions, penaltyOptions, feeToIncomeAccountMappings, accountingRuleOptions, accountingMappingOptions, charges, chargeOptions, penaltyOptions, feeToIncomeAccountMappings,
penaltyToIncomeAccountMappings, interestRateCharts, chartTemplate, interestFreePeriodApplicable, interestFreeFromPeriod, penaltyToIncomeAccountMappings, interestRateCharts, chartTemplate, preClosurePenalApplicable, preClosurePenalInterest,
interestFreeToPeriod, interestFreePeriodFrequencyType, preClosurePenalApplicable, preClosurePenalInterest, preClosurePenalInterestOnType, preClosurePenalInterestOnTypeOptions, minDepositTerm, maxDepositTerm, minDepositTermType,
preClosurePenalInterestOnType, interestFreePeriodTypes, preClosurePenalInterestOnTypeOptions, minDepositTerm, maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType, isMandatoryDeposit, allowWithdrawal,
maxDepositTerm, minDepositTermType, maxDepositTermType, inMultiplesOfDepositTerm, inMultiplesOfDepositTermType, adjustAdvanceTowardsFuturePayments, periodFrequencyTypeOptions, minDepositAmount, depositAmount, maxDepositAmount);
recurringDepositType, recurringDepositFrequency, recurringDepositFrequencyType, recurringDepositTypeOptions,
recurringDepositFrequencyTypeOptions, depositTermTypeOptions, inMultiplesOfDepositTermTypeOptions,
minDepositAmount, depositAmount, maxDepositAmount);
} }
public static RecurringDepositProductData withInterestChart(final RecurringDepositProductData product, public static RecurringDepositProductData withInterestChart(final RecurringDepositProductData product,
@@ -373,14 +321,12 @@ public class RecurringDepositProductData extends DepositProductData {
product.withdrawalFeeTypeOptions, product.paymentTypeOptions, product.accountingRuleOptions, product.withdrawalFeeTypeOptions, product.paymentTypeOptions, product.accountingRuleOptions,
product.accountingMappingOptions, product.charges, product.chargeOptions, product.penaltyOptions, product.accountingMappingOptions, product.charges, product.chargeOptions, product.penaltyOptions,
product.feeToIncomeAccountMappings, product.penaltyToIncomeAccountMappings, interestRateCharts, product.chartTemplate, product.feeToIncomeAccountMappings, product.penaltyToIncomeAccountMappings, interestRateCharts, product.chartTemplate,
product.interestFreePeriodApplicable, product.interestFreeFromPeriod, product.interestFreeToPeriod, product.preClosurePenalApplicable, product.preClosurePenalInterest, product.preClosurePenalInterestOnType,
product.interestFreePeriodFrequencyType, product.preClosurePenalApplicable, product.preClosurePenalInterest, product.preClosurePenalInterestOnTypeOptions, product.minDepositTerm, product.maxDepositTerm, product.minDepositTermType,
product.preClosurePenalInterestOnType, product.interestFreePeriodTypeOptions, product.preClosurePenalInterestOnTypeOptions, product.maxDepositTermType, product.inMultiplesOfDepositTerm, product.inMultiplesOfDepositTermType,
product.minDepositTerm, product.maxDepositTerm, product.minDepositTermType, product.maxDepositTermType, product.isMandatoryDeposit, product.allowWithdrawal, product.adjustAdvanceTowardsFuturePayments,
product.inMultiplesOfDepositTerm, product.inMultiplesOfDepositTermType, product.recurringDepositType, product.periodFrequencyTypeOptions, product.minDepositAmount, product.depositAmount, product.maxDepositAmount);
product.recurringDepositFrequency, product.recurringDepositFrequencyType, product.recurringDepositTypeOptions,
product.recurringDepositFrequencyTypeOptions, product.depositTermTypeOptions, product.inMultiplesOfDepositTermTypeOptions, product.minDepositAmount,
product.depositAmount, product.maxDepositAmount);
} }
private RecurringDepositProductData(final Long id, final String name, final String shortName, final String description, 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> feeToIncomeAccountMappings,
final Collection<ChargeToGLAccountMapper> penaltyToIncomeAccountMappings, final Collection<ChargeToGLAccountMapper> penaltyToIncomeAccountMappings,
final Collection<InterestRateChartData> interestRateCharts, final InterestRateChartData chartTemplate, final Collection<InterestRateChartData> interestRateCharts, final InterestRateChartData chartTemplate,
final boolean interestFreePeriodApplicable, final Integer interestFreeFromPeriod, final Integer interestFreeToPeriod, final boolean preClosurePenalApplicable, final BigDecimal preClosurePenalInterest,
final EnumOptionData interestFreePeriodFrequencyType, final boolean preClosurePenalApplicable, final EnumOptionData preClosurePenalInterestOnType, final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions,
final BigDecimal preClosurePenalInterest, final EnumOptionData preClosurePenalInterestOnType, final Integer minDepositTerm, final Integer maxDepositTerm, final EnumOptionData minDepositTermType,
final Collection<EnumOptionData> interestFreePeriodTypeOptions, final EnumOptionData maxDepositTermType, final Integer inMultiplesOfDepositTerm,
final Collection<EnumOptionData> preClosurePenalInterestOnTypeOptions, final Integer minDepositTerm, final EnumOptionData inMultiplesOfDepositTermType, final boolean isMandatoryDeposit, boolean allowWithdrawal,
final Integer maxDepositTerm, final EnumOptionData minDepositTermType, final EnumOptionData maxDepositTermType, boolean adjustAdvanceTowardsFuturePayments, final Collection<EnumOptionData> periodFrequencyTypeOptions,
final Integer inMultiplesOfDepositTerm, final EnumOptionData inMultiplesOfDepositTermType, final BigDecimal minDepositAmount, final BigDecimal depositAmount, final BigDecimal maxDepositAmount) {
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) {
super(id, name, shortName, description, currency, nominalAnnualInterestRate, interestCompoundingPeriodType, super(id, name, shortName, description, currency, nominalAnnualInterestRate, interestCompoundingPeriodType,
interestPostingPeriodType, interestCalculationType, interestCalculationDaysInYearType, lockinPeriodFrequency, interestPostingPeriodType, interestCalculationType, interestCalculationDaysInYearType, lockinPeriodFrequency,
@@ -422,10 +363,6 @@ public class RecurringDepositProductData extends DepositProductData {
accountingRuleOptions, accountingMappingOptions, charges, chargeOptions, penaltyOptions, feeToIncomeAccountMappings, accountingRuleOptions, accountingMappingOptions, charges, chargeOptions, penaltyOptions, feeToIncomeAccountMappings,
penaltyToIncomeAccountMappings, interestRateCharts, chartTemplate); penaltyToIncomeAccountMappings, interestRateCharts, chartTemplate);
this.interestFreePeriodApplicable = interestFreePeriodApplicable;
this.interestFreeFromPeriod = interestFreeFromPeriod;
this.interestFreeToPeriod = interestFreeToPeriod;
this.interestFreePeriodFrequencyType = interestFreePeriodFrequencyType;
this.preClosurePenalApplicable = preClosurePenalApplicable; this.preClosurePenalApplicable = preClosurePenalApplicable;
this.preClosurePenalInterest = preClosurePenalInterest; this.preClosurePenalInterest = preClosurePenalInterest;
this.preClosurePenalInterestOnType = preClosurePenalInterestOnType; this.preClosurePenalInterestOnType = preClosurePenalInterestOnType;
@@ -435,21 +372,16 @@ public class RecurringDepositProductData extends DepositProductData {
this.maxDepositTermType = maxDepositTermType; this.maxDepositTermType = maxDepositTermType;
this.inMultiplesOfDepositTerm = inMultiplesOfDepositTerm; this.inMultiplesOfDepositTerm = inMultiplesOfDepositTerm;
this.inMultiplesOfDepositTermType = inMultiplesOfDepositTermType; this.inMultiplesOfDepositTermType = inMultiplesOfDepositTermType;
this.recurringDepositFrequencyType = recurringDepositFrequencyType;
this.recurringDepositFrequency = recurringDepositFrequency;
this.recurringDepositType = recurringDepositType;
this.minDepositAmount = minDepositAmount; this.minDepositAmount = minDepositAmount;
this.depositAmount = depositAmount; this.depositAmount = depositAmount;
this.maxDepositAmount = maxDepositAmount; this.maxDepositAmount = maxDepositAmount;
this.isMandatoryDeposit = isMandatoryDeposit;
this.allowWithdrawal = allowWithdrawal;
this.adjustAdvanceTowardsFuturePayments = adjustAdvanceTowardsFuturePayments;
// template data // template data
this.interestFreePeriodTypeOptions = interestFreePeriodTypeOptions;
this.preClosurePenalInterestOnTypeOptions = preClosurePenalInterestOnTypeOptions; this.preClosurePenalInterestOnTypeOptions = preClosurePenalInterestOnTypeOptions;
this.recurringDepositTypeOptions = recurringDepositTypeOptions; this.periodFrequencyTypeOptions = periodFrequencyTypeOptions;
this.recurringDepositFrequencyTypeOptions = recurringDepositFrequencyTypeOptions;
this.depositTermTypeOptions = depositTermTypeOptions;
this.inMultiplesOfDepositTermTypeOptions = inMultiplesOfDepositTermTypeOptions;
} }
} }
@@ -14,6 +14,7 @@ public class SavingsAccountTransactionDTO {
private final BigDecimal transactionAmount; private final BigDecimal transactionAmount;
private final PaymentDetail paymentDetail; private final PaymentDetail paymentDetail;
private final Date createdDate; private final Date createdDate;
private final Long savingsAccountId;
public SavingsAccountTransactionDTO(final DateTimeFormatter formatter, final LocalDate transactionDate, public SavingsAccountTransactionDTO(final DateTimeFormatter formatter, final LocalDate transactionDate,
final BigDecimal transactionAmount, final PaymentDetail paymentDetail, final Date createdDate) { final BigDecimal transactionAmount, final PaymentDetail paymentDetail, final Date createdDate) {
@@ -22,7 +23,28 @@ public class SavingsAccountTransactionDTO {
this.transactionAmount = transactionAmount; this.transactionAmount = transactionAmount;
this.paymentDetail = paymentDetail; this.paymentDetail = paymentDetail;
this.createdDate = createdDate; 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() { public DateTimeFormatter getFormatter() {
return this.formatter; return this.formatter;
@@ -43,4 +65,9 @@ public class SavingsAccountTransactionDTO {
public Date getCreatedDate() { public Date getCreatedDate() {
return this.createdDate; return this.createdDate;
} }
public Long getSavingsAccountId() {
return this.savingsAccountId;
}
} }
@@ -330,4 +330,15 @@ public class SavingsProductData {
public int accountingRuleTypeId() { public int accountingRuleTypeId() {
return this.accountingRule.getId().intValue(); 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; 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.chartIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.depositAmountParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.depositAmountParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.depositPeriodFrequencyIdParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.depositPeriodFrequencyIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.depositPeriodParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.depositPeriodParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.expectedFirstDepositOnDateParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.expectedFirstDepositOnDateParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.recurringDepositAmountParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.isCalendarInheritedParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.recurringDepositFrequencyParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.isMandatoryDepositParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.recurringDepositFrequencyTypeIdParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.mandatoryRecommendedDepositAmountParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.recurringDepositTypeIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.transferInterestToSavingsParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.transferInterestToSavingsParamName;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.accountNoParamName; import static org.mifosplatform.portfolio.savings.SavingsApiConstants.accountNoParamName;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.clientIdParamName; 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 static org.mifosplatform.portfolio.savings.SavingsApiConstants.withdrawalFeeForTransfersParamName;
import java.math.BigDecimal; 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 java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.joda.time.LocalDate; 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.api.JsonCommand;
import org.mifosplatform.infrastructure.core.exception.InvalidJsonException;
import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper; import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper;
import org.mifosplatform.infrastructure.core.service.DateUtils; import org.mifosplatform.infrastructure.core.service.DateUtils;
import org.mifosplatform.organisation.staff.domain.Staff; 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.ClientNotInGroupException;
import org.mifosplatform.portfolio.group.exception.GroupNotActiveException; import org.mifosplatform.portfolio.group.exception.GroupNotActiveException;
import org.mifosplatform.portfolio.interestratechart.domain.InterestRateChart; 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.DepositAccountOnClosureType;
import org.mifosplatform.portfolio.savings.DepositAccountType; import org.mifosplatform.portfolio.savings.DepositAccountType;
import org.mifosplatform.portfolio.savings.RecurringDepositType;
import org.mifosplatform.portfolio.savings.SavingsCompoundingInterestPeriodType; import org.mifosplatform.portfolio.savings.SavingsCompoundingInterestPeriodType;
import org.mifosplatform.portfolio.savings.SavingsInterestCalculationDaysInYearType; import org.mifosplatform.portfolio.savings.SavingsInterestCalculationDaysInYearType;
import org.mifosplatform.portfolio.savings.SavingsInterestCalculationType; import org.mifosplatform.portfolio.savings.SavingsInterestCalculationType;
import org.mifosplatform.portfolio.savings.SavingsPeriodFrequencyType; import org.mifosplatform.portfolio.savings.SavingsPeriodFrequencyType;
import org.mifosplatform.portfolio.savings.SavingsPostingInterestPeriodType; 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.FixedDepositProductNotFoundException;
import org.mifosplatform.portfolio.savings.exception.RecurringDepositProductNotFoundException; import org.mifosplatform.portfolio.savings.exception.RecurringDepositProductNotFoundException;
import org.mifosplatform.portfolio.savings.exception.SavingsProductNotFoundException; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
@Service @Service
public class DepositAccountAssembler { public class DepositAccountAssembler {
@@ -83,6 +100,7 @@ public class DepositAccountAssembler {
private final SavingsAccountChargeAssembler savingsAccountChargeAssembler; private final SavingsAccountChargeAssembler savingsAccountChargeAssembler;
private final FromJsonHelper fromApiJsonHelper; private final FromJsonHelper fromApiJsonHelper;
private final DepositProductAssembler depositProductAssembler; private final DepositProductAssembler depositProductAssembler;
private final ConfigurationDomainService configurationDomainService;
@Autowired @Autowired
public DepositAccountAssembler(final SavingsAccountTransactionSummaryWrapper savingsAccountTransactionSummaryWrapper, public DepositAccountAssembler(final SavingsAccountTransactionSummaryWrapper savingsAccountTransactionSummaryWrapper,
@@ -92,7 +110,9 @@ public class DepositAccountAssembler {
final SavingsAccountChargeAssembler savingsAccountChargeAssembler, final FromJsonHelper fromApiJsonHelper, final SavingsAccountChargeAssembler savingsAccountChargeAssembler, final FromJsonHelper fromApiJsonHelper,
final DepositProductAssembler depositProductAssembler, final DepositProductAssembler depositProductAssembler,
final RecurringDepositProductRepository recurringDepositProductRepository, final RecurringDepositProductRepository recurringDepositProductRepository,
final AccountTransfersReadPlatformService accountTransfersReadPlatformService) { final AccountTransfersReadPlatformService accountTransfersReadPlatformService,
final ConfigurationDomainService configurationDomainService) {
this.savingsAccountTransactionSummaryWrapper = savingsAccountTransactionSummaryWrapper; this.savingsAccountTransactionSummaryWrapper = savingsAccountTransactionSummaryWrapper;
this.clientRepository = clientRepository; this.clientRepository = clientRepository;
this.groupRepository = groupRepository; this.groupRepository = groupRepository;
@@ -104,6 +124,7 @@ public class DepositAccountAssembler {
this.depositProductAssembler = depositProductAssembler; this.depositProductAssembler = depositProductAssembler;
this.recurringDepositProductRepository = recurringDepositProductRepository; this.recurringDepositProductRepository = recurringDepositProductRepository;
this.savingsHelper = new SavingsHelper(accountTransfersReadPlatformService); this.savingsHelper = new SavingsHelper(accountTransfersReadPlatformService);
this.configurationDomainService = configurationDomainService;
} }
/** /**
@@ -246,7 +267,9 @@ public class DepositAccountAssembler {
productChart = product.applicableChart(submittedOnDate); productChart = product.applicableChart(submittedOnDate);
} }
accountChart = DepositAccountInterestRateChart.from(productChart); if (productChart != null) {
accountChart = DepositAccountInterestRateChart.from(productChart);
}
SavingsAccount account = null; SavingsAccount account = null;
if (depositAccountType.isFixedDeposit()) { if (depositAccountType.isFixedDeposit()) {
@@ -287,6 +310,7 @@ public class DepositAccountAssembler {
if (account != null) { if (account != null) {
account.setHelpers(this.savingsAccountTransactionSummaryWrapper, this.savingsHelper); account.setHelpers(this.savingsAccountTransactionSummaryWrapper, this.savingsHelper);
account.validateNewApplicationState(DateUtils.getLocalDateOfTenant(), depositAccountType.resourceName()); account.validateNewApplicationState(DateUtils.getLocalDateOfTenant(), depositAccountType.resourceName());
updateIncentiveAttributes(account.getClient(), account.accountSubmittedOrActivationDate());
} }
return account; return account;
@@ -295,10 +319,17 @@ public class DepositAccountAssembler {
public SavingsAccount assembleFrom(final Long savingsId, DepositAccountType depositAccountType) { public SavingsAccount assembleFrom(final Long savingsId, DepositAccountType depositAccountType) {
final SavingsAccount account = this.savingsAccountRepository.findOneWithNotFoundDetection(savingsId, depositAccountType); final SavingsAccount account = this.savingsAccountRepository.findOneWithNotFoundDetection(savingsId, depositAccountType);
account.setHelpers(this.savingsAccountTransactionSummaryWrapper, this.savingsHelper); account.setHelpers(this.savingsAccountTransactionSummaryWrapper, this.savingsHelper);
updateIncentiveAttributes(account.getClient(), account.accountSubmittedOrActivationDate());
return account; 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) { public void assignSavingAccountHelpers(final SavingsAccount savingsAccount) {
savingsAccount.setHelpers(this.savingsAccountTransactionSummaryWrapper, this.savingsHelper); savingsAccount.setHelpers(this.savingsAccountTransactionSummaryWrapper, this.savingsHelper);
} }
@@ -334,44 +365,71 @@ public class DepositAccountAssembler {
public DepositAccountRecurringDetail assembleAccountRecurringDetail(final JsonCommand command, public DepositAccountRecurringDetail assembleAccountRecurringDetail(final JsonCommand command,
final DepositRecurringDetail prodRecurringDetail) { final DepositRecurringDetail prodRecurringDetail) {
RecurringDepositType recurringDepositType = null; final BigDecimal recurringDepositAmount = command.bigDecimalValueOfParameterNamed(mandatoryRecommendedDepositAmountParamName);
Integer recurringDepositTypeValue = null; boolean isMandatoryDeposit;
boolean allowWithdrawal;
boolean adjustAdvanceTowardsFuturePayments;
boolean isCalendarInherited;
final BigDecimal recurringDepositAmount = command.bigDecimalValueOfParameterNamed(recurringDepositAmountParamName); if (command.parameterExists(isMandatoryDepositParamName)) {
isMandatoryDeposit = command.booleanObjectValueOfParameterNamed(isMandatoryDepositParamName);
if (command.parameterExists(recurringDepositTypeIdParamName)) {
recurringDepositTypeValue = command.integerValueOfParameterNamed(recurringDepositTypeIdParamName);
} else { } else {
recurringDepositTypeValue = prodRecurringDetail.recurringDepositType(); isMandatoryDeposit = prodRecurringDetail.isMandatoryDeposit();
} }
if (recurringDepositTypeValue != null) { if (command.parameterExists(allowWithdrawalParamName)) {
recurringDepositType = RecurringDepositType.fromInt(recurringDepositTypeValue); allowWithdrawal = command.booleanObjectValueOfParameterNamed(allowWithdrawalParamName);
}
SavingsPeriodFrequencyType recurringDepositFrequencyType = null;
Integer recurringDepositFrequencyTypeValue = null;
if (command.parameterExists(recurringDepositFrequencyTypeIdParamName)) {
recurringDepositFrequencyTypeValue = command.integerValueOfParameterNamed(recurringDepositFrequencyTypeIdParamName);
} else { } else {
recurringDepositFrequencyTypeValue = prodRecurringDetail.recurringDepositFrequencyTypeId(); allowWithdrawal = prodRecurringDetail.allowWithdrawal();
} }
if (recurringDepositFrequencyTypeValue != null) { if (command.parameterExists(adjustAdvanceTowardsFuturePaymentsParamName)) {
recurringDepositFrequencyType = SavingsPeriodFrequencyType.fromInt(recurringDepositFrequencyTypeValue); adjustAdvanceTowardsFuturePayments = command.booleanObjectValueOfParameterNamed(adjustAdvanceTowardsFuturePaymentsParamName);
}
Integer recurringDepositFrequency = null;
if (command.parameterExists(recurringDepositFrequencyTypeIdParamName)) {
recurringDepositFrequency = command.integerValueOfParameterNamed(recurringDepositFrequencyParamName);
} else { } else {
recurringDepositFrequency = prodRecurringDetail.recurringDepositFrequency(); adjustAdvanceTowardsFuturePayments = prodRecurringDetail.adjustAdvanceTowardsFuturePayments();
} }
final DepositRecurringDetail depositRecurringDetail = DepositRecurringDetail.createFrom(recurringDepositType, if (command.parameterExists(isCalendarInheritedParamName)) {
recurringDepositFrequency, recurringDepositFrequencyType); isCalendarInherited = command.booleanObjectValueOfParameterNamed(isCalendarInheritedParamName);
} else {
isCalendarInherited = false;
}
final DepositRecurringDetail depositRecurringDetail = DepositRecurringDetail.createFrom(isMandatoryDeposit, allowWithdrawal,
adjustAdvanceTowardsFuturePayments);
final DepositAccountRecurringDetail depositAccountRecurringDetail = DepositAccountRecurringDetail.createNew(recurringDepositAmount, final DepositAccountRecurringDetail depositAccountRecurringDetail = DepositAccountRecurringDetail.createNew(recurringDepositAmount,
depositRecurringDetail, null); depositRecurringDetail, null, isCalendarInherited);
return depositAccountRecurringDetail; 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, SavingsAccountTransaction handleWithdrawal(SavingsAccount account, DateTimeFormatter fmt, LocalDate transactionDate,
BigDecimal transactionAmount, PaymentDetail paymentDetail, boolean applyWithdrawFee); 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); 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); 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); 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.ApplicationCurrencyRepositoryWrapper;
import org.mifosplatform.organisation.monetary.domain.MonetaryCurrency; import org.mifosplatform.organisation.monetary.domain.MonetaryCurrency;
import org.mifosplatform.organisation.monetary.domain.Money; import org.mifosplatform.organisation.monetary.domain.Money;
import org.mifosplatform.portfolio.account.domain.AccountTransferDetailRepository; import org.mifosplatform.portfolio.account.PortfolioAccountType;
import org.mifosplatform.portfolio.account.domain.AccountTransferDetails; import org.mifosplatform.portfolio.account.data.AccountTransferDTO;
import org.mifosplatform.portfolio.account.domain.AccountTransferTransaction;
import org.mifosplatform.portfolio.account.domain.AccountTransferType; 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.AccountNumberGenerator;
import org.mifosplatform.portfolio.client.domain.AccountNumberGeneratorFactory; import org.mifosplatform.portfolio.client.domain.AccountNumberGeneratorFactory;
import org.mifosplatform.portfolio.paymentdetail.domain.PaymentDetail; import org.mifosplatform.portfolio.paymentdetail.domain.PaymentDetail;
import org.mifosplatform.portfolio.savings.DepositAccountType; import org.mifosplatform.portfolio.savings.DepositAccountType;
import org.mifosplatform.portfolio.savings.SavingsApiConstants;
import org.mifosplatform.portfolio.savings.data.SavingsAccountTransactionDTO; import org.mifosplatform.portfolio.savings.data.SavingsAccountTransactionDTO;
import org.mifosplatform.useradministration.domain.AppUser; import org.mifosplatform.useradministration.domain.AppUser;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -48,26 +49,26 @@ public class DepositAccountDomainServiceJpa implements DepositAccountDomainServi
private final ApplicationCurrencyRepositoryWrapper applicationCurrencyRepositoryWrapper; private final ApplicationCurrencyRepositoryWrapper applicationCurrencyRepositoryWrapper;
private final JournalEntryWritePlatformService journalEntryWritePlatformService; private final JournalEntryWritePlatformService journalEntryWritePlatformService;
private final AccountNumberGeneratorFactory accountIdentifierGeneratorFactory; private final AccountNumberGeneratorFactory accountIdentifierGeneratorFactory;
private final AccountTransferDetailRepository accountTransferDetailRepository;
private final DepositAccountAssembler depositAccountAssembler; private final DepositAccountAssembler depositAccountAssembler;
private final SavingsAccountDomainService savingsAccountDomainService; private final SavingsAccountDomainService savingsAccountDomainService;
private final AccountTransfersWritePlatformService accountTransfersWritePlatformService;
@Autowired @Autowired
public DepositAccountDomainServiceJpa(final SavingsAccountRepositoryWrapper savingsAccountRepository, public DepositAccountDomainServiceJpa(final SavingsAccountRepositoryWrapper savingsAccountRepository,
final SavingsAccountTransactionRepository savingsAccountTransactionRepository, final SavingsAccountTransactionRepository savingsAccountTransactionRepository,
final ApplicationCurrencyRepositoryWrapper applicationCurrencyRepositoryWrapper, final ApplicationCurrencyRepositoryWrapper applicationCurrencyRepositoryWrapper,
final JournalEntryWritePlatformService journalEntryWritePlatformService, final JournalEntryWritePlatformService journalEntryWritePlatformService,
final AccountNumberGeneratorFactory accountIdentifierGeneratorFactory, final AccountNumberGeneratorFactory accountIdentifierGeneratorFactory, final DepositAccountAssembler depositAccountAssembler,
final AccountTransferDetailRepository accountTransferDetailRepository, final DepositAccountAssembler depositAccountAssembler, final SavingsAccountDomainService savingsAccountDomainService,
final SavingsAccountDomainService savingsAccountDomainService) { final AccountTransfersWritePlatformService accountTransfersWritePlatformService) {
this.savingsAccountRepository = savingsAccountRepository; this.savingsAccountRepository = savingsAccountRepository;
this.savingsAccountTransactionRepository = savingsAccountTransactionRepository; this.savingsAccountTransactionRepository = savingsAccountTransactionRepository;
this.applicationCurrencyRepositoryWrapper = applicationCurrencyRepositoryWrapper; this.applicationCurrencyRepositoryWrapper = applicationCurrencyRepositoryWrapper;
this.journalEntryWritePlatformService = journalEntryWritePlatformService; this.journalEntryWritePlatformService = journalEntryWritePlatformService;
this.accountIdentifierGeneratorFactory = accountIdentifierGeneratorFactory; this.accountIdentifierGeneratorFactory = accountIdentifierGeneratorFactory;
this.accountTransferDetailRepository = accountTransferDetailRepository;
this.depositAccountAssembler = depositAccountAssembler; this.depositAccountAssembler = depositAccountAssembler;
this.savingsAccountDomainService = savingsAccountDomainService; this.savingsAccountDomainService = savingsAccountDomainService;
this.accountTransfersWritePlatformService = accountTransfersWritePlatformService;
} }
@Transactional @Transactional
@@ -102,12 +103,36 @@ public class DepositAccountDomainServiceJpa implements DepositAccountDomainServi
@Transactional @Transactional
@Override @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) { 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> existingTransactionIds = new HashSet<Long>();
final Set<Long> existingReversedTransactionIds = new HashSet<Long>(); final Set<Long> existingReversedTransactionIds = new HashSet<Long>();
updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds); updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds);
/*<<<<<<< HEAD
final SavingsAccountTransactionDTO transactionDTO = new SavingsAccountTransactionDTO(fmt, transactionDate, transactionAmount, final SavingsAccountTransactionDTO transactionDTO = new SavingsAccountTransactionDTO(fmt, transactionDate, transactionAmount,
paymentDetail, new Date()); paymentDetail, new Date());
final SavingsAccountTransaction deposit = account.deposit(transactionDTO); final SavingsAccountTransaction deposit = account.deposit(transactionDTO);
@@ -119,108 +144,107 @@ public class DepositAccountDomainServiceJpa implements DepositAccountDomainServi
} else { } else {
final LocalDate today = DateUtils.getLocalDateOfTenant(); final LocalDate today = DateUtils.getLocalDateOfTenant();
account.calculateInterestUsing(mc, today, isInterestTransfer); 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); this.savingsAccountRepository.save(account);
postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds); postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds);
return deposit; return savingsTransactionId;
} }
@Transactional @Transactional
@Override @Override
public SavingsAccountTransaction handleAccountClosure(final SavingsAccount account, final PaymentDetail paymentDetail, public Long handleRDAccountClosure(final RecurringDepositAccount account, final PaymentDetail paymentDetail, final AppUser user,
final AppUser user, final JsonCommand command, final LocalDate tenantsTodayDate, final Map<String, Object> changes) { final JsonCommand command, final LocalDate tenantsTodayDate, final Map<String, Object> changes) {
final Set<Long> existingTransactionIds = new HashSet<Long>(); final Set<Long> existingTransactionIds = new HashSet<Long>();
final Set<Long> existingReversedTransactionIds = new HashSet<Long>(); final Set<Long> existingReversedTransactionIds = new HashSet<Long>();
updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds); updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds);
final DepositAccountType depositAccountType = account.depositAccountType();
SavingsAccountTransaction withdrawal = null;
final MathContext mc = MathContext.DECIMAL64; final MathContext mc = MathContext.DECIMAL64;
if (depositAccountType.isFixedDeposit()) { final Locale locale = command.extractLocale();
final FixedDepositAccount fdAccount = (FixedDepositAccount) account; final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale);
withdrawal = fdAccount.close(user, command, tenantsTodayDate, paymentDetail, changes); final LocalDate closedDate = command.localDateValueOfParameterNamed(SavingsApiConstants.closedOnDateParamName);
final Money transactionAmount = withdrawal.getAmount(fdAccount.getCurrency()); Long savingsTransactionId = null;
final LocalDate transactionDate = withdrawal.transactionLocalDate(); account.postMaturityInterest();
if (fdAccount.isReinvestOnClosure()) { final BigDecimal transactionAmount = account.getAccountBalance();
FixedDepositAccount reinvestedDeposit = fdAccount.reInvest(transactionAmount); if (account.isReinvestOnClosure()) {
fdAccount.updateMaturityDateAndAmountBeforeAccountActivation(mc); RecurringDepositAccount reinvestedDeposit = account.reInvest(transactionAmount);
this.savingsAccountRepository.save(reinvestedDeposit); depositAccountAssembler.assignSavingAccountHelpers(reinvestedDeposit);
autoGenerateAccountNumber(reinvestedDeposit); reinvestedDeposit.updateMaturityDateAndAmount(mc);
} else if (fdAccount.isTransferToSavingsOnClosure()) { reinvestedDeposit.processAccountUponActivation(fmt);
final Locale locale = command.extractLocale(); reinvestedDeposit.updateMaturityDateAndAmount(mc);
final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale); this.savingsAccountRepository.save(reinvestedDeposit);
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 AccountTransferDetails accountTransferDetails = AccountTransferDetails.savingsToSavingsTransfer(fdAccount.office(), Money amountForDeposit = reinvestedDeposit.activateWithBalance();
fdAccount.getClient(), fdAccount, toSavingsAccount.office(), toSavingsAccount.getClient(), toSavingsAccount, if (amountForDeposit.isGreaterThanZero()) {
AccountTransferType.ACCOUNT_TRANSFER.getValue()); handleRDDeposit(reinvestedDeposit, fmt, reinvestedDeposit.getActivationLocalDate(), amountForDeposit.getAmount(),
AccountTransferTransaction accountTransferTransaction = AccountTransferTransaction.savingsToSavingsTransfer( paymentDetail);
accountTransferDetails, withdrawal, deposit, transactionDate, transactionAmount, transferDescription);
accountTransferDetails.addAccountTransferTransaction(accountTransferTransaction);
this.accountTransferDetailRepository.save(accountTransferDetails);
} }
} else if (depositAccountType.isRecurringDeposit()) { reinvestedDeposit.updateMaturityDateAndAmount(mc);
final RecurringDepositAccount rdAccount = (RecurringDepositAccount) account; this.savingsAccountRepository.save(reinvestedDeposit);
withdrawal = rdAccount.close(user, command, tenantsTodayDate, paymentDetail, changes); autoGenerateAccountNumber(reinvestedDeposit);
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);
this.savingsAccountRepository.save(reinvestedDeposit); final SavingsAccountTransaction withdrawal = this.handleWithdrawal(account, fmt, closedDate, account.getAccountBalance(),
autoGenerateAccountNumber(reinvestedDeposit); paymentDetail, false);
} else if (rdAccount.isTransferToSavingsOnClosure()) { savingsTransactionId = withdrawal.getId();
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 AccountTransferDetails accountTransferDetails = AccountTransferDetails.savingsToSavingsTransfer(rdAccount.office(), } else if (account.isTransferToSavingsOnClosure()) {
rdAccount.getClient(), rdAccount, toSavingsAccount.office(), toSavingsAccount.getClient(), toSavingsAccount, final Long toSavingsId = command.longValueOfParameterNamed(toSavingsAccountIdParamName);
AccountTransferType.ACCOUNT_TRANSFER.getValue()); final String transferDescription = command.stringValueOfParameterNamed(transferDescriptionParamName);
AccountTransferTransaction accountTransferTransaction = AccountTransferTransaction.savingsToSavingsTransfer( final SavingsAccount toSavingsAccount = this.depositAccountAssembler.assembleFrom(toSavingsId,
accountTransferDetails, withdrawal, deposit, transactionDate, transactionAmount, transferDescription); DepositAccountType.SAVINGS_DEPOSIT);
accountTransferDetails.addAccountTransferTransaction(accountTransferTransaction); final AccountTransferDTO accountTransferDTO = new AccountTransferDTO(closedDate, transactionAmount,
PortfolioAccountType.SAVINGS, PortfolioAccountType.SAVINGS, null, null, transferDescription, locale, fmt, null, null,
this.accountTransferDetailRepository.save(accountTransferDetails); 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); this.savingsAccountRepository.save(account);
postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds); postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds);
return withdrawal; return savingsTransactionId;
} }
private void autoGenerateAccountNumber(final SavingsAccount account) { private void autoGenerateAccountNumber(final SavingsAccount account) {
@@ -234,75 +258,79 @@ public class DepositAccountDomainServiceJpa implements DepositAccountDomainServi
@Transactional @Transactional
@Override @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 AppUser user, final JsonCommand command, final LocalDate tenantsTodayDate, final Map<String, Object> changes) {
final Set<Long> existingTransactionIds = new HashSet<Long>(); final Set<Long> existingTransactionIds = new HashSet<Long>();
final Set<Long> existingReversedTransactionIds = new HashSet<Long>(); final Set<Long> existingReversedTransactionIds = new HashSet<Long>();
updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds); updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds);
final DepositAccountType depositAccountType = account.depositAccountType(); final LocalDate closedDate = command.localDateValueOfParameterNamed(SavingsApiConstants.closedOnDateParamName);
SavingsAccountTransaction withdrawal = null; final Locale locale = command.extractLocale();
if (depositAccountType.isFixedDeposit()) { final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale);
final FixedDepositAccount fdAccount = (FixedDepositAccount) account; Long savingsTransactionId = null;
withdrawal = fdAccount.prematureClosure(user, command, tenantsTodayDate, paymentDetail, changes); // post interest
final Money transactionAmount = withdrawal.getAmount(fdAccount.getCurrency()); account.postPreMaturityInterest(closedDate);
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 AccountTransferDetails accountTransferDetails = AccountTransferDetails.savingsToSavingsTransfer(fdAccount.office(), if (account.isTransferToSavingsOnClosure()) {
fdAccount.getClient(), fdAccount, toSavingsAccount.office(), toSavingsAccount.getClient(), toSavingsAccount, final Long toSavingsId = command.longValueOfParameterNamed(toSavingsAccountIdParamName);
AccountTransferType.ACCOUNT_TRANSFER.getValue()); final String transferDescription = command.stringValueOfParameterNamed(transferDescriptionParamName);
AccountTransferTransaction accountTransferTransaction = AccountTransferTransaction.savingsToSavingsTransfer( final SavingsAccount toSavingsAccount = this.depositAccountAssembler.assembleFrom(toSavingsId,
accountTransferDetails, withdrawal, deposit, transactionDate, transactionAmount, transferDescription); DepositAccountType.SAVINGS_DEPOSIT);
final AccountTransferDTO accountTransferDTO = new AccountTransferDTO(closedDate, account.getAccountBalance(),
accountTransferDetails.addAccountTransferTransaction(accountTransferTransaction); 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.accountTransferDetailRepository.save(accountTransferDetails); this.accountTransfersWritePlatformService.transferFunds(accountTransferDTO);
} } else {
} else if (depositAccountType.isRecurringDeposit()) { final SavingsAccountTransaction withdrawal = this.handleWithdrawal(account, fmt, closedDate, account.getAccountBalance(),
final RecurringDepositAccount rdAccount = (RecurringDepositAccount) account; paymentDetail, false);
withdrawal = rdAccount.prematureClosure(user, command, tenantsTodayDate, paymentDetail, changes); savingsTransactionId = withdrawal.getId();
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);
} }
account.prematureClosure(user, command, tenantsTodayDate, changes);
this.savingsAccountRepository.save(account); this.savingsAccountRepository.save(account);
postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds); postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds);
return savingsTransactionId;
return withdrawal;
} }
private Long saveTransactionToGenerateTransactionId(final SavingsAccountTransaction transaction) { private Long saveTransactionToGenerateTransactionId(final SavingsAccountTransaction transaction) {
@@ -20,6 +20,7 @@ import javax.persistence.Table;
import org.hibernate.annotations.LazyCollection; import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption; import org.hibernate.annotations.LazyCollectionOption;
import org.joda.time.LocalDate; 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.InterestRateChart;
import org.mifosplatform.portfolio.interestratechart.domain.InterestRateChartFields; import org.mifosplatform.portfolio.interestratechart.domain.InterestRateChartFields;
import org.mifosplatform.portfolio.interestratechart.domain.InterestRateChartSlab; import org.mifosplatform.portfolio.interestratechart.domain.InterestRateChartSlab;
@@ -50,8 +51,9 @@ public class DepositAccountInterestRateChart extends AbstractPersistable<Long> {
for (InterestRateChartSlab interestRateChartSlab : chartSlabs) { for (InterestRateChartSlab interestRateChartSlab : chartSlabs) {
depostiChartSlabs.add(DepositAccountInterestRateChartSlabs.from(interestRateChartSlab.slabFields(), null)); depostiChartSlabs.add(DepositAccountInterestRateChartSlabs.from(interestRateChartSlab.slabFields(), null));
} }
final DepositAccountInterestRateChart depositChart = new DepositAccountInterestRateChart(productChart.chartFields(), null, depostiChartSlabs); final DepositAccountInterestRateChart depositChart = new DepositAccountInterestRateChart(productChart.chartFields(), null,
//update deposit account interest rate chart ference to chart Slabs depostiChartSlabs);
// update deposit account interest rate chart ference to chart Slabs
depositChart.updateChartSlabsReference(); depositChart.updateChartSlabsReference();
return depositChart; return depositChart;
} }
@@ -63,13 +65,13 @@ public class DepositAccountInterestRateChart extends AbstractPersistable<Long> {
this.chartSlabs = chartSlabs; this.chartSlabs = chartSlabs;
} }
private void updateChartSlabsReference(){ private void updateChartSlabsReference() {
final Set<DepositAccountInterestRateChartSlabs> chartSlabs = setOfChartSlabs(); final Set<DepositAccountInterestRateChartSlabs> chartSlabs = setOfChartSlabs();
for (DepositAccountInterestRateChartSlabs chartSlab : chartSlabs) { for (DepositAccountInterestRateChartSlabs chartSlab : chartSlabs) {
chartSlab.updateChartReference(this); chartSlab.updateChartReference(this);
} }
} }
public Set<DepositAccountInterestRateChartSlabs> setOfChartSlabs() { public Set<DepositAccountInterestRateChartSlabs> setOfChartSlabs() {
if (this.chartSlabs == null) { if (this.chartSlabs == null) {
this.chartSlabs = new HashSet<DepositAccountInterestRateChartSlabs>(); this.chartSlabs = new HashSet<DepositAccountInterestRateChartSlabs>();
@@ -86,11 +88,6 @@ public class DepositAccountInterestRateChart extends AbstractPersistable<Long> {
return null; return null;
} }
/*private boolean removeChartSlab(DepositAccountInterestRateChartSlabs chartSlab) {
final Set<DepositAccountInterestRateChartSlabs> chartSlabs = setOfChartSlabs();
return chartSlabs.remove(chartSlab);
}*/
public LocalDate getFromDateAsLocalDate() { public LocalDate getFromDateAsLocalDate() {
return this.chartFields.getFromDateAsLocalDate(); return this.chartFields.getFromDateAsLocalDate();
} }
@@ -107,26 +104,43 @@ public class DepositAccountInterestRateChart extends AbstractPersistable<Long> {
return this.account; return this.account;
} }
/*private void throwExceptionIfValidationWarningsExist(final List<ApiParameterError> dataValidationErrors) {
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
}*/
public InterestRateChartFields chartFields() { public InterestRateChartFields chartFields() {
return this.chartFields; return this.chartFields;
} }
public void updateDepositAccountReference(final SavingsAccount account){ public void updateDepositAccountReference(final SavingsAccount account) {
this.account = 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; BigDecimal effectiveInterestRate = BigDecimal.ZERO;
for (DepositAccountInterestRateChartSlabs slab : setOfChartSlabs()) { for (DepositAccountInterestRateChartSlabs slab : setOfChartSlabs()) {
if(slab.slabFields().isBetweenPeriod(periodStartDate, periodEndDate) && slab.slabFields().isAmountBetween(depositAmount)){ if (slab.slabFields().isBetweenPeriod(periodStartDate, periodEndDate) && slab.slabFields().isAmountBetween(depositAmount)) {
effectiveInterestRate = slab.slabFields().annualInterestRate();
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; return effectiveInterestRate;
} }
} }
@@ -5,7 +5,7 @@
*/ */
package org.mifosplatform.portfolio.savings.domain; 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.math.BigDecimal;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@@ -19,48 +19,76 @@ import javax.persistence.OneToOne;
import javax.persistence.Table; import javax.persistence.Table;
import org.mifosplatform.infrastructure.core.api.JsonCommand; 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.SavingsPeriodFrequencyType;
import org.springframework.data.jpa.domain.AbstractPersistable; import org.springframework.data.jpa.domain.AbstractPersistable;
@Entity @Entity
@Table(name = "m_deposit_account_recurring_detail") @Table(name = "m_deposit_account_recurring_detail")
public class DepositAccountRecurringDetail extends AbstractPersistable<Long> { public class DepositAccountRecurringDetail extends AbstractPersistable<Long> {
@Column(name = "recurring_deposit_amount", scale = 6, precision = 19, nullable = true) @Column(name = "mandatory_recommended_deposit_amount", scale = 6, precision = 19, nullable = true)
private BigDecimal recurringDepositAmount; 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 @Embedded
private DepositRecurringDetail recurringDetail; private DepositRecurringDetail recurringDetail;
@OneToOne @OneToOne
@JoinColumn(name = "savings_account_id", nullable = false) @JoinColumn(name = "savings_account_id", nullable = false)
private SavingsAccount account; 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.recurringDetail = recurringDetail;
this.account = account; 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); final Map<String, Object> actualChanges = new LinkedHashMap<String, Object>(10);
if (command.isChangeInBigDecimalParameterNamed(recurringDepositAmountParamName, this.recurringDepositAmount)) { if (command.isChangeInBigDecimalParameterNamed(mandatoryRecommendedDepositAmountParamName, this.mandatoryRecommendedDepositAmount)) {
final BigDecimal newValue = command.bigDecimalValueOfParameterNamed(recurringDepositAmountParamName); final BigDecimal newValue = command.bigDecimalValueOfParameterNamed(mandatoryRecommendedDepositAmountParamName);
actualChanges.put(recurringDepositAmountParamName, newValue); actualChanges.put(mandatoryRecommendedDepositAmountParamName, newValue);
this.recurringDepositAmount = newValue; this.mandatoryRecommendedDepositAmount = newValue;
} }
if (this.recurringDetail != null) { if (this.recurringDetail != null) {
actualChanges.putAll(this.recurringDetail.update(command, baseDataValidator)); actualChanges.putAll(this.recurringDetail.update(command));
} }
return actualChanges; return actualChanges;
} }
@@ -72,30 +100,36 @@ public class DepositAccountRecurringDetail extends AbstractPersistable<Long> {
public void updateAccountReference(final SavingsAccount account) { public void updateAccountReference(final SavingsAccount account) {
this.account = account; this.account = account;
} }
public Integer recurringDepositType() { public boolean isMandatoryDeposit() {
return this.recurringDetail().recurringDepositType(); return this.recurringDetail.isMandatoryDeposit();
} }
public Integer recurringDepositFrequency() { public boolean allowWithdrawal() {
return this.recurringDetail().recurringDepositFrequency(); return this.recurringDetail.allowWithdrawal();
} }
public Integer recurringDepositFrequencyTypeId() { public boolean adjustAdvanceTowardsFuturePayments() {
return this.recurringDetail().recurringDepositFrequencyTypeId(); return this.recurringDetail.adjustAdvanceTowardsFuturePayments();
}
public BigDecimal mandatoryRecommendedDepositAmount() {
return this.mandatoryRecommendedDepositAmount;
}
public boolean isCalendarInherited(){
return this.isCalendarInherited;
} }
public SavingsPeriodFrequencyType recurringDepositFrequencyType() { public DepositAccountRecurringDetail copy() {
return SavingsPeriodFrequencyType.fromInt(this.recurringDepositFrequencyTypeId()); final BigDecimal mandatoryRecommendedDepositAmount = this.mandatoryRecommendedDepositAmount;
}
public BigDecimal recurringDepositAmount(){
return this.recurringDepositAmount;
}
public DepositAccountRecurringDetail copy(){
final BigDecimal recurringDepositAmount = this.recurringDepositAmount;
final DepositRecurringDetail recurringDetail = this.recurringDetail.copy(); 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; 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.depositAmountParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.depositPeriodFrequencyIdParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.depositPeriodFrequencyIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.depositPeriodParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.depositPeriodParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.expectedFirstDepositOnDateParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.expectedFirstDepositOnDateParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.transferInterestToSavingsParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.transferInterestToSavingsParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.localeParamName;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
@@ -32,9 +34,7 @@ import org.joda.time.Weeks;
import org.joda.time.Years; import org.joda.time.Years;
import org.mifosplatform.infrastructure.core.api.JsonCommand; import org.mifosplatform.infrastructure.core.api.JsonCommand;
import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder; 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.DepositAccountOnClosureType;
import org.mifosplatform.portfolio.savings.SavingsApiConstants;
import org.mifosplatform.portfolio.savings.SavingsPeriodFrequencyType; import org.mifosplatform.portfolio.savings.SavingsPeriodFrequencyType;
import org.mifosplatform.portfolio.savings.service.SavingsEnumerations; import org.mifosplatform.portfolio.savings.service.SavingsEnumerations;
import org.springframework.data.jpa.domain.AbstractPersistable; import org.springframework.data.jpa.domain.AbstractPersistable;
@@ -132,13 +132,12 @@ public class DepositAccountTermAndPreClosure extends AbstractPersistable<Long> {
final String localeAsInput = command.locale(); final String localeAsInput = command.locale();
final String dateFormat = command.dateFormat(); final String dateFormat = command.dateFormat();
if (command.isChangeInLocalDateParameterNamed(expectedFirstDepositOnDateParamName, this.getExpectedFirstDepositOnDate())) {
if (command.isChangeInLocalDateParameterNamed(expectedFirstDepositOnDateParamName, getExpectedFirstDepositOnDate())) {
final LocalDate newValue = command.localDateValueOfParameterNamed(expectedFirstDepositOnDateParamName); final LocalDate newValue = command.localDateValueOfParameterNamed(expectedFirstDepositOnDateParamName);
final String newValueAsString = command.stringValueOfParameterNamed(expectedFirstDepositOnDateParamName); final String newValueAsString = command.stringValueOfParameterNamed(expectedFirstDepositOnDateParamName);
actualChanges.put(expectedFirstDepositOnDateParamName, newValueAsString); actualChanges.put(expectedFirstDepositOnDateParamName, newValueAsString);
actualChanges.put(SavingsApiConstants.localeParamName, localeAsInput); actualChanges.put(localeParamName, localeAsInput);
actualChanges.put(SavingsApiConstants.dateFormatParamName, dateFormat); actualChanges.put(dateFormatParamName, dateFormat);
this.expectedFirstDepositOnDate = newValue.toDate(); this.expectedFirstDepositOnDate = newValue.toDate();
} }
@@ -263,10 +262,10 @@ public class DepositAccountTermAndPreClosure extends AbstractPersistable<Long> {
return DepositAccountOnClosureType.fromInt(this.onAccountClosureType).isTransferToSavings(); return DepositAccountOnClosureType.fromInt(this.onAccountClosureType).isTransferToSavings();
} }
public DepositAccountTermAndPreClosure deepCopy(Money depositAmount) { public DepositAccountTermAndPreClosure copy(BigDecimal depositAmount) {
final SavingsAccount account = null; final SavingsAccount account = null;
final BigDecimal maturityAmount = null; final BigDecimal maturityAmount = null;
final BigDecimal actualDepositAmount = null; final BigDecimal actualDepositAmount = depositAmount;
final LocalDate maturityDate = null; final LocalDate maturityDate = null;
final Integer depositPeriod = this.depositPeriod; final Integer depositPeriod = this.depositPeriod;
final SavingsPeriodFrequencyType depositPeriodFrequency = SavingsPeriodFrequencyType.fromInt(this.depositPeriodFrequency); final SavingsPeriodFrequencyType depositPeriodFrequency = SavingsPeriodFrequencyType.fromInt(this.depositPeriodFrequency);
@@ -285,8 +284,15 @@ public class DepositAccountTermAndPreClosure extends AbstractPersistable<Long> {
this.expectedFirstDepositOnDate = expectedFirstDepositOnDate.toDate(); this.expectedFirstDepositOnDate = expectedFirstDepositOnDate.toDate();
} }
public boolean isTransferInterestToLinkedAccount() { public boolean isTransferInterestToLinkedAccount() {
return this.transferInterestToLinkedAccount; 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; 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.preClosurePenalApplicableParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.preClosurePenalInterestOnTypeIdParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.preClosurePenalInterestOnTypeIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.preClosurePenalInterestParamName; 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.api.JsonCommand;
import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder; 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.PreClosurePenalInterestOnType;
import org.mifosplatform.portfolio.savings.service.SavingsEnumerations; import org.mifosplatform.portfolio.savings.service.SavingsEnumerations;
@@ -36,46 +30,27 @@ import org.mifosplatform.portfolio.savings.service.SavingsEnumerations;
@Embeddable @Embeddable
public class DepositPreClosureDetail { public class DepositPreClosureDetail {
@Column(name = "interest_free_period_applicable")
private boolean interestFreePeriodApplicable;
@Column(name = "pre_closure_penal_applicable") @Column(name = "pre_closure_penal_applicable")
private boolean preClosurePenalApplicable; 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) @Column(name = "pre_closure_penal_interest", scale = 6, precision = 19, nullable = true)
private BigDecimal preClosurePenalInterest; private BigDecimal preClosurePenalInterest;
@Column(name = "pre_closure_penal_interest_on_enum", nullable = true) @Column(name = "pre_closure_penal_interest_on_enum", nullable = true)
private Integer preClosurePenalInterestOnType; private Integer preClosurePenalInterestOnType;
public static DepositPreClosureDetail createFrom(final boolean interestFreePeriodApplicable, final Integer interestFreeFromPeriod, public static DepositPreClosureDetail createFrom(final boolean preClosurePenalApplicable, final BigDecimal preClosurePenalInterest,
final Integer interestFreeToPeriod, final InterestRateChartPeriodType periodType, final boolean preClosurePenalApplicable, final PreClosurePenalInterestOnType preClosurePenalInterestType) {
final BigDecimal preClosurePenalInterest, final PreClosurePenalInterestOnType preClosurePenalInterestType) {
return new DepositPreClosureDetail(interestFreePeriodApplicable, interestFreeFromPeriod, interestFreeToPeriod, periodType, return new DepositPreClosureDetail(preClosurePenalApplicable, preClosurePenalInterest, preClosurePenalInterestType);
preClosurePenalApplicable, preClosurePenalInterest, preClosurePenalInterestType);
} }
protected DepositPreClosureDetail() { protected DepositPreClosureDetail() {
// //
} }
private DepositPreClosureDetail(final boolean interestFreePeriodApplicable, final Integer interestFreeFromPeriod, private DepositPreClosureDetail(final boolean preClosurePenalApplicable, final BigDecimal preClosurePenalInterest,
final Integer interestFreeToPeriod, final InterestRateChartPeriodType periodType, final boolean preClosurePenalApplicable, final PreClosurePenalInterestOnType preClosurePenalInterestType) {
final BigDecimal preClosurePenalInterest, final PreClosurePenalInterestOnType preClosurePenalInterestType) {
this.interestFreePeriodApplicable = interestFreePeriodApplicable;
this.interestFreeFromPeriod = interestFreeFromPeriod;
this.interestFreeToPeriod = interestFreeToPeriod;
this.interestFreePeriodFrequencyType = (periodType == null) ? null : periodType.getValue();
this.preClosurePenalApplicable = preClosurePenalApplicable; this.preClosurePenalApplicable = preClosurePenalApplicable;
this.preClosurePenalInterest = preClosurePenalInterest; this.preClosurePenalInterest = preClosurePenalInterest;
this.preClosurePenalInterestOnType = (preClosurePenalInterestType == null) ? null : preClosurePenalInterestType.getValue(); this.preClosurePenalInterestOnType = (preClosurePenalInterestType == null) ? null : preClosurePenalInterestType.getValue();
@@ -86,52 +61,6 @@ public class DepositPreClosureDetail {
final String localeAsInput = command.locale(); 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)) { if (command.isChangeInBooleanParameterNamed(preClosurePenalApplicableParamName, this.preClosurePenalApplicable)) {
final boolean newValue = command.booleanPrimitiveValueOfParameterNamed(preClosurePenalApplicableParamName); final boolean newValue = command.booleanPrimitiveValueOfParameterNamed(preClosurePenalApplicableParamName);
actualChanges.put(preClosurePenalApplicableParamName, newValue); actualChanges.put(preClosurePenalApplicableParamName, newValue);
@@ -167,44 +96,13 @@ public class DepositPreClosureDetail {
this.preClosurePenalInterestOnType = null; 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; 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() { public boolean preClosurePenalApplicable() {
return this.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() { public BigDecimal preClosurePenalInterest() {
return this.preClosurePenalInterest; return this.preClosurePenalInterest;
} }
@@ -213,19 +111,16 @@ public class DepositPreClosureDetail {
return this.preClosurePenalInterestOnType; return this.preClosurePenalInterestOnType;
} }
public PreClosurePenalInterestOnType preClosurePenalInterestOnType(){ public PreClosurePenalInterestOnType preClosurePenalInterestOnType() {
return PreClosurePenalInterestOnType.fromInt(preClosurePenalInterestOnType); return PreClosurePenalInterestOnType.fromInt(preClosurePenalInterestOnType);
} }
public DepositPreClosureDetail copy(){ public DepositPreClosureDetail copy() {
final boolean interestFreePeriodApplicable = this.interestFreePeriodApplicable;
final Integer interestFreeFromPeriod = this.interestFreeFromPeriod;
final Integer interestFreeToPeriod = this.interestFreeToPeriod;
final boolean preClosurePenalApplicable = this.preClosurePenalApplicable; final boolean preClosurePenalApplicable = this.preClosurePenalApplicable;
final BigDecimal preClosurePenalInterest = this.preClosurePenalInterest; final BigDecimal preClosurePenalInterest = this.preClosurePenalInterest;
final InterestRateChartPeriodType periodType = InterestRateChartPeriodType.fromInt(this.interestFreePeriodFrequencyType); final PreClosurePenalInterestOnType preClosurePenalInterestType = PreClosurePenalInterestOnType
final PreClosurePenalInterestOnType preClosurePenalInterestType = PreClosurePenalInterestOnType.fromInt(this.preClosurePenalInterestOnType); .fromInt(this.preClosurePenalInterestOnType);
return DepositPreClosureDetail.createFrom(interestFreePeriodApplicable, interestFreeFromPeriod, interestFreeToPeriod, periodType, preClosurePenalApplicable, preClosurePenalInterest, preClosurePenalInterestType); return DepositPreClosureDetail.createFrom(preClosurePenalApplicable, preClosurePenalInterest, preClosurePenalInterestType);
} }
} }
@@ -13,7 +13,6 @@ import javax.persistence.Column;
import javax.persistence.Embeddable; import javax.persistence.Embeddable;
import org.mifosplatform.infrastructure.core.api.JsonCommand; import org.mifosplatform.infrastructure.core.api.JsonCommand;
import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder;
/** /**
* RecurringDepositProductAmountDetails encapsulates all recurring Deposit * RecurringDepositProductAmountDetails encapsulates all recurring Deposit
@@ -47,7 +46,7 @@ public class DepositProductAmountDetails {
this.maxDepositAmount = maxDepositAmount; 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); final Map<String, Object> actualChanges = new LinkedHashMap<String, Object>(20);
@@ -5,15 +5,15 @@
*/ */
package org.mifosplatform.portfolio.savings.domain; 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.adjustAdvanceTowardsFuturePaymentsParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.RECURRING_DEPOSIT_PRODUCT_RESOURCE_NAME; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.allowWithdrawalParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.chartsParamName; 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.inMultiplesOfDepositTermParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.inMultiplesOfDepositTermTypeIdParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.inMultiplesOfDepositTermTypeIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.interestFreeFromPeriodParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.isMandatoryDepositParamName;
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.maxDepositTermParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.maxDepositTermParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.maxDepositTermTypeIdParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.maxDepositTermTypeIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.minDepositTermParamName; 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.preClosurePenalApplicableParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.preClosurePenalInterestOnTypeIdParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.preClosurePenalInterestOnTypeIdParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.preClosurePenalInterestParamName; 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.chargesParamName;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.currencyCodeParamName; import static org.mifosplatform.portfolio.savings.SavingsApiConstants.currencyCodeParamName;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.descriptionParamName; 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 static org.mifosplatform.portfolio.savings.SavingsApiConstants.shortNameParamName;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Set; import java.util.Set;
import org.mifosplatform.accounting.common.AccountingRuleType; import org.mifosplatform.accounting.common.AccountingRuleType;
import org.mifosplatform.infrastructure.core.api.JsonCommand; 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.organisation.monetary.domain.MonetaryCurrency;
import org.mifosplatform.portfolio.charge.domain.Charge; import org.mifosplatform.portfolio.charge.domain.Charge;
import org.mifosplatform.portfolio.charge.domain.ChargeRepositoryWrapper; import org.mifosplatform.portfolio.charge.domain.ChargeRepositoryWrapper;
import org.mifosplatform.portfolio.charge.exception.ChargeCannotBeAppliedToException; 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.domain.InterestRateChart;
import org.mifosplatform.portfolio.interestratechart.service.InterestRateChartAssembler; import org.mifosplatform.portfolio.interestratechart.service.InterestRateChartAssembler;
import org.mifosplatform.portfolio.loanproduct.exception.InvalidCurrencyException; import org.mifosplatform.portfolio.loanproduct.exception.InvalidCurrencyException;
import org.mifosplatform.portfolio.savings.PreClosurePenalInterestOnType; import org.mifosplatform.portfolio.savings.PreClosurePenalInterestOnType;
import org.mifosplatform.portfolio.savings.RecurringDepositType;
import org.mifosplatform.portfolio.savings.SavingsCompoundingInterestPeriodType; import org.mifosplatform.portfolio.savings.SavingsCompoundingInterestPeriodType;
import org.mifosplatform.portfolio.savings.SavingsInterestCalculationDaysInYearType; import org.mifosplatform.portfolio.savings.SavingsInterestCalculationDaysInYearType;
import org.mifosplatform.portfolio.savings.SavingsInterestCalculationType; import org.mifosplatform.portfolio.savings.SavingsInterestCalculationType;
import org.mifosplatform.portfolio.savings.SavingsPeriodFrequencyType; import org.mifosplatform.portfolio.savings.SavingsPeriodFrequencyType;
import org.mifosplatform.portfolio.savings.SavingsPostingInterestPeriodType; import org.mifosplatform.portfolio.savings.SavingsPostingInterestPeriodType;
import org.springframework.beans.factory.annotation.Autowired; 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.JsonArray;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
@Component @Service
public class DepositProductAssembler { public class DepositProductAssembler {
private final ChargeRepositoryWrapper chargeRepository; private final ChargeRepositoryWrapper chargeRepository;
@@ -131,7 +118,7 @@ public class DepositProductAssembler {
if (lockinPeriodFrequencyTypeValue != null) { if (lockinPeriodFrequencyTypeValue != null) {
lockinPeriodFrequencyType = SavingsPeriodFrequencyType.fromInt(lockinPeriodFrequencyTypeValue); lockinPeriodFrequencyType = SavingsPeriodFrequencyType.fromInt(lockinPeriodFrequencyTypeValue);
} }
final AccountingRuleType accountingRuleType = AccountingRuleType.fromInt(command.integerValueOfParameterNamed("accountingRule")); final AccountingRuleType accountingRuleType = AccountingRuleType.fromInt(command.integerValueOfParameterNamed("accountingRule"));
final DepositPreClosureDetail preClosureDetail = this.assemblePreClosureDetail(command); final DepositPreClosureDetail preClosureDetail = this.assemblePreClosureDetail(command);
@@ -154,27 +141,11 @@ public class DepositProductAssembler {
// update product reference // update product reference
productTermAndPreClosure.updateProductReference(fixedDepositProduct); productTermAndPreClosure.updateProductReference(fixedDepositProduct);
validateFixedDepositProductDomainRules(fixedDepositProduct); fixedDepositProduct.validateDomainRules();
return fixedDepositProduct; 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) { public RecurringDepositProduct assembleRecurringDepositProduct(final JsonCommand command) {
final String name = command.stringValueOfParameterNamed(nameParamName); final String name = command.stringValueOfParameterNamed(nameParamName);
@@ -212,14 +183,14 @@ public class DepositProductAssembler {
if (interestCalculationDaysInYearTypeValue != null) { if (interestCalculationDaysInYearTypeValue != null) {
interestCalculationDaysInYearType = SavingsInterestCalculationDaysInYearType.fromInt(interestCalculationDaysInYearTypeValue); interestCalculationDaysInYearType = SavingsInterestCalculationDaysInYearType.fromInt(interestCalculationDaysInYearTypeValue);
} }
final Integer lockinPeriodFrequency = command.integerValueOfParameterNamedDefaultToNullIfZero(lockinPeriodFrequencyParamName); final Integer lockinPeriodFrequency = command.integerValueOfParameterNamedDefaultToNullIfZero(lockinPeriodFrequencyParamName);
SavingsPeriodFrequencyType lockinPeriodFrequencyType = null; SavingsPeriodFrequencyType lockinPeriodFrequencyType = null;
final Integer lockinPeriodFrequencyTypeValue = command.integerValueOfParameterNamed(lockinPeriodFrequencyTypeParamName); final Integer lockinPeriodFrequencyTypeValue = command.integerValueOfParameterNamed(lockinPeriodFrequencyTypeParamName);
if (lockinPeriodFrequencyTypeValue != null) { if (lockinPeriodFrequencyTypeValue != null) {
lockinPeriodFrequencyType = SavingsPeriodFrequencyType.fromInt(lockinPeriodFrequencyTypeValue); lockinPeriodFrequencyType = SavingsPeriodFrequencyType.fromInt(lockinPeriodFrequencyTypeValue);
} }
final AccountingRuleType accountingRuleType = AccountingRuleType.fromInt(command.integerValueOfParameterNamed("accountingRule")); final AccountingRuleType accountingRuleType = AccountingRuleType.fromInt(command.integerValueOfParameterNamed("accountingRule"));
final DepositPreClosureDetail preClosureDetail = this.assemblePreClosureDetail(command); final DepositPreClosureDetail preClosureDetail = this.assemblePreClosureDetail(command);
@@ -248,46 +219,13 @@ public class DepositProductAssembler {
productTermAndPreClosure.updateProductReference(recurringDepositProduct); productTermAndPreClosure.updateProductReference(recurringDepositProduct);
productRecurringDetail.updateProductReference(recurringDepositProduct); productRecurringDetail.updateProductReference(recurringDepositProduct);
validateRecurringDepositProductDomainRules(recurringDepositProduct); recurringDepositProduct.validateDomainRules();
return recurringDepositProduct; 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) { 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; boolean preClosurePenalApplicable = false;
BigDecimal preClosurePenalInterest = null; BigDecimal preClosurePenalInterest = null;
PreClosurePenalInterestOnType preClosurePenalInterestType = null; PreClosurePenalInterestOnType preClosurePenalInterestType = null;
@@ -303,53 +241,13 @@ public class DepositProductAssembler {
} }
} }
DepositPreClosureDetail preClosureDetail = DepositPreClosureDetail.createFrom(interestFreePeriodApplicable, interestFreeFromPeriod, DepositPreClosureDetail preClosureDetail = DepositPreClosureDetail.createFrom(preClosurePenalApplicable, preClosurePenalInterest,
interestFreeToPeriod, interestFreePeriodFrequencyType, preClosurePenalApplicable, preClosurePenalInterest,
preClosurePenalInterestType); preClosurePenalInterestType);
return preClosureDetail; return preClosureDetail;
} }
public DepositPreClosureDetail assemblePreClosureDetail(final JsonCommand command, DepositPreClosureDetail produPreClosureDetail) { 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; boolean preClosurePenalApplicable = false;
BigDecimal preClosurePenalInterest = null; BigDecimal preClosurePenalInterest = null;
PreClosurePenalInterestOnType preClosurePenalInterestType = null; PreClosurePenalInterestOnType preClosurePenalInterestType = null;
@@ -378,9 +276,8 @@ public class DepositProductAssembler {
preClosurePenalInterestType = preClosurePenalInterestOnTypeId == null ? null : PreClosurePenalInterestOnType preClosurePenalInterestType = preClosurePenalInterestOnTypeId == null ? null : PreClosurePenalInterestOnType
.fromInt(preClosurePenalInterestOnTypeId); .fromInt(preClosurePenalInterestOnTypeId);
DepositPreClosureDetail preClosureDetail1 = DepositPreClosureDetail.createFrom(interestFreePeriodApplicable, DepositPreClosureDetail preClosureDetail1 = DepositPreClosureDetail.createFrom(preClosurePenalApplicable, preClosurePenalInterest,
interestFreeFromPeriod, interestFreeToPeriod, interestFreePeriodFrequencyType, preClosurePenalApplicable, preClosurePenalInterestType);
preClosurePenalInterest, preClosurePenalInterestType);
return preClosureDetail1; return preClosureDetail1;
} }
@@ -468,22 +365,17 @@ public class DepositProductAssembler {
public DepositRecurringDetail assembleRecurringDetail(final JsonCommand command) { public DepositRecurringDetail assembleRecurringDetail(final JsonCommand command) {
RecurringDepositType recurringDepositType = null; Boolean isMandatoryDeposit = command.booleanObjectValueOfParameterNamed(isMandatoryDepositParamName);
final Integer recurringDepositTypeValue = command.integerValueOfParameterNamed(recurringDepositTypeIdParamName); Boolean allowWithdrawal = command.booleanObjectValueOfParameterNamed(allowWithdrawalParamName);
if (recurringDepositTypeValue != null) { Boolean adjustAdvanceTowardsFuturePayments = command
recurringDepositType = RecurringDepositType.fromInt(recurringDepositTypeValue); .booleanObjectValueOfParameterNamed(adjustAdvanceTowardsFuturePaymentsParamName);
}
SavingsPeriodFrequencyType recurringDepositFrequencyType = null; if (isMandatoryDeposit == null) isMandatoryDeposit = false;
final Integer recurringDepositFrequencyTypeValue = command.integerValueOfParameterNamed(recurringDepositFrequencyTypeIdParamName); if (allowWithdrawal == null) allowWithdrawal = false;
if (recurringDepositFrequencyTypeValue != null) { if (adjustAdvanceTowardsFuturePayments == null) adjustAdvanceTowardsFuturePayments = false;
recurringDepositFrequencyType = SavingsPeriodFrequencyType.fromInt(recurringDepositFrequencyTypeValue);
}
final Integer recurringDepositFrequency = command.integerValueOfParameterNamed(recurringDepositFrequencyParamName); final DepositRecurringDetail depositRecurringDetail = DepositRecurringDetail.createFrom(isMandatoryDeposit, allowWithdrawal,
adjustAdvanceTowardsFuturePayments);
final DepositRecurringDetail depositRecurringDetail = DepositRecurringDetail.createFrom(recurringDepositType,
recurringDepositFrequency, recurringDepositFrequencyType);
return depositRecurringDetail; return depositRecurringDetail;
} }
@@ -538,29 +430,25 @@ public class DepositProductAssembler {
return charts; return charts;
} }
private void throwExceptionIfValidationWarningsExist(final List<ApiParameterError> dataValidationErrors) {
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
}
public DepositProductAmountDetails assembleDepositAmountDetails(final JsonCommand command) { public DepositProductAmountDetails assembleDepositAmountDetails(final JsonCommand command) {
BigDecimal minDepositAmount = null; BigDecimal minDepositAmount = null;
if(command.parameterExists(depositMinAmountParamName)) { if (command.parameterExists(depositMinAmountParamName)) {
minDepositAmount = command.bigDecimalValueOfParameterNamed(depositMinAmountParamName); minDepositAmount = command.bigDecimalValueOfParameterNamed(depositMinAmountParamName);
} }
BigDecimal maxDepositAmount = null; BigDecimal maxDepositAmount = null;
if(command.parameterExists(depositMaxAmountParamName)) { if (command.parameterExists(depositMaxAmountParamName)) {
maxDepositAmount = command.bigDecimalValueOfParameterNamed(depositMaxAmountParamName); maxDepositAmount = command.bigDecimalValueOfParameterNamed(depositMaxAmountParamName);
} }
BigDecimal depositAmount = null; BigDecimal depositAmount = null;
if(command.parameterExists(depositAmountParamName)) { if (command.parameterExists(depositAmountParamName)) {
depositAmount = command.bigDecimalValueOfParameterNamed(depositAmountParamName); depositAmount = command.bigDecimalValueOfParameterNamed(depositAmountParamName);
} }
final DepositProductAmountDetails depositRecurringDetail = new DepositProductAmountDetails(minDepositAmount, final DepositProductAmountDetails depositRecurringDetail = new DepositProductAmountDetails(minDepositAmount, depositAmount,
depositAmount, maxDepositAmount); maxDepositAmount);
return depositRecurringDetail; return depositRecurringDetail;
} }
@@ -15,7 +15,6 @@ import javax.persistence.OneToOne;
import javax.persistence.Table; import javax.persistence.Table;
import org.mifosplatform.infrastructure.core.api.JsonCommand; import org.mifosplatform.infrastructure.core.api.JsonCommand;
import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder;
import org.springframework.data.jpa.domain.AbstractPersistable; import org.springframework.data.jpa.domain.AbstractPersistable;
@Entity @Entity
@@ -43,10 +42,10 @@ public class DepositProductRecurringDetail extends AbstractPersistable<Long> {
this.product = (RecurringDepositProduct) product; 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); final Map<String, Object> actualChanges = new LinkedHashMap<String, Object>(10);
if (this.recurringDetail != null) { if (this.recurringDetail != null) {
actualChanges.putAll(this.recurringDetail.update(command, baseDataValidator)); actualChanges.putAll(this.recurringDetail.update(command));
} }
return actualChanges; return actualChanges;
} }
@@ -65,7 +65,7 @@ public class DepositProductTermAndPreClosure extends AbstractPersistable<Long> {
} }
if(this.depositProductAmountDetails != null) { if(this.depositProductAmountDetails != null) {
actualChanges.putAll(this.depositProductAmountDetails.update(command, baseDataValidator)); actualChanges.putAll(this.depositProductAmountDetails.update(command));
} }
return actualChanges; return actualChanges;
} }
@@ -5,9 +5,9 @@
*/ */
package org.mifosplatform.portfolio.savings.domain; package org.mifosplatform.portfolio.savings.domain;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.recurringDepositFrequencyParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.adjustAdvanceTowardsFuturePaymentsParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.recurringDepositFrequencyTypeIdParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.allowWithdrawalParamName;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.recurringDepositTypeIdParamName; import static org.mifosplatform.portfolio.savings.DepositsApiConstants.isMandatoryDepositParamName;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
@@ -16,10 +16,6 @@ import javax.persistence.Column;
import javax.persistence.Embeddable; import javax.persistence.Embeddable;
import org.mifosplatform.infrastructure.core.api.JsonCommand; 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 * DepositRecurringDetail encapsulates all the details of a
@@ -29,77 +25,68 @@ import org.mifosplatform.portfolio.savings.service.SavingsEnumerations;
@Embeddable @Embeddable
public class DepositRecurringDetail { public class DepositRecurringDetail {
@Column(name = "recurring_deposit_type_enum", nullable = true) @Column(name = "is_mandatory", nullable = true)
private Integer recurringDepositType; private boolean isMandatoryDeposit;
@Column(name = "recurring_deposit_frequency", nullable = true) @Column(name = "allow_withdrawal", nullable = true)
private Integer recurringDepositFrequency; private boolean allowWithdrawal;
@Column(name = "recurring_deposit_frequency_type_enum", nullable = true) @Column(name = "adjust_advance_towards_future_payments", nullable = true)
private Integer recurringDepositFrequencyType; private boolean adjustAdvanceTowardsFuturePayments;
public static DepositRecurringDetail createFrom(final RecurringDepositType recurringDepositType,
final Integer recurringDepositFrequency, final SavingsPeriodFrequencyType recurringDepositFrequencyType) {
return new DepositRecurringDetail(recurringDepositType, recurringDepositFrequency, recurringDepositFrequencyType);
}
protected DepositRecurringDetail() { protected DepositRecurringDetail() {
// //
} }
private DepositRecurringDetail(final RecurringDepositType recurringDepositType, final Integer recurringDepositFrequency, public static DepositRecurringDetail createFrom(final boolean isMandatoryDeposit, boolean allowWithdrawal,
final SavingsPeriodFrequencyType recurringDepositFrequencyType) { boolean adjustAdvanceTowardsFuturePayments) {
this.recurringDepositFrequency = recurringDepositFrequency;
this.recurringDepositFrequencyType = recurringDepositFrequencyType.getValue(); return new DepositRecurringDetail(isMandatoryDeposit, allowWithdrawal, adjustAdvanceTowardsFuturePayments);
this.recurringDepositType = recurringDepositType.getValue();
} }
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); final Map<String, Object> actualChanges = new LinkedHashMap<String, Object>(10);
if (command.isChangeInIntegerParameterNamed(recurringDepositFrequencyParamName, this.recurringDepositFrequency)) { if (command.isChangeInBooleanParameterNamed(isMandatoryDepositParamName, this.isMandatoryDeposit)) {
final Integer newValue = command.integerValueOfParameterNamed(recurringDepositFrequencyParamName); final boolean newValue = command.booleanObjectValueOfParameterNamed(isMandatoryDepositParamName);
actualChanges.put(recurringDepositFrequencyParamName, newValue); actualChanges.put(isMandatoryDepositParamName, newValue);
this.recurringDepositFrequency = newValue; this.isMandatoryDeposit = newValue;
} }
if (command.isChangeInIntegerParameterNamed(recurringDepositFrequencyTypeIdParamName, this.recurringDepositFrequencyType)) { if (command.isChangeInBooleanParameterNamed(allowWithdrawalParamName, this.allowWithdrawal)) {
final Integer newValue = command.integerValueOfParameterNamed(recurringDepositFrequencyTypeIdParamName); final boolean newValue = command.booleanObjectValueOfParameterNamed(allowWithdrawalParamName);
actualChanges.put(recurringDepositFrequencyTypeIdParamName, SavingsEnumerations.recurringDepositFrequencyType(newValue)); actualChanges.put(allowWithdrawalParamName, newValue);
this.recurringDepositFrequencyType = newValue; this.allowWithdrawal = newValue;
} }
if (command.isChangeInIntegerParameterNamed(recurringDepositTypeIdParamName, this.recurringDepositType)) { if (command.isChangeInBooleanParameterNamed(adjustAdvanceTowardsFuturePaymentsParamName, this.adjustAdvanceTowardsFuturePayments)) {
final Integer newValue = command.integerValueOfParameterNamed(recurringDepositTypeIdParamName); final boolean newValue = command.booleanObjectValueOfParameterNamed(adjustAdvanceTowardsFuturePaymentsParamName);
actualChanges.put(recurringDepositTypeIdParamName, SavingsEnumerations.recurringDepositType(newValue)); actualChanges.put(adjustAdvanceTowardsFuturePaymentsParamName, newValue);
this.recurringDepositType = newValue; this.adjustAdvanceTowardsFuturePayments = newValue;
} }
return actualChanges; return actualChanges;
} }
public Integer recurringDepositType() { public boolean isMandatoryDeposit() {
return this.recurringDepositType; return this.isMandatoryDeposit;
} }
public Integer recurringDepositFrequency() { public boolean allowWithdrawal() {
return this.recurringDepositFrequency; return this.allowWithdrawal;
} }
public Integer recurringDepositFrequencyTypeId() { public boolean adjustAdvanceTowardsFuturePayments() {
return this.recurringDepositFrequencyType; return this.adjustAdvanceTowardsFuturePayments;
}
public SavingsPeriodFrequencyType recurringDepositFrequencyType() {
return SavingsPeriodFrequencyType.fromInt(this.recurringDepositFrequencyType);
} }
public DepositRecurringDetail copy() { public DepositRecurringDetail copy() {
final RecurringDepositType recurringDepositType = RecurringDepositType.fromInt(this.recurringDepositType); return DepositRecurringDetail.createFrom(this.isMandatoryDeposit, this.allowWithdrawal, this.adjustAdvanceTowardsFuturePayments);
final Integer recurringDepositFrequency = this.recurringDepositFrequency;
final SavingsPeriodFrequencyType recurringDepositFrequencyType = SavingsPeriodFrequencyType
.fromInt(this.recurringDepositFrequencyType);
return DepositRecurringDetail.createFrom(recurringDepositType, recurringDepositFrequency, recurringDepositFrequencyType);
} }
} }
@@ -164,21 +164,27 @@ public class DepositTermDetail {
public boolean isValidInMultiplesOfPeriod(final Integer depositPeriod, final SavingsPeriodFrequencyType depositPeriodFrequencyType) { public boolean isValidInMultiplesOfPeriod(final Integer depositPeriod, final SavingsPeriodFrequencyType depositPeriodFrequencyType) {
boolean isValidInMultiplesOfPeriod = true;
final Integer depositPeriodInDays = this.convertToSafeDays(depositPeriod, depositPeriodFrequencyType); final Integer depositPeriodInDays = this.convertToSafeDays(depositPeriod, depositPeriodFrequencyType);
final Integer inMultiplesOfInDays = this.convertToSafeDays(this.inMultiplesOfDepositTerm(), if (this.inMultiplesOfDepositTerm() != null) {
SavingsPeriodFrequencyType.fromInt(this.inMultiplesOfDepositTermType())); final Integer inMultiplesOfInDays = this.convertToSafeDays(this.inMultiplesOfDepositTerm(),
final Integer minDepositInDays = this.convertToSafeDays(minDepositTerm, SavingsPeriodFrequencyType.fromInt(minDepositTermType)); 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) { private boolean isEqualOrGreaterThanMin(LocalDate depositStartDate, LocalDate depositEndDate) {
if (minDepositTerm() == null) return true;
final SavingsPeriodFrequencyType periodFrequencyType = SavingsPeriodFrequencyType.fromInt(this.minDepositTermType()); final SavingsPeriodFrequencyType periodFrequencyType = SavingsPeriodFrequencyType.fromInt(this.minDepositTermType());
final Integer depositPeriod = depositPeriod(depositStartDate, depositEndDate, periodFrequencyType); final Integer depositPeriod = depositPeriod(depositStartDate, depositEndDate, periodFrequencyType);
return minDepositTerm() == null || depositPeriod.compareTo(minDepositTerm()) >= 0; return minDepositTerm() == null || depositPeriod.compareTo(minDepositTerm()) >= 0;
} }
private boolean isEqualOrLessThanMax(LocalDate depositStartDate, LocalDate depositEndDate) { private boolean isEqualOrLessThanMax(LocalDate depositStartDate, LocalDate depositEndDate) {
if (maxDepositTerm() == null) return true;
final SavingsPeriodFrequencyType periodFrequencyType = SavingsPeriodFrequencyType.fromInt(this.maxDepositTermType()); final SavingsPeriodFrequencyType periodFrequencyType = SavingsPeriodFrequencyType.fromInt(this.maxDepositTermType());
final Integer depositPeriod = depositPeriod(depositStartDate, depositEndDate, periodFrequencyType); final Integer depositPeriod = depositPeriod(depositStartDate, depositEndDate, periodFrequencyType);
return maxDepositTerm() == null || depositPeriod.compareTo(maxDepositTerm()) <= 0; 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.accountdetails.domain.AccountType;
import org.mifosplatform.portfolio.client.domain.Client; import org.mifosplatform.portfolio.client.domain.Client;
import org.mifosplatform.portfolio.group.domain.Group; 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.domain.InterestRateChart;
import org.mifosplatform.portfolio.interestratechart.service.InterestRateChartAssembler; 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.DepositAccountOnClosureType;
import org.mifosplatform.portfolio.savings.DepositsApiConstants; import org.mifosplatform.portfolio.savings.DepositsApiConstants;
import org.mifosplatform.portfolio.savings.PreClosurePenalInterestOnType; import org.mifosplatform.portfolio.savings.PreClosurePenalInterestOnType;
@@ -125,8 +125,8 @@ public class FixedDepositAccount extends SavingsAccount {
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors) final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
.resource(FIXED_DEPOSIT_ACCOUNT_RESOURCE_NAME + SavingsApiConstants.modifyApplicationAction); .resource(FIXED_DEPOSIT_ACCOUNT_RESOURCE_NAME + SavingsApiConstants.modifyApplicationAction);
super.modifyApplication(command, actualChanges, baseDataValidator); super.modifyApplication(command, actualChanges, baseDataValidator);
final Map<String, Object> termAndPreClosureChanges = accountTermAndPreClosure.update(command, baseDataValidator);
accountTermAndPreClosure.update(command, baseDataValidator); actualChanges.putAll(termAndPreClosureChanges);
validateDomainRules(baseDataValidator); validateDomainRules(baseDataValidator);
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); } if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
} }
@@ -134,33 +134,38 @@ public class FixedDepositAccount extends SavingsAccount {
@Override @Override
protected BigDecimal getEffectiveInterestRateAsFraction(final MathContext mc, final LocalDate interestPostingUpToDate) { protected BigDecimal getEffectiveInterestRateAsFraction(final MathContext mc, final LocalDate interestPostingUpToDate) {
final boolean isPreMatureClosure = SavingsAccountStatusType.fromInt(this.status).isPreMatureClosure(); // default it to nominalAnnualInterst rate. interest chart overrrides
boolean applyPreMaturePenalty = false; // this value.
BigDecimal penalInterest = BigDecimal.ZERO; BigDecimal applicableInterestRate = this.nominalAnnualInterestRate;
LocalDate depositCloseDate = calculateMaturityDate(); if (this.chart != null) {
if (isPreMatureClosure) { final boolean isPreMatureClosure = SavingsAccountStatusType.fromInt(this.status).isPreMatureClosure();
if (this.accountTermAndPreClosure.isPreClosurePenalApplicable()) { boolean applyPreMaturePenalty = false;
applyPreMaturePenalty = true; BigDecimal penalInterest = BigDecimal.ZERO;
penalInterest = this.accountTermAndPreClosure.depositPreClosureDetail().preClosurePenalInterest(); LocalDate depositCloseDate = calculateMaturityDate();
final PreClosurePenalInterestOnType preClosurePenalInterestOnType = this.accountTermAndPreClosure.depositPreClosureDetail() if (isPreMatureClosure) {
.preClosurePenalInterestOnType(); if (this.accountTermAndPreClosure.isPreClosurePenalApplicable()) {
if (preClosurePenalInterestOnType.isWholeTerm()) { applyPreMaturePenalty = true;
depositCloseDate = interestCalculatedUpto(); penalInterest = this.accountTermAndPreClosure.depositPreClosureDetail().preClosurePenalInterest();
} else if (preClosurePenalInterestOnType.isTillPrematureWithdrawal()) { final PreClosurePenalInterestOnType preClosurePenalInterestOnType = this.accountTermAndPreClosure
depositCloseDate = interestPostingUpToDate; .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; this.nominalAnnualInterestRate = applicableInterestRate;
return applicableInterestRate.divide(BigDecimal.valueOf(100l), mc); return applicableInterestRate.divide(BigDecimal.valueOf(100l), mc);
@@ -177,10 +182,23 @@ public class FixedDepositAccount extends SavingsAccount {
updateMaturityDateAndAmount(mc, allTransactions); updateMaturityDateAndAmount(mc, allTransactions);
} }
public void updateMaturityDateAndAmount(final MathContext mc) {
updateMaturityDateAndAmount(mc, retreiveOrderedNonInterestPostingTransactions());
}
public void updateMaturityDateAndAmount(final MathContext mc, final List<SavingsAccountTransaction> transactions) { public void updateMaturityDateAndAmount(final MathContext mc, final List<SavingsAccountTransaction> transactions) {
final LocalDate maturityDate = calculateMaturityDate(); final LocalDate maturityDate = calculateMaturityDate();
final LocalDate interestCalculationUpto = maturityDate.minusDays(1); 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); 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()); Money totalInterestPayable = Money.zero(getCurrency());
for (PostingPeriod postingPeriod : postingPeriods) { for (PostingPeriod postingPeriod : postingPeriods) {
totalInterestPayable = totalInterestPayable.plus(postingPeriod.getInterestEarned()); totalInterestPayable = totalInterestPayable.plus(postingPeriod.getInterestEarned());
@@ -206,7 +224,7 @@ public class FixedDepositAccount extends SavingsAccount {
if (!this.maturityDate().isAfter(todayDate)) { if (!this.maturityDate().isAfter(todayDate)) {
// update account status // update account status
this.status = SavingsAccountStatusType.MATURED.getValue(); 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, private List<PostingPeriod> calculateInterestPayable(final MathContext mc, final LocalDate maturityDate,
final List<SavingsAccountTransaction> transactions) { 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 SavingsPostingInterestPeriodType postingPeriodType = SavingsPostingInterestPeriodType.fromInt(this.interestPostingPeriodType);
final SavingsCompoundingInterestPeriodType compoundingPeriodType = SavingsCompoundingInterestPeriodType final SavingsCompoundingInterestPeriodType compoundingPeriodType = SavingsCompoundingInterestPeriodType
@@ -279,8 +292,8 @@ public class FixedDepositAccount extends SavingsAccount {
return allPostingPeriods; return allPostingPeriods;
} }
public SavingsAccountTransaction prematureClosure(final AppUser currentUser, final JsonCommand command, public void prematureClosure(final AppUser currentUser, final JsonCommand command,
final LocalDate tenantsTodayDate, final PaymentDetail paymentDetail, final Map<String, Object> actualChanges) { final LocalDate tenantsTodayDate, final Map<String, Object> actualChanges) {
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>(); final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors) final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
@@ -302,6 +315,12 @@ public class FixedDepositAccount extends SavingsAccount {
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); } 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())) { if (closedDate.isAfter(maturityDate())) {
baseDataValidator.reset().parameter(SavingsApiConstants.closedOnDateParamName).value(closedDate) baseDataValidator.reset().parameter(SavingsApiConstants.closedOnDateParamName).value(closedDate)
.failWithCode("must.be.before.maturity.date"); .failWithCode("must.be.before.maturity.date");
@@ -329,15 +348,14 @@ public class FixedDepositAccount extends SavingsAccount {
final Integer onAccountClosureId = command.integerValueOfParameterNamed(onAccountClosureIdParamName); final Integer onAccountClosureId = command.integerValueOfParameterNamed(onAccountClosureIdParamName);
final DepositAccountOnClosureType onClosureType = DepositAccountOnClosureType.fromInt(onAccountClosureId); final DepositAccountOnClosureType onClosureType = DepositAccountOnClosureType.fromInt(onAccountClosureId);
this.accountTermAndPreClosure.updateOnAccountClosureStatus(onClosureType); 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 Money transactionAmountMoney = Money.of(this.currency, this.getAccountBalance());
final SavingsAccountTransaction withdraw = SavingsAccountTransaction.withdrawal(this, office(), paymentDetail, closedDate, final SavingsAccountTransaction withdraw = SavingsAccountTransaction.withdrawal(this, office(), paymentDetail, closedDate,
transactionAmountMoney, new Date()); transactionAmountMoney, new Date());
this.transactions.add(withdraw); this.transactions.add(withdraw);
*/
actualChanges.put(SavingsApiConstants.statusParamName, SavingsEnumerations.status(this.status)); actualChanges.put(SavingsApiConstants.statusParamName, SavingsEnumerations.status(this.status));
actualChanges.put(SavingsApiConstants.localeParamName, command.locale()); actualChanges.put(SavingsApiConstants.localeParamName, command.locale());
actualChanges.put(SavingsApiConstants.dateFormatParamName, command.dateFormat()); actualChanges.put(SavingsApiConstants.dateFormatParamName, command.dateFormat());
@@ -349,8 +367,7 @@ public class FixedDepositAccount extends SavingsAccount {
this.withdrawnBy = null; this.withdrawnBy = null;
this.closedOnDate = closedDate.toDate(); this.closedOnDate = closedDate.toDate();
this.closedBy = currentUser; this.closedBy = currentUser;
this.summary.updateSummary(this.currency, this.savingsAccountTransactionSummaryWrapper, this.transactions);
return withdraw;
} }
@Override @Override
@@ -358,8 +375,8 @@ public class FixedDepositAccount extends SavingsAccount {
return Money.of(this.currency, this.accountTermAndPreClosure.depositAmount()); return Money.of(this.currency, this.accountTermAndPreClosure.depositAmount());
} }
public SavingsAccountTransaction close(final AppUser currentUser, final JsonCommand command, final LocalDate tenantsTodayDate, public void close(final AppUser currentUser, final JsonCommand command, final LocalDate tenantsTodayDate,
final PaymentDetail paymentDetail, final Map<String, Object> actualChanges) { final Map<String, Object> actualChanges) {
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>(); final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors) final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
@@ -390,6 +407,7 @@ public class FixedDepositAccount extends SavingsAccount {
.failWithCode("cannot.be.a.future.date"); .failWithCode("cannot.be.a.future.date");
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); } if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
} }
final List<SavingsAccountTransaction> savingsAccountTransactions = retreiveListOfTransactions(); final List<SavingsAccountTransaction> savingsAccountTransactions = retreiveListOfTransactions();
if (savingsAccountTransactions.size() > 0) { if (savingsAccountTransactions.size() > 0) {
final SavingsAccountTransaction accountTransaction = savingsAccountTransactions.get(savingsAccountTransactions.size() - 1); final SavingsAccountTransaction accountTransaction = savingsAccountTransactions.get(savingsAccountTransactions.size() - 1);
@@ -407,13 +425,14 @@ public class FixedDepositAccount extends SavingsAccount {
final DepositAccountOnClosureType onClosureType = DepositAccountOnClosureType.fromInt(onAccountClosureId); final DepositAccountOnClosureType onClosureType = DepositAccountOnClosureType.fromInt(onAccountClosureId);
this.accountTermAndPreClosure.updateOnAccountClosureStatus(onClosureType); this.accountTermAndPreClosure.updateOnAccountClosureStatus(onClosureType);
postMaturityInterest(maturityDate()); // // withdraw deposit amount before closing the account
// final Money transactionAmountMoney = Money.of(this.currency,
// withdraw deposit amount before closing the account // this.getAccountBalance());
final Money transactionAmountMoney = Money.of(this.currency, this.getAccountBalance()); // final SavingsAccountTransaction withdraw =
final SavingsAccountTransaction withdraw = SavingsAccountTransaction.withdrawal(this, office(), paymentDetail, closedDate, // SavingsAccountTransaction.withdrawal(this, office(), paymentDetail,
transactionAmountMoney, new Date()); // closedDate,
this.transactions.add(withdraw); // transactionAmountMoney, new Date());
// this.transactions.add(withdraw);
actualChanges.put(SavingsApiConstants.statusParamName, SavingsEnumerations.status(this.status)); actualChanges.put(SavingsApiConstants.statusParamName, SavingsEnumerations.status(this.status));
actualChanges.put(SavingsApiConstants.localeParamName, command.locale()); actualChanges.put(SavingsApiConstants.localeParamName, command.locale());
@@ -426,12 +445,12 @@ public class FixedDepositAccount extends SavingsAccount {
this.withdrawnBy = null; this.withdrawnBy = null;
this.closedOnDate = closedDate.toDate(); this.closedOnDate = closedDate.toDate();
this.closedBy = currentUser; this.closedBy = currentUser;
// this.summary.updateSummary(this.currency,
return withdraw; // this.savingsAccountTransactionSummaryWrapper, this.transactions);
} }
public void postMaturityInterest(final LocalDate interestPostingUpToDate) { public void postMaturityInterest() {
final LocalDate interestPostingUpToDate = maturityDate();
final MathContext mc = MathContext.DECIMAL64; final MathContext mc = MathContext.DECIMAL64;
final boolean isInterestTransfer = false; final boolean isInterestTransfer = false;
final List<PostingPeriod> postingPeriods = calculateInterestUsing(mc, interestPostingUpToDate, isInterestTransfer); final List<PostingPeriod> postingPeriods = calculateInterestUsing(mc, interestPostingUpToDate, isInterestTransfer);
@@ -569,10 +588,22 @@ public class FixedDepositAccount extends SavingsAccount {
return interestPostedToDate; return interestPostedToDate;
} }
public void updateMaturityDateAndAmountAfterAccountActivation(final MathContext mc) { @Override
List<SavingsAccountTransaction> allTransactions = new ArrayList<SavingsAccountTransaction>(); public Map<String, Object> activate(final AppUser currentUser, final JsonCommand command, final LocalDate tenantsTodayDate) {
allTransactions.addAll(retreiveOrderedNonInterestPostingTransactions()); final Map<String, Object> actualChanges = super.activate(currentUser, command, tenantsTodayDate);
updateMaturityDateAndAmount(mc, allTransactions);
// 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() { private LocalDate depositStartDate() {
@@ -629,9 +660,7 @@ public class FixedDepositAccount extends SavingsAccount {
} }
} }
if (this.chart == null) { if (this.chart != null) {
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode("no.valid.interest.rate.slab.available");
} else {
final LocalDate chartFromDate = this.chart.getFromDateAsLocalDate(); final LocalDate chartFromDate = this.chart.getFromDateAsLocalDate();
LocalDate chartEndDate = this.chart.getEndDateAsLocalDate(); LocalDate chartEndDate = this.chart.getEndDateAsLocalDate();
chartEndDate = chartEndDate == null ? DateUtils.getLocalDateOfTenant() : chartEndDate; chartEndDate = chartEndDate == null ? DateUtils.getLocalDateOfTenant() : chartEndDate;
@@ -640,7 +669,22 @@ public class FixedDepositAccount extends SavingsAccount {
if (!chartInterval.contains(accountSubmittedOrActivationDate())) { if (!chartInterval.contains(accountSubmittedOrActivationDate())) {
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode("no.valid.interest.rate.slab.available"); 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() { public boolean isReinvestOnClosure() {
@@ -651,9 +695,9 @@ public class FixedDepositAccount extends SavingsAccount {
return this.accountTermAndPreClosure.isTransferToSavingsOnClosure(); 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 SavingsProduct product = this.product;
final InterestRateChart productChart = product.applicableChart(getClosedOnDate()); final InterestRateChart productChart = product.applicableChart(getClosedOnDate());
final DepositAccountInterestRateChart newChart = DepositAccountInterestRateChart.from(productChart); 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.deleteParamName;
import static org.mifosplatform.portfolio.interestratechart.InterestRateChartApiConstants.idParamName; 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.FIXED_DEPOSIT_PRODUCT_RESOURCE_NAME;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.maxDepositTermParamName;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
@@ -72,16 +73,15 @@ public class FixedDepositProduct extends SavingsProduct {
final MonetaryCurrency currency, final BigDecimal interestRate, final MonetaryCurrency currency, final BigDecimal interestRate,
final SavingsCompoundingInterestPeriodType interestCompoundingPeriodType, final SavingsCompoundingInterestPeriodType interestCompoundingPeriodType,
final SavingsPostingInterestPeriodType interestPostingPeriodType, final SavingsInterestCalculationType interestCalculationType, final SavingsPostingInterestPeriodType interestPostingPeriodType, final SavingsInterestCalculationType interestCalculationType,
final SavingsInterestCalculationDaysInYearType interestCalculationDaysInYearType, final SavingsInterestCalculationDaysInYearType interestCalculationDaysInYearType, final Integer lockinPeriodFrequency,
final Integer lockinPeriodFrequency, final SavingsPeriodFrequencyType lockinPeriodFrequencyType, final SavingsPeriodFrequencyType lockinPeriodFrequencyType, final AccountingRuleType accountingRuleType,
final AccountingRuleType accountingRuleType, final Set<Charge> charges, final Set<Charge> charges, final DepositProductTermAndPreClosure productTermAndPreClosure, final Set<InterestRateChart> charts) {
final DepositProductTermAndPreClosure productTermAndPreClosure, final Set<InterestRateChart> charts) {
final BigDecimal minRequiredOpeningBalance = null; final BigDecimal minRequiredOpeningBalance = null;
final boolean withdrawalFeeApplicableForTransfer = false; final boolean withdrawalFeeApplicableForTransfer = false;
final boolean allowOverdraft = false; final boolean allowOverdraft = false;
final BigDecimal overdraftLimit = null; final BigDecimal overdraftLimit = null;
return new FixedDepositProduct(name, shortName, description, currency, interestRate, interestCompoundingPeriodType, return new FixedDepositProduct(name, shortName, description, currency, interestRate, interestCompoundingPeriodType,
interestPostingPeriodType, interestCalculationType, interestCalculationDaysInYearType, minRequiredOpeningBalance, interestPostingPeriodType, interestCalculationType, interestCalculationDaysInYearType, minRequiredOpeningBalance,
lockinPeriodFrequency, lockinPeriodFrequencyType, withdrawalFeeApplicableForTransfer, accountingRuleType, charges, lockinPeriodFrequency, lockinPeriodFrequencyType, withdrawalFeeApplicableForTransfer, accountingRuleType, charges,
@@ -135,6 +135,8 @@ public class FixedDepositProduct extends SavingsProduct {
actualChanges.putAll(this.update(command, baseDataValidator)); actualChanges.putAll(this.update(command, baseDataValidator));
validateDomainRules(baseDataValidator);
throwExceptionIfValidationWarningsExist(dataValidationErrors); throwExceptionIfValidationWarningsExist(dataValidationErrors);
return actualChanges; return actualChanges;
@@ -188,7 +190,7 @@ public class FixedDepositProduct extends SavingsProduct {
} }
} }
this.validateCharts(baseDataValidator); // this.validateCharts(baseDataValidator);
// add chart changes to actual changes list. // add chart changes to actual changes list.
if (!chartsChanges.isEmpty()) { if (!chartsChanges.isEmpty()) {
@@ -249,7 +251,7 @@ public class FixedDepositProduct extends SavingsProduct {
InterestRateChart applicableChart = null; InterestRateChart applicableChart = null;
if (this.charts != null) { if (this.charts != null) {
for (InterestRateChart chart : this.charts) { for (InterestRateChart chart : this.charts) {
if(chart.isApplicableChartFor(target)){ if (chart.isApplicableChartFor(target)) {
applicableChart = chart; applicableChart = chart;
break; break;
} }
@@ -261,37 +263,70 @@ public class FixedDepositProduct extends SavingsProduct {
public DepositProductTermAndPreClosure depositProductTermAndPreClosure() { public DepositProductTermAndPreClosure depositProductTermAndPreClosure() {
return this.productTermAndPreClosure; return this.productTermAndPreClosure;
} }
@SuppressWarnings("unchecked") public void validateInterestPostingAndCompoundingPeriodTypes(final DataValidatorBuilder baseDataValidator) {
public void validateInterestPostingAndCompoundingPeriodTypes(final DataValidatorBuilder baseDataValidator) { Map<SavingsPostingInterestPeriodType, List<SavingsCompoundingInterestPeriodType>> postingtoCompoundMap = new HashMap<SavingsPostingInterestPeriodType, List<SavingsCompoundingInterestPeriodType>>();
Map<SavingsPostingInterestPeriodType, List<SavingsCompoundingInterestPeriodType>> postingtoCompoundMap = postingtoCompoundMap.put(
new HashMap<SavingsPostingInterestPeriodType, List<SavingsCompoundingInterestPeriodType>>(); SavingsPostingInterestPeriodType.MONTHLY,
postingtoCompoundMap.put(SavingsPostingInterestPeriodType.MONTHLY, Arrays.asList(new SavingsCompoundingInterestPeriodType[] { SavingsCompoundingInterestPeriodType.DAILY,
Arrays.asList(new SavingsCompoundingInterestPeriodType[]{SavingsCompoundingInterestPeriodType.DAILY,SavingsCompoundingInterestPeriodType.MONTHLY})); SavingsCompoundingInterestPeriodType.MONTHLY }));
postingtoCompoundMap.put(SavingsPostingInterestPeriodType.QUATERLY, postingtoCompoundMap.put(
Arrays.asList(new SavingsCompoundingInterestPeriodType[]{SavingsCompoundingInterestPeriodType.DAILY SavingsPostingInterestPeriodType.QUATERLY,
,SavingsCompoundingInterestPeriodType.MONTHLY,SavingsCompoundingInterestPeriodType.QUATERLY})); Arrays.asList(new SavingsCompoundingInterestPeriodType[] { SavingsCompoundingInterestPeriodType.DAILY,
SavingsCompoundingInterestPeriodType.MONTHLY, SavingsCompoundingInterestPeriodType.QUATERLY }));
postingtoCompoundMap.put(SavingsPostingInterestPeriodType.BIANNUAL,
Arrays.asList(new SavingsCompoundingInterestPeriodType[]{SavingsCompoundingInterestPeriodType.DAILY, postingtoCompoundMap.put(
SavingsCompoundingInterestPeriodType.MONTHLY,SavingsCompoundingInterestPeriodType.QUATERLY,SavingsCompoundingInterestPeriodType.BI_ANNUAL})); SavingsPostingInterestPeriodType.BIANNUAL,
Arrays.asList(new SavingsCompoundingInterestPeriodType[] { SavingsCompoundingInterestPeriodType.DAILY,
postingtoCompoundMap.put(SavingsPostingInterestPeriodType.ANNUAL, SavingsCompoundingInterestPeriodType.MONTHLY, SavingsCompoundingInterestPeriodType.QUATERLY,
Arrays.asList(new SavingsCompoundingInterestPeriodType[]{SavingsCompoundingInterestPeriodType.DAILY, SavingsCompoundingInterestPeriodType.BI_ANNUAL }));
SavingsCompoundingInterestPeriodType.MONTHLY,SavingsCompoundingInterestPeriodType.QUATERLY
,SavingsCompoundingInterestPeriodType.BI_ANNUAL,SavingsCompoundingInterestPeriodType.ANNUAL})); postingtoCompoundMap.put(
SavingsPostingInterestPeriodType.ANNUAL,
SavingsPostingInterestPeriodType savingsPostingInterestPeriodType = SavingsPostingInterestPeriodType.fromInt(interestPostingPeriodType); Arrays.asList(new SavingsCompoundingInterestPeriodType[] { SavingsCompoundingInterestPeriodType.DAILY,
SavingsCompoundingInterestPeriodType savingsCompoundingInterestPeriodType = SavingsCompoundingInterestPeriodType.fromInt(interestCompoundingPeriodType); SavingsCompoundingInterestPeriodType.MONTHLY, SavingsCompoundingInterestPeriodType.QUATERLY,
SavingsCompoundingInterestPeriodType.BI_ANNUAL, SavingsCompoundingInterestPeriodType.ANNUAL }));
if(postingtoCompoundMap.get(savingsPostingInterestPeriodType) == null ||
!postingtoCompoundMap.get(savingsPostingInterestPeriodType).contains(savingsCompoundingInterestPeriodType)) { SavingsPostingInterestPeriodType savingsPostingInterestPeriodType = SavingsPostingInterestPeriodType
baseDataValidator.failWithCodeNoParameterAddedToErrorCode("posting.period.type.is.less.than.compound.period.type", .fromInt(interestPostingPeriodType);
savingsPostingInterestPeriodType.name(),savingsCompoundingInterestPeriodType.name()); 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.DiscriminatorValue;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.FetchType; import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne; import javax.persistence.OneToOne;
import javax.persistence.Transient; import javax.persistence.Transient;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.joda.time.LocalDate; import org.joda.time.LocalDate;
import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter; 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.organisation.staff.domain.Staff;
import org.mifosplatform.portfolio.accountdetails.domain.AccountType; import org.mifosplatform.portfolio.accountdetails.domain.AccountType;
import org.mifosplatform.portfolio.client.domain.Client; 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.group.domain.Group;
import org.mifosplatform.portfolio.interestratechart.data.ClientIncentiveAttributes;
import org.mifosplatform.portfolio.interestratechart.domain.InterestRateChart; import org.mifosplatform.portfolio.interestratechart.domain.InterestRateChart;
import org.mifosplatform.portfolio.interestratechart.service.InterestRateChartAssembler; 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.DepositAccountOnClosureType;
import org.mifosplatform.portfolio.savings.DepositsApiConstants; import org.mifosplatform.portfolio.savings.DepositsApiConstants;
import org.mifosplatform.portfolio.savings.PreClosurePenalInterestOnType; import org.mifosplatform.portfolio.savings.PreClosurePenalInterestOnType;
@@ -70,10 +74,14 @@ public class RecurringDepositAccount extends SavingsAccount {
private DepositAccountRecurringDetail recurringDetail; private DepositAccountRecurringDetail recurringDetail;
@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "account") @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 @Transient
protected InterestRateChartAssembler chartAssembler; private InterestRateChartAssembler chartAssembler;
protected RecurringDepositAccount() { protected RecurringDepositAccount() {
// //
@@ -153,9 +161,9 @@ public class RecurringDepositAccount extends SavingsAccount {
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors) final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
.resource(RECURRING_DEPOSIT_ACCOUNT_RESOURCE_NAME + SavingsApiConstants.modifyApplicationAction); .resource(RECURRING_DEPOSIT_ACCOUNT_RESOURCE_NAME + SavingsApiConstants.modifyApplicationAction);
super.modifyApplication(command, actualChanges, baseDataValidator); super.modifyApplication(command, actualChanges, baseDataValidator);
final Map<String, Object> termAndPreClosureChanges = accountTermAndPreClosure.update(command, baseDataValidator);
accountTermAndPreClosure.update(command, baseDataValidator); actualChanges.putAll(termAndPreClosureChanges);
recurringDetail.update(command, baseDataValidator); recurringDetail.update(command);
validateDomainRules(baseDataValidator); validateDomainRules(baseDataValidator);
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); } if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
@@ -182,9 +190,10 @@ public class RecurringDepositAccount extends SavingsAccount {
} }
} }
final BigDecimal depositAmount = recurringDetail.recurringDepositAmount(); final BigDecimal depositAmount = accountTermAndPreClosure.depositAmount();
final ClientIncentiveAttributes incentiveAttributes = (this.client == null) ? null : this.client.incentiveAttributes();
BigDecimal applicableInterestRate = this.chart.getApplicableInterestRate(depositAmount, depositStartDate(), depositCloseDate); BigDecimal applicableInterestRate = this.chart.getApplicableInterestRate(depositAmount, depositStartDate(), depositCloseDate,
incentiveAttributes);
if (applyPreMaturePenalty) { if (applyPreMaturePenalty) {
applicableInterestRate = applicableInterestRate.subtract(penalInterest); applicableInterestRate = applicableInterestRate.subtract(penalInterest);
@@ -196,11 +205,10 @@ public class RecurringDepositAccount extends SavingsAccount {
return applicableInterestRate.divide(BigDecimal.valueOf(100l), mc); 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 maturityDate = calculateMaturityDate();
final LocalDate interestCalculationUpto = maturityDate.minusDays(1); final LocalDate interestCalculationUpto = maturityDate.minusDays(1);
final List<SavingsAccountTransaction> allTransactions = generateIncludingFutureTransactions(transactionStartDate, final List<SavingsAccountTransaction> allTransactions = generateIncludingFutureTransactions(interestCalculationUpto);
interestCalculationUpto);
final List<PostingPeriod> postingPeriods = calculateInterestPayable(mc, interestCalculationUpto, allTransactions); final List<PostingPeriod> postingPeriods = calculateInterestPayable(mc, interestCalculationUpto, allTransactions);
Money totalInterestPayable = Money.zero(getCurrency()); Money totalInterestPayable = Money.zero(getCurrency());
@@ -228,7 +236,7 @@ public class RecurringDepositAccount extends SavingsAccount {
if (!this.maturityDate().isAfter(todayDate)) { if (!this.maturityDate().isAfter(todayDate)) {
// update account status // update account status
this.status = SavingsAccountStatusType.MATURED.getValue(); this.status = SavingsAccountStatusType.MATURED.getValue();
postMaturityInterest(maturityDate()); postMaturityInterest();
} }
} }
@@ -301,19 +309,16 @@ public class RecurringDepositAccount extends SavingsAccount {
return allPostingPeriods; return allPostingPeriods;
} }
private List<SavingsAccountTransaction> generateIncludingFutureTransactions(final LocalDate transactionStartDate, private List<SavingsAccountTransaction> generateIncludingFutureTransactions(final LocalDate depositEndDate) {
final LocalDate depositEndDate) {
LocalDate transactionDate = transactionStartDate;
final BigDecimal recurringDepositAmount = this.recurringDetail.recurringDepositAmount();
List<SavingsAccountTransaction> allTransactions = new ArrayList<SavingsAccountTransaction>(); List<SavingsAccountTransaction> allTransactions = new ArrayList<SavingsAccountTransaction>();
// add existing transactions // add existing transactions
allTransactions.addAll(retreiveOrderedNonInterestPostingTransactions()); allTransactions.addAll(retreiveOrderedNonInterestPostingTransactions());
while (!transactionDate.isAfter(depositEndDate) && !transactionDate.isEqual(depositEndDate)) { for (RecurringDepositScheduleInstallment installment : depositScheduleInstallments()) {
final Money transactionAmountMoney = Money.of(this.currency, recurringDepositAmount); if (installment.isPrincipalNotCompleted(getCurrency())) {
final SavingsAccountTransaction transaction = SavingsAccountTransaction.deposit(null, office(), null, transactionDate, final SavingsAccountTransaction transaction = SavingsAccountTransaction.deposit(null, office(), null,
transactionAmountMoney, new Date()); installment.dueDate(), installment.getDepositAmountOutstanding(getCurrency()), installment.dueDate().toDate());
allTransactions.add(transaction); allTransactions.add(transaction);
transactionDate = nextDepositDate(transactionDate); }
} }
allTransactions = sortTransactions(allTransactions); allTransactions = sortTransactions(allTransactions);
@@ -338,7 +343,7 @@ public class RecurringDepositAccount extends SavingsAccount {
LocalDate endOfBalanceDate = depositEndDate; LocalDate endOfBalanceDate = depositEndDate;
for (int i = allTransactions.size() - 1; i >= 0; i--) { for (int i = allTransactions.size() - 1; i >= 0; i--) {
final SavingsAccountTransaction transaction = allTransactions.get(i); final SavingsAccountTransaction transaction = allTransactions.get(i);
if (transaction.isNotReversed()) { if (transaction.isNotReversed() && !transaction.isInterestPostingAndNotReversed()) {
transaction.updateCumulativeBalanceAndDates(this.currency, endOfBalanceDate); transaction.updateCumulativeBalanceAndDates(this.currency, endOfBalanceDate);
endOfBalanceDate = transaction.transactionLocalDate().minusDays(1); endOfBalanceDate = transaction.transactionLocalDate().minusDays(1);
} }
@@ -346,49 +351,37 @@ public class RecurringDepositAccount extends SavingsAccount {
return allTransactions; return allTransactions;
} }
public LocalDate nextDepositDate(LocalDate depositDate) { private LocalDate calculateNextDepositDate(final LocalDate lastDepositDate, final PeriodFrequencyType frequency,
final LocalDate depositStartDate = depositStartDate(); final int recurringEvery) {
LocalDate nextDepositDate = depositStartDate; LocalDate nextDepositDate = lastDepositDate;
while (!depositDate.isBefore(nextDepositDate)) {
nextDepositDate = calculateNextDepositDate(nextDepositDate);
}
return nextDepositDate;
}
private LocalDate calculateNextDepositDate(final LocalDate depositDate) { switch (frequency) {
final Integer depositFrequency = this.recurringDetail.recurringDepositFrequency();
LocalDate nextDepositDate = depositDate;
final SavingsPeriodFrequencyType depositFrequencyType = this.recurringDetail.recurringDepositFrequencyType();
switch (depositFrequencyType) {
case DAYS: case DAYS:
nextDepositDate = depositDate.plusDays(depositFrequency); nextDepositDate = lastDepositDate.plusDays(recurringEvery);
break; break;
case WEEKS: case WEEKS:
nextDepositDate = depositDate.plusWeeks(depositFrequency); nextDepositDate = lastDepositDate.plusWeeks(recurringEvery);
break; break;
case MONTHS: case MONTHS:
nextDepositDate = depositDate.plusMonths(depositFrequency); nextDepositDate = lastDepositDate.plusMonths(recurringEvery);
break; break;
case YEARS: case YEARS:
nextDepositDate = depositDate.plusYears(depositFrequency); nextDepositDate = lastDepositDate.plusYears(recurringEvery);
break; break;
case INVALID: case INVALID:
nextDepositDate = null;
break; break;
} }
return nextDepositDate; return nextDepositDate;
} }
public LocalDate depositStartDate() { public LocalDate depositStartDate() {
// TODO: Support to add deposit start date which can be a date after
// account activation date.
final LocalDate depositStartDate = accountTermAndPreClosure.getExpectedFirstDepositOnDate(); final LocalDate depositStartDate = accountTermAndPreClosure.getExpectedFirstDepositOnDate();
if (depositStartDate == null) return accountSubmittedOrActivationDate(); if (depositStartDate == null) return accountSubmittedOrActivationDate();
return depositStartDate; return depositStartDate;
} }
public SavingsAccountTransaction prematureClosure(final AppUser currentUser, final JsonCommand command, public void prematureClosure(final AppUser currentUser, final JsonCommand command, final LocalDate tenantsTodayDate,
final LocalDate tenantsTodayDate, final PaymentDetail paymentDetail, final Map<String, Object> actualChanges) { final Map<String, Object> actualChanges) {
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>(); final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors) final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
@@ -410,6 +403,12 @@ public class RecurringDepositAccount extends SavingsAccount {
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); } 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())) { if (closedDate.isAfter(maturityDate())) {
baseDataValidator.reset().parameter(SavingsApiConstants.closedOnDateParamName).value(closedDate) baseDataValidator.reset().parameter(SavingsApiConstants.closedOnDateParamName).value(closedDate)
.failWithCode("must.be.before.maturity.date"); .failWithCode("must.be.before.maturity.date");
@@ -421,6 +420,13 @@ public class RecurringDepositAccount extends SavingsAccount {
.failWithCode("cannot.be.a.future.date"); .failWithCode("cannot.be.a.future.date");
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); } 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(); final List<SavingsAccountTransaction> savingsAccountTransactions = retreiveListOfTransactions();
if (savingsAccountTransactions.size() > 0) { if (savingsAccountTransactions.size() > 0) {
final SavingsAccountTransaction accountTransaction = savingsAccountTransactions.get(savingsAccountTransactions.size() - 1); final SavingsAccountTransaction accountTransaction = savingsAccountTransactions.get(savingsAccountTransactions.size() - 1);
@@ -438,14 +444,14 @@ public class RecurringDepositAccount extends SavingsAccount {
final DepositAccountOnClosureType onClosureType = DepositAccountOnClosureType.fromInt(onAccountClosureId); final DepositAccountOnClosureType onClosureType = DepositAccountOnClosureType.fromInt(onAccountClosureId);
this.accountTermAndPreClosure.updateOnAccountClosureStatus(onClosureType); this.accountTermAndPreClosure.updateOnAccountClosureStatus(onClosureType);
postPreMaturityInterest(closedDate); /*
* // withdraw deposit amount before closing the account final Money
// withdraw deposit amount before closing the account * transactionAmountMoney = Money.of(this.currency,
final Money transactionAmountMoney = Money.of(this.currency, this.getAccountBalance()); * this.getAccountBalance()); final SavingsAccountTransaction withdraw =
final SavingsAccountTransaction withdraw = SavingsAccountTransaction.withdrawal(this, office(), paymentDetail, closedDate, * SavingsAccountTransaction.withdrawal(this, office(), paymentDetail,
transactionAmountMoney, new Date()); * closedDate, transactionAmountMoney, new Date());
this.transactions.add(withdraw); * this.transactions.add(withdraw);
*/
actualChanges.put(SavingsApiConstants.statusParamName, SavingsEnumerations.status(this.status)); actualChanges.put(SavingsApiConstants.statusParamName, SavingsEnumerations.status(this.status));
actualChanges.put(SavingsApiConstants.localeParamName, command.locale()); actualChanges.put(SavingsApiConstants.localeParamName, command.locale());
actualChanges.put(SavingsApiConstants.dateFormatParamName, command.dateFormat()); actualChanges.put(SavingsApiConstants.dateFormatParamName, command.dateFormat());
@@ -457,8 +463,8 @@ public class RecurringDepositAccount extends SavingsAccount {
this.withdrawnBy = null; this.withdrawnBy = null;
this.closedOnDate = closedDate.toDate(); this.closedOnDate = closedDate.toDate();
this.closedBy = currentUser; this.closedBy = currentUser;
this.summary.updateSummary(this.currency, this.savingsAccountTransactionSummaryWrapper, this.transactions);
return withdraw;
} }
@Override @Override
@@ -466,8 +472,21 @@ public class RecurringDepositAccount extends SavingsAccount {
return Money.of(this.currency, this.minRequiredOpeningBalance); return Money.of(this.currency, this.minRequiredOpeningBalance);
} }
public SavingsAccountTransaction close(final AppUser currentUser, final JsonCommand command, final LocalDate tenantsTodayDate, protected void processAccountUponActivation(final DateTimeFormatter fmt) {
final PaymentDetail paymentDetail, final Map<String, Object> actualChanges) { 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 List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors) final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
@@ -515,13 +534,14 @@ public class RecurringDepositAccount extends SavingsAccount {
final DepositAccountOnClosureType onClosureType = DepositAccountOnClosureType.fromInt(onAccountClosureId); final DepositAccountOnClosureType onClosureType = DepositAccountOnClosureType.fromInt(onAccountClosureId);
this.accountTermAndPreClosure.updateOnAccountClosureStatus(onClosureType); this.accountTermAndPreClosure.updateOnAccountClosureStatus(onClosureType);
postMaturityInterest(maturityDate()); /*
* // withdraw deposit amount before closing the account final Money
// withdraw deposit amount before closing the account * transactionAmountMoney = Money.of(this.currency,
final Money transactionAmountMoney = Money.of(this.currency, this.getAccountBalance()); * this.getAccountBalance()); final SavingsAccountTransaction withdraw =
final SavingsAccountTransaction withdraw = SavingsAccountTransaction.withdrawal(this, office(), paymentDetail, closedDate, * SavingsAccountTransaction.withdrawal(this, office(), paymentDetail,
transactionAmountMoney, new Date()); * closedDate, transactionAmountMoney, new Date());
this.transactions.add(withdraw); * this.transactions.add(withdraw);
*/
actualChanges.put(SavingsApiConstants.statusParamName, SavingsEnumerations.status(this.status)); actualChanges.put(SavingsApiConstants.statusParamName, SavingsEnumerations.status(this.status));
actualChanges.put(SavingsApiConstants.localeParamName, command.locale()); actualChanges.put(SavingsApiConstants.localeParamName, command.locale());
@@ -534,15 +554,14 @@ public class RecurringDepositAccount extends SavingsAccount {
this.withdrawnBy = null; this.withdrawnBy = null;
this.closedOnDate = closedDate.toDate(); this.closedOnDate = closedDate.toDate();
this.closedBy = currentUser; this.closedBy = currentUser;
this.summary.updateSummary(this.currency, this.savingsAccountTransactionSummaryWrapper, this.transactions);
return withdraw;
} }
public void postMaturityInterest(final LocalDate interestPostingUpToDate) { public void postMaturityInterest() {
final LocalDate interestPostingUpToDate = maturityDate();
final MathContext mc = MathContext.DECIMAL64; final MathContext mc = MathContext.DECIMAL64;
boolean isInterestTransfer = false; 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); Money interestPostedToDate = Money.zero(this.currency);
@@ -632,12 +651,12 @@ public class RecurringDepositAccount extends SavingsAccount {
final Money interestEarnedForPeriod = interestPostingPeriod.getInterestEarned(); final Money interestEarnedForPeriod = interestPostingPeriod.getInterestEarned();
interestOnMaturity = interestOnMaturity.plus(interestEarnedForPeriod); interestOnMaturity = interestOnMaturity.plus(interestEarnedForPeriod);
} }
this.summary.updateFromInterestPeriodSummaries(this.currency, postingPeriods);
return interestOnMaturity; return interestOnMaturity;
} }
@Override @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); final LocalDate interestPostingUpToDate = interestPostingUpToDate(postingDate);
super.postInterest(mc, interestPostingUpToDate, isInterestTransfer); super.postInterest(mc, interestPostingUpToDate, isInterestTransfer);
} }
@@ -657,10 +676,14 @@ public class RecurringDepositAccount extends SavingsAccount {
return interestPostingUpToDate; return interestPostingUpToDate;
} }
private LocalDate maturityDate() { public LocalDate maturityDate() {
return this.accountTermAndPreClosure.getMaturityLocalDate(); return this.accountTermAndPreClosure.getMaturityLocalDate();
} }
public BigDecimal maturityAmount() {
return this.accountTermAndPreClosure.maturityAmount();
}
private LocalDate interestCalculatedUpto() { private LocalDate interestCalculatedUpto() {
LocalDate uptoMaturityDate = calculateMaturityDate(); LocalDate uptoMaturityDate = calculateMaturityDate();
if (uptoMaturityDate != null) { if (uptoMaturityDate != null) {
@@ -683,15 +706,20 @@ public class RecurringDepositAccount extends SavingsAccount {
@Override @Override
public Map<String, Object> activate(final AppUser currentUser, final JsonCommand command, final LocalDate tenantsTodayDate) { 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 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 if (accountTermAndPreClosure.isAfterExpectedFirstDepositDate(getActivationLocalDate())) {
// recalculate the nextTransaction date 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; return actualChanges;
} }
@@ -722,7 +750,7 @@ public class RecurringDepositAccount extends SavingsAccount {
if (!isBeforeMaturityDate(transactionDTO.getTransactionDate())) { if (!isBeforeMaturityDate(transactionDTO.getTransactionDate())) {
final String defaultUserMessage = "Transaction is not allowed. Transaction date is on or after account maturity date."; final String defaultUserMessage = "Transaction is not allowed. Transaction date is on or after account maturity date.";
final ApiParameterError error = ApiParameterError.parameterError( 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())); "transactionDate", transactionDTO.getTransactionDate().toString(transactionDTO.getFormatter()));
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>(); final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
@@ -730,15 +758,96 @@ public class RecurringDepositAccount extends SavingsAccount {
throw new PlatformApiDataValidationException(dataValidationErrors); throw new PlatformApiDataValidationException(dataValidationErrors);
} }
final SavingsAccountTransaction transaction = super.deposit(transactionDTO);
final LocalDate nextTransactionDate = nextDepositDate(transactionDTO.getTransactionDate());
final MathContext mc = MathContext.DECIMAL64; if (isBeforeDepositStartDate(transactionDTO.getTransactionDate())) {
updateMaturityDateAndAmount(mc, nextTransactionDate); 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; 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() { private boolean isAccountMatured() {
return SavingsAccountStatusType.fromInt(status).isMatured(); return SavingsAccountStatusType.fromInt(status).isMatured();
} }
@@ -748,6 +857,10 @@ public class RecurringDepositAccount extends SavingsAccount {
return compareDate.isBefore(maturityDate); return compareDate.isBefore(maturityDate);
} }
private boolean isBeforeDepositStartDate(LocalDate compareDate) {
return compareDate.isBefore(depositStartDate());
}
public void validateDomainRules() { public void validateDomainRules() {
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>(); final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors) final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
@@ -760,17 +873,17 @@ public class RecurringDepositAccount extends SavingsAccount {
final boolean isMinTermGreaterThanMax = this.accountTermAndPreClosure.depositTermDetail() final boolean isMinTermGreaterThanMax = this.accountTermAndPreClosure.depositTermDetail()
.isMinDepositTermGreaterThanMaxDepositTerm(); .isMinDepositTermGreaterThanMaxDepositTerm();
final boolean isValidDepositPeriod = this.accountTermAndPreClosure.depositTermDetail().isDepositBetweenMinAndMax(
depositStartDate(), calculateMaturityDate());
// deposit period should be within min and max deposit term // deposit period should be within min and max deposit term
if (isMinTermGreaterThanMax) { if (isMinTermGreaterThanMax) {
final Integer maxTerm = this.accountTermAndPreClosure.depositTermDetail().maxDepositTerm(); final Integer maxTerm = this.accountTermAndPreClosure.depositTermDetail().maxDepositTerm();
baseDataValidator.reset().parameter(maxDepositTermParamName).value(maxTerm) baseDataValidator.reset().parameter(maxDepositTermParamName).value(maxTerm)
.failWithCodeNoParameterAddedToErrorCode("max.term.lessthan.min.term"); .failWithCodeNoParameterAddedToErrorCode("max.term.lessthan.min.term");
} }
final Integer depositPeriod = this.accountTermAndPreClosure.depositPeriod(); final Integer depositPeriod = this.accountTermAndPreClosure.depositPeriod();
final SavingsPeriodFrequencyType depositPeriodFrequencyType = this.accountTermAndPreClosure.depositPeriodFrequencyType(); final SavingsPeriodFrequencyType depositPeriodFrequencyType = this.accountTermAndPreClosure.depositPeriodFrequencyType();
final boolean isValidDepositPeriod = this.accountTermAndPreClosure.depositTermDetail().isDepositBetweenMinAndMax(
depositStartDate(), calculateMaturityDate());
if (!isValidDepositPeriod) { if (!isValidDepositPeriod) {
baseDataValidator.reset().parameter(depositPeriodParamName).value(depositPeriod) baseDataValidator.reset().parameter(depositPeriodParamName).value(depositPeriod)
.failWithCodeNoParameterAddedToErrorCode("deposit.period.not.between.min.and.max.deposit.term"); .failWithCodeNoParameterAddedToErrorCode("deposit.period.not.between.min.and.max.deposit.term");
@@ -785,30 +898,59 @@ public class RecurringDepositAccount extends SavingsAccount {
} }
} }
} }
if (isAccountLocked(calculateMaturityDate())) {
final LocalDate chartFromDate = this.chart.getFromDateAsLocalDate(); baseDataValidator
LocalDate chartEndDate = this.chart.getEndDateAsLocalDate(); .reset()
chartEndDate = chartEndDate == null ? DateUtils.getLocalDateOfTenant() : chartEndDate; .parameter(depositPeriodParamName)
.value(depositPeriod)
final LocalDateInterval chartInterval = LocalDateInterval.create(chartFromDate, chartEndDate); .failWithCode("deposit.period.must.be.greater.than.lock.in.period",
if (!chartInterval.contains(accountSubmittedOrActivationDate())) { "Deposit period must be greater than account lock-in period.");
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode("no.valid.interest.rate.slab.available.for.date.range");
} }
final boolean firstDepositDateBeforeMaturityAndOnOrAfterActivationDate = firstDepositDateBeforeMaturityAndOnOrAfterActivationDate(); if (firstDepositDateBeforeAccountSubmittedOrActivationDate()) {
if (!firstDepositDateBeforeMaturityAndOnOrAfterActivationDate) {
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode( 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(); // FIXME: Handle this scenario
BigDecimal applicableInterestRate = this.chart.getApplicableInterestRate(recurringDepositAmount, depositStartDate(), /*
calculateMaturityDate()); * //final boolean recurringFrequencyBeforeDepositPeriod =
* recurringFrequencyBeforeDepositPeriod();
*
* if (!recurringFrequencyBeforeDepositPeriod) {
* baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode(
* "recurring.frequency.not.before.deposit.period"); }
*/
}
if (applicableInterestRate.equals(BigDecimal.ZERO)) { public void validateApplicableInterestRate() {
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode( final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
"no.applicable.interest.rate.is.found.based.on.amount.and.deposit.period"); 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(); 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 DepositAccountRecurringDetail recurringDetail = this.recurringDetail.copy();
final SavingsProduct product = this.product; final SavingsProduct product = this.product;
final InterestRateChart productChart = product.applicableChart(getClosedOnDate()); final InterestRateChart productChart = product.applicableChart(getClosedOnDate());
@@ -845,14 +987,14 @@ public class RecurringDepositAccount extends SavingsAccount {
final SavingsInterestCalculationType interestCalculationType = SavingsInterestCalculationType.fromInt(this.interestCalculationType); final SavingsInterestCalculationType interestCalculationType = SavingsInterestCalculationType.fromInt(this.interestCalculationType);
final SavingsInterestCalculationDaysInYearType daysInYearType = SavingsInterestCalculationDaysInYearType final SavingsInterestCalculationDaysInYearType daysInYearType = SavingsInterestCalculationDaysInYearType
.fromInt(this.interestCalculationDaysInYearType); .fromInt(this.interestCalculationDaysInYearType);
final BigDecimal minRequiredOpeningBalance = depositAmount.getAmount(); final BigDecimal minRequiredOpeningBalance = depositAmount;
final BigDecimal interestRate = BigDecimal.ZERO; final BigDecimal interestRate = BigDecimal.ZERO;
final Set<SavingsAccountCharge> savingsAccountCharges = null; final Set<SavingsAccountCharge> savingsAccountCharges = null;
final SavingsPeriodFrequencyType lockinPeriodFrequencyType = SavingsPeriodFrequencyType.fromInt(this.lockinPeriodFrequencyType); final SavingsPeriodFrequencyType lockinPeriodFrequencyType = SavingsPeriodFrequencyType.fromInt(this.lockinPeriodFrequencyType);
final Integer lockinPeriodFrequency = this.lockinPeriodFrequency; final Integer lockinPeriodFrequency = this.lockinPeriodFrequency;
final boolean withdrawalFeeApplicableForTransfer = false; final boolean withdrawalFeeApplicableForTransfer = false;
LocalDate now = LocalDate.now(); LocalDate now = DateUtils.getLocalDateOfTenant();
newAccountTermAndPreClosure.updateExpectedFirstDepositDate(now); newAccountTermAndPreClosure.updateExpectedFirstDepositDate(now);
@@ -870,14 +1012,10 @@ public class RecurringDepositAccount extends SavingsAccount {
} }
private boolean firstDepositDateBeforeMaturityAndOnOrAfterActivationDate() { private boolean firstDepositDateBeforeAccountSubmittedOrActivationDate() {
LocalDate expectedFirstDepositLocalDate = accountTermAndPreClosure.getExpectedFirstDepositOnDate(); final LocalDate expectedFirstDepositLocalDate = accountTermAndPreClosure.getExpectedFirstDepositOnDate();
LocalDate maturityLocalDate = calculateMaturityDate(); if (expectedFirstDepositLocalDate == null) return false;
LocalDate activateOnSubmittedLocalDate = accountSubmittedOrActivationDate(); return expectedFirstDepositLocalDate.isBefore(accountSubmittedOrActivationDate());
if (expectedFirstDepositLocalDate != null) { return expectedFirstDepositLocalDate.isBefore(maturityLocalDate)
&& (activateOnSubmittedLocalDate.isEqual(expectedFirstDepositLocalDate) || activateOnSubmittedLocalDate
.isBefore(expectedFirstDepositLocalDate)); }
return true;
} }
public void setDatesFrom(final LocalDate now) { public void setDatesFrom(final LocalDate now) {
@@ -898,4 +1036,57 @@ public class RecurringDepositAccount extends SavingsAccount {
protected boolean isTransferInterestToOtherAccount() { protected boolean isTransferInterestToOtherAccount() {
return this.accountTermAndPreClosure.isTransferInterestToLinkedAccount(); 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; 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.RECURRING_DEPOSIT_PRODUCT_RESOURCE_NAME;
import static org.mifosplatform.portfolio.savings.DepositsApiConstants.maxDepositTermParamName;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; 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.organisation.monetary.domain.MonetaryCurrency;
import org.mifosplatform.portfolio.charge.domain.Charge; import org.mifosplatform.portfolio.charge.domain.Charge;
import org.mifosplatform.portfolio.interestratechart.domain.InterestRateChart; import org.mifosplatform.portfolio.interestratechart.domain.InterestRateChart;
import org.mifosplatform.portfolio.savings.DepositsApiConstants;
import org.mifosplatform.portfolio.savings.SavingsCompoundingInterestPeriodType; import org.mifosplatform.portfolio.savings.SavingsCompoundingInterestPeriodType;
import org.mifosplatform.portfolio.savings.SavingsInterestCalculationDaysInYearType; import org.mifosplatform.portfolio.savings.SavingsInterestCalculationDaysInYearType;
import org.mifosplatform.portfolio.savings.SavingsInterestCalculationType; import org.mifosplatform.portfolio.savings.SavingsInterestCalculationType;
@@ -91,6 +93,8 @@ public class RecurringDepositProduct extends FixedDepositProduct {
actualChanges.putAll(this.update(command, baseDataValidator)); actualChanges.putAll(this.update(command, baseDataValidator));
validateDomainRules(baseDataValidator);
throwExceptionIfValidationWarningsExist(dataValidationErrors); throwExceptionIfValidationWarningsExist(dataValidationErrors);
return actualChanges; return actualChanges;
@@ -103,7 +107,7 @@ public class RecurringDepositProduct extends FixedDepositProduct {
actualChanges.putAll(super.update(command, baseDataValidator)); actualChanges.putAll(super.update(command, baseDataValidator));
if (this.recurringDetail != null) { if (this.recurringDetail != null) {
actualChanges.putAll(this.recurringDetail.update(command, baseDataValidator)); actualChanges.putAll(this.recurringDetail.update(command));
} }
return actualChanges; return actualChanges;
@@ -117,4 +121,33 @@ public class RecurringDepositProduct extends FixedDepositProduct {
return this.recurringDetail; 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.data.SavingsAccountTransactionDTO;
import org.mifosplatform.portfolio.savings.domain.interest.PostingPeriod; import org.mifosplatform.portfolio.savings.domain.interest.PostingPeriod;
import org.mifosplatform.portfolio.savings.exception.InsufficientAccountBalanceException; 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.SavingsActivityPriorToClientTransferException;
import org.mifosplatform.portfolio.savings.exception.SavingsTransferTransactionsCannotBeUndoneException; import org.mifosplatform.portfolio.savings.exception.SavingsTransferTransactionsCannotBeUndoneException;
import org.mifosplatform.portfolio.savings.service.SavingsEnumerations; import org.mifosplatform.portfolio.savings.service.SavingsEnumerations;
@@ -583,13 +584,16 @@ public class SavingsAccount extends AbstractPersistable<Long> {
if (isTransactionsModified) { if (isTransactionsModified) {
accountTransactionsSorted = retreiveListOfTransactions(); 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; LocalDate endOfBalanceDate = interestPostingUpToDate;
for (int i = accountTransactionsSorted.size() - 1; i >= 0; i--) { for (int i = accountTransactionsSorted.size() - 1; i >= 0; i--) {
final SavingsAccountTransaction transaction = accountTransactionsSorted.get(i); final SavingsAccountTransaction transaction = accountTransactionsSorted.get(i);
if (transaction.isNotReversed() && !transaction.isInterestPostingAndNotReversed()) { if (transaction.isNotReversed() && !transaction.isInterestPostingAndNotReversed()) {
transaction.updateCumulativeBalanceAndDates(this.currency, endOfBalanceDate); transaction.updateCumulativeBalanceAndDates(this.currency, endOfBalanceDate);
// this transactions transaction date is end of balance date for // this transactions transaction date is end of balance date for
// previous transaction. // previous transaction.
endOfBalanceDate = transaction.transactionLocalDate().minusDays(1); endOfBalanceDate = transaction.transactionLocalDate().minusDays(1);
@@ -598,11 +602,12 @@ public class SavingsAccount extends AbstractPersistable<Long> {
} }
public SavingsAccountTransaction deposit(final SavingsAccountTransactionDTO transactionDTO) { public SavingsAccountTransaction deposit(final SavingsAccountTransactionDTO transactionDTO) {
final String resourceTypeName = depositAccountType().resourceName();
if (isNotActive()) { if (isNotActive()) {
final String defaultUserMessage = "Transaction is not allowed. Account is not active."; final String defaultUserMessage = "Transaction is not allowed. Account is not active.";
final ApiParameterError error = ApiParameterError.parameterError("error.msg.savingsaccount.transaction.account.is.not.active", final ApiParameterError error = ApiParameterError.parameterError("error.msg." + resourceTypeName
defaultUserMessage, "transactionDate", transactionDTO.getTransactionDate().toString(transactionDTO.getFormatter())); + ".transaction.account.is.not.active", defaultUserMessage, "transactionDate", transactionDTO.getTransactionDate()
.toString(transactionDTO.getFormatter()));
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>(); final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
dataValidationErrors.add(error); dataValidationErrors.add(error);
@@ -612,7 +617,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
if (isDateInTheFuture(transactionDTO.getTransactionDate())) { if (isDateInTheFuture(transactionDTO.getTransactionDate())) {
final String defaultUserMessage = "Transaction date cannot be in the future."; 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())); defaultUserMessage, "transactionDate", transactionDTO.getTransactionDate().toString(transactionDTO.getFormatter()));
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>(); 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()), final Object[] defaultUserArgs = Arrays.asList(transactionDTO.getTransactionDate().toString(transactionDTO.getFormatter()),
getActivationLocalDate().toString(transactionDTO.getFormatter())).toArray(); getActivationLocalDate().toString(transactionDTO.getFormatter())).toArray();
final String defaultUserMessage = "Transaction date cannot be before accounts activation date."; final String defaultUserMessage = "Transaction date cannot be before accounts activation date.";
final ApiParameterError error = ApiParameterError.parameterError("error.msg.savingsaccount.transaction.before.activation.date", final ApiParameterError error = ApiParameterError.parameterError("error.msg." + resourceTypeName
defaultUserMessage, "transactionDate", defaultUserArgs); + ".transaction.before.activation.date", defaultUserMessage, "transactionDate", defaultUserArgs);
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>(); final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
dataValidationErrors.add(error); dataValidationErrors.add(error);
@@ -785,7 +790,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
// //
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>(); final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors) final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
.resource(SAVINGS_ACCOUNT_RESOURCE_NAME + transactionAction); .resource(depositAccountType().resourceName() + transactionAction);
if (this.allowOverdraft) { if (this.allowOverdraft) {
Money limit = runningBalance.zero(); 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; boolean isLocked = false;
final boolean accountHasLockedInSetting = this.lockedInUntilDate != null; final boolean accountHasLockedInSetting = this.lockedInUntilDate != null;
if (accountHasLockedInSetting) { if (accountHasLockedInSetting) {
@@ -1308,24 +1313,20 @@ public class SavingsAccount extends AbstractPersistable<Long> {
} }
} }
if (transactionToUndo == null) { if (transactionToUndo == null) { throw new SavingsAccountTransactionNotFoundException(this.getId(), transactionId); }
// throw non found exception
validateAttemptToUndoTransferRelatedTransactions(transactionToUndo);
} else { validateActivityNotBeforeClientOrGroupTransferDate(SavingsEvent.SAVINGS_UNDO_TRANSACTION, transactionToUndo.transactionLocalDate());
validateAttemptToUndoTransferRelatedTransactions(transactionToUndo); transactionToUndo.reverse();
validateActivityNotBeforeClientOrGroupTransferDate(SavingsEvent.SAVINGS_UNDO_TRANSACTION, if (transactionToUndo.isChargeTransaction() || transactionToUndo.isWaiveCharge()) {
transactionToUndo.transactionLocalDate()); // undo charge
transactionToUndo.reverse(); final Set<SavingsAccountChargePaidBy> chargesPaidBy = transactionToUndo.getSavingsAccountChargesPaid();
if (transactionToUndo.isChargeTransaction() || transactionToUndo.isWaiveCharge()) { for (final SavingsAccountChargePaidBy savingsAccountChargePaidBy : chargesPaidBy) {
// undo charge final SavingsAccountCharge chargeToUndo = savingsAccountChargePaidBy.getSavingsAccountCharge();
final Set<SavingsAccountChargePaidBy> chargesPaidBy = transactionToUndo.getSavingsAccountChargesPaid(); if (transactionToUndo.isChargeTransaction()) {
for (final SavingsAccountChargePaidBy savingsAccountChargePaidBy : chargesPaidBy) { chargeToUndo.undoPayment(this.getCurrency(), transactionToUndo.getAmount(this.getCurrency()));
final SavingsAccountCharge chargeToUndo = savingsAccountChargePaidBy.getSavingsAccountCharge(); } else if (transactionToUndo.isWaiveCharge()) {
if (transactionToUndo.isChargeTransaction()) { chargeToUndo.undoWaiver(this.getCurrency(), transactionToUndo.getAmount(this.getCurrency()));
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 List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors) 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); final SavingsAccountStatusType currentStatus = SavingsAccountStatusType.fromInt(this.status);
if (!SavingsAccountStatusType.APPROVED.hasStateOf(currentStatus)) { if (!SavingsAccountStatusType.APPROVED.hasStateOf(currentStatus)) {
@@ -2043,4 +2044,10 @@ public class SavingsAccount extends AbstractPersistable<Long> {
protected boolean isTransferInterestToOtherAccount() { protected boolean isTransferInterestToOtherAccount() {
return false; 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; 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.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.allowOverdraftParamName;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.clientIdParamName; import static org.mifosplatform.portfolio.savings.SavingsApiConstants.clientIdParamName;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.externalIdParamName; import static org.mifosplatform.portfolio.savings.SavingsApiConstants.externalIdParamName;
@@ -215,7 +215,7 @@ public class SavingsProduct extends AbstractPersistable<Long> {
} }
public BigDecimal nominalAnnualInterestRate() { public BigDecimal nominalAnnualInterestRate() {
return Money.of(this.currency, this.nominalAnnualInterestRate).getAmount(); return this.nominalAnnualInterestRate;
} }
public SavingsCompoundingInterestPeriodType interestCompoundingPeriodType() { public SavingsCompoundingInterestPeriodType interestCompoundingPeriodType() {
@@ -6,7 +6,6 @@ import java.math.RoundingMode;
import org.joda.time.LocalDate; import org.joda.time.LocalDate;
import org.mifosplatform.infrastructure.core.domain.LocalDateInterval; import org.mifosplatform.infrastructure.core.domain.LocalDateInterval;
import org.mifosplatform.infrastructure.core.service.DateUtils;
import org.mifosplatform.organisation.monetary.domain.Money; import org.mifosplatform.organisation.monetary.domain.Money;
public class EndOfDayBalance { public class EndOfDayBalance {
@@ -118,6 +118,8 @@ public class MonthlyCompoundingPeriod implements CompoundingPeriod {
// break; // break;
case INVALID: case INVALID:
break; break;
default:
break;
} }
interestEarned = interestEarned.add(interestOnBalanceUnrounded); interestEarned = interestEarned.add(interestOnBalanceUnrounded);
@@ -14,18 +14,18 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@Service @Service
public class CloseDepositAccountCommandHandler implements NewCommandSourceHandler { public class ActivateFixedDepositAccountCommandHandler implements NewCommandSourceHandler {
private final DepositAccountWritePlatformService depositAccountWritePlatformService; private final DepositAccountWritePlatformService depositAccountWritePlatformService;
@Autowired @Autowired
public CloseDepositAccountCommandHandler(final DepositAccountWritePlatformService depositAccountWritePlatformService) { public ActivateFixedDepositAccountCommandHandler(final DepositAccountWritePlatformService depositAccountWritePlatformService) {
this.depositAccountWritePlatformService = depositAccountWritePlatformService; this.depositAccountWritePlatformService = depositAccountWritePlatformService;
} }
@Transactional @Transactional
@Override @Override
public CommandProcessingResult processCommand(final JsonCommand command) { 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; import org.springframework.transaction.annotation.Transactional;
@Service @Service
public class CalculateInterestDepositAccountCommandHandler implements NewCommandSourceHandler { public class ActivateRecurringDepositAccountCommandHandler implements NewCommandSourceHandler {
private final DepositAccountWritePlatformService depositAccountWritePlatformService; private final DepositAccountWritePlatformService depositAccountWritePlatformService;
@Autowired @Autowired
public CalculateInterestDepositAccountCommandHandler(final DepositAccountWritePlatformService depositAccountWritePlatformService) { public ActivateRecurringDepositAccountCommandHandler(final DepositAccountWritePlatformService depositAccountWritePlatformService) {
this.depositAccountWritePlatformService = depositAccountWritePlatformService; this.depositAccountWritePlatformService = depositAccountWritePlatformService;
} }
@Transactional @Transactional
@Override @Override
public CommandProcessingResult processCommand(final JsonCommand command) { 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; import org.springframework.transaction.annotation.Transactional;
@Service @Service
public class DepositAccountDepositCommandHandler implements NewCommandSourceHandler { public class CloseFixedDepositAccountCommandHandler implements NewCommandSourceHandler {
private final DepositAccountWritePlatformService depositAccountWritePlatformService; private final DepositAccountWritePlatformService depositAccountWritePlatformService;
@Autowired @Autowired
public DepositAccountDepositCommandHandler(final DepositAccountWritePlatformService depositAccountWritePlatformService) { public CloseFixedDepositAccountCommandHandler(final DepositAccountWritePlatformService depositAccountWritePlatformService) {
this.depositAccountWritePlatformService = depositAccountWritePlatformService; this.depositAccountWritePlatformService = depositAccountWritePlatformService;
} }
@Transactional @Transactional
@Override @Override
public CommandProcessingResult processCommand(final JsonCommand command) { 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