update noteTypeid to be more descriptive in response as per other enum values.

This commit is contained in:
Keith Woodlock
2012-06-06 15:23:28 +01:00
parent e68f7f7589
commit 8ddbb0935d
6 changed files with 55 additions and 18 deletions
@@ -278,13 +278,13 @@
<div> <div>
<div class="notespacer"> <div class="notespacer">
<span class="ui-icon ui-icon-note" style="float: left; margin-right: 5px;"></span> <span class="ui-icon ui-icon-note" style="float: left; margin-right: 5px;"></span>
{{#if noteTypeId === 100}} {{#if noteType.id === 100}}
<span><spring:message code="widget.notes.label.client.note"/></span> <span><spring:message code="widget.notes.label.client.note"/></span>
{{/if}} {{/if}}
{{#if noteTypeId === 200}} {{#if noteType.id === 200}}
<span><spring:message code="widget.notes.label.loan.note"/></span> <span><spring:message code="widget.notes.label.loan.note"/></span>
{{/if}} {{/if}}
{{#if noteTypeId === 300}} {{#if noteType.id === 300}}
<span><spring:message code="widget.notes.label.loan.transaction.note"/></span> <span><spring:message code="widget.notes.label.loan.transaction.note"/></span>
{{/if}} {{/if}}
<span><a href="#" class="editclientnote" id="editclientnotelink{{=id}}"><spring:message code="link.edit"/></a></span> <span><a href="#" class="editclientnote" id="editclientnotelink{{=id}}"><spring:message code="link.edit"/></a></span>
@@ -607,7 +607,7 @@
<div class="row"> <div class="row">
<span class="longrowlabel"><spring:message code="label.client.account.loan.term"/></span> <span class="longrowlabel"><spring:message code="label.client.account.loan.term"/></span>
<span class="rowvalue">{{=loanTermInMonths}} <spring:message code="label.months"/> / ({{=loanTermInDays}} <spring:message code="label.days"/>)</span> <span class="rowvalue">{{=expectedLoanTermInMonths}} <spring:message code="label.months"/> / ({{=expectedLoanTermInDays}} <spring:message code="label.days"/>)</span>
</div> </div>
{{#if closedOnDate !== null}} {{#if closedOnDate !== null}}
@@ -10,7 +10,7 @@ public class NoteData {
private Long clientId; private Long clientId;
private Long loanId; private Long loanId;
private Long loanTransactionId; private Long loanTransactionId;
private Integer noteTypeId; private EnumOptionData noteType;
private String note; private String note;
@@ -26,14 +26,14 @@ public class NoteData {
} }
public NoteData(Long id, Long clientId, Long loanId, public NoteData(Long id, Long clientId, Long loanId,
Long transactionId, Integer noteTypeId, String note, Long transactionId, EnumOptionData noteType, String note,
DateTime createdDate, Long createdById, String createdByUsername, DateTime createdDate, Long createdById, String createdByUsername,
DateTime lastModifiedDate, Long lastModifiedById, String updatedByUsername) { DateTime lastModifiedDate, Long lastModifiedById, String updatedByUsername) {
this.id = id; this.id = id;
this.clientId = clientId; this.clientId = clientId;
this.loanId = loanId; this.loanId = loanId;
this.loanTransactionId = transactionId; this.loanTransactionId = transactionId;
this.noteTypeId = noteTypeId; this.noteType = noteType;
this.note = note; this.note = note;
this.createdOn = createdDate; this.createdOn = createdDate;
this.createdById = createdById; this.createdById = createdById;
@@ -131,11 +131,11 @@ public class NoteData {
this.updatedOn = updatedOn; this.updatedOn = updatedOn;
} }
public Integer getNoteTypeId() { public EnumOptionData getNoteType() {
return noteTypeId; return noteType;
} }
public void setNoteTypeId(Integer noteTypeId) { public void setNoteType(EnumOptionData noteType) {
this.noteTypeId = noteTypeId; this.noteType = noteType;
} }
} }
@@ -44,18 +44,23 @@ public class Note extends AbstractAuditableCustom<AppUser, Long> {
private Integer noteTypeId; private Integer noteTypeId;
public enum NoteType { public enum NoteType {
CLIENT(100), LOAN(200), LOAN_TRANSACTION(300); CLIENT(100, "noteType.client"), LOAN(200, "noteType.loan"), LOAN_TRANSACTION(300, "noteType.loan.transaction");
private int value; private Integer value;
private String code;
NoteType(int value) { this.value = value; } NoteType(final Integer value, final String code) { this.value = value; this.code = code; }
public int getValue() { return value; } public Integer getValue() { return value; }
public static NoteType parse(int id) { public String getCode() {
return code;
}
public static NoteType parse(Integer id) {
NoteType right = null; // Default NoteType right = null; // Default
for (NoteType item : NoteType.values()) { for (NoteType item : NoteType.values()) {
if (item.getValue()==id) { if (item.getValue().intValue() == id.intValue()) {
right = item; right = item;
break; break;
} }
@@ -0,0 +1,27 @@
package org.mifosng.platform.client.domain;
import org.mifosng.platform.api.data.EnumOptionData;
import org.mifosng.platform.client.domain.Note.NoteType;
public class NoteEnumerations {
public static EnumOptionData noteType(final Integer id) {
return noteType(Note.NoteType.parse(id));
}
public static EnumOptionData noteType(NoteType type) {
EnumOptionData optionData = null;
switch (type) {
case CLIENT:
optionData = new EnumOptionData(type.getValue().longValue(), type.getCode(), "Client note");
break;
case LOAN:
optionData = new EnumOptionData(type.getValue().longValue(), type.getCode(), "Loan note");
break;
case LOAN_TRANSACTION:
optionData = new EnumOptionData(type.getValue().longValue(), type.getCode(), "Loan transaction note");
break;
}
return optionData;
}
}
@@ -15,9 +15,11 @@ import org.mifosng.platform.api.data.AppUserData;
import org.mifosng.platform.api.data.ClientData; import org.mifosng.platform.api.data.ClientData;
import org.mifosng.platform.api.data.ClientLoanAccountSummaryCollectionData; import org.mifosng.platform.api.data.ClientLoanAccountSummaryCollectionData;
import org.mifosng.platform.api.data.ClientLoanAccountSummaryData; import org.mifosng.platform.api.data.ClientLoanAccountSummaryData;
import org.mifosng.platform.api.data.EnumOptionData;
import org.mifosng.platform.api.data.NoteData; import org.mifosng.platform.api.data.NoteData;
import org.mifosng.platform.api.data.OfficeData; import org.mifosng.platform.api.data.OfficeData;
import org.mifosng.platform.api.data.OfficeLookup; import org.mifosng.platform.api.data.OfficeLookup;
import org.mifosng.platform.client.domain.NoteEnumerations;
import org.mifosng.platform.exceptions.ClientNotFoundException; import org.mifosng.platform.exceptions.ClientNotFoundException;
import org.mifosng.platform.exceptions.NoteNotFoundException; import org.mifosng.platform.exceptions.NoteNotFoundException;
import org.mifosng.platform.infrastructure.JdbcSupport; import org.mifosng.platform.infrastructure.JdbcSupport;
@@ -306,6 +308,7 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
Long loanId = JdbcSupport.getLong(rs, "loanId"); Long loanId = JdbcSupport.getLong(rs, "loanId");
Long transactionId = JdbcSupport.getLong(rs, "transactionId"); Long transactionId = JdbcSupport.getLong(rs, "transactionId");
Integer noteTypeId = JdbcSupport.getInteger(rs, "noteTypeEnum"); Integer noteTypeId = JdbcSupport.getInteger(rs, "noteTypeEnum");
EnumOptionData noteType = NoteEnumerations.noteType(noteTypeId);
String note = rs.getString("note"); String note = rs.getString("note");
DateTime createdDate = JdbcSupport.getDateTime(rs, "createdDate"); DateTime createdDate = JdbcSupport.getDateTime(rs, "createdDate");
@@ -317,7 +320,7 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
String updatedByUsername = findUserById(createdById, allUsers); String updatedByUsername = findUserById(createdById, allUsers);
return new NoteData(id, clientId, loanId, transactionId, return new NoteData(id, clientId, loanId, transactionId,
noteTypeId, note, createdDate, createdById, noteType, note, createdDate, createdById,
createdByUsername, lastModifiedDate, lastModifiedById, createdByUsername, lastModifiedDate, lastModifiedById,
updatedByUsername); updatedByUsername);
} }
@@ -60,6 +60,8 @@ public class PeriodicInterestRateCalculator {
case EQUAL_INSTALLMENTS: case EQUAL_INSTALLMENTS:
principalDue = totalDuePerInstallment.minus(interestForInstallment); principalDue = totalDuePerInstallment.minus(interestForInstallment);
break; break;
case INVALID:
break;
} }
return principalDue; return principalDue;