remove invalid suppression of warnings which were shown as warnings in eclipse indigo but fixed in eclipse juno and kepler.

This commit is contained in:
Keith Woodlock
2013-08-08 00:17:54 +01:00
parent cc684e02c3
commit f260591ea9
29 changed files with 972 additions and 986 deletions
@@ -33,7 +33,6 @@ public class GLClosure extends AbstractAuditableCustom<AppUser, Long> {
@JoinColumn(name = "office_id", nullable = false) @JoinColumn(name = "office_id", nullable = false)
private Office office; private Office office;
@SuppressWarnings("unused")
@Column(name = "is_deleted", nullable = false) @Column(name = "is_deleted", nullable = false)
private boolean deleted = true; private boolean deleted = true;
@@ -35,20 +35,16 @@ public class JournalEntry extends AbstractAuditableCustom<AppUser, Long> {
@JoinColumn(name = "account_id", nullable = false) @JoinColumn(name = "account_id", nullable = false)
private GLAccount glAccount; private GLAccount glAccount;
@SuppressWarnings("unused")
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "reversal_id") @JoinColumn(name = "reversal_id")
private JournalEntry reversalJournalEntry; private JournalEntry reversalJournalEntry;
@SuppressWarnings("unused")
@Column(name = "transaction_id", nullable = false, length = 50) @Column(name = "transaction_id", nullable = false, length = 50)
private String transactionId; private String transactionId;
@SuppressWarnings("unused")
@Column(name = "reversed", nullable = false) @Column(name = "reversed", nullable = false)
private boolean reversed = false; private boolean reversed = false;
@SuppressWarnings("unused")
@Column(name = "manual_entry", nullable = false) @Column(name = "manual_entry", nullable = false)
private boolean manualEntry = false; private boolean manualEntry = false;
@@ -62,15 +58,12 @@ public class JournalEntry extends AbstractAuditableCustom<AppUser, Long> {
@Column(name = "amount", scale = 6, precision = 19, nullable = false) @Column(name = "amount", scale = 6, precision = 19, nullable = false)
private BigDecimal amount; private BigDecimal amount;
@SuppressWarnings("unused")
@Column(name = "description", length = 500) @Column(name = "description", length = 500)
private String description; private String description;
@SuppressWarnings("unused")
@Column(name = "entity_type_enum", length = 50) @Column(name = "entity_type_enum", length = 50)
private Integer entityType; private Integer entityType;
@SuppressWarnings("unused")
@Column(name = "entity_id") @Column(name = "entity_id")
private Long entityId; private Long entityId;
@@ -20,7 +20,6 @@ import org.springframework.data.jpa.domain.AbstractPersistable;
@Table(name = "acc_rule_tags", uniqueConstraints = { @UniqueConstraint(columnNames = { "acc_rule_id", "tag_id", "acc_type_enum" }, name = "UNIQUE_ACCOUNT_RULE_TAGS") }) @Table(name = "acc_rule_tags", uniqueConstraints = { @UniqueConstraint(columnNames = { "acc_rule_id", "tag_id", "acc_type_enum" }, name = "UNIQUE_ACCOUNT_RULE_TAGS") })
public class AccountingTagRule extends AbstractPersistable<Long> { public class AccountingTagRule extends AbstractPersistable<Long> {
@SuppressWarnings("unused")
@ManyToOne @ManyToOne
@JoinColumn(name = "acc_rule_id", nullable = false) @JoinColumn(name = "acc_rule_id", nullable = false)
private AccountingRule accountingRule; private AccountingRule accountingRule;
@@ -25,171 +25,175 @@ import org.springframework.data.jpa.domain.AbstractPersistable;
@Table(name = "m_portfolio_command_source") @Table(name = "m_portfolio_command_source")
public class CommandSource extends AbstractPersistable<Long> { public class CommandSource extends AbstractPersistable<Long> {
@Column(name = "action_name", nullable = true, length = 100) @Column(name = "action_name", nullable = true, length = 100)
private String actionName; private String actionName;
@Column(name = "entity_name", nullable = true, length = 100) @Column(name = "entity_name", nullable = true, length = 100)
private String entityName; private String entityName;
@SuppressWarnings("unused") @Column(name = "office_id")
@Column(name = "office_id") private Long officeId;
private Long officeId;
@SuppressWarnings("unused") @Column(name = "group_id")
@Column(name = "group_id") private Long groupId;
private Long groupId;
@SuppressWarnings("unused") @Column(name = "client_id")
@Column(name = "client_id") private Long clientId;
private Long clientId;
@SuppressWarnings("unused") @Column(name = "loan_id")
@Column(name = "loan_id") private Long loanId;
private Long loanId;
@SuppressWarnings("unused") @Column(name = "savings_account_id")
@Column(name = "savings_account_id") private Long savingsId;
private Long savingsId;
@Column(name = "api_get_url", length = 100) @Column(name = "api_get_url", length = 100)
private String resourceGetUrl; private String resourceGetUrl;
@Column(name = "resource_id") @Column(name = "resource_id")
private Long resourceId; private Long resourceId;
@Column(name = "subresource_id") @Column(name = "subresource_id")
private Long subresourceId; private Long subresourceId;
@Column(name = "command_as_json", length = 1000) @Column(name = "command_as_json", length = 1000)
private String commandAsJson; private String commandAsJson;
@SuppressWarnings("unused") @ManyToOne
@ManyToOne @JoinColumn(name = "maker_id", nullable = false)
@JoinColumn(name = "maker_id", nullable = false) private AppUser maker;
private AppUser maker;
@SuppressWarnings("unused") @Column(name = "made_on_date", nullable = false)
@Column(name = "made_on_date", nullable = false) @Temporal(TemporalType.TIMESTAMP)
@Temporal(TemporalType.TIMESTAMP) private Date madeOnDate;
private Date madeOnDate;
@SuppressWarnings("unused") @ManyToOne
@ManyToOne @JoinColumn(name = "checker_id", nullable = true)
@JoinColumn(name = "checker_id", nullable = true) private AppUser checker;
private AppUser checker;
@SuppressWarnings("unused") @Column(name = "checked_on_date", nullable = true)
@Column(name = "checked_on_date", nullable = true) @Temporal(TemporalType.TIMESTAMP)
@Temporal(TemporalType.TIMESTAMP) private Date checkedOnDate;
private Date checkedOnDate;
@Column(name = "processing_result_enum", nullable = false) @Column(name = "processing_result_enum", nullable = false)
private Integer processingResult; private Integer processingResult;
@Column(name = "product_id")
private Long productId;
public static CommandSource fullEntryFrom(final CommandWrapper wrapper, final JsonCommand command, final AppUser maker) { @Column(name = "product_id")
return new CommandSource(wrapper.actionName(), wrapper.entityName(), wrapper.getHref(), command.entityId(), command.subentityId(), private Long productId;
command.json(), maker, DateTime.now());
}
protected CommandSource() { public static CommandSource fullEntryFrom(final CommandWrapper wrapper,
// final JsonCommand command, final AppUser maker) {
} return new CommandSource(wrapper.actionName(), wrapper.entityName(),
wrapper.getHref(), command.entityId(), command.subentityId(),
command.json(), maker, DateTime.now());
}
private CommandSource(final String actionName, final String entityName, final String href, final Long resourceId, protected CommandSource() {
final Long subresourceId, final String commandSerializedAsJson, final AppUser maker, final DateTime madeOnDateTime) { //
this.actionName = actionName; }
this.entityName = entityName;
this.resourceGetUrl = href;
this.resourceId = resourceId;
this.subresourceId = subresourceId;
this.commandAsJson = commandSerializedAsJson;
this.maker = maker;
this.madeOnDate = madeOnDateTime.toDate();
this.processingResult = CommandProcessingResultType.PROCESSED.getValue();
}
public void markAsChecked(final AppUser checker, final DateTime checkedOnDate) { private CommandSource(final String actionName, final String entityName,
this.checker = checker; final String href, final Long resourceId, final Long subresourceId,
this.checkedOnDate = checkedOnDate.toDate(); final String commandSerializedAsJson, final AppUser maker,
this.processingResult = CommandProcessingResultType.PROCESSED.getValue(); final DateTime madeOnDateTime) {
} this.actionName = actionName;
this.entityName = entityName;
this.resourceGetUrl = href;
this.resourceId = resourceId;
this.subresourceId = subresourceId;
this.commandAsJson = commandSerializedAsJson;
this.maker = maker;
this.madeOnDate = madeOnDateTime.toDate();
this.processingResult = CommandProcessingResultType.PROCESSED
.getValue();
}
public void updateResourceId(final Long resourceId) { public void markAsChecked(final AppUser checker,
this.resourceId = resourceId; final DateTime checkedOnDate) {
} this.checker = checker;
this.checkedOnDate = checkedOnDate.toDate();
this.processingResult = CommandProcessingResultType.PROCESSED
.getValue();
}
public void updateSubresourceId(final Long subresourceId) { public void updateResourceId(final Long resourceId) {
this.subresourceId = subresourceId; this.resourceId = resourceId;
} }
public void updateJsonTo(final String json) { public void updateSubresourceId(final Long subresourceId) {
this.commandAsJson = json; this.subresourceId = subresourceId;
} }
public Long resourceId() { public void updateJsonTo(final String json) {
return this.resourceId; this.commandAsJson = json;
} }
public Long subresourceId() { public Long resourceId() {
return this.subresourceId; return this.resourceId;
} }
public boolean hasJson() { public Long subresourceId() {
return StringUtils.isNotBlank(this.commandAsJson); return this.subresourceId;
} }
public String json() { public boolean hasJson() {
return this.commandAsJson; return StringUtils.isNotBlank(this.commandAsJson);
} }
public String getActionName() { public String json() {
return this.actionName; return this.commandAsJson;
} }
public String getEntityName() { public String getActionName() {
return this.entityName; return this.actionName;
} }
public String getPermissionCode() { public String getEntityName() {
return this.actionName + "_" + this.entityName; return this.entityName;
} }
public Long getResourceId() { public String getPermissionCode() {
return this.resourceId; return this.actionName + "_" + this.entityName;
} }
public Long getSubresourceId() { public Long getResourceId() {
return this.subresourceId; return this.resourceId;
} }
public void markAsAwaitingApproval() { public Long getSubresourceId() {
this.processingResult = CommandProcessingResultType.AWAITING_APPROVAL.getValue(); return this.subresourceId;
} }
public boolean isMarkedAsAwaitingApproval() { public void markAsAwaitingApproval() {
if (this.processingResult.equals(CommandProcessingResultType.AWAITING_APPROVAL.getValue())) return true; this.processingResult = CommandProcessingResultType.AWAITING_APPROVAL
.getValue();
}
return false; public boolean isMarkedAsAwaitingApproval() {
} if (this.processingResult
.equals(CommandProcessingResultType.AWAITING_APPROVAL
.getValue())) {
return true;
}
public void updateForAudit(final Long officeId, final Long groupId, final Long clientId, final Long loanId, final Long savingsId, return false;
final Long productId) { }
this.officeId = officeId;
this.groupId = groupId;
this.clientId = clientId;
this.loanId = loanId;
this.savingsId = savingsId;
this.productId = productId;
}
public String getResourceGetUrl() { public void updateForAudit(final Long officeId, final Long groupId,
return this.resourceGetUrl; final Long clientId, final Long loanId, final Long savingsId,
} final Long productId) {
this.officeId = officeId;
this.groupId = groupId;
this.clientId = clientId;
this.loanId = loanId;
this.savingsId = savingsId;
this.productId = productId;
}
public Long getProductId() { public String getResourceGetUrl() {
return this.productId; return this.resourceGetUrl;
} }
public Long getProductId() {
return this.productId;
}
} }
@@ -22,72 +22,85 @@ import org.mifosplatform.infrastructure.core.api.JsonCommand;
import org.springframework.data.jpa.domain.AbstractPersistable; import org.springframework.data.jpa.domain.AbstractPersistable;
@Entity @Entity
@Table(name = "m_code_value", uniqueConstraints = { @UniqueConstraint(columnNames = { "code_id", "code_value" }, name = "code_value_duplicate") }) @Table(name = "m_code_value", uniqueConstraints = { @UniqueConstraint(columnNames = {
"code_id", "code_value" }, name = "code_value_duplicate") })
public class CodeValue extends AbstractPersistable<Long> { public class CodeValue extends AbstractPersistable<Long> {
@Column(name = "code_value", length = 100) @Column(name = "code_value", length = 100)
private String label; private String label;
@Column(name = "order_position") @Column(name = "order_position")
private int position; private int position;
@SuppressWarnings("unused") @ManyToOne
@ManyToOne @JoinColumn(name = "code_id", nullable = false)
@JoinColumn(name = "code_id", nullable = false) private Code code;
private Code code;
public static CodeValue createNew(Code code, final String label, final int position) { public static CodeValue createNew(final Code code, final String label,
return new CodeValue(code, label, position); final int position) {
} return new CodeValue(code, label, position);
}
protected CodeValue() { protected CodeValue() {
// //
} }
private CodeValue(final Code code, final String label, final int position) { private CodeValue(final Code code, final String label, final int position) {
this.code = code; this.code = code;
this.label = StringUtils.defaultIfEmpty(label, null); this.label = StringUtils.defaultIfEmpty(label, null);
this.position = position; this.position = position;
} }
public String label() { public String label() {
return label; return this.label;
} }
public int position() { public int position() {
return position; return this.position;
} }
public static CodeValue fromJson(Code code, final JsonCommand command) {
final String label = command.stringValueOfParameterNamed(CODEVALUE_JSON_INPUT_PARAMS.NAME.getValue()); public static CodeValue fromJson(final Code code, final JsonCommand command) {
Integer position = command.integerValueSansLocaleOfParameterNamed(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue());
if(position == null) position = new Integer(0);
return new CodeValue(code, label, position.intValue());
}
public Map<String, Object> update(final JsonCommand command) {
final Map<String, Object> actualChanges = new LinkedHashMap<String, Object>(2); final String label = command
.stringValueOfParameterNamed(CODEVALUE_JSON_INPUT_PARAMS.NAME
.getValue());
Integer position = command
.integerValueSansLocaleOfParameterNamed(CODEVALUE_JSON_INPUT_PARAMS.POSITION
.getValue());
if (position == null) {
position = new Integer(0);
}
return new CodeValue(code, label, position.intValue());
}
final String labelParamName = CODEVALUE_JSON_INPUT_PARAMS.NAME.getValue(); public Map<String, Object> update(final JsonCommand command) {
if (command.isChangeInStringParameterNamed(labelParamName, this.label)) {
final String newValue = command.stringValueOfParameterNamed(labelParamName);
actualChanges.put(labelParamName, newValue);
this.label = StringUtils.defaultIfEmpty(newValue, null);
}
final String positionParamName = CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue();
if (command.isChangeInIntegerSansLocaleParameterNamed(positionParamName, this.position)) {
final Integer newValue = command.integerValueSansLocaleOfParameterNamed(positionParamName);
actualChanges.put(positionParamName, newValue);
this.position = newValue.intValue();
}
return actualChanges;
}
public CodeValueData toData() { final Map<String, Object> actualChanges = new LinkedHashMap<String, Object>(
return CodeValueData.instance(this.getId(), this.label, this.position); 2);
}
final String labelParamName = CODEVALUE_JSON_INPUT_PARAMS.NAME
.getValue();
if (command.isChangeInStringParameterNamed(labelParamName, this.label)) {
final String newValue = command
.stringValueOfParameterNamed(labelParamName);
actualChanges.put(labelParamName, newValue);
this.label = StringUtils.defaultIfEmpty(newValue, null);
}
final String positionParamName = CODEVALUE_JSON_INPUT_PARAMS.POSITION
.getValue();
if (command.isChangeInIntegerSansLocaleParameterNamed(
positionParamName, this.position)) {
final Integer newValue = command
.integerValueSansLocaleOfParameterNamed(positionParamName);
actualChanges.put(positionParamName, newValue);
this.position = newValue.intValue();
}
return actualChanges;
}
public CodeValueData toData() {
return CodeValueData.instance(getId(), this.label, this.position);
}
} }
@@ -14,10 +14,9 @@ import javax.persistence.UniqueConstraint;
import org.springframework.data.jpa.domain.AbstractPersistable; import org.springframework.data.jpa.domain.AbstractPersistable;
@Entity @Entity
@Table(name = "c_external_service", uniqueConstraints = { @UniqueConstraint(columnNames = ("name")) }) @Table(name = "c_external_service", uniqueConstraints = { @UniqueConstraint(columnNames = "name") })
public class ExternalService extends AbstractPersistable<Long> { public class ExternalService extends AbstractPersistable<Long> {
@SuppressWarnings("unused")
@Column(name = "name", nullable = false) @Column(name = "name", nullable = false)
private String name; private String name;
@@ -15,7 +15,6 @@ import org.springframework.data.jpa.domain.AbstractPersistable;
@Table(name = "c_configuration") @Table(name = "c_configuration")
public class GlobalConfigurationProperty extends AbstractPersistable<Long> { public class GlobalConfigurationProperty extends AbstractPersistable<Long> {
@SuppressWarnings("unused")
@Column(name = "name", nullable = false) @Column(name = "name", nullable = false)
private final String name; private final String name;
@@ -28,7 +28,6 @@ public class ScheduledJobDetail extends AbstractPersistable<Long> {
@Column(name = "cron_expression") @Column(name = "cron_expression")
private String cronExpression; private String cronExpression;
@SuppressWarnings("unused")
@Column(name = "create_time") @Column(name = "create_time")
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Date createTime; private Date createTime;
@@ -39,12 +38,10 @@ public class ScheduledJobDetail extends AbstractPersistable<Long> {
@Column(name = "group_name") @Column(name = "group_name")
private String groupName; private String groupName;
@SuppressWarnings("unused")
@Column(name = "previous_run_start_time") @Column(name = "previous_run_start_time")
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Date previousRunStartTime; private Date previousRunStartTime;
@SuppressWarnings("unused")
@Column(name = "next_run_time") @Column(name = "next_run_time")
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Date nextRunTime; private Date nextRunTime;
@@ -52,7 +49,6 @@ public class ScheduledJobDetail extends AbstractPersistable<Long> {
@Column(name = "job_key") @Column(name = "job_key")
private String jobKey; private String jobKey;
@SuppressWarnings("unused")
@Column(name = "initializing_errorlog") @Column(name = "initializing_errorlog")
private String errorLog; private String errorLog;
@@ -62,7 +58,6 @@ public class ScheduledJobDetail extends AbstractPersistable<Long> {
@Column(name = "currently_running") @Column(name = "currently_running")
private boolean currentlyRunning; private boolean currentlyRunning;
@SuppressWarnings("unused")
@Column(name = "updates_allowed") @Column(name = "updates_allowed")
private boolean updatesAllowed; private boolean updatesAllowed;
@@ -113,7 +108,7 @@ public class ScheduledJobDetail extends AbstractPersistable<Long> {
this.nextRunTime = nextRunTime; this.nextRunTime = nextRunTime;
} }
public void updateJobKey(String jobKey) { public void updateJobKey(final String jobKey) {
this.jobKey = jobKey; this.jobKey = jobKey;
} }
@@ -125,7 +120,7 @@ public class ScheduledJobDetail extends AbstractPersistable<Long> {
return this.currentlyRunning; return this.currentlyRunning;
} }
public void updateCurrentlyRunningStatus(boolean currentlyRunning) { public void updateCurrentlyRunningStatus(final boolean currentlyRunning) {
this.currentlyRunning = currentlyRunning; this.currentlyRunning = currentlyRunning;
} }
@@ -16,38 +16,30 @@ import org.springframework.data.jpa.domain.AbstractPersistable;
@Table(name = "job_run_history") @Table(name = "job_run_history")
public class ScheduledJobRunHistory extends AbstractPersistable<Long> { public class ScheduledJobRunHistory extends AbstractPersistable<Long> {
@SuppressWarnings("unused")
@ManyToOne @ManyToOne
@JoinColumn(name = "job_id") @JoinColumn(name = "job_id")
private ScheduledJobDetail scheduledJobDetail; private ScheduledJobDetail scheduledJobDetail;
@SuppressWarnings("unused")
@Column(name = "version") @Column(name = "version")
private Long version; private Long version;
@SuppressWarnings("unused")
@Column(name = "start_time") @Column(name = "start_time")
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Date startTime; private Date startTime;
@SuppressWarnings("unused")
@Column(name = "end_time") @Column(name = "end_time")
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Date endTime; private Date endTime;
@SuppressWarnings("unused")
@Column(name = "status") @Column(name = "status")
private String status; private String status;
@SuppressWarnings("unused")
@Column(name = "error_message") @Column(name = "error_message")
private String errorMessage; private String errorMessage;
@SuppressWarnings("unused")
@Column(name = "trigger_type") @Column(name = "trigger_type")
private String triggerType; private String triggerType;
@SuppressWarnings("unused")
@Column(name = "error_log") @Column(name = "error_log")
private String errorLog; private String errorLog;
@@ -30,7 +30,6 @@ import org.springframework.data.jpa.domain.AbstractPersistable;
@Table(name = "m_holiday", uniqueConstraints = { @UniqueConstraint(columnNames = { "name" }, name = "holiday_name") }) @Table(name = "m_holiday", uniqueConstraints = { @UniqueConstraint(columnNames = { "name" }, name = "holiday_name") })
public class Holiday extends AbstractPersistable<Long> { public class Holiday extends AbstractPersistable<Long> {
@SuppressWarnings("unused")
@Column(name = "name", unique = true, nullable = false, length = 100) @Column(name = "name", unique = true, nullable = false, length = 100)
private String name; private String name;
@@ -49,7 +48,6 @@ public class Holiday extends AbstractPersistable<Long> {
@Column(name = "processed", nullable = false) @Column(name = "processed", nullable = false)
private boolean processed; private boolean processed;
@SuppressWarnings("unused")
@Column(name = "description", length = 100) @Column(name = "description", length = 100)
private String description; private String description;
@@ -28,30 +28,24 @@ import org.springframework.data.jpa.domain.AbstractPersistable;
@Table(name = "m_office_transaction") @Table(name = "m_office_transaction")
public class OfficeTransaction extends AbstractPersistable<Long> { public class OfficeTransaction extends AbstractPersistable<Long> {
@SuppressWarnings("unused")
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "from_office_id") @JoinColumn(name = "from_office_id")
private Office from; private Office from;
@SuppressWarnings("unused")
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "to_office_id") @JoinColumn(name = "to_office_id")
private Office to; private Office to;
@SuppressWarnings("unused")
@Column(name = "transaction_date", nullable = false) @Column(name = "transaction_date", nullable = false)
@Temporal(TemporalType.DATE) @Temporal(TemporalType.DATE)
private Date transactionDate; private Date transactionDate;
@SuppressWarnings("unused")
@Embedded @Embedded
private MonetaryCurrency currency; private MonetaryCurrency currency;
@SuppressWarnings("unused")
@Column(name = "transaction_amount", scale = 6, precision = 19, nullable = false) @Column(name = "transaction_amount", scale = 6, precision = 19, nullable = false)
private BigDecimal transactionAmount; private BigDecimal transactionAmount;
@SuppressWarnings("unused")
@Column(name = "description", nullable = true, length = 100) @Column(name = "description", nullable = true, length = 100)
private String description; private String description;
@@ -18,23 +18,18 @@ import org.springframework.data.jpa.domain.AbstractPersistable;
@Table(name = "m_organisation_currency") @Table(name = "m_organisation_currency")
public class OrganisationCurrency extends AbstractPersistable<Long> { public class OrganisationCurrency extends AbstractPersistable<Long> {
@SuppressWarnings("unused")
@Column(name = "code", nullable = false, length = 3) @Column(name = "code", nullable = false, length = 3)
private final String code; private final String code;
@SuppressWarnings("unused")
@Column(name = "decimal_places", nullable = false) @Column(name = "decimal_places", nullable = false)
private final Integer decimalPlaces; private final Integer decimalPlaces;
@SuppressWarnings("unused")
@Column(name = "name", nullable = false, length = 50) @Column(name = "name", nullable = false, length = 50)
private final String name; private final String name;
@SuppressWarnings("unused")
@Column(name = "internationalized_name_code", nullable = false, length = 50) @Column(name = "internationalized_name_code", nullable = false, length = 50)
private final String nameCode; private final String nameCode;
@SuppressWarnings("unused")
@Column(name = "display_symbol", nullable = true, length = 10) @Column(name = "display_symbol", nullable = true, length = 10)
private final String displaySymbol; private final String displaySymbol;
@@ -50,7 +50,6 @@ public class Staff extends AbstractPersistable<Long> {
@Column(name = "organisational_role_enum", nullable = true) @Column(name = "organisational_role_enum", nullable = true)
private Integer organisationalRoleType; private Integer organisationalRoleType;
@SuppressWarnings("unused")
@ManyToOne @ManyToOne
@JoinColumn(name = "organisational_role_parent_staff_id", nullable = true) @JoinColumn(name = "organisational_role_parent_staff_id", nullable = true)
private Staff organisationalRoleParentStaff; private Staff organisationalRoleParentStaff;
@@ -58,13 +57,13 @@ public class Staff extends AbstractPersistable<Long> {
public static Staff fromJson(final Office staffOffice, final JsonCommand command) { public static Staff fromJson(final Office staffOffice, final JsonCommand command) {
final String firstnameParamName = "firstname"; final String firstnameParamName = "firstname";
String firstname = command.stringValueOfParameterNamed(firstnameParamName); final String firstname = command.stringValueOfParameterNamed(firstnameParamName);
final String lastnameParamName = "lastname"; final String lastnameParamName = "lastname";
String lastname = command.stringValueOfParameterNamed(lastnameParamName); final String lastname = command.stringValueOfParameterNamed(lastnameParamName);
final String externalIdParamName = "externalId"; final String externalIdParamName = "externalId";
String externalId = command.stringValueOfParameterNamedAllowingNull(externalIdParamName); final String externalId = command.stringValueOfParameterNamedAllowingNull(externalIdParamName);
final String isLoanOfficerParamName = "isLoanOfficer"; final String isLoanOfficerParamName = "isLoanOfficer";
final boolean isLoanOfficer = command.booleanPrimitiveValueOfParameterNamed(isLoanOfficerParamName); final boolean isLoanOfficer = command.booleanPrimitiveValueOfParameterNamed(isLoanOfficerParamName);
@@ -96,11 +96,9 @@ public final class Client extends AbstractPersistable<Long> {
@Transient @Transient
private boolean accountNumberRequiresAutoGeneration = false; private boolean accountNumberRequiresAutoGeneration = false;
@SuppressWarnings("unused")
@Column(name = "closure_reason_cv_id", nullable = true) @Column(name = "closure_reason_cv_id", nullable = true)
private Long closureReasonId; private Long closureReasonId;
@SuppressWarnings("unused")
@Column(name = "closedon_date", nullable = true) @Column(name = "closedon_date", nullable = true)
@Temporal(TemporalType.DATE) @Temporal(TemporalType.DATE)
private Date closureDate; private Date closureDate;
@@ -464,7 +462,7 @@ public final class Client extends AbstractPersistable<Long> {
} }
public Integer getStatus() { public Integer getStatus() {
return status; return this.status;
} }
public boolean isActivatedAfter(final LocalDate submittedOn) { public boolean isActivatedAfter(final LocalDate submittedOn) {
@@ -23,78 +23,89 @@ import org.mifosplatform.useradministration.domain.AppUser;
@Entity @Entity
@Table(name = "m_client_identifier", uniqueConstraints = { @Table(name = "m_client_identifier", uniqueConstraints = {
@UniqueConstraint(columnNames = { "document_type_id", "document_key" }, name = "unique_identifier_key"), @UniqueConstraint(columnNames = { "document_type_id", "document_key" }, name = "unique_identifier_key"),
@UniqueConstraint(columnNames = { "client_id", "document_type_id" }, name = "unique_client_identifier") }) @UniqueConstraint(columnNames = { "client_id", "document_type_id" }, name = "unique_client_identifier") })
public class ClientIdentifier extends AbstractAuditableCustom<AppUser, Long> { public class ClientIdentifier extends AbstractAuditableCustom<AppUser, Long> {
@SuppressWarnings("unused") @ManyToOne
@ManyToOne @JoinColumn(name = "client_id", nullable = false)
@JoinColumn(name = "client_id", nullable = false) private Client client;
private Client client;
@ManyToOne @ManyToOne
@JoinColumn(name = "document_type_id", nullable = false) @JoinColumn(name = "document_type_id", nullable = false)
private CodeValue documentType; private CodeValue documentType;
@Column(name = "document_key", length = 1000) @Column(name = "document_key", length = 1000)
private String documentKey; private String documentKey;
@Column(name = "description", length = 1000) @Column(name = "description", length = 1000)
private String description; private String description;
public static ClientIdentifier fromJson(final Client client, final CodeValue documentType, final JsonCommand command) { public static ClientIdentifier fromJson(final Client client,
final String documentKey = command.stringValueOfParameterNamed("documentKey"); final CodeValue documentType, final JsonCommand command) {
final String description = command.stringValueOfParameterNamed("description"); final String documentKey = command
return new ClientIdentifier(client, documentType, documentKey, description); .stringValueOfParameterNamed("documentKey");
} final String description = command
.stringValueOfParameterNamed("description");
return new ClientIdentifier(client, documentType, documentKey,
description);
}
protected ClientIdentifier() { protected ClientIdentifier() {
// //
} }
private ClientIdentifier(final Client client, final CodeValue documentType, final String documentKey, final String description) { private ClientIdentifier(final Client client, final CodeValue documentType,
this.client = client; final String documentKey, final String description) {
this.documentType = documentType; this.client = client;
this.documentKey = StringUtils.defaultIfEmpty(documentKey, null); this.documentType = documentType;
this.description = StringUtils.defaultIfEmpty(description, null); this.documentKey = StringUtils.defaultIfEmpty(documentKey, null);
} this.description = StringUtils.defaultIfEmpty(description, null);
}
public void update(final CodeValue documentType) { public void update(final CodeValue documentType) {
this.documentType = documentType; this.documentType = documentType;
} }
public Map<String, Object> update(final JsonCommand command) { public Map<String, Object> update(final JsonCommand command) {
final Map<String, Object> actualChanges = new LinkedHashMap<String, Object>(7); final Map<String, Object> actualChanges = new LinkedHashMap<String, Object>(
7);
final String documentTypeIdParamName = "documentTypeId"; final String documentTypeIdParamName = "documentTypeId";
if (command.isChangeInLongParameterNamed(documentTypeIdParamName, this.documentType.getId())) { if (command.isChangeInLongParameterNamed(documentTypeIdParamName,
final Long newValue = command.longValueOfParameterNamed(documentTypeIdParamName); this.documentType.getId())) {
actualChanges.put(documentTypeIdParamName, newValue); final Long newValue = command
} .longValueOfParameterNamed(documentTypeIdParamName);
actualChanges.put(documentTypeIdParamName, newValue);
}
final String documentKeyParamName = "documentKey"; final String documentKeyParamName = "documentKey";
if (command.isChangeInStringParameterNamed(documentKeyParamName, this.documentKey)) { if (command.isChangeInStringParameterNamed(documentKeyParamName,
final String newValue = command.stringValueOfParameterNamed(documentKeyParamName); this.documentKey)) {
actualChanges.put(documentKeyParamName, newValue); final String newValue = command
this.documentKey = StringUtils.defaultIfEmpty(newValue, null); .stringValueOfParameterNamed(documentKeyParamName);
} actualChanges.put(documentKeyParamName, newValue);
this.documentKey = StringUtils.defaultIfEmpty(newValue, null);
}
final String descriptionParamName = "description"; final String descriptionParamName = "description";
if (command.isChangeInStringParameterNamed(descriptionParamName, this.description)) { if (command.isChangeInStringParameterNamed(descriptionParamName,
final String newValue = command.stringValueOfParameterNamed(descriptionParamName); this.description)) {
actualChanges.put(descriptionParamName, newValue); final String newValue = command
this.description = StringUtils.defaultIfEmpty(newValue, null); .stringValueOfParameterNamed(descriptionParamName);
} actualChanges.put(descriptionParamName, newValue);
this.description = StringUtils.defaultIfEmpty(newValue, null);
}
return actualChanges; return actualChanges;
} }
public String documentKey() { public String documentKey() {
return this.documentKey; return this.documentKey;
} }
public Long documentTypeId() { public Long documentTypeId() {
return this.documentType.getId(); return this.documentType.getId();
} }
} }
@@ -30,7 +30,6 @@ import org.springframework.data.jpa.domain.AbstractPersistable;
@Table(name = "m_loan_collateral") @Table(name = "m_loan_collateral")
public class LoanCollateral extends AbstractPersistable<Long> { public class LoanCollateral extends AbstractPersistable<Long> {
@SuppressWarnings("unused")
@ManyToOne(optional = false) @ManyToOne(optional = false)
@JoinColumn(name = "loan_id", nullable = false) @JoinColumn(name = "loan_id", nullable = false)
private Loan loan; private Loan loan;
@@ -105,10 +104,10 @@ public class LoanCollateral extends AbstractPersistable<Long> {
public CollateralData toData() { public CollateralData toData() {
final CodeValueData typeData = this.type.toData(); final CodeValueData typeData = this.type.toData();
return CollateralData.instance(this.getId(), typeData, this.value, this.description, null); return CollateralData.instance(getId(), typeData, this.value, this.description, null);
} }
public void setCollateralType(CodeValue type) { public void setCollateralType(final CodeValue type) {
this.type = type; this.type = type;
} }
@@ -117,9 +116,9 @@ public class LoanCollateral extends AbstractPersistable<Long> {
if (obj == null) { return false; } if (obj == null) { return false; }
if (obj == this) { return true; } if (obj == this) { return true; }
if (obj.getClass() != getClass()) { return false; } if (obj.getClass() != getClass()) { return false; }
LoanCollateral rhs = (LoanCollateral) obj; final LoanCollateral rhs = (LoanCollateral) obj;
return new EqualsBuilder().appendSuper(super.equals(obj)) // return new EqualsBuilder().appendSuper(super.equals(obj)) //
.append(this.getId(), rhs.getId()) // .append(getId(), rhs.getId()) //
.append(this.type.getId(), rhs.type.getId()) // .append(this.type.getId(), rhs.type.getId()) //
.append(this.description, rhs.description) // .append(this.description, rhs.description) //
.append(this.value, this.value)// .append(this.value, this.value)//
@@ -129,7 +128,7 @@ public class LoanCollateral extends AbstractPersistable<Long> {
@Override @Override
public int hashCode() { public int hashCode() {
return new HashCodeBuilder(3, 5) // return new HashCodeBuilder(3, 5) //
.append(this.getId()) // .append(getId()) //
.append(this.type.getId()) // .append(this.type.getId()) //
.append(this.description) // .append(this.description) //
.append(this.value)// .append(this.value)//
@@ -19,7 +19,6 @@ import org.springframework.data.jpa.domain.AbstractPersistable;
@Table(name = "m_group_roles") @Table(name = "m_group_roles")
public class GroupRole extends AbstractPersistable<Long> { public class GroupRole extends AbstractPersistable<Long> {
@SuppressWarnings("unused")
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "group_id") @JoinColumn(name = "group_id")
private Group group; private Group group;
@@ -149,27 +149,22 @@ public class Loan extends AbstractPersistable<Long> {
@Column(name = "submittedon_date") @Column(name = "submittedon_date")
private Date submittedOnDate; private Date submittedOnDate;
@SuppressWarnings("unused")
@ManyToOne(optional = true) @ManyToOne(optional = true)
@JoinColumn(name = "submittedon_userid", nullable = true) @JoinColumn(name = "submittedon_userid", nullable = true)
private AppUser submittedBy; private AppUser submittedBy;
@SuppressWarnings("unused")
@Temporal(TemporalType.DATE) @Temporal(TemporalType.DATE)
@Column(name = "rejectedon_date") @Column(name = "rejectedon_date")
private Date rejectedOnDate; private Date rejectedOnDate;
@SuppressWarnings("unused")
@ManyToOne(optional = true) @ManyToOne(optional = true)
@JoinColumn(name = "rejectedon_userid", nullable = true) @JoinColumn(name = "rejectedon_userid", nullable = true)
private AppUser rejectedBy; private AppUser rejectedBy;
@SuppressWarnings("unused")
@Temporal(TemporalType.DATE) @Temporal(TemporalType.DATE)
@Column(name = "withdrawnon_date") @Column(name = "withdrawnon_date")
private Date withdrawnOnDate; private Date withdrawnOnDate;
@SuppressWarnings("unused")
@ManyToOne(optional = true) @ManyToOne(optional = true)
@JoinColumn(name = "withdrawnon_userid", nullable = true) @JoinColumn(name = "withdrawnon_userid", nullable = true)
private AppUser withdrawnBy; private AppUser withdrawnBy;
@@ -178,7 +173,6 @@ public class Loan extends AbstractPersistable<Long> {
@Column(name = "approvedon_date") @Column(name = "approvedon_date")
private Date approvedOnDate; private Date approvedOnDate;
@SuppressWarnings("unused")
@ManyToOne(optional = true) @ManyToOne(optional = true)
@JoinColumn(name = "approvedon_userid", nullable = true) @JoinColumn(name = "approvedon_userid", nullable = true)
private AppUser approvedBy; private AppUser approvedBy;
@@ -191,7 +185,6 @@ public class Loan extends AbstractPersistable<Long> {
@Column(name = "disbursedon_date") @Column(name = "disbursedon_date")
private Date actualDisbursementDate; private Date actualDisbursementDate;
@SuppressWarnings("unused")
@ManyToOne(optional = true) @ManyToOne(optional = true)
@JoinColumn(name = "disbursedon_userid", nullable = true) @JoinColumn(name = "disbursedon_userid", nullable = true)
private AppUser disbursedBy; private AppUser disbursedBy;
@@ -200,12 +193,10 @@ public class Loan extends AbstractPersistable<Long> {
@Column(name = "closedon_date") @Column(name = "closedon_date")
private Date closedOnDate; private Date closedOnDate;
@SuppressWarnings("unused")
@ManyToOne(optional = true) @ManyToOne(optional = true)
@JoinColumn(name = "closedon_userid", nullable = true) @JoinColumn(name = "closedon_userid", nullable = true)
private AppUser closedBy; private AppUser closedBy;
@SuppressWarnings("unused")
@Temporal(TemporalType.DATE) @Temporal(TemporalType.DATE)
@Column(name = "writtenoffon_date") @Column(name = "writtenoffon_date")
private Date writtenOffOnDate; private Date writtenOffOnDate;
@@ -214,12 +205,10 @@ public class Loan extends AbstractPersistable<Long> {
@Column(name = "rescheduledon_date") @Column(name = "rescheduledon_date")
private Date rescheduledOnDate; private Date rescheduledOnDate;
@SuppressWarnings("unused")
@Temporal(TemporalType.DATE) @Temporal(TemporalType.DATE)
@Column(name = "expected_maturedon_date") @Column(name = "expected_maturedon_date")
private Date expectedMaturityDate; private Date expectedMaturityDate;
@SuppressWarnings("unused")
@Temporal(TemporalType.DATE) @Temporal(TemporalType.DATE)
@Column(name = "maturedon_date") @Column(name = "maturedon_date")
private Date actualMaturityDate; private Date actualMaturityDate;
@@ -232,7 +221,6 @@ public class Loan extends AbstractPersistable<Long> {
@Column(name = "interest_calculated_from_date") @Column(name = "interest_calculated_from_date")
private Date interestChargedFromDate; private Date interestChargedFromDate;
@SuppressWarnings("unused")
@Column(name = "total_overpaid_derived", scale = 6, precision = 19) @Column(name = "total_overpaid_derived", scale = 6, precision = 19)
private BigDecimal totalOverpaid; private BigDecimal totalOverpaid;
@@ -382,7 +370,7 @@ public class Loan extends AbstractPersistable<Long> {
Money chargesDue = Money.of(getCurrency(), BigDecimal.ZERO); Money chargesDue = Money.of(getCurrency(), BigDecimal.ZERO);
for (LoanCharge charge : setOfLoanCharges()) { for (final LoanCharge charge : setOfLoanCharges()) {
if (charge.isDueAtDisbursement()) { if (charge.isDueAtDisbursement()) {
chargesDue = chargesDue.plus(charge.amount()); chargesDue = chargesDue.plus(charge.amount());
} }
@@ -392,14 +380,14 @@ public class Loan extends AbstractPersistable<Long> {
} }
private Set<LoanCharge> associateChargesWithThisLoan(final Set<LoanCharge> loanCharges) { private Set<LoanCharge> associateChargesWithThisLoan(final Set<LoanCharge> loanCharges) {
for (LoanCharge loanCharge : loanCharges) { for (final LoanCharge loanCharge : loanCharges) {
loanCharge.update(this); loanCharge.update(this);
} }
return loanCharges; return loanCharges;
} }
private Set<LoanCollateral> associateWithThisLoan(final Set<LoanCollateral> collateral) { private Set<LoanCollateral> associateWithThisLoan(final Set<LoanCollateral> collateral) {
for (LoanCollateral item : collateral) { for (final LoanCollateral item : collateral) {
item.associateWith(this); item.associateWith(this);
} }
return collateral; return collateral;
@@ -455,13 +443,13 @@ public class Loan extends AbstractPersistable<Long> {
final List<LoanTransaction> allNonContraTransactionsPostDisbursement = retreiveListOfTransactionsPostDisbursement(); final List<LoanTransaction> allNonContraTransactionsPostDisbursement = retreiveListOfTransactionsPostDisbursement();
changedTransactionDetail = loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(), changedTransactionDetail = loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(),
allNonContraTransactionsPostDisbursement, getCurrency(), this.repaymentScheduleInstallments, setOfLoanCharges()); allNonContraTransactionsPostDisbursement, getCurrency(), this.repaymentScheduleInstallments, setOfLoanCharges());
for (LoanTransaction transaction : changedTransactionDetail.getNewTransactions()) { for (final LoanTransaction transaction : changedTransactionDetail.getNewTransactions()) {
transaction.updateLoan(this); transaction.updateLoan(this);
} }
this.loanTransactions.addAll(changedTransactionDetail.getNewTransactions()); this.loanTransactions.addAll(changedTransactionDetail.getNewTransactions());
} else { } else {
// just reprocess the loan schedule only for now. // just reprocess the loan schedule only for now.
LoanRepaymentScheduleProcessingWrapper wrapper = new LoanRepaymentScheduleProcessingWrapper(); final LoanRepaymentScheduleProcessingWrapper wrapper = new LoanRepaymentScheduleProcessingWrapper();
wrapper.reprocess(getCurrency(), getDisbursementDate(), this.repaymentScheduleInstallments, setOfLoanCharges()); wrapper.reprocess(getCurrency(), getDisbursementDate(), this.repaymentScheduleInstallments, setOfLoanCharges());
} }
@@ -497,7 +485,7 @@ public class Loan extends AbstractPersistable<Long> {
transactionDate = suppliedTransactionDate; transactionDate = suppliedTransactionDate;
} else { } else {
transactionDate = loanCharge.getDueLocalDate(); transactionDate = loanCharge.getDueLocalDate();
LocalDate currentDate = DateUtils.getLocalDateOfTenant(); final LocalDate currentDate = DateUtils.getLocalDateOfTenant();
// if loan charge is to be applied on a future date, the loan // if loan charge is to be applied on a future date, the loan
// transaction would show todays date as applied date // transaction would show todays date as applied date
@@ -549,7 +537,7 @@ public class Loan extends AbstractPersistable<Long> {
// if you want ability to remove loan charges that are waived. // if you want ability to remove loan charges that are waived.
validateLoanChargeIsNotWaived(loanCharge); validateLoanChargeIsNotWaived(loanCharge);
boolean removed = setOfLoanCharges().remove(loanCharge); final boolean removed = setOfLoanCharges().remove(loanCharge);
if (removed) { if (removed) {
updateSummaryWithTotalFeeChargesDueAtDisbursement(deriveSumTotalOfChargesDueAtDisbursement()); updateSummaryWithTotalFeeChargesDueAtDisbursement(deriveSumTotalOfChargesDueAtDisbursement());
} }
@@ -578,7 +566,7 @@ public class Loan extends AbstractPersistable<Long> {
private void removeOrModifyTransactionAssociatedWithLoanChargeIfDueAtDisbursement(final LoanCharge loanCharge) { private void removeOrModifyTransactionAssociatedWithLoanChargeIfDueAtDisbursement(final LoanCharge loanCharge) {
if (loanCharge.isDueAtDisbursement()) { if (loanCharge.isDueAtDisbursement()) {
LoanTransaction transactionToRemove = null; LoanTransaction transactionToRemove = null;
for (LoanTransaction transaction : this.loanTransactions) { for (final LoanTransaction transaction : this.loanTransactions) {
if (transaction.isRepaymentAtDisbursement()) { if (transaction.isRepaymentAtDisbursement()) {
final MonetaryCurrency currency = loanCurrency(); final MonetaryCurrency currency = loanCurrency();
@@ -630,7 +618,7 @@ public class Loan extends AbstractPersistable<Long> {
getCurrency(), this.repaymentScheduleInstallments, setOfLoanCharges()); getCurrency(), this.repaymentScheduleInstallments, setOfLoanCharges());
} else { } else {
// reprocess loan schedule based on charge been waived. // reprocess loan schedule based on charge been waived.
LoanRepaymentScheduleProcessingWrapper wrapper = new LoanRepaymentScheduleProcessingWrapper(); final LoanRepaymentScheduleProcessingWrapper wrapper = new LoanRepaymentScheduleProcessingWrapper();
wrapper.reprocess(getCurrency(), getDisbursementDate(), this.repaymentScheduleInstallments, setOfLoanCharges()); wrapper.reprocess(getCurrency(), getDisbursementDate(), this.repaymentScheduleInstallments, setOfLoanCharges());
} }
@@ -687,7 +675,7 @@ public class Loan extends AbstractPersistable<Long> {
getCurrency(), this.repaymentScheduleInstallments, setOfLoanCharges()); getCurrency(), this.repaymentScheduleInstallments, setOfLoanCharges());
} else { } else {
// reprocess loan schedule based on charge been waived. // reprocess loan schedule based on charge been waived.
LoanRepaymentScheduleProcessingWrapper wrapper = new LoanRepaymentScheduleProcessingWrapper(); final LoanRepaymentScheduleProcessingWrapper wrapper = new LoanRepaymentScheduleProcessingWrapper();
wrapper.reprocess(getCurrency(), getDisbursementDate(), this.repaymentScheduleInstallments, setOfLoanCharges()); wrapper.reprocess(getCurrency(), getDisbursementDate(), this.repaymentScheduleInstallments, setOfLoanCharges());
} }
@@ -732,12 +720,12 @@ public class Loan extends AbstractPersistable<Long> {
} }
public void updateLoanOfficerOnLoanApplication(final Staff newLoanOfficer) { public void updateLoanOfficerOnLoanApplication(final Staff newLoanOfficer) {
if (!this.isSubmittedAndPendingApproval()) { if (!isSubmittedAndPendingApproval()) {
Long loanOfficerId = null; Long loanOfficerId = null;
if (this.loanOfficer != null) { if (this.loanOfficer != null) {
loanOfficerId = this.loanOfficer.getId(); loanOfficerId = this.loanOfficer.getId();
} }
throw new LoanOfficerAssignmentException(this.getId(), loanOfficerId); throw new LoanOfficerAssignmentException(getId(), loanOfficerId);
} }
this.loanOfficer = newLoanOfficer; this.loanOfficer = newLoanOfficer;
} }
@@ -763,15 +751,15 @@ public class Loan extends AbstractPersistable<Long> {
public void updateLoanSchedule(final LoanScheduleModel modifiedLoanSchedule) { public void updateLoanSchedule(final LoanScheduleModel modifiedLoanSchedule) {
this.repaymentScheduleInstallments.clear(); this.repaymentScheduleInstallments.clear();
for (LoanScheduleModelPeriod scheduledLoanInstallment : modifiedLoanSchedule.getPeriods()) { for (final LoanScheduleModelPeriod scheduledLoanInstallment : modifiedLoanSchedule.getPeriods()) {
if (scheduledLoanInstallment.isRepaymentPeriod()) { if (scheduledLoanInstallment.isRepaymentPeriod()) {
LoanRepaymentScheduleInstallment installment = new LoanRepaymentScheduleInstallment(this, final LoanRepaymentScheduleInstallment installment = new LoanRepaymentScheduleInstallment(this,
scheduledLoanInstallment.periodNumber(), scheduledLoanInstallment.periodFromDate(), scheduledLoanInstallment.periodNumber(), scheduledLoanInstallment.periodFromDate(),
scheduledLoanInstallment.periodDueDate(), scheduledLoanInstallment.principalDue(), scheduledLoanInstallment.periodDueDate(), scheduledLoanInstallment.principalDue(),
scheduledLoanInstallment.interestDue(), scheduledLoanInstallment.feeChargesDue(), scheduledLoanInstallment.interestDue(), scheduledLoanInstallment.feeChargesDue(),
scheduledLoanInstallment.penaltyChargesDue()); scheduledLoanInstallment.penaltyChargesDue());
this.addRepaymentScheduleInstallment(installment); addRepaymentScheduleInstallment(installment);
} }
} }
@@ -812,7 +800,7 @@ public class Loan extends AbstractPersistable<Long> {
final Map<String, Object> actualChanges = this.loanRepaymentScheduleDetail.updateLoanApplicationAttributes(command, aprCalculator); final Map<String, Object> actualChanges = this.loanRepaymentScheduleDetail.updateLoanApplicationAttributes(command, aprCalculator);
if (!actualChanges.isEmpty()) { if (!actualChanges.isEmpty()) {
boolean recalculateLoanSchedule = !(actualChanges.size() == 1 && actualChanges.containsKey("inArrearsTolerance")); final boolean recalculateLoanSchedule = !(actualChanges.size() == 1 && actualChanges.containsKey("inArrearsTolerance"));
actualChanges.put("recalculateLoanSchedule", recalculateLoanSchedule); actualChanges.put("recalculateLoanSchedule", recalculateLoanSchedule);
} }
@@ -962,14 +950,14 @@ public class Loan extends AbstractPersistable<Long> {
throw new InvalidLoanStateTransitionException("submittal", "cannot.be.a.future.date", errorMessage, getSubmittedOnDate()); throw new InvalidLoanStateTransitionException("submittal", "cannot.be.a.future.date", errorMessage, getSubmittedOnDate());
} }
if (!(client == null)) { if (!(this.client == null)) {
if (getSubmittedOnDate().isBefore(client.getActivationLocalDate())) { if (getSubmittedOnDate().isBefore(this.client.getActivationLocalDate())) {
final String errorMessage = "The date on which a loan is submitted cannot be earlier than client's activation date."; final String errorMessage = "The date on which a loan is submitted cannot be earlier than client's activation date.";
throw new InvalidLoanStateTransitionException("submittal", "cannot.be.before.client.activation.date", errorMessage, throw new InvalidLoanStateTransitionException("submittal", "cannot.be.before.client.activation.date", errorMessage,
getSubmittedOnDate()); getSubmittedOnDate());
} }
} else if (!(group == null)) { } else if (!(this.group == null)) {
if (getSubmittedOnDate().isBefore(group.getActivationLocalDate())) { if (getSubmittedOnDate().isBefore(this.group.getActivationLocalDate())) {
final String errorMessage = "The date on which a loan is submitted cannot be earlier than groups's activation date."; final String errorMessage = "The date on which a loan is submitted cannot be earlier than groups's activation date.";
throw new InvalidLoanStateTransitionException("submittal", "cannot.be.before.group.activation.date", errorMessage, throw new InvalidLoanStateTransitionException("submittal", "cannot.be.before.group.activation.date", errorMessage,
getSubmittedOnDate()); getSubmittedOnDate());
@@ -994,7 +982,7 @@ public class Loan extends AbstractPersistable<Long> {
actualChanges.put(chargesParamName, getLoanCharges(possiblyModifedLoanCharges)); actualChanges.put(chargesParamName, getLoanCharges(possiblyModifedLoanCharges));
actualChanges.put("recalculateLoanSchedule", true); actualChanges.put("recalculateLoanSchedule", true);
for (LoanCharge loanCharge : possiblyModifedLoanCharges) { for (final LoanCharge loanCharge : possiblyModifedLoanCharges) {
validateChargeHasValidSpecifiedDateIfApplicable(loanCharge, getDisbursementDate(), getLastRepaymentPeriodDueDate()); validateChargeHasValidSpecifiedDateIfApplicable(loanCharge, getDisbursementDate(), getLastRepaymentPeriodDueDate());
} }
} }
@@ -1038,10 +1026,10 @@ public class Loan extends AbstractPersistable<Long> {
CollateralData[] existingLoanCollateral = null; CollateralData[] existingLoanCollateral = null;
List<CollateralData> loanCollateralList = new ArrayList<CollateralData>(); final List<CollateralData> loanCollateralList = new ArrayList<CollateralData>();
for (LoanCollateral loanCollateral : setOfLoanCollateral) { for (final LoanCollateral loanCollateral : setOfLoanCollateral) {
CollateralData data = loanCollateral.toData(); final CollateralData data = loanCollateral.toData();
loanCollateralList.add(data); loanCollateralList.add(data);
} }
@@ -1055,8 +1043,8 @@ public class Loan extends AbstractPersistable<Long> {
LoanChargeCommand[] existingLoanCharges = null; LoanChargeCommand[] existingLoanCharges = null;
List<LoanChargeCommand> loanChargesList = new ArrayList<LoanChargeCommand>(); final List<LoanChargeCommand> loanChargesList = new ArrayList<LoanChargeCommand>();
for (LoanCharge loanCharge : setOfLoanCharges) { for (final LoanCharge loanCharge : setOfLoanCharges) {
loanChargesList.add(loanCharge.toCommand()); loanChargesList.add(loanCharge.toCommand());
} }
@@ -1066,9 +1054,9 @@ public class Loan extends AbstractPersistable<Long> {
} }
private void removeFirstDisbursementTransaction() { private void removeFirstDisbursementTransaction() {
for (LoanTransaction loanTransaction : loanTransactions) { for (final LoanTransaction loanTransaction : this.loanTransactions) {
if (loanTransaction.isDisbursement()) { if (loanTransaction.isDisbursement()) {
loanTransactions.remove(loanTransaction); this.loanTransactions.remove(loanTransaction);
break; break;
} }
} }
@@ -1086,7 +1074,7 @@ public class Loan extends AbstractPersistable<Long> {
from = LoanStatus.fromInt(this.loanStatus); from = LoanStatus.fromInt(this.loanStatus);
} }
LoanStatus statusEnum = lifecycleStateMachine.transition(LoanEvent.LOAN_CREATED, from); final LoanStatus statusEnum = lifecycleStateMachine.transition(LoanEvent.LOAN_CREATED, from);
this.loanStatus = statusEnum.getValue(); this.loanStatus = statusEnum.getValue();
this.externalId = externalId; this.externalId = externalId;
@@ -1105,11 +1093,11 @@ public class Loan extends AbstractPersistable<Long> {
throw new InvalidLoanStateTransitionException("submittal", "cannot.be.a.future.date", errorMessage, submittedOn); throw new InvalidLoanStateTransitionException("submittal", "cannot.be.a.future.date", errorMessage, submittedOn);
} }
if (client != null && client.isActivatedAfter(submittedOn)) { if (this.client != null && this.client.isActivatedAfter(submittedOn)) {
final String errorMessage = "The date on which a loan is submitted cannot be earlier than client's activation date."; final String errorMessage = "The date on which a loan is submitted cannot be earlier than client's activation date.";
throw new InvalidLoanStateTransitionException("submittal", "cannot.be.before.client.activation.date", errorMessage, submittedOn); throw new InvalidLoanStateTransitionException("submittal", "cannot.be.before.client.activation.date", errorMessage, submittedOn);
} }
if (group != null && group.isActivatedAfter(submittedOn)) { if (this.group != null && this.group.isActivatedAfter(submittedOn)) {
final String errorMessage = "The date on which a loan is submitted cannot be earlier than groups's activation date."; final String errorMessage = "The date on which a loan is submitted cannot be earlier than groups's activation date.";
throw new InvalidLoanStateTransitionException("submittal", "cannot.be.before.group.activation.date", errorMessage, submittedOn); throw new InvalidLoanStateTransitionException("submittal", "cannot.be.before.group.activation.date", errorMessage, submittedOn);
} }
@@ -1122,7 +1110,7 @@ public class Loan extends AbstractPersistable<Long> {
} }
// charges are optional // charges are optional
for (LoanCharge loanCharge : setOfLoanCharges()) { for (final LoanCharge loanCharge : setOfLoanCharges()) {
validateChargeHasValidSpecifiedDateIfApplicable(loanCharge, getDisbursementDate(), getLastRepaymentPeriodDueDate()); validateChargeHasValidSpecifiedDateIfApplicable(loanCharge, getDisbursementDate(), getLastRepaymentPeriodDueDate());
} }
@@ -1132,7 +1120,7 @@ public class Loan extends AbstractPersistable<Long> {
} }
private LocalDate determineExpectedMaturityDate() { private LocalDate determineExpectedMaturityDate() {
int numberOfInstallments = this.repaymentScheduleInstallments.size(); final int numberOfInstallments = this.repaymentScheduleInstallments.size();
return this.repaymentScheduleInstallments.get(numberOfInstallments - 1).getDueDate(); return this.repaymentScheduleInstallments.get(numberOfInstallments - 1).getDueDate();
} }
@@ -1146,7 +1134,7 @@ public class Loan extends AbstractPersistable<Long> {
this.loanStatus = statusEnum.getValue(); this.loanStatus = statusEnum.getValue();
actualChanges.put("status", LoanEnumerations.status(this.loanStatus)); actualChanges.put("status", LoanEnumerations.status(this.loanStatus));
LocalDate rejectedOn = command.localDateValueOfParameterNamed("rejectedOnDate"); final LocalDate rejectedOn = command.localDateValueOfParameterNamed("rejectedOnDate");
final Locale locale = new Locale(command.locale()); final Locale locale = new Locale(command.locale());
final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale); final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale);
@@ -1294,9 +1282,9 @@ public class Loan extends AbstractPersistable<Long> {
private Collection<Long> findExistingTransactionIds() { private Collection<Long> findExistingTransactionIds() {
Collection<Long> ids = new ArrayList<Long>(); final Collection<Long> ids = new ArrayList<Long>();
for (LoanTransaction transaction : this.loanTransactions) { for (final LoanTransaction transaction : this.loanTransactions) {
ids.add(transaction.getId()); ids.add(transaction.getId());
} }
@@ -1307,7 +1295,7 @@ public class Loan extends AbstractPersistable<Long> {
final Collection<Long> ids = new ArrayList<Long>(); final Collection<Long> ids = new ArrayList<Long>();
for (LoanTransaction transaction : this.loanTransactions) { for (final LoanTransaction transaction : this.loanTransactions) {
if (transaction.isReversed()) { if (transaction.isReversed()) {
ids.add(transaction.getId()); ids.add(transaction.getId());
} }
@@ -1324,7 +1312,7 @@ public class Loan extends AbstractPersistable<Long> {
updateLoanToPreDisbursalState(); updateLoanToPreDisbursalState();
final LoanStatus statusEnum = loanLifecycleStateMachine.transition(LoanEvent.LOAN_DISBURSED, LoanStatus.fromInt(this.loanStatus)); final LoanStatus statusEnum = this.loanLifecycleStateMachine.transition(LoanEvent.LOAN_DISBURSED, LoanStatus.fromInt(this.loanStatus));
if (!statusEnum.hasStateOf(LoanStatus.fromInt(this.loanStatus))) { if (!statusEnum.hasStateOf(LoanStatus.fromInt(this.loanStatus))) {
existingTransactionIds.addAll(findExistingTransactionIds()); existingTransactionIds.addAll(findExistingTransactionIds());
@@ -1358,7 +1346,7 @@ public class Loan extends AbstractPersistable<Long> {
updateLoanSummaryDerivedFields(); updateLoanSummaryDerivedFields();
} }
Money interestApplied = Money.of(this.getCurrency(), this.summary.getTotalInterestCharged()); final Money interestApplied = Money.of(getCurrency(), this.summary.getTotalInterestCharged());
final LoanTransaction interestAppliedTransaction = LoanTransaction.applyInterest(this, interestApplied, actualDisbursementDate); final LoanTransaction interestAppliedTransaction = LoanTransaction.applyInterest(this, interestApplied, actualDisbursementDate);
this.loanTransactions.add(interestAppliedTransaction); this.loanTransactions.add(interestAppliedTransaction);
} }
@@ -1368,8 +1356,8 @@ public class Loan extends AbstractPersistable<Long> {
private void updateLoanRepaymentPeriodsDerivedFields(final LocalDate actualDisbursementDate) { private void updateLoanRepaymentPeriodsDerivedFields(final LocalDate actualDisbursementDate) {
for (LoanRepaymentScheduleInstallment repaymentPeriod : this.repaymentScheduleInstallments) { for (final LoanRepaymentScheduleInstallment repaymentPeriod : this.repaymentScheduleInstallments) {
repaymentPeriod.updateDerivedFields(this.loanCurrency(), actualDisbursementDate); repaymentPeriod.updateDerivedFields(loanCurrency(), actualDisbursementDate);
} }
} }
@@ -1389,11 +1377,11 @@ public class Loan extends AbstractPersistable<Long> {
final Integer loanTermFrequency = this.termFrequency; final Integer loanTermFrequency = this.termFrequency;
final PeriodFrequencyType loanTermPeriodFrequencyType = PeriodFrequencyType.fromInt(this.termPeriodFrequencyType); final PeriodFrequencyType loanTermPeriodFrequencyType = PeriodFrequencyType.fromInt(this.termPeriodFrequencyType);
LoanApplicationTerms loanApplicationTerms = LoanApplicationTerms.assembleFrom(applicationCurrency, loanTermFrequency, final LoanApplicationTerms loanApplicationTerms = LoanApplicationTerms.assembleFrom(applicationCurrency, loanTermFrequency,
loanTermPeriodFrequencyType, getDisbursementDate(), getExpectedFirstRepaymentOnDate(), calculatedRepaymentsStartingFromDate, getInArrearsTolerance(), loanTermPeriodFrequencyType, getDisbursementDate(), getExpectedFirstRepaymentOnDate(), calculatedRepaymentsStartingFromDate, getInArrearsTolerance(),
this.loanRepaymentScheduleDetail); this.loanRepaymentScheduleDetail);
LoanScheduleModel loanSchedule = loanScheduleGenerator.generate(mc, applicationCurrency, loanApplicationTerms, this.charges, isHolidayEnabled, holidays, workingDays); final LoanScheduleModel loanSchedule = loanScheduleGenerator.generate(mc, applicationCurrency, loanApplicationTerms, this.charges, isHolidayEnabled, holidays, workingDays);
updateLoanSchedule(loanSchedule); updateLoanSchedule(loanSchedule);
} }
@@ -1415,8 +1403,8 @@ public class Loan extends AbstractPersistable<Long> {
final Money totalFeeChargesDueAtDisbursement = this.summary.getTotalFeeChargesDueAtDisbursement(loanCurrency()); final Money totalFeeChargesDueAtDisbursement = this.summary.getTotalFeeChargesDueAtDisbursement(loanCurrency());
if (totalFeeChargesDueAtDisbursement.isGreaterThanZero()) { if (totalFeeChargesDueAtDisbursement.isGreaterThanZero()) {
LoanTransaction chargesPayment = LoanTransaction.repaymentAtDisbursement(totalFeeChargesDueAtDisbursement, null, disbursedOn, txnExternalId); final LoanTransaction chargesPayment = LoanTransaction.repaymentAtDisbursement(totalFeeChargesDueAtDisbursement, null, disbursedOn, txnExternalId);
Money zero = Money.zero(getCurrency()); final Money zero = Money.zero(getCurrency());
chargesPayment.updateComponents(zero, zero, totalFeeChargesDueAtDisbursement, zero); chargesPayment.updateComponents(zero, zero, totalFeeChargesDueAtDisbursement, zero);
chargesPayment.updateLoan(this); chargesPayment.updateLoan(this);
this.loanTransactions.add(chargesPayment); this.loanTransactions.add(chargesPayment);
@@ -1426,11 +1414,11 @@ public class Loan extends AbstractPersistable<Long> {
* "APPLY Charge" transactions are created for all other fees ( * "APPLY Charge" transactions are created for all other fees (
* which are created during disbursal but not repaid) * which are created during disbursal but not repaid)
**/ **/
for (LoanCharge charge : setOfLoanCharges()) { for (final LoanCharge charge : setOfLoanCharges()) {
if (charge.isDueAtDisbursement()) { if (charge.isDueAtDisbursement()) {
charge.markAsFullyPaid(); charge.markAsFullyPaid();
// Add "Loan Charge Paid By" details to this transaction // Add "Loan Charge Paid By" details to this transaction
LoanChargePaidBy loanChargePaidBy = new LoanChargePaidBy(chargesPayment, charge, charge.amount()); final LoanChargePaidBy loanChargePaidBy = new LoanChargePaidBy(chargesPayment, charge, charge.amount());
chargesPayment.getLoanChargesPaid().add(loanChargePaidBy); chargesPayment.getLoanChargesPaid().add(loanChargePaidBy);
} else { } else {
handleChargeAppliedTransaction(charge, disbursedOn); handleChargeAppliedTransaction(charge, disbursedOn);
@@ -1481,7 +1469,7 @@ public class Loan extends AbstractPersistable<Long> {
private final void reverseExistingTransactions() { private final void reverseExistingTransactions() {
for (LoanTransaction transaction : this.loanTransactions) { for (final LoanTransaction transaction : this.loanTransactions) {
transaction.reverse(); transaction.reverse();
} }
} }
@@ -1489,15 +1477,15 @@ public class Loan extends AbstractPersistable<Long> {
private void updateLoanToPreDisbursalState() { private void updateLoanToPreDisbursalState() {
this.actualDisbursementDate = null; this.actualDisbursementDate = null;
for (LoanCharge charge : setOfLoanCharges()) { for (final LoanCharge charge : setOfLoanCharges()) {
charge.resetToOriginal(loanCurrency()); charge.resetToOriginal(loanCurrency());
} }
for (LoanRepaymentScheduleInstallment currentInstallment : this.repaymentScheduleInstallments) { for (final LoanRepaymentScheduleInstallment currentInstallment : this.repaymentScheduleInstallments) {
currentInstallment.resetDerivedComponents(); currentInstallment.resetDerivedComponents();
} }
LoanRepaymentScheduleProcessingWrapper wrapper = new LoanRepaymentScheduleProcessingWrapper(); final LoanRepaymentScheduleProcessingWrapper wrapper = new LoanRepaymentScheduleProcessingWrapper();
wrapper.reprocess(getCurrency(), getDisbursementDate(), this.repaymentScheduleInstallments, setOfLoanCharges()); wrapper.reprocess(getCurrency(), getDisbursementDate(), this.repaymentScheduleInstallments, setOfLoanCharges());
updateLoanSummaryDerivedFields(); updateLoanSummaryDerivedFields();
@@ -1510,7 +1498,7 @@ public class Loan extends AbstractPersistable<Long> {
existingTransactionIds.addAll(findExistingTransactionIds()); existingTransactionIds.addAll(findExistingTransactionIds());
existingReversedTransactionIds.addAll(findExistingReversedTransactionIds()); existingReversedTransactionIds.addAll(findExistingReversedTransactionIds());
ChangedTransactionDetail changedTransactionDetail = handleRepaymentOrWaiverTransaction(waiveInterestTransaction, final ChangedTransactionDetail changedTransactionDetail = handleRepaymentOrWaiverTransaction(waiveInterestTransaction,
loanLifecycleStateMachine, null); loanLifecycleStateMachine, null);
return changedTransactionDetail; return changedTransactionDetail;
@@ -1527,7 +1515,7 @@ public class Loan extends AbstractPersistable<Long> {
existingTransactionIds.addAll(findExistingTransactionIds()); existingTransactionIds.addAll(findExistingTransactionIds());
existingReversedTransactionIds.addAll(findExistingReversedTransactionIds()); existingReversedTransactionIds.addAll(findExistingReversedTransactionIds());
ChangedTransactionDetail changedTransactionDetail = handleRepaymentOrWaiverTransaction(repaymentTransaction, final ChangedTransactionDetail changedTransactionDetail = handleRepaymentOrWaiverTransaction(repaymentTransaction,
loanLifecycleStateMachine, null); loanLifecycleStateMachine, null);
return changedTransactionDetail; return changedTransactionDetail;
@@ -1544,7 +1532,7 @@ public class Loan extends AbstractPersistable<Long> {
loanTransaction.updateLoan(this); loanTransaction.updateLoan(this);
boolean isTransactionChronologicallyLatest = isChronologicallyLatestRepaymentOrWaiver(loanTransaction, this.loanTransactions); final boolean isTransactionChronologicallyLatest = isChronologicallyLatestRepaymentOrWaiver(loanTransaction, this.loanTransactions);
if (loanTransaction.isNotZero(loanCurrency())) { if (loanTransaction.isNotZero(loanCurrency())) {
this.loanTransactions.add(loanTransaction); this.loanTransactions.add(loanTransaction);
@@ -1555,12 +1543,12 @@ public class Loan extends AbstractPersistable<Long> {
throw new InvalidLoanTransactionTypeException("transaction", "is.not.a.repayment.or.waiver.transaction", errorMessage); throw new InvalidLoanTransactionTypeException("transaction", "is.not.a.repayment.or.waiver.transaction", errorMessage);
} }
LocalDate loanTransactionDate = loanTransaction.getTransactionDate(); final LocalDate loanTransactionDate = loanTransaction.getTransactionDate();
if (loanTransactionDate.isBefore(this.getDisbursementDate())) { if (loanTransactionDate.isBefore(getDisbursementDate())) {
final String errorMessage = "The transaction date cannot be before the loan disbursement date: " final String errorMessage = "The transaction date cannot be before the loan disbursement date: "
+ getApprovedOnDate().toString(); + getApprovedOnDate().toString();
throw new InvalidLoanStateTransitionException("transaction", "cannot.be.before.disbursement.date", errorMessage, throw new InvalidLoanStateTransitionException("transaction", "cannot.be.before.disbursement.date", errorMessage,
loanTransactionDate, this.getDisbursementDate()); loanTransactionDate, getDisbursementDate());
} }
if (loanTransactionDate.isAfter(DateUtils.getLocalDateOfTenant())) { if (loanTransactionDate.isAfter(DateUtils.getLocalDateOfTenant())) {
@@ -1589,7 +1577,7 @@ public class Loan extends AbstractPersistable<Long> {
final List<LoanTransaction> allNonContraTransactionsPostDisbursement = retreiveListOfTransactionsPostDisbursement(); final List<LoanTransaction> allNonContraTransactionsPostDisbursement = retreiveListOfTransactionsPostDisbursement();
changedTransactionDetail = loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(), changedTransactionDetail = loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(),
allNonContraTransactionsPostDisbursement, getCurrency(), this.repaymentScheduleInstallments, setOfLoanCharges()); allNonContraTransactionsPostDisbursement, getCurrency(), this.repaymentScheduleInstallments, setOfLoanCharges());
for (LoanTransaction newLoanTransaction : changedTransactionDetail.getNewTransactions()) { for (final LoanTransaction newLoanTransaction : changedTransactionDetail.getNewTransactions()) {
newLoanTransaction.updateLoan(this); newLoanTransaction.updateLoan(this);
} }
this.loanTransactions.addAll(changedTransactionDetail.getNewTransactions()); this.loanTransactions.addAll(changedTransactionDetail.getNewTransactions());
@@ -1603,20 +1591,20 @@ public class Loan extends AbstractPersistable<Long> {
} }
private List<LoanTransaction> retreiveListOfTransactionsPostDisbursement() { private List<LoanTransaction> retreiveListOfTransactionsPostDisbursement() {
List<LoanTransaction> repaymentsOrWaivers = new ArrayList<LoanTransaction>(); final List<LoanTransaction> repaymentsOrWaivers = new ArrayList<LoanTransaction>();
for (LoanTransaction transaction : this.loanTransactions) { for (final LoanTransaction transaction : this.loanTransactions) {
if (!transaction.isDisbursement() && transaction.isNotReversed()) { if (!transaction.isDisbursement() && transaction.isNotReversed()) {
repaymentsOrWaivers.add(transaction); repaymentsOrWaivers.add(transaction);
} }
} }
LoanTransactionComparator transactionComparator = new LoanTransactionComparator(); final LoanTransactionComparator transactionComparator = new LoanTransactionComparator();
Collections.sort(repaymentsOrWaivers, transactionComparator); Collections.sort(repaymentsOrWaivers, transactionComparator);
return repaymentsOrWaivers; return repaymentsOrWaivers;
} }
private void doPostLoanTransactionChecks(final LocalDate transactionDate, final LoanLifecycleStateMachine loanLifecycleStateMachine) { private void doPostLoanTransactionChecks(final LocalDate transactionDate, final LoanLifecycleStateMachine loanLifecycleStateMachine) {
if (this.isOverPaid()) { if (isOverPaid()) {
// FIXME - kw - update account balance to negative amount. // FIXME - kw - update account balance to negative amount.
handleLoanOverpayment(loanLifecycleStateMachine); handleLoanOverpayment(loanLifecycleStateMachine);
} else if (this.summary.isRepaidInFull(loanCurrency())) { } else if (this.summary.isRepaidInFull(loanCurrency())) {
@@ -1626,7 +1614,7 @@ public class Loan extends AbstractPersistable<Long> {
private void handleLoanRepaymentInFull(final LocalDate transactionDate, final LoanLifecycleStateMachine loanLifecycleStateMachine) { private void handleLoanRepaymentInFull(final LocalDate transactionDate, final LoanLifecycleStateMachine loanLifecycleStateMachine) {
LoanStatus statusEnum = loanLifecycleStateMachine.transition(LoanEvent.REPAID_IN_FULL, LoanStatus.fromInt(this.loanStatus)); final LoanStatus statusEnum = loanLifecycleStateMachine.transition(LoanEvent.REPAID_IN_FULL, LoanStatus.fromInt(this.loanStatus));
this.loanStatus = statusEnum.getValue(); this.loanStatus = statusEnum.getValue();
this.closedOnDate = transactionDate.toDate(); this.closedOnDate = transactionDate.toDate();
@@ -1635,7 +1623,7 @@ public class Loan extends AbstractPersistable<Long> {
private void handleLoanOverpayment(final LoanLifecycleStateMachine loanLifecycleStateMachine) { private void handleLoanOverpayment(final LoanLifecycleStateMachine loanLifecycleStateMachine) {
LoanStatus statusEnum = loanLifecycleStateMachine.transition(LoanEvent.LOAN_OVERPAYMENT, LoanStatus.fromInt(this.loanStatus)); final LoanStatus statusEnum = loanLifecycleStateMachine.transition(LoanEvent.LOAN_OVERPAYMENT, LoanStatus.fromInt(this.loanStatus));
this.loanStatus = statusEnum.getValue(); this.loanStatus = statusEnum.getValue();
this.closedOnDate = null; this.closedOnDate = null;
@@ -1647,8 +1635,8 @@ public class Loan extends AbstractPersistable<Long> {
boolean isChronologicallyLatestRepaymentOrWaiver = true; boolean isChronologicallyLatestRepaymentOrWaiver = true;
LocalDate currentTransactionDate = loanTransaction.getTransactionDate(); final LocalDate currentTransactionDate = loanTransaction.getTransactionDate();
for (LoanTransaction previousTransaction : loanTransactions) { for (final LoanTransaction previousTransaction : loanTransactions) {
if (!previousTransaction.isDisbursement() && previousTransaction.isNotReversed()) { if (!previousTransaction.isDisbursement() && previousTransaction.isNotReversed()) {
if (currentTransactionDate.isBefore(previousTransaction.getTransactionDate()) if (currentTransactionDate.isBefore(previousTransaction.getTransactionDate())
|| currentTransactionDate.isEqual(previousTransaction.getTransactionDate())) { || currentTransactionDate.isEqual(previousTransaction.getTransactionDate())) {
@@ -1665,8 +1653,8 @@ public class Loan extends AbstractPersistable<Long> {
boolean isChronologicallyLatestRepaymentOrWaiver = true; boolean isChronologicallyLatestRepaymentOrWaiver = true;
LocalDate currentTransactionDate = loanTransaction.getTransactionDate(); final LocalDate currentTransactionDate = loanTransaction.getTransactionDate();
for (LoanTransaction previousTransaction : loanTransactions) { for (final LoanTransaction previousTransaction : loanTransactions) {
if (previousTransaction.isNotReversed()) { if (previousTransaction.isNotReversed()) {
if (currentTransactionDate.isBefore(previousTransaction.getTransactionDate()) if (currentTransactionDate.isBefore(previousTransaction.getTransactionDate())
|| currentTransactionDate.isEqual(previousTransaction.getTransactionDate())) { || currentTransactionDate.isEqual(previousTransaction.getTransactionDate())) {
@@ -1681,7 +1669,7 @@ public class Loan extends AbstractPersistable<Long> {
public LocalDate possibleNextRepaymentDate() { public LocalDate possibleNextRepaymentDate() {
LocalDate earliestUnpaidInstallmentDate = new LocalDate(); LocalDate earliestUnpaidInstallmentDate = new LocalDate();
for (LoanRepaymentScheduleInstallment installment : this.repaymentScheduleInstallments) { for (final LoanRepaymentScheduleInstallment installment : this.repaymentScheduleInstallments) {
if (installment.isNotFullyPaidOff()) { if (installment.isNotFullyPaidOff()) {
earliestUnpaidInstallmentDate = installment.getDueDate(); earliestUnpaidInstallmentDate = installment.getDueDate();
break; break;
@@ -1689,7 +1677,7 @@ public class Loan extends AbstractPersistable<Long> {
} }
LocalDate lastTransactionDate = null; LocalDate lastTransactionDate = null;
for (LoanTransaction transaction : this.loanTransactions) { for (final LoanTransaction transaction : this.loanTransactions) {
if (transaction.isRepayment() && transaction.isNonZero()) { if (transaction.isRepayment() && transaction.isNonZero()) {
lastTransactionDate = transaction.getTransactionDate(); lastTransactionDate = transaction.getTransactionDate();
} }
@@ -1704,10 +1692,10 @@ public class Loan extends AbstractPersistable<Long> {
} }
public Money possibleNextRepaymentAmount() { public Money possibleNextRepaymentAmount() {
MonetaryCurrency currency = this.loanRepaymentScheduleDetail.getPrincipal().getCurrency(); final MonetaryCurrency currency = this.loanRepaymentScheduleDetail.getPrincipal().getCurrency();
Money possibleNextRepaymentAmount = Money.zero(currency); Money possibleNextRepaymentAmount = Money.zero(currency);
for (LoanRepaymentScheduleInstallment installment : this.repaymentScheduleInstallments) { for (final LoanRepaymentScheduleInstallment installment : this.repaymentScheduleInstallments) {
if (installment.isNotFullyPaidOff()) { if (installment.isNotFullyPaidOff()) {
possibleNextRepaymentAmount = installment.getTotalOutstanding(currency); possibleNextRepaymentAmount = installment.getTotalOutstanding(currency);
break; break;
@@ -1726,7 +1714,7 @@ public class Loan extends AbstractPersistable<Long> {
if (totalInterestOutstanding.isGreaterThanZero()) { if (totalInterestOutstanding.isGreaterThanZero()) {
// find earliest known instance of overdue interest and default to // find earliest known instance of overdue interest and default to
// that // that
for (LoanRepaymentScheduleInstallment scheduledRepayment : this.repaymentScheduleInstallments) { for (final LoanRepaymentScheduleInstallment scheduledRepayment : this.repaymentScheduleInstallments) {
final Money outstandingForPeriod = scheduledRepayment.getInterestOutstanding(loanCurrency()); final Money outstandingForPeriod = scheduledRepayment.getInterestOutstanding(loanCurrency());
if (scheduledRepayment.isOverdueOn(new LocalDate()) && scheduledRepayment.isNotFullyPaidOff() if (scheduledRepayment.isOverdueOn(new LocalDate()) && scheduledRepayment.isNotFullyPaidOff()
@@ -1765,7 +1753,7 @@ public class Loan extends AbstractPersistable<Long> {
if (isClosedWrittenOff()) { if (isClosedWrittenOff()) {
// find write off transaction and reverse it // find write off transaction and reverse it
LoanTransaction writeOffTransaction = findWriteOffTransaction(); final LoanTransaction writeOffTransaction = findWriteOffTransaction();
writeOffTransaction.reverse(); writeOffTransaction.reverse();
} }
@@ -1784,7 +1772,7 @@ public class Loan extends AbstractPersistable<Long> {
private LoanTransaction findWriteOffTransaction() { private LoanTransaction findWriteOffTransaction() {
LoanTransaction writeOff = null; LoanTransaction writeOff = null;
for (LoanTransaction transaction : this.loanTransactions) { for (final LoanTransaction transaction : this.loanTransactions) {
if (!transaction.isReversed() && transaction.isWriteOff()) { if (!transaction.isReversed() && transaction.isWriteOff()) {
writeOff = transaction; writeOff = transaction;
} }
@@ -1805,7 +1793,7 @@ public class Loan extends AbstractPersistable<Long> {
Money cumulativeTotalPaidOnInstallments = Money.zero(currency); Money cumulativeTotalPaidOnInstallments = Money.zero(currency);
Money cumulativeTotalWaivedOnInstallments = Money.zero(currency); Money cumulativeTotalWaivedOnInstallments = Money.zero(currency);
for (LoanRepaymentScheduleInstallment scheduledRepayment : this.repaymentScheduleInstallments) { for (final LoanRepaymentScheduleInstallment scheduledRepayment : this.repaymentScheduleInstallments) {
cumulativeTotalPaidOnInstallments = cumulativeTotalPaidOnInstallments cumulativeTotalPaidOnInstallments = cumulativeTotalPaidOnInstallments
.plus(scheduledRepayment.getPrincipalCompleted(currency).plus(scheduledRepayment.getInterestPaid(currency))) .plus(scheduledRepayment.getPrincipalCompleted(currency).plus(scheduledRepayment.getInterestPaid(currency)))
@@ -1847,7 +1835,7 @@ public class Loan extends AbstractPersistable<Long> {
changes.put("closedOnDate", command.stringValueOfParameterNamed("transactionDate")); changes.put("closedOnDate", command.stringValueOfParameterNamed("transactionDate"));
changes.put("writtenOffOnDate", command.stringValueOfParameterNamed("transactionDate")); changes.put("writtenOffOnDate", command.stringValueOfParameterNamed("transactionDate"));
if (writtenOffOnLocalDate.isBefore(this.getDisbursementDate())) { if (writtenOffOnLocalDate.isBefore(getDisbursementDate())) {
final String errorMessage = "The date on which a loan is written off cannot be before the loan disbursement date: " final String errorMessage = "The date on which a loan is written off cannot be before the loan disbursement date: "
+ getDisbursementDate().toString(); + getDisbursementDate().toString();
throw new InvalidLoanStateTransitionException("writeoff", "cannot.be.before.submittal.date", errorMessage, throw new InvalidLoanStateTransitionException("writeoff", "cannot.be.before.submittal.date", errorMessage,
@@ -1860,7 +1848,7 @@ public class Loan extends AbstractPersistable<Long> {
} }
loanTransaction = LoanTransaction.writeoff(this, writtenOffOnLocalDate, txnExternalId); loanTransaction = LoanTransaction.writeoff(this, writtenOffOnLocalDate, txnExternalId);
final boolean isLastTransaction = isChronologicallyLatestTransaction(loanTransaction, loanTransactions); final boolean isLastTransaction = isChronologicallyLatestTransaction(loanTransaction, this.loanTransactions);
if (!isLastTransaction) { if (!isLastTransaction) {
final String errorMessage = "The date of the writeoff transaction must occur on or before previous transactions."; final String errorMessage = "The date of the writeoff transaction must occur on or before previous transactions.";
throw new InvalidLoanStateTransitionException("writeoff", "must.occur.on.or.after.other.transaction.dates", errorMessage, throw new InvalidLoanStateTransitionException("writeoff", "must.occur.on.or.after.other.transaction.dates", errorMessage,
@@ -1891,7 +1879,7 @@ public class Loan extends AbstractPersistable<Long> {
this.closedOnDate = closureDate.toDate(); this.closedOnDate = closureDate.toDate();
changes.put("closedOnDate", command.stringValueOfParameterNamed("transactionDate")); changes.put("closedOnDate", command.stringValueOfParameterNamed("transactionDate"));
if (closureDate.isBefore(this.getDisbursementDate())) { if (closureDate.isBefore(getDisbursementDate())) {
final String errorMessage = "The date on which a loan is closed cannot be before the loan disbursement date: " final String errorMessage = "The date on which a loan is closed cannot be before the loan disbursement date: "
+ getDisbursementDate().toString(); + getDisbursementDate().toString();
throw new InvalidLoanStateTransitionException("close", "cannot.be.before.submittal.date", errorMessage, closureDate, throw new InvalidLoanStateTransitionException("close", "cannot.be.before.submittal.date", errorMessage, closureDate,
@@ -1917,7 +1905,7 @@ public class Loan extends AbstractPersistable<Long> {
this.closedOnDate = closureDate.toDate(); this.closedOnDate = closureDate.toDate();
loanTransaction = LoanTransaction.writeoff(this, closureDate, txnExternalId); loanTransaction = LoanTransaction.writeoff(this, closureDate, txnExternalId);
boolean isLastTransaction = isChronologicallyLatestTransaction(loanTransaction, loanTransactions); final boolean isLastTransaction = isChronologicallyLatestTransaction(loanTransaction, this.loanTransactions);
if (!isLastTransaction) { if (!isLastTransaction) {
final String errorMessage = "The closing date of the loan must be on or after latest transaction date."; final String errorMessage = "The closing date of the loan must be on or after latest transaction date.";
throw new InvalidLoanStateTransitionException("close.loan", "must.occur.on.or.after.latest.transaction.date", throw new InvalidLoanStateTransitionException("close.loan", "must.occur.on.or.after.latest.transaction.date",
@@ -1981,8 +1969,8 @@ public class Loan extends AbstractPersistable<Long> {
changes.put("closedOnDate", command.stringValueOfParameterNamed("transactionDate")); changes.put("closedOnDate", command.stringValueOfParameterNamed("transactionDate"));
changes.put("rescheduledOnDate", command.stringValueOfParameterNamed("transactionDate")); changes.put("rescheduledOnDate", command.stringValueOfParameterNamed("transactionDate"));
LocalDate rescheduledOnLocalDate = new LocalDate(rescheduledOnDate); final LocalDate rescheduledOnLocalDate = new LocalDate(this.rescheduledOnDate);
if (rescheduledOnLocalDate.isBefore(this.getDisbursementDate())) { if (rescheduledOnLocalDate.isBefore(getDisbursementDate())) {
final String errorMessage = "The date on which a loan is rescheduled cannot be before the loan disbursement date: " final String errorMessage = "The date on which a loan is rescheduled cannot be before the loan disbursement date: "
+ getDisbursementDate().toString(); + getDisbursementDate().toString();
throw new InvalidLoanStateTransitionException("close.reschedule", "cannot.be.before.submittal.date", errorMessage, throw new InvalidLoanStateTransitionException("close.reschedule", "cannot.be.before.submittal.date", errorMessage,
@@ -2009,7 +1997,7 @@ public class Loan extends AbstractPersistable<Long> {
} }
private boolean isNotDisbursed() { private boolean isNotDisbursed() {
return !this.isDisbursed(); return !isDisbursed();
} }
private boolean isDisbursed() { private boolean isDisbursed() {
@@ -2017,7 +2005,7 @@ public class Loan extends AbstractPersistable<Long> {
} }
private boolean isClosed() { private boolean isClosed() {
return status().isClosed() || this.isCancelled(); return status().isClosed() || isCancelled();
} }
private boolean isClosedObligationsMet() { private boolean isClosedObligationsMet() {
@@ -2033,7 +2021,7 @@ public class Loan extends AbstractPersistable<Long> {
} }
private boolean isCancelled() { private boolean isCancelled() {
return this.isRejected() || this.isWithdrawn(); return isRejected() || isWithdrawn();
} }
private boolean isWithdrawn() { private boolean isWithdrawn() {
@@ -2050,7 +2038,7 @@ public class Loan extends AbstractPersistable<Long> {
private boolean hasDisbursementTransaction() { private boolean hasDisbursementTransaction() {
boolean hasRepaymentTransaction = false; boolean hasRepaymentTransaction = false;
for (LoanTransaction loanTransaction : this.loanTransactions) { for (final LoanTransaction loanTransaction : this.loanTransactions) {
if (loanTransaction.isDisbursement() && loanTransaction.isNotReversed()) { if (loanTransaction.isDisbursement() && loanTransaction.isNotReversed()) {
hasRepaymentTransaction = true; hasRepaymentTransaction = true;
break; break;
@@ -2060,7 +2048,7 @@ public class Loan extends AbstractPersistable<Long> {
} }
public boolean isSubmittedOnDateAfter(final LocalDate compareDate) { public boolean isSubmittedOnDateAfter(final LocalDate compareDate) {
return this.submittedOnDate == null ? false : (new LocalDate(submittedOnDate)).isAfter(compareDate); return this.submittedOnDate == null ? false : new LocalDate(this.submittedOnDate).isAfter(compareDate);
} }
public LocalDate getSubmittedOnDate() { public LocalDate getSubmittedOnDate() {
@@ -2115,7 +2103,7 @@ public class Loan extends AbstractPersistable<Long> {
private Money getTotalPaidInRepayments() { private Money getTotalPaidInRepayments() {
Money cumulativePaid = Money.zero(loanCurrency()); Money cumulativePaid = Money.zero(loanCurrency());
for (LoanTransaction repayment : this.loanTransactions) { for (final LoanTransaction repayment : this.loanTransactions) {
if (repayment.isRepayment()) { if (repayment.isRepayment()) {
cumulativePaid = cumulativePaid.plus(repayment.getAmount(loanCurrency())); cumulativePaid = cumulativePaid.plus(repayment.getAmount(loanCurrency()));
} }
@@ -2127,7 +2115,7 @@ public class Loan extends AbstractPersistable<Long> {
private Money getTotalInterestOutstandingOnLoan() { private Money getTotalInterestOutstandingOnLoan() {
Money cumulativeInterest = Money.zero(loanCurrency()); Money cumulativeInterest = Money.zero(loanCurrency());
for (LoanRepaymentScheduleInstallment scheduledRepayment : this.repaymentScheduleInstallments) { for (final LoanRepaymentScheduleInstallment scheduledRepayment : this.repaymentScheduleInstallments) {
cumulativeInterest = cumulativeInterest.plus(scheduledRepayment.getInterestOutstanding(loanCurrency())); cumulativeInterest = cumulativeInterest.plus(scheduledRepayment.getInterestOutstanding(loanCurrency()));
} }
@@ -2138,7 +2126,7 @@ public class Loan extends AbstractPersistable<Long> {
private Money getTotalInterestOverdueOnLoan() { private Money getTotalInterestOverdueOnLoan() {
Money cumulativeInterestOverdue = Money.zero(this.loanRepaymentScheduleDetail.getPrincipal().getCurrency()); Money cumulativeInterestOverdue = Money.zero(this.loanRepaymentScheduleDetail.getPrincipal().getCurrency());
for (LoanRepaymentScheduleInstallment scheduledRepayment : this.repaymentScheduleInstallments) { for (final LoanRepaymentScheduleInstallment scheduledRepayment : this.repaymentScheduleInstallments) {
final Money interestOutstandingForPeriod = scheduledRepayment.getInterestOutstanding(loanCurrency()); final Money interestOutstandingForPeriod = scheduledRepayment.getInterestOutstanding(loanCurrency());
if (scheduledRepayment.isOverdueOn(new LocalDate())) { if (scheduledRepayment.isOverdueOn(new LocalDate())) {
@@ -2154,7 +2142,7 @@ public class Loan extends AbstractPersistable<Long> {
} }
public boolean hasIdentifyOf(final Long loanId) { public boolean hasIdentifyOf(final Long loanId) {
return loanId.equals(this.getId()); return loanId.equals(getId());
} }
public boolean hasLoanOfficer(final Staff fromLoanOfficer) { public boolean hasLoanOfficer(final Staff fromLoanOfficer) {
@@ -2199,7 +2187,7 @@ public class Loan extends AbstractPersistable<Long> {
final LoanOfficerAssignmentHistory lastAssignmentRecord = findLastAssignmentHistoryRecord(newLoanOfficer); final LoanOfficerAssignmentHistory lastAssignmentRecord = findLastAssignmentHistoryRecord(newLoanOfficer);
// assignment date should not be less than loan submitted date // assignment date should not be less than loan submitted date
if (this.isSubmittedOnDateAfter(assignmentDate)) { if (isSubmittedOnDateAfter(assignmentDate)) {
final String errorMessage = "The Loan Officer assignment date (" + assignmentDate.toString() final String errorMessage = "The Loan Officer assignment date (" + assignmentDate.toString()
+ ") cannot be before loan submitted date (" + getSubmittedOnDate().toString() + ")."; + ") cannot be before loan submitted date (" + getSubmittedOnDate().toString() + ").";
@@ -2227,8 +2215,8 @@ public class Loan extends AbstractPersistable<Long> {
latestHistoryRecord.updateLoanOfficer(newLoanOfficer); latestHistoryRecord.updateLoanOfficer(newLoanOfficer);
this.loanOfficer = newLoanOfficer; this.loanOfficer = newLoanOfficer;
} else if (latestHistoryRecord != null && latestHistoryRecord.hasStartDateBefore(assignmentDate)) { } else if (latestHistoryRecord != null && latestHistoryRecord.hasStartDateBefore(assignmentDate)) {
final String errorMessage = "Loan with identifier " + this.getId() + " was already assigned before date " + assignmentDate; final String errorMessage = "Loan with identifier " + getId() + " was already assigned before date " + assignmentDate;
throw new LoanOfficerAssignmentDateException("is.before.last.assignment.date", errorMessage, this.getId(), assignmentDate); throw new LoanOfficerAssignmentDateException("is.before.last.assignment.date", errorMessage, getId(), assignmentDate);
} else { } else {
if (latestHistoryRecord != null) { if (latestHistoryRecord != null) {
// loan officer correctly changed from previous loan officer to // loan officer correctly changed from previous loan officer to
@@ -2237,7 +2225,7 @@ public class Loan extends AbstractPersistable<Long> {
} }
this.loanOfficer = newLoanOfficer; this.loanOfficer = newLoanOfficer;
if (this.isNotSubmittedAndPendingApproval()) { if (isNotSubmittedAndPendingApproval()) {
final LoanOfficerAssignmentHistory loanOfficerAssignmentHistory = LoanOfficerAssignmentHistory.createNew(this, final LoanOfficerAssignmentHistory loanOfficerAssignmentHistory = LoanOfficerAssignmentHistory.createNew(this,
this.loanOfficer, assignmentDate); this.loanOfficer, assignmentDate);
this.loanOfficerHistory.add(loanOfficerAssignmentHistory); this.loanOfficerHistory.add(loanOfficerAssignmentHistory);
@@ -2266,8 +2254,7 @@ public class Loan extends AbstractPersistable<Long> {
final String errorMessage = "The Loan officer Unassign date(" + unassignDate + ") cannot be before its assignment date (" final String errorMessage = "The Loan officer Unassign date(" + unassignDate + ") cannot be before its assignment date ("
+ latestHistoryRecord.getStartDate() + ")."; + latestHistoryRecord.getStartDate() + ").";
throw new LoanOfficerUnassignmentDateException("cannot.be.before.assignment.date", errorMessage, this.getId(), this throw new LoanOfficerUnassignmentDateException("cannot.be.before.assignment.date", errorMessage, getId(), getLoanOfficer().getId(), latestHistoryRecord.getStartDate(), unassignDate);
.getLoanOfficer().getId(), latestHistoryRecord.getStartDate(), unassignDate);
} else if (unassignDate.isAfter(today)) { } else if (unassignDate.isAfter(today)) {
@@ -2280,7 +2267,7 @@ public class Loan extends AbstractPersistable<Long> {
private LoanOfficerAssignmentHistory findLatestIncompleteHistoryRecord() { private LoanOfficerAssignmentHistory findLatestIncompleteHistoryRecord() {
LoanOfficerAssignmentHistory latestRecordWithNoEndDate = null; LoanOfficerAssignmentHistory latestRecordWithNoEndDate = null;
for (LoanOfficerAssignmentHistory historyRecord : this.loanOfficerHistory) { for (final LoanOfficerAssignmentHistory historyRecord : this.loanOfficerHistory) {
if (historyRecord.isCurrentRecord()) { if (historyRecord.isCurrentRecord()) {
latestRecordWithNoEndDate = historyRecord; latestRecordWithNoEndDate = historyRecord;
break; break;
@@ -2292,7 +2279,7 @@ public class Loan extends AbstractPersistable<Long> {
private LoanOfficerAssignmentHistory findLastAssignmentHistoryRecord(final Staff newLoanOfficer) { private LoanOfficerAssignmentHistory findLastAssignmentHistoryRecord(final Staff newLoanOfficer) {
LoanOfficerAssignmentHistory lastAssignmentRecordLatestEndDate = null; LoanOfficerAssignmentHistory lastAssignmentRecordLatestEndDate = null;
for (LoanOfficerAssignmentHistory historyRecord : this.loanOfficerHistory) { for (final LoanOfficerAssignmentHistory historyRecord : this.loanOfficerHistory) {
if (historyRecord.isCurrentRecord() && !historyRecord.isSameLoanOfficer(newLoanOfficer)) { if (historyRecord.isCurrentRecord() && !historyRecord.isSameLoanOfficer(newLoanOfficer)) {
lastAssignmentRecordLatestEndDate = historyRecord; lastAssignmentRecordLatestEndDate = historyRecord;
@@ -2363,15 +2350,15 @@ public class Loan extends AbstractPersistable<Long> {
final List<Long> existingReversedTransactionIds) { final List<Long> existingReversedTransactionIds) {
final Map<String, Object> accountingBridgeData = new LinkedHashMap<String, Object>(); final Map<String, Object> accountingBridgeData = new LinkedHashMap<String, Object>();
accountingBridgeData.put("loanId", this.getId()); accountingBridgeData.put("loanId", getId());
accountingBridgeData.put("loanProductId", this.productId()); accountingBridgeData.put("loanProductId", productId());
accountingBridgeData.put("officeId", this.getOfficeId()); accountingBridgeData.put("officeId", getOfficeId());
accountingBridgeData.put("calculatedInterest", this.summary.getTotalInterestCharged()); accountingBridgeData.put("calculatedInterest", this.summary.getTotalInterestCharged());
accountingBridgeData.put("cashBasedAccountingEnabled", this.isCashBasedAccountingEnabledOnLoanProduct()); accountingBridgeData.put("cashBasedAccountingEnabled", isCashBasedAccountingEnabledOnLoanProduct());
accountingBridgeData.put("accrualBasedAccountingEnabled", this.isAccrualBasedAccountingEnabledOnLoanProduct()); accountingBridgeData.put("accrualBasedAccountingEnabled", isAccrualBasedAccountingEnabledOnLoanProduct());
final List<Map<String, Object>> newLoanTransactions = new ArrayList<Map<String, Object>>(); final List<Map<String, Object>> newLoanTransactions = new ArrayList<Map<String, Object>>();
for (LoanTransaction transaction : this.loanTransactions) { for (final LoanTransaction transaction : this.loanTransactions) {
if (transaction.isReversed() && !existingReversedTransactionIds.contains(transaction.getId())) { if (transaction.isReversed() && !existingReversedTransactionIds.contains(transaction.getId())) {
newLoanTransactions.add(transaction.toMapData(currencyData)); newLoanTransactions.add(transaction.toMapData(currencyData));
} else if (!existingTransactionIds.contains(transaction.getId())) { } else if (!existingTransactionIds.contains(transaction.getId())) {
@@ -2401,9 +2388,9 @@ public class Loan extends AbstractPersistable<Long> {
public void updateLoanRepaymentScheduleDates(final LocalDate meetingStartDate, final String recuringRule, public void updateLoanRepaymentScheduleDates(final LocalDate meetingStartDate, final String recuringRule,
final boolean isHolidayEnabled, final List<Holiday> holidays, final WorkingDays workingDays) { final boolean isHolidayEnabled, final List<Holiday> holidays, final WorkingDays workingDays) {
//update repayment dates of repayment schedule installaments //update repayment dates of repayment schedule installaments
LocalDate tmpFromDate = this.getDisbursementDate();//first repayment's from date is same as disbursement date. LocalDate tmpFromDate = getDisbursementDate();//first repayment's from date is same as disbursement date.
LocalDate newRepaymentDate = null; LocalDate newRepaymentDate = null;
for (LoanRepaymentScheduleInstallment loanRepaymentScheduleInstallment : this.repaymentScheduleInstallments) { for (final LoanRepaymentScheduleInstallment loanRepaymentScheduleInstallment : this.repaymentScheduleInstallments) {
final LocalDate oldDueDate = loanRepaymentScheduleInstallment.getDueDate(); final LocalDate oldDueDate = loanRepaymentScheduleInstallment.getDueDate();
// FIXME: AA this won't update repayment dates before current date. // FIXME: AA this won't update repayment dates before current date.
if (oldDueDate.isAfter(meetingStartDate) && oldDueDate.isAfter(DateUtils.getLocalDateOfTenant())) { if (oldDueDate.isAfter(meetingStartDate) && oldDueDate.isAfter(DateUtils.getLocalDateOfTenant())) {
@@ -2430,9 +2417,9 @@ public class Loan extends AbstractPersistable<Long> {
public void applyHolidayToRepaymentScheduleDates(final Holiday holiday) { public void applyHolidayToRepaymentScheduleDates(final Holiday holiday) {
// first repayment's from date is same as disbursement date. // first repayment's from date is same as disbursement date.
LocalDate tmpFromDate = this.getDisbursementDate(); LocalDate tmpFromDate = getDisbursementDate();
// Loop through all loanRepayments // Loop through all loanRepayments
for (LoanRepaymentScheduleInstallment loanRepaymentScheduleInstallment : this.repaymentScheduleInstallments) { for (final LoanRepaymentScheduleInstallment loanRepaymentScheduleInstallment : this.repaymentScheduleInstallments) {
final LocalDate oldDueDate = loanRepaymentScheduleInstallment.getDueDate(); final LocalDate oldDueDate = loanRepaymentScheduleInstallment.getDueDate();
// update from date if it's not same as previous installament's due // update from date if it's not same as previous installament's due
@@ -2440,10 +2427,12 @@ public class Loan extends AbstractPersistable<Long> {
if (!loanRepaymentScheduleInstallment.getFromDate().isEqual(tmpFromDate)) { if (!loanRepaymentScheduleInstallment.getFromDate().isEqual(tmpFromDate)) {
loanRepaymentScheduleInstallment.updateFromDate(tmpFromDate); loanRepaymentScheduleInstallment.updateFromDate(tmpFromDate);
} }
if (oldDueDate.isAfter(holiday.getToDateLocalDate())) break; if (oldDueDate.isAfter(holiday.getToDateLocalDate())) {
break;
}
if (oldDueDate.equals(holiday.getFromDateLocalDate()) || oldDueDate.equals(holiday.getToDateLocalDate()) if (oldDueDate.equals(holiday.getFromDateLocalDate()) || oldDueDate.equals(holiday.getToDateLocalDate())
|| (oldDueDate.isAfter(holiday.getFromDateLocalDate()) && oldDueDate.isBefore(holiday.getToDateLocalDate()))) { || oldDueDate.isAfter(holiday.getFromDateLocalDate()) && oldDueDate.isBefore(holiday.getToDateLocalDate())) {
//FIXME: AA do we need to apply non-working days. //FIXME: AA do we need to apply non-working days.
//Assuming holiday's repayment reschedule to date cannot be created on a non-working day. //Assuming holiday's repayment reschedule to date cannot be created on a non-working day.
final LocalDate newRepaymentDate = holiday.getRepaymentsRescheduledToLocalDate(); final LocalDate newRepaymentDate = holiday.getRepaymentsRescheduledToLocalDate();
@@ -25,7 +25,6 @@ import org.mifosplatform.useradministration.domain.AppUser;
@Table(name = "m_loan_officer_assignment_history") @Table(name = "m_loan_officer_assignment_history")
public class LoanOfficerAssignmentHistory extends AbstractAuditableCustom<AppUser, Long> { public class LoanOfficerAssignmentHistory extends AbstractAuditableCustom<AppUser, Long> {
@SuppressWarnings("unused")
@ManyToOne @ManyToOne
@JoinColumn(name = "loan_id", nullable = false) @JoinColumn(name = "loan_id", nullable = false)
private Loan loan; private Loan loan;
@@ -74,7 +73,7 @@ public class LoanOfficerAssignmentHistory extends AbstractAuditableCustom<AppUse
} }
public LocalDate getStartDate() { public LocalDate getStartDate() {
return new LocalDate(startDate); return new LocalDate(this.startDate);
} }
public boolean hasStartDateBefore(final LocalDate matchingDate) { public boolean hasStartDateBefore(final LocalDate matchingDate) {
@@ -91,7 +90,7 @@ public class LoanOfficerAssignmentHistory extends AbstractAuditableCustom<AppUse
* @return * @return
*/ */
public boolean isEndDateAfter(final LocalDate compareDate){ public boolean isEndDateAfter(final LocalDate compareDate){
return this.endDate == null ? false : (new LocalDate(endDate)).isAfter(compareDate); return this.endDate == null ? false : new LocalDate(this.endDate).isAfter(compareDate);
} }
public LocalDate getEndDate(){ public LocalDate getEndDate(){
@@ -95,7 +95,6 @@ public final class LoanRepaymentScheduleInstallment extends AbstractAuditableCus
@Column(name = "completed_derived", nullable = false) @Column(name = "completed_derived", nullable = false)
private boolean obligationsMet; private boolean obligationsMet;
@SuppressWarnings("unused")
@Temporal(TemporalType.DATE) @Temporal(TemporalType.DATE)
@Column(name = "obligations_met_on_date") @Column(name = "obligations_met_on_date")
private Date obligationsMetOnDate; private Date obligationsMetOnDate;
@@ -376,10 +375,10 @@ public final class LoanRepaymentScheduleInstallment extends AbstractAuditableCus
} }
public Money waiveInterestComponent(final LocalDate transactionDate, final Money transactionAmountRemaining) { public Money waiveInterestComponent(final LocalDate transactionDate, final Money transactionAmountRemaining) {
MonetaryCurrency currency = transactionAmountRemaining.getCurrency(); final MonetaryCurrency currency = transactionAmountRemaining.getCurrency();
Money waivedInterestPortionOfTransaction = Money.zero(currency); Money waivedInterestPortionOfTransaction = Money.zero(currency);
Money interestDue = getInterestOutstanding(currency); final Money interestDue = getInterestOutstanding(currency);
if (transactionAmountRemaining.isGreaterThanOrEqualTo(interestDue)) { if (transactionAmountRemaining.isGreaterThanOrEqualTo(interestDue)) {
this.interestWaived = getInterestWaived(currency).plus(interestDue).getAmount(); this.interestWaived = getInterestWaived(currency).plus(interestDue).getAmount();
waivedInterestPortionOfTransaction = waivedInterestPortionOfTransaction.plus(interestDue); waivedInterestPortionOfTransaction = waivedInterestPortionOfTransaction.plus(interestDue);
@@ -396,10 +395,10 @@ public final class LoanRepaymentScheduleInstallment extends AbstractAuditableCus
} }
public Money waivePenaltyChargesComponent(final LocalDate transactionDate, final Money transactionAmountRemaining) { public Money waivePenaltyChargesComponent(final LocalDate transactionDate, final Money transactionAmountRemaining) {
MonetaryCurrency currency = transactionAmountRemaining.getCurrency(); final MonetaryCurrency currency = transactionAmountRemaining.getCurrency();
Money waivedPenaltyChargesPortionOfTransaction = Money.zero(currency); Money waivedPenaltyChargesPortionOfTransaction = Money.zero(currency);
Money penanltiesDue = getPenaltyChargesOutstanding(currency); final Money penanltiesDue = getPenaltyChargesOutstanding(currency);
if (transactionAmountRemaining.isGreaterThanOrEqualTo(penanltiesDue)) { if (transactionAmountRemaining.isGreaterThanOrEqualTo(penanltiesDue)) {
this.penaltyChargesWaived = getPenaltyChargesWaived(currency).plus(penanltiesDue).getAmount(); this.penaltyChargesWaived = getPenaltyChargesWaived(currency).plus(penanltiesDue).getAmount();
waivedPenaltyChargesPortionOfTransaction = waivedPenaltyChargesPortionOfTransaction.plus(penanltiesDue); waivedPenaltyChargesPortionOfTransaction = waivedPenaltyChargesPortionOfTransaction.plus(penanltiesDue);
@@ -416,10 +415,10 @@ public final class LoanRepaymentScheduleInstallment extends AbstractAuditableCus
} }
public Money waiveFeeChargesComponent(final LocalDate transactionDate, final Money transactionAmountRemaining) { public Money waiveFeeChargesComponent(final LocalDate transactionDate, final Money transactionAmountRemaining) {
MonetaryCurrency currency = transactionAmountRemaining.getCurrency(); final MonetaryCurrency currency = transactionAmountRemaining.getCurrency();
Money waivedFeeChargesPortionOfTransaction = Money.zero(currency); Money waivedFeeChargesPortionOfTransaction = Money.zero(currency);
Money feesDue = getPenaltyChargesOutstanding(currency); final Money feesDue = getPenaltyChargesOutstanding(currency);
if (transactionAmountRemaining.isGreaterThanOrEqualTo(feesDue)) { if (transactionAmountRemaining.isGreaterThanOrEqualTo(feesDue)) {
this.feeChargesWaived = getFeeChargesWaived(currency).plus(feesDue).getAmount(); this.feeChargesWaived = getFeeChargesWaived(currency).plus(feesDue).getAmount();
waivedFeeChargesPortionOfTransaction = waivedFeeChargesPortionOfTransaction.plus(feesDue); waivedFeeChargesPortionOfTransaction = waivedFeeChargesPortionOfTransaction.plus(feesDue);
@@ -474,7 +473,7 @@ public final class LoanRepaymentScheduleInstallment extends AbstractAuditableCus
} }
public boolean isOverdueOn(final LocalDate date) { public boolean isOverdueOn(final LocalDate date) {
return this.getDueDate().isBefore(date); return getDueDate().isBefore(date);
} }
public void updateChargePortion(final Money feeChargesDue, final Money feeChargesWaived, final Money feeChargesWrittenOff, public void updateChargePortion(final Money feeChargesDue, final Money feeChargesWaived, final Money feeChargesWrittenOff,
@@ -84,27 +84,21 @@ public final class LoanSummary {
@Column(name = "penalty_charges_outstanding_derived", scale = 6, precision = 19) @Column(name = "penalty_charges_outstanding_derived", scale = 6, precision = 19)
private BigDecimal totalPenaltyChargesOutstanding; private BigDecimal totalPenaltyChargesOutstanding;
@SuppressWarnings("unused")
@Column(name = "total_expected_repayment_derived", scale = 6, precision = 19) @Column(name = "total_expected_repayment_derived", scale = 6, precision = 19)
private BigDecimal totalExpectedRepayment; private BigDecimal totalExpectedRepayment;
@SuppressWarnings("unused")
@Column(name = "total_repayment_derived", scale = 6, precision = 19) @Column(name = "total_repayment_derived", scale = 6, precision = 19)
private BigDecimal totalRepayment; private BigDecimal totalRepayment;
@SuppressWarnings("unused")
@Column(name = "total_expected_costofloan_derived", scale = 6, precision = 19) @Column(name = "total_expected_costofloan_derived", scale = 6, precision = 19)
private BigDecimal totalExpectedCostOfLoan; private BigDecimal totalExpectedCostOfLoan;
@SuppressWarnings("unused")
@Column(name = "total_costofloan_derived", scale = 6, precision = 19) @Column(name = "total_costofloan_derived", scale = 6, precision = 19)
private BigDecimal totalCostOfLoan; private BigDecimal totalCostOfLoan;
@SuppressWarnings("unused")
@Column(name = "total_waived_derived", scale = 6, precision = 19) @Column(name = "total_waived_derived", scale = 6, precision = 19)
private BigDecimal totalWaived; private BigDecimal totalWaived;
@SuppressWarnings("unused")
@Column(name = "total_writtenoff_derived", scale = 6, precision = 19) @Column(name = "total_writtenoff_derived", scale = 6, precision = 19)
private BigDecimal totalWrittenOff; private BigDecimal totalWrittenOff;
@@ -185,7 +179,7 @@ public final class LoanSummary {
this.totalPrincipalWrittenOff = summaryWrapper.calculateTotalPrincipalWrittenOff(repaymentScheduleInstallments, currency) this.totalPrincipalWrittenOff = summaryWrapper.calculateTotalPrincipalWrittenOff(repaymentScheduleInstallments, currency)
.getAmount(); .getAmount();
this.totalPrincipalOutstanding = principal.minus(totalPrincipalRepaid).minus(totalPrincipalWrittenOff).getAmount(); this.totalPrincipalOutstanding = principal.minus(this.totalPrincipalRepaid).minus(this.totalPrincipalWrittenOff).getAmount();
final Money totalInterestCharged = summaryWrapper.calculateTotalInterestCharged(repaymentScheduleInstallments, currency); final Money totalInterestCharged = summaryWrapper.calculateTotalInterestCharged(repaymentScheduleInstallments, currency);
this.totalInterestCharged = totalInterestCharged.getAmount(); this.totalInterestCharged = totalInterestCharged.getAmount();
@@ -63,12 +63,10 @@ public final class LoanSummaryArrearsAging implements Persistable<Long> {
@Column(name = "total_overdue_derived", scale = 6, precision = 19) @Column(name = "total_overdue_derived", scale = 6, precision = 19)
private BigDecimal totalOverdue; private BigDecimal totalOverdue;
@SuppressWarnings("unused")
@Temporal(TemporalType.DATE) @Temporal(TemporalType.DATE)
@Column(name = "overdue_since_date_derived") @Column(name = "overdue_since_date_derived")
private Date overdueSinceDate; private Date overdueSinceDate;
@SuppressWarnings("unused")
@OneToOne(optional = false) @OneToOne(optional = false)
@PrimaryKeyJoinColumn @PrimaryKeyJoinColumn
private Loan loan; private Loan loan;
@@ -70,10 +70,9 @@ public class NotesApiResource {
public String retrieveNotesByResource(@PathParam("resourceType") final String resourceType, public String retrieveNotesByResource(@PathParam("resourceType") final String resourceType,
@PathParam("resourceId") final Long resourceId, @Context final UriInfo uriInfo) { @PathParam("resourceId") final Long resourceId, @Context final UriInfo uriInfo) {
NoteType noteType = NoteType.fromApiUrl(resourceType); final NoteType noteType = NoteType.fromApiUrl(resourceType);
if (noteType == null) { throw new NoteResourceNotSupportedException(resourceType); } if (noteType == null) { throw new NoteResourceNotSupportedException(resourceType); }
;
this.context.authenticatedUser().validateHasReadPermission(getResourceNameForPermissions(noteType)); this.context.authenticatedUser().validateHasReadPermission(getResourceNameForPermissions(noteType));
@@ -92,10 +91,9 @@ public class NotesApiResource {
public String retrieveNote(@PathParam("resourceType") final String resourceType, @PathParam("resourceId") final Long resourceId, public String retrieveNote(@PathParam("resourceType") final String resourceType, @PathParam("resourceId") final Long resourceId,
@PathParam("noteId") final Long noteId, @Context final UriInfo uriInfo) { @PathParam("noteId") final Long noteId, @Context final UriInfo uriInfo) {
NoteType noteType = NoteType.fromApiUrl(resourceType); final NoteType noteType = NoteType.fromApiUrl(resourceType);
if (noteType == null) { throw new NoteResourceNotSupportedException(resourceType); } if (noteType == null) { throw new NoteResourceNotSupportedException(resourceType); }
;
this.context.authenticatedUser().validateHasReadPermission(getResourceNameForPermissions(noteType)); this.context.authenticatedUser().validateHasReadPermission(getResourceNameForPermissions(noteType));
@@ -113,10 +111,9 @@ public class NotesApiResource {
public String addNewNote(@PathParam("resourceType") final String resourceType, @PathParam("resourceId") final Long resourceId, public String addNewNote(@PathParam("resourceType") final String resourceType, @PathParam("resourceId") final Long resourceId,
final String apiRequestBodyAsJson) { final String apiRequestBodyAsJson) {
NoteType noteType = NoteType.fromApiUrl(resourceType); final NoteType noteType = NoteType.fromApiUrl(resourceType);
if (noteType == null) { throw new NoteResourceNotSupportedException(resourceType); } if (noteType == null) { throw new NoteResourceNotSupportedException(resourceType); }
;
final String resourceNameForPermissions = getResourceNameForPermissions(noteType); final String resourceNameForPermissions = getResourceNameForPermissions(noteType);
final CommandWrapper commandRequest = new CommandWrapperBuilder().createNote(resourceNameForPermissions, resourceType, resourceId) final CommandWrapper commandRequest = new CommandWrapperBuilder().createNote(resourceNameForPermissions, resourceType, resourceId)
@@ -134,10 +131,9 @@ public class NotesApiResource {
public String updateNote(@PathParam("resourceType") final String resourceType, @PathParam("resourceId") final Long resourceId, public String updateNote(@PathParam("resourceType") final String resourceType, @PathParam("resourceId") final Long resourceId,
@PathParam("noteId") final Long noteId, final String apiRequestBodyAsJson) { @PathParam("noteId") final Long noteId, final String apiRequestBodyAsJson) {
NoteType noteType = NoteType.fromApiUrl(resourceType); final NoteType noteType = NoteType.fromApiUrl(resourceType);
if (noteType == null) { throw new NoteResourceNotSupportedException(resourceType); } if (noteType == null) { throw new NoteResourceNotSupportedException(resourceType); }
;
final String resourceNameForPermissions = getResourceNameForPermissions(noteType); final String resourceNameForPermissions = getResourceNameForPermissions(noteType);
@@ -156,10 +152,9 @@ public class NotesApiResource {
public String deleteNote(@PathParam("resourceType") final String resourceType, @PathParam("resourceId") final Long resourceId, public String deleteNote(@PathParam("resourceType") final String resourceType, @PathParam("resourceId") final Long resourceId,
@PathParam("noteId") final Long noteId) { @PathParam("noteId") final Long noteId) {
NoteType noteType = NoteType.fromApiUrl(resourceType); final NoteType noteType = NoteType.fromApiUrl(resourceType);
if (noteType == null) { throw new NoteResourceNotSupportedException(resourceType); } if (noteType == null) { throw new NoteResourceNotSupportedException(resourceType); }
;
final String resourceNameForPermissions = getResourceNameForPermissions(noteType); final String resourceNameForPermissions = getResourceNameForPermissions(noteType);
@@ -32,17 +32,14 @@ public class Note extends AbstractAuditableCustom<AppUser, Long> {
@JoinColumn(name = "client_id", nullable = true) @JoinColumn(name = "client_id", nullable = true)
private final Client client; private final Client client;
@SuppressWarnings("unused")
@ManyToOne @ManyToOne
@JoinColumn(name = "group_id", nullable = true) @JoinColumn(name = "group_id", nullable = true)
private Group group; private Group group;
@SuppressWarnings("unused")
@ManyToOne @ManyToOne
@JoinColumn(name = "loan_id", nullable = true) @JoinColumn(name = "loan_id", nullable = true)
private Loan loan; private Loan loan;
@SuppressWarnings("unused")
@ManyToOne @ManyToOne
@JoinColumn(name = "loan_transaction_id", nullable = true) @JoinColumn(name = "loan_transaction_id", nullable = true)
private LoanTransaction loanTransaction; private LoanTransaction loanTransaction;
@@ -50,11 +47,9 @@ public class Note extends AbstractAuditableCustom<AppUser, Long> {
@Column(name = "note", length = 1000) @Column(name = "note", length = 1000)
private String note; private String note;
@SuppressWarnings("unused")
@Column(name = "note_type_enum") @Column(name = "note_type_enum")
private final Integer noteTypeId; private final Integer noteTypeId;
@SuppressWarnings("unused")
@ManyToOne @ManyToOne
@JoinColumn(name = "savings_account_id", nullable = true) @JoinColumn(name = "savings_account_id", nullable = true)
private SavingsAccount savingsAccount; private SavingsAccount savingsAccount;
@@ -106,7 +106,6 @@ public class SavingsAccount extends AbstractPersistable<Long> {
@Column(name = "status_enum", nullable = false) @Column(name = "status_enum", nullable = false)
private Integer status; private Integer status;
@SuppressWarnings("unused")
@Column(name = "account_type_enum", nullable = false) @Column(name = "account_type_enum", nullable = false)
private Integer accountType; private Integer accountType;
@@ -114,27 +113,22 @@ public class SavingsAccount extends AbstractPersistable<Long> {
@Column(name = "submittedon_date", nullable = true) @Column(name = "submittedon_date", nullable = true)
private Date submittedOnDate; private Date submittedOnDate;
@SuppressWarnings("unused")
@ManyToOne(optional = true) @ManyToOne(optional = true)
@JoinColumn(name = "submittedon_userid", nullable = true) @JoinColumn(name = "submittedon_userid", nullable = true)
private AppUser submittedBy; private AppUser submittedBy;
@SuppressWarnings("unused")
@Temporal(TemporalType.DATE) @Temporal(TemporalType.DATE)
@Column(name = "rejectedon_date") @Column(name = "rejectedon_date")
private Date rejectedOnDate; private Date rejectedOnDate;
@SuppressWarnings("unused")
@ManyToOne(optional = true) @ManyToOne(optional = true)
@JoinColumn(name = "rejectedon_userid", nullable = true) @JoinColumn(name = "rejectedon_userid", nullable = true)
private AppUser rejectedBy; private AppUser rejectedBy;
@SuppressWarnings("unused")
@Temporal(TemporalType.DATE) @Temporal(TemporalType.DATE)
@Column(name = "withdrawnon_date") @Column(name = "withdrawnon_date")
private Date withdrawnOnDate; private Date withdrawnOnDate;
@SuppressWarnings("unused")
@ManyToOne(optional = true) @ManyToOne(optional = true)
@JoinColumn(name = "withdrawnon_userid", nullable = true) @JoinColumn(name = "withdrawnon_userid", nullable = true)
private AppUser withdrawnBy; private AppUser withdrawnBy;
@@ -143,7 +137,6 @@ public class SavingsAccount extends AbstractPersistable<Long> {
@Column(name = "approvedon_date") @Column(name = "approvedon_date")
private Date approvedOnDate; private Date approvedOnDate;
@SuppressWarnings("unused")
@ManyToOne(optional = true) @ManyToOne(optional = true)
@JoinColumn(name = "approvedon_userid", nullable = true) @JoinColumn(name = "approvedon_userid", nullable = true)
private AppUser approvedBy; private AppUser approvedBy;
@@ -152,17 +145,14 @@ public class SavingsAccount extends AbstractPersistable<Long> {
@Column(name = "activatedon_date", nullable = true) @Column(name = "activatedon_date", nullable = true)
private Date activatedOnDate; private Date activatedOnDate;
@SuppressWarnings("unused")
@ManyToOne(optional = true) @ManyToOne(optional = true)
@JoinColumn(name = "activatedon_userid", nullable = true) @JoinColumn(name = "activatedon_userid", nullable = true)
private AppUser activatedBy; private AppUser activatedBy;
@SuppressWarnings("unused")
@Temporal(TemporalType.DATE) @Temporal(TemporalType.DATE)
@Column(name = "closedon_date") @Column(name = "closedon_date")
private Date closedOnDate; private Date closedOnDate;
@SuppressWarnings("unused")
@ManyToOne(optional = true) @ManyToOne(optional = true)
@JoinColumn(name = "closedon_userid", nullable = true) @JoinColumn(name = "closedon_userid", nullable = true)
private AppUser closedBy; private AppUser closedBy;
@@ -361,7 +351,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
existingTransactionIds.addAll(findExistingTransactionIds()); existingTransactionIds.addAll(findExistingTransactionIds());
existingReversedTransactionIds.addAll(findExistingReversedTransactionIds()); existingReversedTransactionIds.addAll(findExistingReversedTransactionIds());
for (PostingPeriod interestPostingPeriod : postingPeriods) { for (final PostingPeriod interestPostingPeriod : postingPeriods) {
final LocalDate interestPostingTransactionDate = interestPostingPeriod.dateOfPostingTransaction(); final LocalDate interestPostingTransactionDate = interestPostingPeriod.dateOfPostingTransaction();
final Money interestEarnedToBePostedForPeriod = interestPostingPeriod.getInterestEarned(); final Money interestEarnedToBePostedForPeriod = interestPostingPeriod.getInterestEarned();
@@ -370,14 +360,14 @@ public class SavingsAccount extends AbstractPersistable<Long> {
interestPostedToDate = interestPostedToDate.plus(interestEarnedToBePostedForPeriod); interestPostedToDate = interestPostedToDate.plus(interestEarnedToBePostedForPeriod);
SavingsAccountTransaction postingTransaction = findInterestPostingTransactionFor(interestPostingTransactionDate); final SavingsAccountTransaction postingTransaction = findInterestPostingTransactionFor(interestPostingTransactionDate);
if (postingTransaction == null) { if (postingTransaction == null) {
final SavingsAccountTransaction newPostingTransaction = SavingsAccountTransaction.interestPosting(this, final SavingsAccountTransaction newPostingTransaction = SavingsAccountTransaction.interestPosting(this,
interestPostingTransactionDate, interestEarnedToBePostedForPeriod); interestPostingTransactionDate, interestEarnedToBePostedForPeriod);
this.transactions.add(newPostingTransaction); this.transactions.add(newPostingTransaction);
recalucateDailyBalanceDetails = true; recalucateDailyBalanceDetails = true;
} else { } else {
boolean correctionRequired = postingTransaction.hasNotAmount(interestEarnedToBePostedForPeriod); final boolean correctionRequired = postingTransaction.hasNotAmount(interestEarnedToBePostedForPeriod);
if (correctionRequired) { if (correctionRequired) {
postingTransaction.reverse(); postingTransaction.reverse();
final SavingsAccountTransaction newPostingTransaction = SavingsAccountTransaction.interestPosting(this, final SavingsAccountTransaction newPostingTransaction = SavingsAccountTransaction.interestPosting(this,
@@ -407,7 +397,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
SavingsAccountTransaction postingTransation = null; SavingsAccountTransaction postingTransation = null;
for (SavingsAccountTransaction transaction : this.transactions) { for (final SavingsAccountTransaction transaction : this.transactions) {
if (transaction.isInterestPostingAndNotReversed() && transaction.occursOn(postingDate)) { if (transaction.isInterestPostingAndNotReversed() && transaction.occursOn(postingDate)) {
postingTransation = transaction; postingTransation = transaction;
break; break;
@@ -454,19 +444,19 @@ public class SavingsAccount extends AbstractPersistable<Long> {
final SavingsInterestCalculationDaysInYearType daysInYearType = SavingsInterestCalculationDaysInYearType final SavingsInterestCalculationDaysInYearType daysInYearType = SavingsInterestCalculationDaysInYearType
.fromInt(this.interestCalculationDaysInYearType); .fromInt(this.interestCalculationDaysInYearType);
List<LocalDateInterval> postingPeriodIntervals = savingsHelper.determineInterestPostingPeriods(getActivationLocalDate(), final List<LocalDateInterval> postingPeriodIntervals = this.savingsHelper.determineInterestPostingPeriods(getActivationLocalDate(),
upToInterestCalculationDate, postingPeriodType); upToInterestCalculationDate, postingPeriodType);
List<PostingPeriod> allPostingPeriods = new ArrayList<PostingPeriod>(); final List<PostingPeriod> allPostingPeriods = new ArrayList<PostingPeriod>();
Money periodStartingBalance = Money.zero(this.currency); Money periodStartingBalance = Money.zero(this.currency);
final SavingsInterestCalculationType interestCalculationType = SavingsInterestCalculationType.fromInt(this.interestCalculationType); final SavingsInterestCalculationType interestCalculationType = SavingsInterestCalculationType.fromInt(this.interestCalculationType);
BigDecimal interestRateAsFraction = nominalAnnualInterestRate.divide(BigDecimal.valueOf(100l), mc); final BigDecimal interestRateAsFraction = this.nominalAnnualInterestRate.divide(BigDecimal.valueOf(100l), mc);
for (LocalDateInterval periodInterval : postingPeriodIntervals) { for (final LocalDateInterval periodInterval : postingPeriodIntervals) {
PostingPeriod postingPeriod = PostingPeriod.createFrom(periodInterval, periodStartingBalance, final PostingPeriod postingPeriod = PostingPeriod.createFrom(periodInterval, periodStartingBalance,
retreiveOrderedListOfTransactions(), currency, compoundingPeriodType, interestCalculationType, interestRateAsFraction, retreiveOrderedListOfTransactions(), this.currency, compoundingPeriodType, interestCalculationType, interestRateAsFraction,
daysInYearType.getValue()); daysInYearType.getValue());
periodStartingBalance = postingPeriod.closingBalance(); periodStartingBalance = postingPeriod.closingBalance();
@@ -474,20 +464,20 @@ public class SavingsAccount extends AbstractPersistable<Long> {
allPostingPeriods.add(postingPeriod); allPostingPeriods.add(postingPeriod);
} }
savingsHelper.calculateInterestForAllPostingPeriods(currency, allPostingPeriods); this.savingsHelper.calculateInterestForAllPostingPeriods(this.currency, allPostingPeriods);
this.summary.updateFromInterestPeriodSummaries(currency, allPostingPeriods); this.summary.updateFromInterestPeriodSummaries(this.currency, allPostingPeriods);
this.summary.updateSummary(this.currency, this.savingsAccountTransactionSummaryWrapper, this.transactions); this.summary.updateSummary(this.currency, this.savingsAccountTransactionSummaryWrapper, this.transactions);
return allPostingPeriods; return allPostingPeriods;
} }
private List<SavingsAccountTransaction> retreiveOrderedListOfTransactions() { private List<SavingsAccountTransaction> retreiveOrderedListOfTransactions() {
List<SavingsAccountTransaction> listOfTransactionsSorted = retreiveListOfTransactions(); final List<SavingsAccountTransaction> listOfTransactionsSorted = retreiveListOfTransactions();
List<SavingsAccountTransaction> orderedNonInterestPostingTransactions = new ArrayList<SavingsAccountTransaction>(); final List<SavingsAccountTransaction> orderedNonInterestPostingTransactions = new ArrayList<SavingsAccountTransaction>();
for (SavingsAccountTransaction transaction : listOfTransactionsSorted) { for (final SavingsAccountTransaction transaction : listOfTransactionsSorted) {
if (!transaction.isInterestPostingAndNotReversed() && transaction.isNotReversed()) { if (!transaction.isInterestPostingAndNotReversed() && transaction.isNotReversed()) {
orderedNonInterestPostingTransactions.add(transaction); orderedNonInterestPostingTransactions.add(transaction);
} }
@@ -497,12 +487,12 @@ public class SavingsAccount extends AbstractPersistable<Long> {
} }
private List<SavingsAccountTransaction> retreiveListOfTransactions() { private List<SavingsAccountTransaction> retreiveListOfTransactions() {
List<SavingsAccountTransaction> listOfTransactionsSorted = new ArrayList<SavingsAccountTransaction>(); final List<SavingsAccountTransaction> listOfTransactionsSorted = new ArrayList<SavingsAccountTransaction>();
for (SavingsAccountTransaction transaction : this.transactions) { for (final SavingsAccountTransaction transaction : this.transactions) {
listOfTransactionsSorted.add(transaction); listOfTransactionsSorted.add(transaction);
} }
SavingsAccountTransactionComparator transactionComparator = new SavingsAccountTransactionComparator(); final SavingsAccountTransactionComparator transactionComparator = new SavingsAccountTransactionComparator();
Collections.sort(listOfTransactionsSorted, transactionComparator); Collections.sort(listOfTransactionsSorted, transactionComparator);
return listOfTransactionsSorted; return listOfTransactionsSorted;
@@ -512,9 +502,9 @@ public class SavingsAccount extends AbstractPersistable<Long> {
Money runningBalance = openingAccountBalance.copy(); Money runningBalance = openingAccountBalance.copy();
List<SavingsAccountTransaction> accountTransactionsSorted = retreiveListOfTransactions(); final List<SavingsAccountTransaction> accountTransactionsSorted = retreiveListOfTransactions();
for (SavingsAccountTransaction transaction : accountTransactionsSorted) { for (final SavingsAccountTransaction transaction : accountTransactionsSorted) {
if (transaction.isReversed()) { if (transaction.isReversed()) {
transaction.zeroBalanceFields(); transaction.zeroBalanceFields();
} else { } else {
@@ -533,7 +523,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
// loop over transactions in reverse // loop over transactions in reverse
LocalDate endOfBalanceDate = DateUtils.getLocalDateOfTenant(); LocalDate endOfBalanceDate = DateUtils.getLocalDateOfTenant();
for (int i = accountTransactionsSorted.size() - 1; i >= 0; i--) { for (int i = accountTransactionsSorted.size() - 1; i >= 0; i--) {
SavingsAccountTransaction transaction = accountTransactionsSorted.get(i); final SavingsAccountTransaction transaction = accountTransactionsSorted.get(i);
if (transaction.isNotReversed()) { if (transaction.isNotReversed()) {
transaction.updateCumulativeBalanceAndDates(this.currency, endOfBalanceDate); transaction.updateCumulativeBalanceAndDates(this.currency, endOfBalanceDate);
@@ -698,7 +688,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
boolean transactionBeforeLastInterestPosting = false; boolean transactionBeforeLastInterestPosting = false;
for (SavingsAccountTransaction transaction : retreiveListOfTransactions()) { for (final SavingsAccountTransaction transaction : retreiveListOfTransactions()) {
if (transaction.isInterestPostingAndNotReversed() && transaction.isAfter(transactionDate)) { if (transaction.isInterestPostingAndNotReversed() && transaction.isAfter(transactionDate)) {
transactionBeforeLastInterestPosting = true; transactionBeforeLastInterestPosting = true;
break; break;
@@ -713,7 +703,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
Money runningBalance = Money.zero(this.currency); Money runningBalance = Money.zero(this.currency);
for (SavingsAccountTransaction transaction : transactionsSortedByDate) { for (final SavingsAccountTransaction transaction : transactionsSortedByDate) {
if (transaction.isNotReversed() && transaction.isCredit()) { if (transaction.isNotReversed() && transaction.isCredit()) {
runningBalance = runningBalance.plus(transaction.getAmount(this.currency)); runningBalance = runningBalance.plus(transaction.getAmount(this.currency));
} else if (transaction.isNotReversed() && transaction.isDebit()) { } else if (transaction.isNotReversed() && transaction.isDebit()) {
@@ -733,7 +723,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
Money runningBalance = Money.zero(this.currency); Money runningBalance = Money.zero(this.currency);
for (SavingsAccountTransaction transaction : transactionsSortedByDate) { for (final SavingsAccountTransaction transaction : transactionsSortedByDate) {
if (transaction.isNotReversed() && transaction.isCredit()) { if (transaction.isNotReversed() && transaction.isCredit()) {
runningBalance = runningBalance.plus(transaction.getAmount(this.currency)); runningBalance = runningBalance.plus(transaction.getAmount(this.currency));
} else if (transaction.isNotReversed() && transaction.isDebit()) { } else if (transaction.isNotReversed() && transaction.isDebit()) {
@@ -767,7 +757,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); } if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
} }
LocalDate nextAnnualFeeDueDate = getNextAnnualFeeDueDate(); final LocalDate nextAnnualFeeDueDate = getNextAnnualFeeDueDate();
if (nextAnnualFeeDueDate == null || annualFeeSettingsNotSet()) { if (nextAnnualFeeDueDate == null || annualFeeSettingsNotSet()) {
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode("no.annualfee.settings"); baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode("no.annualfee.settings");
@@ -806,7 +796,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
existingReversedTransactionIds.addAll(findExistingReversedTransactionIds()); existingReversedTransactionIds.addAll(findExistingReversedTransactionIds());
final Money annualFee = Money.of(this.currency, this.annualFeeAmount); final Money annualFee = Money.of(this.currency, this.annualFeeAmount);
SavingsAccountTransaction annualFeeTransaction = SavingsAccountTransaction.annualFee(this, annualFeeTransactionDate, annualFee); final SavingsAccountTransaction annualFeeTransaction = SavingsAccountTransaction.annualFee(this, annualFeeTransactionDate, annualFee);
this.transactions.add(annualFeeTransaction); this.transactions.add(annualFeeTransaction);
this.summary.updateSummary(this.currency, this.savingsAccountTransactionSummaryWrapper, this.transactions); this.summary.updateSummary(this.currency, this.savingsAccountTransactionSummaryWrapper, this.transactions);
@@ -815,7 +805,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
currentAnnualFeeNextDueDate = findLatestAnnualFeeTransactionDueDate(); currentAnnualFeeNextDueDate = findLatestAnnualFeeTransactionDueDate();
if (currentAnnualFeeNextDueDate != null) { if (currentAnnualFeeNextDueDate != null) {
LocalDate newAnnualFeeNextDueDate = new LocalDate(currentAnnualFeeNextDueDate).withMonthOfYear(this.annualFeeOnMonth) final LocalDate newAnnualFeeNextDueDate = new LocalDate(currentAnnualFeeNextDueDate).withMonthOfYear(this.annualFeeOnMonth)
.withDayOfMonth(this.annualFeeOnDay).plusYears(1); .withDayOfMonth(this.annualFeeOnDay).plusYears(1);
this.annualFeeNextDueDate = newAnnualFeeNextDueDate.toDate(); this.annualFeeNextDueDate = newAnnualFeeNextDueDate.toDate();
} else { } else {
@@ -847,7 +837,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
} }
private void updateToNextAnnualFeeDueDateFrom(final LocalDate startingDate) { private void updateToNextAnnualFeeDueDateFrom(final LocalDate startingDate) {
LocalDate nextDueLocalDate = startingDate.withMonthOfYear(this.annualFeeOnMonth).withDayOfMonth(this.annualFeeOnDay); final LocalDate nextDueLocalDate = startingDate.withMonthOfYear(this.annualFeeOnMonth).withDayOfMonth(this.annualFeeOnDay);
this.annualFeeNextDueDate = nextDueLocalDate.toDate(); this.annualFeeNextDueDate = nextDueLocalDate.toDate();
} }
@@ -902,7 +892,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors) final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
.resource(SAVINGS_ACCOUNT_RESOURCE_NAME + SavingsApiConstants.modifyApplicationAction); .resource(SAVINGS_ACCOUNT_RESOURCE_NAME + SavingsApiConstants.modifyApplicationAction);
SavingsAccountStatusType currentStatus = SavingsAccountStatusType.fromInt(this.status); final SavingsAccountStatusType currentStatus = SavingsAccountStatusType.fromInt(this.status);
if (!SavingsAccountStatusType.SUBMITTED_AND_PENDING_APPROVAL.hasStateOf(currentStatus)) { if (!SavingsAccountStatusType.SUBMITTED_AND_PENDING_APPROVAL.hasStateOf(currentStatus)) {
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode("not.in.submittedandpendingapproval.state"); baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode("not.in.submittedandpendingapproval.state");
@@ -1124,16 +1114,16 @@ public class SavingsAccount extends AbstractPersistable<Long> {
.resource(SAVINGS_ACCOUNT_RESOURCE_NAME); .resource(SAVINGS_ACCOUNT_RESOURCE_NAME);
if (this.lockinPeriodFrequency == null) { if (this.lockinPeriodFrequency == null) {
baseDataValidator.reset().parameter(lockinPeriodFrequencyTypeParamName).value(lockinPeriodFrequencyType).ignoreIfNull() baseDataValidator.reset().parameter(lockinPeriodFrequencyTypeParamName).value(this.lockinPeriodFrequencyType).ignoreIfNull()
.inMinMaxRange(0, 3); .inMinMaxRange(0, 3);
if (this.lockinPeriodFrequencyType != null) { if (this.lockinPeriodFrequencyType != null) {
baseDataValidator.reset().parameter(lockinPeriodFrequencyParamName).value(lockinPeriodFrequency).notNull() baseDataValidator.reset().parameter(lockinPeriodFrequencyParamName).value(this.lockinPeriodFrequency).notNull()
.integerZeroOrGreater(); .integerZeroOrGreater();
} }
} else { } else {
baseDataValidator.reset().parameter(lockinPeriodFrequencyParamName).value(lockinPeriodFrequencyType).integerZeroOrGreater(); baseDataValidator.reset().parameter(lockinPeriodFrequencyParamName).value(this.lockinPeriodFrequencyType).integerZeroOrGreater();
baseDataValidator.reset().parameter(lockinPeriodFrequencyTypeParamName).value(lockinPeriodFrequencyType).notNull() baseDataValidator.reset().parameter(lockinPeriodFrequencyTypeParamName).value(this.lockinPeriodFrequencyType).notNull()
.inMinMaxRange(0, 3); .inMinMaxRange(0, 3);
} }
@@ -1144,14 +1134,14 @@ public class SavingsAccount extends AbstractPersistable<Long> {
final List<Long> existingReversedTransactionIds) { final List<Long> existingReversedTransactionIds) {
final Map<String, Object> accountingBridgeData = new LinkedHashMap<String, Object>(); final Map<String, Object> accountingBridgeData = new LinkedHashMap<String, Object>();
accountingBridgeData.put("savingsId", this.getId()); accountingBridgeData.put("savingsId", getId());
accountingBridgeData.put("savingsProductId", this.productId()); accountingBridgeData.put("savingsProductId", productId());
accountingBridgeData.put("officeId", this.officeId()); accountingBridgeData.put("officeId", officeId());
accountingBridgeData.put("cashBasedAccountingEnabled", this.isCashBasedAccountingEnabledOnSavingsProduct()); accountingBridgeData.put("cashBasedAccountingEnabled", isCashBasedAccountingEnabledOnSavingsProduct());
accountingBridgeData.put("accrualBasedAccountingEnabled", this.isAccrualBasedAccountingEnabledOnSavingsProduct()); accountingBridgeData.put("accrualBasedAccountingEnabled", isAccrualBasedAccountingEnabledOnSavingsProduct());
final List<Map<String, Object>> newLoanTransactions = new ArrayList<Map<String, Object>>(); final List<Map<String, Object>> newLoanTransactions = new ArrayList<Map<String, Object>>();
for (SavingsAccountTransaction transaction : this.transactions) { for (final SavingsAccountTransaction transaction : this.transactions) {
if (transaction.isReversed() && !existingReversedTransactionIds.contains(transaction.getId())) { if (transaction.isReversed() && !existingReversedTransactionIds.contains(transaction.getId())) {
newLoanTransactions.add(transaction.toMapData(currencyData)); newLoanTransactions.add(transaction.toMapData(currencyData));
} else if (!existingTransactionIds.contains(transaction.getId())) { } else if (!existingTransactionIds.contains(transaction.getId())) {
@@ -1165,9 +1155,9 @@ public class SavingsAccount extends AbstractPersistable<Long> {
private Collection<Long> findExistingTransactionIds() { private Collection<Long> findExistingTransactionIds() {
Collection<Long> ids = new ArrayList<Long>(); final Collection<Long> ids = new ArrayList<Long>();
for (SavingsAccountTransaction transaction : this.transactions) { for (final SavingsAccountTransaction transaction : this.transactions) {
ids.add(transaction.getId()); ids.add(transaction.getId());
} }
@@ -1178,7 +1168,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
final Collection<Long> ids = new ArrayList<Long>(); final Collection<Long> ids = new ArrayList<Long>();
for (SavingsAccountTransaction transaction : this.transactions) { for (final SavingsAccountTransaction transaction : this.transactions) {
if (transaction.isReversed()) { if (transaction.isReversed()) {
ids.add(transaction.getId()); ids.add(transaction.getId());
} }
@@ -1279,12 +1269,12 @@ public class SavingsAccount extends AbstractPersistable<Long> {
.failWithCodeNoParameterAddedToErrorCode("cannot.be.a.future.date"); .failWithCodeNoParameterAddedToErrorCode("cannot.be.a.future.date");
} }
if (client != null && client.isActivatedAfter(submittedOn)) { if (this.client != null && this.client.isActivatedAfter(submittedOn)) {
baseDataValidator.reset().parameter(SavingsApiConstants.submittedOnDateParamName).value(client.getActivationLocalDate()) baseDataValidator.reset().parameter(SavingsApiConstants.submittedOnDateParamName).value(this.client.getActivationLocalDate())
.failWithCodeNoParameterAddedToErrorCode("cannot.be.before.client.activation.date"); .failWithCodeNoParameterAddedToErrorCode("cannot.be.before.client.activation.date");
} else if (group != null && group.isActivatedAfter(submittedOn)) { } else if (this.group != null && this.group.isActivatedAfter(submittedOn)) {
baseDataValidator.reset().parameter(SavingsApiConstants.submittedOnDateParamName).value(group.getActivationLocalDate()) baseDataValidator.reset().parameter(SavingsApiConstants.submittedOnDateParamName).value(this.group.getActivationLocalDate())
.failWithCodeNoParameterAddedToErrorCode("cannot.be.before.client.activation.date"); .failWithCodeNoParameterAddedToErrorCode("cannot.be.before.client.activation.date");
} }
@@ -1319,7 +1309,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors) final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
.resource(SAVINGS_ACCOUNT_RESOURCE_NAME + SavingsApiConstants.approvalAction); .resource(SAVINGS_ACCOUNT_RESOURCE_NAME + SavingsApiConstants.approvalAction);
SavingsAccountStatusType currentStatus = SavingsAccountStatusType.fromInt(this.status); final SavingsAccountStatusType currentStatus = SavingsAccountStatusType.fromInt(this.status);
if (!SavingsAccountStatusType.SUBMITTED_AND_PENDING_APPROVAL.hasStateOf(currentStatus)) { if (!SavingsAccountStatusType.SUBMITTED_AND_PENDING_APPROVAL.hasStateOf(currentStatus)) {
baseDataValidator.reset().parameter(SavingsApiConstants.approvedOnDateParamName) baseDataValidator.reset().parameter(SavingsApiConstants.approvedOnDateParamName)
.failWithCodeNoParameterAddedToErrorCode("not.in.submittedandpendingapproval.state"); .failWithCodeNoParameterAddedToErrorCode("not.in.submittedandpendingapproval.state");
@@ -1331,8 +1321,8 @@ public class SavingsAccount extends AbstractPersistable<Long> {
actualChanges.put(SavingsApiConstants.statusParamName, SavingsEnumerations.status(this.status)); actualChanges.put(SavingsApiConstants.statusParamName, SavingsEnumerations.status(this.status));
// only do below if status has changed in the 'approval' case // only do below if status has changed in the 'approval' case
LocalDate approvedOn = command.localDateValueOfParameterNamed(SavingsApiConstants.approvedOnDateParamName); final LocalDate approvedOn = command.localDateValueOfParameterNamed(SavingsApiConstants.approvedOnDateParamName);
String approvedOnDateChange = command.stringValueOfParameterNamed(SavingsApiConstants.approvedOnDateParamName); final String approvedOnDateChange = command.stringValueOfParameterNamed(SavingsApiConstants.approvedOnDateParamName);
this.approvedOnDate = approvedOn.toDate(); this.approvedOnDate = approvedOn.toDate();
this.approvedBy = currentUser; this.approvedBy = currentUser;
@@ -1378,7 +1368,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors) final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
.resource(SAVINGS_ACCOUNT_RESOURCE_NAME + SavingsApiConstants.undoApprovalAction); .resource(SAVINGS_ACCOUNT_RESOURCE_NAME + SavingsApiConstants.undoApprovalAction);
SavingsAccountStatusType currentStatus = SavingsAccountStatusType.fromInt(this.status); final SavingsAccountStatusType currentStatus = SavingsAccountStatusType.fromInt(this.status);
if (!SavingsAccountStatusType.APPROVED.hasStateOf(currentStatus)) { if (!SavingsAccountStatusType.APPROVED.hasStateOf(currentStatus)) {
baseDataValidator.reset().parameter(SavingsApiConstants.approvedOnDateParamName) baseDataValidator.reset().parameter(SavingsApiConstants.approvedOnDateParamName)
@@ -1410,7 +1400,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
final LocalDate upToInterestCalculationDate) { final LocalDate upToInterestCalculationDate) {
SavingsAccountTransaction transactionToUndo = null; SavingsAccountTransaction transactionToUndo = null;
for (SavingsAccountTransaction transaction : this.transactions) { for (final SavingsAccountTransaction transaction : this.transactions) {
if (transaction.isIdentifiedBy(transactionId)) { if (transaction.isIdentifiedBy(transactionId)) {
transactionToUndo = transaction; transactionToUndo = transaction;
} }
@@ -1428,7 +1418,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
if (this.annualFeeNextDueDate == null) { if (this.annualFeeNextDueDate == null) {
updateToNextAnnualFeeDueDateFrom(getActivationLocalDate()); updateToNextAnnualFeeDueDateFrom(getActivationLocalDate());
} else { } else {
LocalDate newAnnualFeeNextDueDate = new LocalDate(this.annualFeeNextDueDate).withMonthOfYear(this.annualFeeOnMonth) final LocalDate newAnnualFeeNextDueDate = new LocalDate(this.annualFeeNextDueDate).withMonthOfYear(this.annualFeeOnMonth)
.withDayOfMonth(this.annualFeeOnDay).plusYears(1); .withDayOfMonth(this.annualFeeOnDay).plusYears(1);
this.annualFeeNextDueDate = newAnnualFeeNextDueDate.toDate(); this.annualFeeNextDueDate = newAnnualFeeNextDueDate.toDate();
} }
@@ -1445,7 +1435,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
Date nextDueDate = null; Date nextDueDate = null;
LocalDate lastAnnualFeeTransactionDate = null; LocalDate lastAnnualFeeTransactionDate = null;
for (SavingsAccountTransaction transaction : retreiveOrderedListOfTransactions()) { for (final SavingsAccountTransaction transaction : retreiveOrderedListOfTransactions()) {
if (transaction.isAnnualFeeAndNotReversed()) { if (transaction.isAnnualFeeAndNotReversed()) {
if (lastAnnualFeeTransactionDate == null) { if (lastAnnualFeeTransactionDate == null) {
lastAnnualFeeTransactionDate = transaction.transactionLocalDate(); lastAnnualFeeTransactionDate = transaction.transactionLocalDate();
@@ -1470,7 +1460,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors) final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
.resource(SAVINGS_ACCOUNT_RESOURCE_NAME + SavingsApiConstants.rejectAction); .resource(SAVINGS_ACCOUNT_RESOURCE_NAME + SavingsApiConstants.rejectAction);
SavingsAccountStatusType currentStatus = SavingsAccountStatusType.fromInt(this.status); final SavingsAccountStatusType currentStatus = SavingsAccountStatusType.fromInt(this.status);
if (!SavingsAccountStatusType.SUBMITTED_AND_PENDING_APPROVAL.hasStateOf(currentStatus)) { if (!SavingsAccountStatusType.SUBMITTED_AND_PENDING_APPROVAL.hasStateOf(currentStatus)) {
baseDataValidator.reset().parameter(SavingsApiConstants.rejectedOnDateParamName) baseDataValidator.reset().parameter(SavingsApiConstants.rejectedOnDateParamName)
@@ -1482,7 +1472,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
this.status = SavingsAccountStatusType.REJECTED.getValue(); this.status = SavingsAccountStatusType.REJECTED.getValue();
actualChanges.put(SavingsApiConstants.statusParamName, SavingsEnumerations.status(this.status)); actualChanges.put(SavingsApiConstants.statusParamName, SavingsEnumerations.status(this.status));
LocalDate rejectedOn = command.localDateValueOfParameterNamed(SavingsApiConstants.rejectedOnDateParamName); final LocalDate rejectedOn = command.localDateValueOfParameterNamed(SavingsApiConstants.rejectedOnDateParamName);
final String rejectedOnAsString = command.stringValueOfParameterNamed(SavingsApiConstants.rejectedOnDateParamName); final String rejectedOnAsString = command.stringValueOfParameterNamed(SavingsApiConstants.rejectedOnDateParamName);
this.rejectedOnDate = rejectedOn.toDate(); this.rejectedOnDate = rejectedOn.toDate();
@@ -1528,7 +1518,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors) final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
.resource(SAVINGS_ACCOUNT_RESOURCE_NAME + SavingsApiConstants.withdrawnByApplicantAction); .resource(SAVINGS_ACCOUNT_RESOURCE_NAME + SavingsApiConstants.withdrawnByApplicantAction);
SavingsAccountStatusType currentStatus = SavingsAccountStatusType.fromInt(this.status); final SavingsAccountStatusType currentStatus = SavingsAccountStatusType.fromInt(this.status);
if (!SavingsAccountStatusType.SUBMITTED_AND_PENDING_APPROVAL.hasStateOf(currentStatus)) { if (!SavingsAccountStatusType.SUBMITTED_AND_PENDING_APPROVAL.hasStateOf(currentStatus)) {
baseDataValidator.reset().parameter(SavingsApiConstants.withdrawnOnDateParamName) baseDataValidator.reset().parameter(SavingsApiConstants.withdrawnOnDateParamName)
@@ -1587,7 +1577,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors) final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
.resource(SAVINGS_ACCOUNT_RESOURCE_NAME + SavingsApiConstants.activateAction); .resource(SAVINGS_ACCOUNT_RESOURCE_NAME + SavingsApiConstants.activateAction);
SavingsAccountStatusType currentStatus = SavingsAccountStatusType.fromInt(this.status); final SavingsAccountStatusType currentStatus = SavingsAccountStatusType.fromInt(this.status);
if (!SavingsAccountStatusType.APPROVED.hasStateOf(currentStatus)) { if (!SavingsAccountStatusType.APPROVED.hasStateOf(currentStatus)) {
baseDataValidator.reset().parameter(SavingsApiConstants.activatedOnDateParamName) baseDataValidator.reset().parameter(SavingsApiConstants.activatedOnDateParamName)
@@ -1622,7 +1612,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
if (this.client != null && this.client.isActivatedAfter(activationDate)) { if (this.client != null && this.client.isActivatedAfter(activationDate)) {
final DateTimeFormatter formatter = DateTimeFormat.forPattern(command.dateFormat()).withLocale(command.extractLocale()); final DateTimeFormatter formatter = DateTimeFormat.forPattern(command.dateFormat()).withLocale(command.extractLocale());
final String dateAsString = formatter.print(client.getActivationLocalDate()); final String dateAsString = formatter.print(this.client.getActivationLocalDate());
baseDataValidator.reset().parameter(SavingsApiConstants.activatedOnDateParamName).value(dateAsString) baseDataValidator.reset().parameter(SavingsApiConstants.activatedOnDateParamName).value(dateAsString)
.failWithCodeNoParameterAddedToErrorCode("cannot.be.before.client.activation.date"); .failWithCodeNoParameterAddedToErrorCode("cannot.be.before.client.activation.date");
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); } if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
@@ -1630,7 +1620,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
if (this.group != null && this.group.isActivatedAfter(activationDate)) { if (this.group != null && this.group.isActivatedAfter(activationDate)) {
final DateTimeFormatter formatter = DateTimeFormat.forPattern(command.dateFormat()).withLocale(command.extractLocale()); final DateTimeFormatter formatter = DateTimeFormat.forPattern(command.dateFormat()).withLocale(command.extractLocale());
final String dateAsString = formatter.print(client.getActivationLocalDate()); final String dateAsString = formatter.print(this.client.getActivationLocalDate());
baseDataValidator.reset().parameter(SavingsApiConstants.activatedOnDateParamName).value(dateAsString) baseDataValidator.reset().parameter(SavingsApiConstants.activatedOnDateParamName).value(dateAsString)
.failWithCodeNoParameterAddedToErrorCode("cannot.be.before.group.activation.date"); .failWithCodeNoParameterAddedToErrorCode("cannot.be.before.group.activation.date");
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); } if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
@@ -28,7 +28,6 @@ public final class SavingsAccountSummary {
@Column(name = "total_withdrawals_derived", scale = 6, precision = 19) @Column(name = "total_withdrawals_derived", scale = 6, precision = 19)
private BigDecimal totalWithdrawals; private BigDecimal totalWithdrawals;
@SuppressWarnings("unused")
@Column(name = "total_interest_earned_derived", scale = 6, precision = 19) @Column(name = "total_interest_earned_derived", scale = 6, precision = 19)
private BigDecimal totalInterestEarned; private BigDecimal totalInterestEarned;
@@ -65,7 +64,7 @@ public final class SavingsAccountSummary {
Money totalEarned = Money.zero(currency); Money totalEarned = Money.zero(currency);
for (PostingPeriod period : allPostingPeriods) { for (final PostingPeriod period : allPostingPeriods) {
totalEarned = totalEarned.plus(period.interest()); totalEarned = totalEarned.plus(period.interest());
} }
@@ -38,7 +38,6 @@ import org.springframework.data.jpa.domain.AbstractPersistable;
@Table(name = "m_savings_account_transaction") @Table(name = "m_savings_account_transaction")
public final class SavingsAccountTransaction extends AbstractPersistable<Long> { public final class SavingsAccountTransaction extends AbstractPersistable<Long> {
@SuppressWarnings("unused")
@ManyToOne(optional = false) @ManyToOne(optional = false)
@JoinColumn(name = "savings_account_id", nullable = false) @JoinColumn(name = "savings_account_id", nullable = false)
private SavingsAccount savingsAccount; private SavingsAccount savingsAccount;
@@ -63,7 +62,6 @@ public final class SavingsAccountTransaction extends AbstractPersistable<Long> {
@Column(name = "running_balance_derived", scale = 6, precision = 19, nullable = false) @Column(name = "running_balance_derived", scale = 6, precision = 19, nullable = false)
private BigDecimal runningBalance; private BigDecimal runningBalance;
@SuppressWarnings("unused")
@Column(name = "cumulative_balance_derived", scale = 6, precision = 19, nullable = false) @Column(name = "cumulative_balance_derived", scale = 6, precision = 19, nullable = false)
private BigDecimal cumulativeBalance; private BigDecimal cumulativeBalance;
@@ -221,10 +219,10 @@ public final class SavingsAccountTransaction extends AbstractPersistable<Long> {
final SavingsAccountTransactionEnumData transactionType = SavingsEnumerations.transactionType(this.typeOf); final SavingsAccountTransactionEnumData transactionType = SavingsEnumerations.transactionType(this.typeOf);
thisTransactionData.put("id", this.getId()); thisTransactionData.put("id", getId());
thisTransactionData.put("type", transactionType); thisTransactionData.put("type", transactionType);
thisTransactionData.put("reversed", Boolean.valueOf(this.isReversed())); thisTransactionData.put("reversed", Boolean.valueOf(isReversed()));
thisTransactionData.put("date", this.getTransactionLocalDate()); thisTransactionData.put("date", getTransactionLocalDate());
thisTransactionData.put("currency", currencyData); thisTransactionData.put("currency", currencyData);
thisTransactionData.put("amount", this.amount); thisTransactionData.put("amount", this.amount);
@@ -236,20 +234,20 @@ public final class SavingsAccountTransaction extends AbstractPersistable<Long> {
} }
public boolean isAfter(final LocalDate transactionDate) { public boolean isAfter(final LocalDate transactionDate) {
return this.getTransactionLocalDate().isAfter(transactionDate); return getTransactionLocalDate().isAfter(transactionDate);
} }
public EndOfDayBalance toEndOfDayBalance(final LocalDateInterval periodInterval, final MonetaryCurrency currency) { public EndOfDayBalance toEndOfDayBalance(final LocalDateInterval periodInterval, final MonetaryCurrency currency) {
Money endOfDayBalance = Money.of(currency, this.runningBalance); final Money endOfDayBalance = Money.of(currency, this.runningBalance);
Money openingBalance = endOfDayBalance; final Money openingBalance = endOfDayBalance;
LocalDate balanceDate = periodInterval.startDate(); LocalDate balanceDate = periodInterval.startDate();
int numberOfDays = periodInterval.daysInPeriodInclusiveOfEndDate(); int numberOfDays = periodInterval.daysInPeriodInclusiveOfEndDate();
if (periodInterval.contains(getTransactionLocalDate())) { if (periodInterval.contains(getTransactionLocalDate())) {
balanceDate = getTransactionLocalDate(); balanceDate = getTransactionLocalDate();
LocalDateInterval newInterval = LocalDateInterval.create(getTransactionLocalDate(), periodInterval.endDate()); final LocalDateInterval newInterval = LocalDateInterval.create(getTransactionLocalDate(), periodInterval.endDate());
numberOfDays = newInterval.daysInPeriodInclusiveOfEndDate(); numberOfDays = newInterval.daysInPeriodInclusiveOfEndDate();
} }
@@ -258,7 +256,7 @@ public final class SavingsAccountTransaction extends AbstractPersistable<Long> {
public EndOfDayBalance toEndOfDayBalance(final Money openingBalance, final LocalDate nextTransactionDate) { public EndOfDayBalance toEndOfDayBalance(final Money openingBalance, final LocalDate nextTransactionDate) {
MonetaryCurrency currency = openingBalance.getCurrency(); final MonetaryCurrency currency = openingBalance.getCurrency();
Money endOfDayBalance = openingBalance.copy(); Money endOfDayBalance = openingBalance.copy();
if (isDeposit()) { if (isDeposit()) {
endOfDayBalance = openingBalance.plus(getAmount(currency)); endOfDayBalance = openingBalance.plus(getAmount(currency));
@@ -274,7 +272,7 @@ public final class SavingsAccountTransaction extends AbstractPersistable<Long> {
} }
public EndOfDayBalance toEndOfDayBalance(final Money openingBalance) { public EndOfDayBalance toEndOfDayBalance(final Money openingBalance) {
MonetaryCurrency currency = openingBalance.getCurrency(); final MonetaryCurrency currency = openingBalance.getCurrency();
Money endOfDayBalance = openingBalance.copy(); Money endOfDayBalance = openingBalance.copy();
if (isDeposit()) { if (isDeposit()) {
endOfDayBalance = openingBalance.plus(getAmount(currency)); endOfDayBalance = openingBalance.plus(getAmount(currency));
@@ -287,7 +285,7 @@ public final class SavingsAccountTransaction extends AbstractPersistable<Long> {
public EndOfDayBalance toEndOfDayBalanceBoundedBy(final Money openingBalance, final LocalDateInterval boundedBy) { public EndOfDayBalance toEndOfDayBalanceBoundedBy(final Money openingBalance, final LocalDateInterval boundedBy) {
MonetaryCurrency currency = openingBalance.getCurrency(); final MonetaryCurrency currency = openingBalance.getCurrency();
Money endOfDayBalance = openingBalance.copy(); Money endOfDayBalance = openingBalance.copy();
int numberOfDaysOfBalance = this.balanceNumberOfDays; int numberOfDaysOfBalance = this.balanceNumberOfDays;
@@ -297,7 +295,7 @@ public final class SavingsAccountTransaction extends AbstractPersistable<Long> {
if (boundedBy.startDate().isAfter(balanceStartDate)) { if (boundedBy.startDate().isAfter(balanceStartDate)) {
balanceStartDate = boundedBy.startDate(); balanceStartDate = boundedBy.startDate();
LocalDateInterval spanOfBalance = LocalDateInterval.create(balanceStartDate, balanceEndDate); final LocalDateInterval spanOfBalance = LocalDateInterval.create(balanceStartDate, balanceEndDate);
numberOfDaysOfBalance = spanOfBalance.daysInPeriodInclusiveOfEndDate(); numberOfDaysOfBalance = spanOfBalance.daysInPeriodInclusiveOfEndDate();
} else { } else {
if (isDeposit()) { if (isDeposit()) {
@@ -309,7 +307,7 @@ public final class SavingsAccountTransaction extends AbstractPersistable<Long> {
if (balanceEndDate.isAfter(boundedBy.endDate())) { if (balanceEndDate.isAfter(boundedBy.endDate())) {
balanceEndDate = boundedBy.endDate(); balanceEndDate = boundedBy.endDate();
LocalDateInterval spanOfBalance = LocalDateInterval.create(balanceStartDate, balanceEndDate); final LocalDateInterval spanOfBalance = LocalDateInterval.create(balanceStartDate, balanceEndDate);
numberOfDaysOfBalance = spanOfBalance.daysInPeriodInclusiveOfEndDate(); numberOfDaysOfBalance = spanOfBalance.daysInPeriodInclusiveOfEndDate();
} }
@@ -321,17 +319,17 @@ public final class SavingsAccountTransaction extends AbstractPersistable<Long> {
} }
public boolean fallsWithin(final LocalDateInterval periodInterval) { public boolean fallsWithin(final LocalDateInterval periodInterval) {
LocalDateInterval balanceInterval = LocalDateInterval.create(getTransactionLocalDate(), getEndOfBalanceLocalDate()); final LocalDateInterval balanceInterval = LocalDateInterval.create(getTransactionLocalDate(), getEndOfBalanceLocalDate());
return periodInterval.contains(balanceInterval); return periodInterval.contains(balanceInterval);
} }
public boolean spansAnyPortionOf(final LocalDateInterval periodInterval) { public boolean spansAnyPortionOf(final LocalDateInterval periodInterval) {
LocalDateInterval balanceInterval = LocalDateInterval.create(getTransactionLocalDate(), getEndOfBalanceLocalDate()); final LocalDateInterval balanceInterval = LocalDateInterval.create(getTransactionLocalDate(), getEndOfBalanceLocalDate());
return balanceInterval.containsPortionOf(periodInterval); return balanceInterval.containsPortionOf(periodInterval);
} }
public boolean isIdentifiedBy(final Long transactionId) { public boolean isIdentifiedBy(final Long transactionId) {
return this.getId().equals(transactionId); return getId().equals(transactionId);
} }
public boolean isCredit() { public boolean isCredit() {
@@ -42,445 +42,491 @@ import org.springframework.security.core.userdetails.User;
@Table(name = "m_appuser", uniqueConstraints = @UniqueConstraint(columnNames = { "username" }, name = "username_org")) @Table(name = "m_appuser", uniqueConstraints = @UniqueConstraint(columnNames = { "username" }, name = "username_org"))
public class AppUser extends AbstractPersistable<Long> implements PlatformUser { public class AppUser extends AbstractPersistable<Long> implements PlatformUser {
private final static Logger logger = LoggerFactory.getLogger(AppUser.class); private final static Logger logger = LoggerFactory.getLogger(AppUser.class);
@Column(name = "email", nullable = false, length = 100) @Column(name = "email", nullable = false, length = 100)
private String email; private String email;
@Column(name = "username", nullable = false, length = 100) @Column(name = "username", nullable = false, length = 100)
private String username; private String username;
@Column(name = "firstname", nullable = false, length = 100) @Column(name = "firstname", nullable = false, length = 100)
private String firstname; private String firstname;
@Column(name = "lastname", nullable = false, length = 100) @Column(name = "lastname", nullable = false, length = 100)
private String lastname; private String lastname;
@Column(name = "password", nullable = false) @Column(name = "password", nullable = false)
private String password; private String password;
@Column(name = "nonexpired", nullable = false) @Column(name = "nonexpired", nullable = false)
private boolean accountNonExpired; private boolean accountNonExpired;
@Column(name = "nonlocked", nullable = false) @Column(name = "nonlocked", nullable = false)
private final boolean accountNonLocked; private final boolean accountNonLocked;
@Column(name = "nonexpired_credentials", nullable = false) @Column(name = "nonexpired_credentials", nullable = false)
private final boolean credentialsNonExpired; private final boolean credentialsNonExpired;
@Column(name = "enabled", nullable = false) @Column(name = "enabled", nullable = false)
private boolean enabled; private boolean enabled;
@SuppressWarnings("unused") @Column(name = "firsttime_login_remaining", nullable = false)
@Column(name = "firsttime_login_remaining", nullable = false) private boolean firstTimeLoginRemaining;
private boolean firstTimeLoginRemaining;
@Column(name = "is_deleted", nullable = false)
@Column(name = "is_deleted", nullable = false) private boolean deleted;
private boolean deleted;
@ManyToOne
@ManyToOne @JoinColumn(name = "office_id", nullable = false)
@JoinColumn(name = "office_id", nullable = false) private Office office;
private Office office;
@ManyToOne
@ManyToOne @JoinColumn(name = "staff_id", nullable = true)
@JoinColumn(name = "staff_id", nullable = true) private Staff staff;
private Staff staff;
@ManyToMany(fetch = FetchType.EAGER)
@ManyToMany(fetch = FetchType.EAGER) @JoinTable(name = "m_appuser_role", joinColumns = @JoinColumn(name = "appuser_id"), inverseJoinColumns = @JoinColumn(name = "role_id"))
@JoinTable(name = "m_appuser_role", joinColumns = @JoinColumn(name = "appuser_id"), inverseJoinColumns = @JoinColumn(name = "role_id")) private Set<Role> roles;
private Set<Role> roles;
public static AppUser fromJson(final Office userOffice,
public static AppUser fromJson(final Office userOffice, final Set<Role> allRoles, final JsonCommand command) { final Set<Role> allRoles, final JsonCommand command) {
final String username = command.stringValueOfParameterNamed("username"); final String username = command.stringValueOfParameterNamed("username");
String password = command.stringValueOfParameterNamed("password"); String password = command.stringValueOfParameterNamed("password");
final Boolean sendPasswordToEmail = command.booleanObjectValueOfParameterNamed("sendPasswordToEmail"); final Boolean sendPasswordToEmail = command
.booleanObjectValueOfParameterNamed("sendPasswordToEmail");
if (sendPasswordToEmail.booleanValue()) {
password = new RandomPasswordGenerator(13).generate(); if (sendPasswordToEmail.booleanValue()) {
} password = new RandomPasswordGenerator(13).generate();
}
boolean userEnabled = true;
boolean userAccountNonExpired = true; final boolean userEnabled = true;
boolean userCredentialsNonExpired = true; final boolean userAccountNonExpired = true;
boolean userAccountNonLocked = true; final boolean userCredentialsNonExpired = true;
final boolean userAccountNonLocked = true;
Collection<SimpleGrantedAuthority> authorities = new ArrayList<SimpleGrantedAuthority>();
authorities.add(new SimpleGrantedAuthority("DUMMY_ROLE_NOT_USED_OR_PERSISTED_TO_AVOID_EXCEPTION")); final Collection<SimpleGrantedAuthority> authorities = new ArrayList<SimpleGrantedAuthority>();
authorities.add(new SimpleGrantedAuthority(
User user = new User(username, password, userEnabled, userAccountNonExpired, userCredentialsNonExpired, userAccountNonLocked, "DUMMY_ROLE_NOT_USED_OR_PERSISTED_TO_AVOID_EXCEPTION"));
authorities);
final User user = new User(username, password, userEnabled,
final String email = command.stringValueOfParameterNamed("email"); userAccountNonExpired, userCredentialsNonExpired,
final String firstname = command.stringValueOfParameterNamed("firstname"); userAccountNonLocked, authorities);
final String lastname = command.stringValueOfParameterNamed("lastname");
final String email = command.stringValueOfParameterNamed("email");
return new AppUser(userOffice, user, allRoles, email, firstname, lastname); final String firstname = command
} .stringValueOfParameterNamed("firstname");
final String lastname = command.stringValueOfParameterNamed("lastname");
protected AppUser() {
this.accountNonLocked = false; return new AppUser(userOffice, user, allRoles, email, firstname,
this.credentialsNonExpired = false; lastname);
this.roles = new HashSet<Role>(); }
}
protected AppUser() {
public AppUser(final Office office, final User user, final Set<Role> roles, final String email, final String firstname, this.accountNonLocked = false;
final String lastname) { this.credentialsNonExpired = false;
this.office = office; this.roles = new HashSet<Role>();
this.email = email.trim(); }
this.username = user.getUsername().trim();
this.firstname = firstname.trim(); public AppUser(final Office office, final User user, final Set<Role> roles,
this.lastname = lastname.trim(); final String email, final String firstname, final String lastname) {
this.password = user.getPassword().trim(); this.office = office;
this.accountNonExpired = user.isAccountNonExpired(); this.email = email.trim();
this.accountNonLocked = user.isAccountNonLocked(); this.username = user.getUsername().trim();
this.credentialsNonExpired = user.isCredentialsNonExpired(); this.firstname = firstname.trim();
this.enabled = user.isEnabled(); this.lastname = lastname.trim();
this.roles = roles; this.password = user.getPassword().trim();
this.firstTimeLoginRemaining = true; this.accountNonExpired = user.isAccountNonExpired();
} this.accountNonLocked = user.isAccountNonLocked();
this.credentialsNonExpired = user.isCredentialsNonExpired();
public EnumOptionData organisationalRoleData() { this.enabled = user.isEnabled();
EnumOptionData organisationalRole = null; this.roles = roles;
if (this.staff != null) { this.firstTimeLoginRemaining = true;
organisationalRole = this.staff.organisationalRoleData(); }
}
return organisationalRole; public EnumOptionData organisationalRoleData() {
} EnumOptionData organisationalRole = null;
if (this.staff != null) {
public void updatePassword(final String encodePassword) { organisationalRole = this.staff.organisationalRoleData();
this.password = encodePassword; }
this.firstTimeLoginRemaining = false; return organisationalRole;
} }
public void changeOffice(final Office differentOffice) { public void updatePassword(final String encodePassword) {
this.office = differentOffice; this.password = encodePassword;
} this.firstTimeLoginRemaining = false;
}
public void updateRoles(final Set<Role> allRoles) {
if (!allRoles.isEmpty()) { public void changeOffice(final Office differentOffice) {
this.roles.clear(); this.office = differentOffice;
this.roles = allRoles; }
}
} public void updateRoles(final Set<Role> allRoles) {
if (!allRoles.isEmpty()) {
public Map<String, Object> update(final JsonCommand command, final PlatformPasswordEncoder platformPasswordEncoder) { this.roles.clear();
this.roles = allRoles;
final Map<String, Object> actualChanges = new LinkedHashMap<String, Object>(7); }
}
// unencoded password provided
final String passwordParamName = "password"; public Map<String, Object> update(final JsonCommand command,
final String passwordEncodedParamName = "passwordEncoded"; final PlatformPasswordEncoder platformPasswordEncoder) {
if (command.hasParameter(passwordParamName)) {
if (command.isChangeInPasswordParameterNamed(passwordParamName, this.password, platformPasswordEncoder, this.getId())) { final Map<String, Object> actualChanges = new LinkedHashMap<String, Object>(
final String passwordEncodedValue = command.passwordValueOfParameterNamed(passwordParamName, platformPasswordEncoder, 7);
this.getId());
actualChanges.put(passwordEncodedParamName, passwordEncodedValue); // unencoded password provided
updatePassword(passwordEncodedValue); final String passwordParamName = "password";
} final String passwordEncodedParamName = "passwordEncoded";
} if (command.hasParameter(passwordParamName)) {
if (command.isChangeInPasswordParameterNamed(passwordParamName,
if (command.hasParameter(passwordEncodedParamName)) { this.password, platformPasswordEncoder, getId())) {
if (command.isChangeInStringParameterNamed(passwordEncodedParamName, this.password)) { final String passwordEncodedValue = command
final String newValue = command.stringValueOfParameterNamed(passwordEncodedParamName); .passwordValueOfParameterNamed(passwordParamName,
actualChanges.put(passwordEncodedParamName, newValue); platformPasswordEncoder, getId());
updatePassword(newValue); actualChanges.put(passwordEncodedParamName,
} passwordEncodedValue);
} updatePassword(passwordEncodedValue);
}
final String officeIdParamName = "officeId"; }
if (command.isChangeInLongParameterNamed(officeIdParamName, this.office.getId())) {
final Long newValue = command.longValueOfParameterNamed(officeIdParamName); if (command.hasParameter(passwordEncodedParamName)) {
actualChanges.put(officeIdParamName, newValue); if (command.isChangeInStringParameterNamed(
} passwordEncodedParamName, this.password)) {
final String newValue = command
final String rolesParamName = "roles"; .stringValueOfParameterNamed(passwordEncodedParamName);
if (command.isChangeInArrayParameterNamed(rolesParamName, getRolesAsIdStringArray())) { actualChanges.put(passwordEncodedParamName, newValue);
final String[] newValue = command.arrayValueOfParameterNamed(rolesParamName); updatePassword(newValue);
actualChanges.put(rolesParamName, newValue); }
} }
final String usernameParamName = "username"; final String officeIdParamName = "officeId";
if (command.isChangeInStringParameterNamed(usernameParamName, this.username)) { if (command.isChangeInLongParameterNamed(officeIdParamName,
final String newValue = command.stringValueOfParameterNamed(usernameParamName); this.office.getId())) {
actualChanges.put(usernameParamName, newValue); final Long newValue = command
this.username = newValue; .longValueOfParameterNamed(officeIdParamName);
} actualChanges.put(officeIdParamName, newValue);
}
final String firstnameParamName = "firstname";
if (command.isChangeInStringParameterNamed(firstnameParamName, this.firstname)) { final String rolesParamName = "roles";
final String newValue = command.stringValueOfParameterNamed(firstnameParamName); if (command.isChangeInArrayParameterNamed(rolesParamName,
actualChanges.put(firstnameParamName, newValue); getRolesAsIdStringArray())) {
this.firstname = newValue; final String[] newValue = command
} .arrayValueOfParameterNamed(rolesParamName);
actualChanges.put(rolesParamName, newValue);
final String lastnameParamName = "lastname"; }
if (command.isChangeInStringParameterNamed(lastnameParamName, this.lastname)) {
final String newValue = command.stringValueOfParameterNamed(lastnameParamName); final String usernameParamName = "username";
actualChanges.put(lastnameParamName, newValue); if (command.isChangeInStringParameterNamed(usernameParamName,
this.lastname = newValue; this.username)) {
} final String newValue = command
.stringValueOfParameterNamed(usernameParamName);
final String emailParamName = "email"; actualChanges.put(usernameParamName, newValue);
if (command.isChangeInStringParameterNamed(emailParamName, this.email)) { this.username = newValue;
final String newValue = command.stringValueOfParameterNamed(emailParamName); }
actualChanges.put(emailParamName, newValue);
this.email = newValue; final String firstnameParamName = "firstname";
} if (command.isChangeInStringParameterNamed(firstnameParamName,
this.firstname)) {
return actualChanges; final String newValue = command
} .stringValueOfParameterNamed(firstnameParamName);
actualChanges.put(firstnameParamName, newValue);
private String[] getRolesAsIdStringArray() { this.firstname = newValue;
List<String> roleIds = new ArrayList<String>(); }
for (Role role : this.roles) { final String lastnameParamName = "lastname";
roleIds.add(role.getId().toString()); if (command.isChangeInStringParameterNamed(lastnameParamName,
} this.lastname)) {
final String newValue = command
return roleIds.toArray(new String[roleIds.size()]); .stringValueOfParameterNamed(lastnameParamName);
} actualChanges.put(lastnameParamName, newValue);
this.lastname = newValue;
/** }
* Delete is a <i>soft delete</i>. Updates flag so it wont appear in
* query/report results. final String emailParamName = "email";
* if (command.isChangeInStringParameterNamed(emailParamName, this.email)) {
* Any fields with unique constraints and prepended with id of record. final String newValue = command
*/ .stringValueOfParameterNamed(emailParamName);
public void delete() { actualChanges.put(emailParamName, newValue);
this.deleted = true; this.email = newValue;
this.enabled = false; }
this.accountNonExpired = false;
this.firstTimeLoginRemaining = true; return actualChanges;
this.username = this.getId() + "_DELETED_" + this.username; }
}
private String[] getRolesAsIdStringArray() {
public boolean isDeleted() { final List<String> roleIds = new ArrayList<String>();
return deleted;
} for (final Role role : this.roles) {
roleIds.add(role.getId().toString());
@Override }
public Collection<GrantedAuthority> getAuthorities() {
return this.populateGrantedAuthorities(); return roleIds.toArray(new String[roleIds.size()]);
} }
private List<GrantedAuthority> populateGrantedAuthorities() { /**
List<GrantedAuthority> grantedAuthorities = new ArrayList<GrantedAuthority>(); * Delete is a <i>soft delete</i>. Updates flag so it wont appear in
for (Role role : this.roles) { * query/report results.
Collection<Permission> permissions = role.getPermissions(); *
for (Permission permission : permissions) { * Any fields with unique constraints and prepended with id of record.
grantedAuthorities.add(new SimpleGrantedAuthority(permission.getCode())); */
} public void delete() {
} this.deleted = true;
return grantedAuthorities; this.enabled = false;
} this.accountNonExpired = false;
this.firstTimeLoginRemaining = true;
@Override this.username = getId() + "_DELETED_" + this.username;
public String getPassword() { }
return this.password;
} public boolean isDeleted() {
return this.deleted;
@Override }
public String getUsername() {
return this.username; @Override
} public Collection<GrantedAuthority> getAuthorities() {
return populateGrantedAuthorities();
@Override }
public boolean isAccountNonExpired() {
return this.accountNonExpired; private List<GrantedAuthority> populateGrantedAuthorities() {
} final List<GrantedAuthority> grantedAuthorities = new ArrayList<GrantedAuthority>();
for (final Role role : this.roles) {
@Override final Collection<Permission> permissions = role.getPermissions();
public boolean isAccountNonLocked() { for (final Permission permission : permissions) {
return this.accountNonLocked; grantedAuthorities.add(new SimpleGrantedAuthority(permission
} .getCode()));
}
@Override }
public boolean isCredentialsNonExpired() { return grantedAuthorities;
return this.credentialsNonExpired; }
}
@Override
@Override public String getPassword() {
public boolean isEnabled() { return this.password;
return this.enabled; }
}
@Override
public String getFirstname() { public String getUsername() {
return firstname; return this.username;
} }
public String getLastname() { @Override
return lastname; public boolean isAccountNonExpired() {
} return this.accountNonExpired;
}
public String getEmail() {
return this.email; @Override
} public boolean isAccountNonLocked() {
return this.accountNonLocked;
public Set<Role> getRoles() { }
return this.roles;
} @Override
public boolean isCredentialsNonExpired() {
public Office getOffice() { return this.credentialsNonExpired;
return this.office; }
}
@Override
public boolean canNotApproveLoanInPast() { public boolean isEnabled() {
return hasNotPermissionForAnyOf("ALL_FUNCTIONS", "APPROVEINPAST_LOAN"); return this.enabled;
} }
public boolean canNotRejectLoanInPast() { public String getFirstname() {
return hasNotPermissionForAnyOf("ALL_FUNCTIONS", "REJECTINPAST_LOAN"); return this.firstname;
} }
public boolean canNotWithdrawByClientLoanInPast() { public String getLastname() {
return hasNotPermissionForAnyOf("ALL_FUNCTIONS", "WITHDRAWINPAST_LOAN"); return this.lastname;
} }
public boolean canNotDisburseLoanInPast() { public String getEmail() {
return hasNotPermissionForAnyOf("ALL_FUNCTIONS", "DISBURSEINPAST_LOAN"); return this.email;
} }
public boolean canNotMakeRepaymentOnLoanInPast() { public Set<Role> getRoles() {
return hasNotPermissionForAnyOf("ALL_FUNCTIONS", "REPAYMENTINPAST_LOAN"); return this.roles;
} }
public boolean hasNotPermissionForReport(final String reportName) { public Office getOffice() {
return this.office;
if (hasNotPermissionForAnyOf("ALL_FUNCTIONS", "ALL_FUNCTIONS_READ", "REPORTING_SUPER_USER", "READ_" + reportName)) return true; }
return false; public boolean canNotApproveLoanInPast() {
} return hasNotPermissionForAnyOf("ALL_FUNCTIONS", "APPROVEINPAST_LOAN");
}
public boolean hasNotPermissionForDatatable(final String datatable, final String accessType) {
public boolean canNotRejectLoanInPast() {
String matchPermission = accessType + "_" + datatable; return hasNotPermissionForAnyOf("ALL_FUNCTIONS", "REJECTINPAST_LOAN");
}
if (accessType.equalsIgnoreCase("READ")) {
public boolean canNotWithdrawByClientLoanInPast() {
if (hasNotPermissionForAnyOf("ALL_FUNCTIONS", "ALL_FUNCTIONS_READ", matchPermission)) return true; return hasNotPermissionForAnyOf("ALL_FUNCTIONS", "WITHDRAWINPAST_LOAN");
}
return false;
} public boolean canNotDisburseLoanInPast() {
return hasNotPermissionForAnyOf("ALL_FUNCTIONS", "DISBURSEINPAST_LOAN");
if (hasNotPermissionForAnyOf("ALL_FUNCTIONS", matchPermission)) return true; }
return false; public boolean canNotMakeRepaymentOnLoanInPast() {
} return hasNotPermissionForAnyOf("ALL_FUNCTIONS", "REPAYMENTINPAST_LOAN");
}
public boolean hasNotPermissionForAnyOf(final String... permissionCodes) {
boolean hasNotPermission = true; public boolean hasNotPermissionForReport(final String reportName) {
for (String permissionCode : permissionCodes) {
boolean checkPermission = this.hasPermissionTo(permissionCode); if (hasNotPermissionForAnyOf("ALL_FUNCTIONS", "ALL_FUNCTIONS_READ",
if (checkPermission) { "REPORTING_SUPER_USER", "READ_" + reportName)) {
hasNotPermission = false; return true;
break; }
}
} return false;
return hasNotPermission; }
}
public boolean hasNotPermissionForDatatable(final String datatable,
public void validateHasReadPermission(final String resourceType) { final String accessType) {
final String authorizationMessage = "User has no authority to view " + resourceType.toLowerCase() + "s"; final String matchPermission = accessType + "_" + datatable;
final String matchPermission = "READ_" + resourceType.toUpperCase();
if (accessType.equalsIgnoreCase("READ")) {
if (!(hasNotPermissionForAnyOf("ALL_FUNCTIONS", "ALL_FUNCTIONS_READ", matchPermission))) return;
if (hasNotPermissionForAnyOf("ALL_FUNCTIONS", "ALL_FUNCTIONS_READ",
throw new NoAuthorizationException(authorizationMessage); matchPermission)) {
} return true;
}
private boolean hasNotPermissionTo(final String permissionCode) {
return !hasPermissionTo(permissionCode); return false;
} }
private boolean hasPermissionTo(final String permissionCode) { if (hasNotPermissionForAnyOf("ALL_FUNCTIONS", matchPermission)) {
boolean hasPermission = hasAllFunctionsPermission(); return true;
if (!hasPermission) { }
for (Role role : this.roles) {
if (role.hasPermissionTo(permissionCode)) { return false;
hasPermission = true; }
break;
} public boolean hasNotPermissionForAnyOf(final String... permissionCodes) {
} boolean hasNotPermission = true;
} for (final String permissionCode : permissionCodes) {
return hasPermission; final boolean checkPermission = hasPermissionTo(permissionCode);
} if (checkPermission) {
hasNotPermission = false;
private boolean hasAllFunctionsPermission() { break;
boolean match = false; }
for (Role role : this.roles) { }
if (role.hasPermissionTo("ALL_FUNCTIONS")) { return hasNotPermission;
match = true; }
break;
} public void validateHasReadPermission(final String resourceType) {
}
return match; final String authorizationMessage = "User has no authority to view "
} + resourceType.toLowerCase() + "s";
final String matchPermission = "READ_" + resourceType.toUpperCase();
public boolean hasIdOf(final Long userId) {
return getId().equals(userId); if (!hasNotPermissionForAnyOf("ALL_FUNCTIONS", "ALL_FUNCTIONS_READ",
} matchPermission)) {
return;
private boolean hasNotAnyPermission(final List<String> permissions) { }
return !hasAnyPermission(permissions);
} throw new NoAuthorizationException(authorizationMessage);
}
private boolean hasAnyPermission(final List<String> permissions) {
boolean hasAtLeastOneOf = false; private boolean hasNotPermissionTo(final String permissionCode) {
return !hasPermissionTo(permissionCode);
for (final String permissionCode : permissions) { }
if (hasPermissionTo(permissionCode)) {
hasAtLeastOneOf = true; private boolean hasPermissionTo(final String permissionCode) {
break; boolean hasPermission = hasAllFunctionsPermission();
} if (!hasPermission) {
} for (final Role role : this.roles) {
if (role.hasPermissionTo(permissionCode)) {
return hasAtLeastOneOf; hasPermission = true;
} break;
}
public void validateHasPermissionTo(final String function, final List<String> allowedPermissions) { }
if (hasNotAnyPermission(allowedPermissions)) { }
final String authorizationMessage = "User has no authority to: " + function; return hasPermission;
throw new NoAuthorizationException(authorizationMessage); }
}
} private boolean hasAllFunctionsPermission() {
boolean match = false;
public void validateHasPermissionTo(final String function) { for (final Role role : this.roles) {
if (hasNotPermissionTo(function)) { if (role.hasPermissionTo("ALL_FUNCTIONS")) {
final String authorizationMessage = "User has no authority to: " + function; match = true;
logger.info("Unauthorized access: userId: " + this.getId() + " action: " + function + " allowed: " + getAuthorities()); break;
throw new NoAuthorizationException(authorizationMessage); }
} }
} return match;
}
public void validateHasCheckerPermissionTo(final String function) {
public boolean hasIdOf(final Long userId) {
final String checkerPermissionName = function.toUpperCase() + "_CHECKER"; return getId().equals(userId);
if (hasNotPermissionTo("CHECKER_SUPER_USER") && hasNotPermissionTo(checkerPermissionName)) { }
final String authorizationMessage = "User has no authority to be a checker for: " + function;
throw new NoAuthorizationException(authorizationMessage); private boolean hasNotAnyPermission(final List<String> permissions) {
} return !hasAnyPermission(permissions);
} }
public void validateHasDatatableReadPermission(final String datatable) { private boolean hasAnyPermission(final List<String> permissions) {
if (hasNotPermissionForDatatable(datatable, "READ")) { throw new NoAuthorizationException("Not authorised to read datatable: " boolean hasAtLeastOneOf = false;
+ datatable); }
} for (final String permissionCode : permissions) {
if (hasPermissionTo(permissionCode)) {
public Long getStaffId() { hasAtLeastOneOf = true;
Long staffId = null; break;
if (this.staff != null) { }
staffId = this.staff.getId(); }
}
return staffId; return hasAtLeastOneOf;
} }
public String getStaffDisplayName() { public void validateHasPermissionTo(final String function,
String staffDisplayName = null; final List<String> allowedPermissions) {
if (this.staff != null) { if (hasNotAnyPermission(allowedPermissions)) {
staffDisplayName = this.staff.displayName(); final String authorizationMessage = "User has no authority to: "
} + function;
return staffDisplayName; throw new NoAuthorizationException(authorizationMessage);
} }
}
public void validateHasPermissionTo(final String function) {
if (hasNotPermissionTo(function)) {
final String authorizationMessage = "User has no authority to: "
+ function;
logger.info("Unauthorized access: userId: " + getId() + " action: "
+ function + " allowed: " + getAuthorities());
throw new NoAuthorizationException(authorizationMessage);
}
}
public void validateHasCheckerPermissionTo(final String function) {
final String checkerPermissionName = function.toUpperCase()
+ "_CHECKER";
if (hasNotPermissionTo("CHECKER_SUPER_USER")
&& hasNotPermissionTo(checkerPermissionName)) {
final String authorizationMessage = "User has no authority to be a checker for: "
+ function;
throw new NoAuthorizationException(authorizationMessage);
}
}
public void validateHasDatatableReadPermission(final String datatable) {
if (hasNotPermissionForDatatable(datatable, "READ")) {
throw new NoAuthorizationException(
"Not authorised to read datatable: " + datatable);
}
}
public Long getStaffId() {
Long staffId = null;
if (this.staff != null) {
staffId = this.staff.getId();
}
return staffId;
}
public String getStaffDisplayName() {
String staffDisplayName = null;
if (this.staff != null) {
staffDisplayName = this.staff.displayName();
}
return staffDisplayName;
}
} }
@@ -21,11 +21,9 @@ public class Permission extends AbstractPersistable<Long> {
@Column(name = "code", nullable = false, length = 100) @Column(name = "code", nullable = false, length = 100)
private final String code; private final String code;
@SuppressWarnings("unused")
@Column(name = "entity_name", nullable = true, length = 100) @Column(name = "entity_name", nullable = true, length = 100)
private final String entityName; private final String entityName;
@SuppressWarnings("unused")
@Column(name = "action_name", nullable = true, length = 100) @Column(name = "action_name", nullable = true, length = 100)
private final String actionName; private final String actionName;
@@ -66,7 +64,7 @@ public class Permission extends AbstractPersistable<Long> {
} }
public boolean enableMakerChecker(final boolean canMakerChecker) { public boolean enableMakerChecker(final boolean canMakerChecker) {
final boolean isUpdatedValueSame = (this.canMakerChecker == canMakerChecker); final boolean isUpdatedValueSame = this.canMakerChecker == canMakerChecker;
this.canMakerChecker = canMakerChecker; this.canMakerChecker = canMakerChecker;
return !isUpdatedValueSame; return !isUpdatedValueSame;