From 8ddbb0935d9693c7e49b0e2e724aa19d91f6e8f2 Mon Sep 17 00:00:00 2001 From: Keith Woodlock Date: Wed, 6 Jun 2012 15:23:28 +0100 Subject: [PATCH] update noteTypeid to be more descriptive in response as per other enum values. --- .../webapp/WEB-INF/views/view-templates.jsp | 8 +++--- .../mifosng/platform/api/data/NoteData.java | 14 +++++----- .../mifosng/platform/client/domain/Note.java | 17 +++++++----- .../client/domain/NoteEnumerations.java | 27 +++++++++++++++++++ .../ClientReadPlatformServiceImpl.java | 5 +++- .../PeriodicInterestRateCalculator.java | 2 ++ 6 files changed, 55 insertions(+), 18 deletions(-) create mode 100644 mifosng-provider/src/main/java/org/mifosng/platform/client/domain/NoteEnumerations.java diff --git a/mifosng-individual-lending-app/src/main/webapp/WEB-INF/views/view-templates.jsp b/mifosng-individual-lending-app/src/main/webapp/WEB-INF/views/view-templates.jsp index bd440c3e3..22ce4003c 100644 --- a/mifosng-individual-lending-app/src/main/webapp/WEB-INF/views/view-templates.jsp +++ b/mifosng-individual-lending-app/src/main/webapp/WEB-INF/views/view-templates.jsp @@ -278,13 +278,13 @@
- {{#if noteTypeId === 100}} + {{#if noteType.id === 100}} {{/if}} - {{#if noteTypeId === 200}} + {{#if noteType.id === 200}} {{/if}} - {{#if noteTypeId === 300}} + {{#if noteType.id === 300}} {{/if}} @@ -607,7 +607,7 @@
- {{=loanTermInMonths}} / ({{=loanTermInDays}} ) + {{=expectedLoanTermInMonths}} / ({{=expectedLoanTermInDays}} )
{{#if closedOnDate !== null}} diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/NoteData.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/data/NoteData.java index 16cc225f3..e5f52dbe2 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/NoteData.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/data/NoteData.java @@ -10,7 +10,7 @@ public class NoteData { private Long clientId; private Long loanId; private Long loanTransactionId; - private Integer noteTypeId; + private EnumOptionData noteType; private String note; @@ -26,14 +26,14 @@ public class NoteData { } 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 lastModifiedDate, Long lastModifiedById, String updatedByUsername) { this.id = id; this.clientId = clientId; this.loanId = loanId; this.loanTransactionId = transactionId; - this.noteTypeId = noteTypeId; + this.noteType = noteType; this.note = note; this.createdOn = createdDate; this.createdById = createdById; @@ -131,11 +131,11 @@ public class NoteData { this.updatedOn = updatedOn; } - public Integer getNoteTypeId() { - return noteTypeId; + public EnumOptionData getNoteType() { + return noteType; } - public void setNoteTypeId(Integer noteTypeId) { - this.noteTypeId = noteTypeId; + public void setNoteType(EnumOptionData noteType) { + this.noteType = noteType; } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/client/domain/Note.java b/mifosng-provider/src/main/java/org/mifosng/platform/client/domain/Note.java index 72d692941..579b7f1f5 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/client/domain/Note.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/client/domain/Note.java @@ -44,18 +44,23 @@ public class Note extends AbstractAuditableCustom { private Integer noteTypeId; 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 for (NoteType item : NoteType.values()) { - if (item.getValue()==id) { + if (item.getValue().intValue() == id.intValue()) { right = item; break; } diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/client/domain/NoteEnumerations.java b/mifosng-provider/src/main/java/org/mifosng/platform/client/domain/NoteEnumerations.java new file mode 100644 index 000000000..dba8639a6 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosng/platform/client/domain/NoteEnumerations.java @@ -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; + } +} diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/client/service/ClientReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosng/platform/client/service/ClientReadPlatformServiceImpl.java index cb44a54ef..26d32c753 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/client/service/ClientReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/client/service/ClientReadPlatformServiceImpl.java @@ -15,9 +15,11 @@ import org.mifosng.platform.api.data.AppUserData; import org.mifosng.platform.api.data.ClientData; import org.mifosng.platform.api.data.ClientLoanAccountSummaryCollectionData; 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.OfficeData; 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.NoteNotFoundException; import org.mifosng.platform.infrastructure.JdbcSupport; @@ -306,6 +308,7 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService Long loanId = JdbcSupport.getLong(rs, "loanId"); Long transactionId = JdbcSupport.getLong(rs, "transactionId"); Integer noteTypeId = JdbcSupport.getInteger(rs, "noteTypeEnum"); + EnumOptionData noteType = NoteEnumerations.noteType(noteTypeId); String note = rs.getString("note"); DateTime createdDate = JdbcSupport.getDateTime(rs, "createdDate"); @@ -317,7 +320,7 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService String updatedByUsername = findUserById(createdById, allUsers); return new NoteData(id, clientId, loanId, transactionId, - noteTypeId, note, createdDate, createdById, + noteType, note, createdDate, createdById, createdByUsername, lastModifiedDate, lastModifiedById, updatedByUsername); } diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/loanschedule/domain/PeriodicInterestRateCalculator.java b/mifosng-provider/src/main/java/org/mifosng/platform/loanschedule/domain/PeriodicInterestRateCalculator.java index 9c2d781d0..8c8f9c827 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/loanschedule/domain/PeriodicInterestRateCalculator.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/loanschedule/domain/PeriodicInterestRateCalculator.java @@ -60,6 +60,8 @@ public class PeriodicInterestRateCalculator { case EQUAL_INSTALLMENTS: principalDue = totalDuePerInstallment.minus(interestForInstallment); break; + case INVALID: + break; } return principalDue;