From 834ee8f76e47d599ae86846ae4cfdeafb728fca1 Mon Sep 17 00:00:00 2001 From: goutham-M Date: Thu, 2 May 2013 15:52:47 +0530 Subject: [PATCH] refrenceNumber added to journal entry add referenceNumber field to acc_gl_journal_entry sql script --- ...dd-referenceNumber-to-acc_gl_journal_entry.sql | 2 ++ .../closure/api/GLClosuresApiResource.java | 2 +- .../api/JournalEntriesApiResource.java | 5 +++-- .../api/JournalEntryJsonInputParams.java | 2 +- .../journalentry/command/JournalEntryCommand.java | 11 ++++++++++- .../journalentry/data/JournalEntryData.java | 5 ++++- .../journalentry/domain/JournalEntry.java | 15 ++++++++++++--- ...ournalEntryCommandFromApiJsonDeserializer.java | 4 +++- .../service/AccountingProcessorHelper.java | 4 ++-- .../JournalEntryReadPlatformServiceImpl.java | 5 +++-- ...ntryWritePlatformServiceJpaRepositoryImpl.java | 8 +++++--- .../commands/domain/CommandWrapper.java | 9 ++++++--- .../commands/service/CommandWrapperBuilder.java | 2 +- .../infrastructure/core/api/JsonCommand.java | 1 - 14 files changed, 53 insertions(+), 22 deletions(-) create mode 100644 mifosng-db/migrations/core_db/V30_add-referenceNumber-to-acc_gl_journal_entry.sql diff --git a/mifosng-db/migrations/core_db/V30_add-referenceNumber-to-acc_gl_journal_entry.sql b/mifosng-db/migrations/core_db/V30_add-referenceNumber-to-acc_gl_journal_entry.sql new file mode 100644 index 000000000..c37eedf76 --- /dev/null +++ b/mifosng-db/migrations/core_db/V30_add-referenceNumber-to-acc_gl_journal_entry.sql @@ -0,0 +1,2 @@ +alter table `acc_gl_journal_entry` +add column `ref_num` varchar(100) default NULL AFTER `reversed`; \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/closure/api/GLClosuresApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/closure/api/GLClosuresApiResource.java index 68d8b7d48..03eca1cd1 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/closure/api/GLClosuresApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/closure/api/GLClosuresApiResource.java @@ -76,7 +76,7 @@ public class GLClosuresApiResource { this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermission); final List glClosureDatas = this.glClosureReadPlatformService.retrieveAllGLClosures(officeId); - + final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); return this.apiJsonSerializerService.serialize(settings, glClosureDatas, RESPONSE_DATA_PARAMETERS); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/api/JournalEntriesApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/api/JournalEntriesApiResource.java index 2921dab46..5ecb419ec 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/api/JournalEntriesApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/api/JournalEntriesApiResource.java @@ -45,7 +45,8 @@ public class JournalEntriesApiResource { private static final Set RESPONSE_DATA_PARAMETERS = new HashSet(Arrays.asList("id", "officeId", "officeName", "glAccountName", "glAccountId", "glAccountCode", "glAccountType", "transactionDate", "entryType", "amount", "transactionId", - "manualEntry", "entityType", "entityId", "createdByUserId", "createdDate", "createdByUserName", "comments", "reversed")); + "manualEntry", "entityType", "entityId", "createdByUserId", "createdDate", "createdByUserName", "comments", "reversed", + "referenceNumber")); private final String resourceNameForPermission = "JOURNALENTRY"; @@ -74,7 +75,7 @@ public class JournalEntriesApiResource { public String retrieveAllJournalEntries(@Context final UriInfo uriInfo, @QueryParam("officeId") final Long officeId, @QueryParam("glAccountId") final Long glAccountId, @QueryParam("manualEntriesOnly") final Boolean onlyManualEntries, @QueryParam("fromDate") final DateParam fromDateParam, @QueryParam("toDate") final DateParam toDateParam, - @QueryParam("transactionId") final String transactionId) { + @QueryParam("transactionId") final String transactionId ) { this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermission); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/api/JournalEntryJsonInputParams.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/api/JournalEntryJsonInputParams.java index 974bc16e6..db398bdc0 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/api/JournalEntryJsonInputParams.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/api/JournalEntryJsonInputParams.java @@ -8,7 +8,7 @@ import java.util.Set; ***/ public enum JournalEntryJsonInputParams { OFFICE_ID("officeId"), TRANSACTION_DATE("transactionDate"), COMMENTS("comments"), CREDITS("credits"), DEBITS("debits"), LOCALE("locale"), DATE_FORMAT( - "dateFormat"); + "dateFormat"), REFERENCE_NUMBER("referenceNumber") ; private final String value; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/command/JournalEntryCommand.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/command/JournalEntryCommand.java index 538e45a0e..3aa4d3bd9 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/command/JournalEntryCommand.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/command/JournalEntryCommand.java @@ -21,17 +21,20 @@ public class JournalEntryCommand { private final Long officeId; private final LocalDate transactionDate; private final String comments; + private final String referenceNumber; private final SingleDebitOrCreditEntryCommand[] credits; private final SingleDebitOrCreditEntryCommand[] debits; public JournalEntryCommand(final Long officeId, final LocalDate transactionDate, final String comments, - final SingleDebitOrCreditEntryCommand[] credits, final SingleDebitOrCreditEntryCommand[] debits) { + final SingleDebitOrCreditEntryCommand[] credits, final SingleDebitOrCreditEntryCommand[] debits, + final String referenceNumber) { this.officeId = officeId; this.transactionDate = transactionDate; this.comments = comments; this.credits = credits; this.debits = debits; + this.referenceNumber = referenceNumber; } public void validateForCreate() { @@ -49,6 +52,8 @@ public class JournalEntryCommand { baseDataValidator.reset().parameter("credits").value(this.credits).notNull(); baseDataValidator.reset().parameter("debits").value(this.debits).notNull(); + + baseDataValidator.reset().parameter("referenceNumber").value(this.referenceNumber).ignoreIfNull().notExceedingLengthOf(100); // validation for credit array elements if (this.credits != null) { @@ -113,4 +118,8 @@ public class JournalEntryCommand { return this.debits; } + public String getReferenceNumber() { + return this.referenceNumber; + } + } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/data/JournalEntryData.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/data/JournalEntryData.java index 6a7792e6c..afaf36d95 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/data/JournalEntryData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/data/JournalEntryData.java @@ -56,12 +56,14 @@ public class JournalEntryData { private final String comments; @SuppressWarnings("unused") private final Boolean reversed; + @SuppressWarnings("unused") + private final String referenceNumber; public JournalEntryData(final Long id, final Long officeId, final String officeName, final String glAccountName, final Long glAccountId, final String glAccountCode, final EnumOptionData glAccountClassification, final LocalDate transactionDate, final EnumOptionData entryType, final BigDecimal amount, final String transactionId, final Boolean manualEntry, final EnumOptionData entityType, final Long entityId, final Long createdByUserId, - final LocalDate createdDate, final String createdByUserName, final String comments, final Boolean reversed) { + final LocalDate createdDate, final String createdByUserName, final String comments, final Boolean reversed, final String referenceNumber) { this.id = id; this.officeId = officeId; this.officeName = officeName; @@ -81,6 +83,7 @@ public class JournalEntryData { this.createdByUserName = createdByUserName; this.comments = comments; this.reversed = reversed; + this.referenceNumber = referenceNumber; } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/domain/JournalEntry.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/domain/JournalEntry.java index df907d492..32e462a78 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/domain/JournalEntry.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/domain/JournalEntry.java @@ -73,12 +73,15 @@ public class JournalEntry extends AbstractAuditableCustom { @SuppressWarnings("unused") @Column(name = "entity_id") private Long entityId; + + @Column(name = "ref_num") + private String referenceNumber; public static JournalEntry createNew(final Office office, final GLAccount glAccount, final String transactionId, final boolean manualEntry, final Date transactionDate, final JournalEntryType journalEntryType, final BigDecimal amount, - final String description, final Integer entityType, final Long entityId) { + final String description, final Integer entityType, final Long entityId, final String referenceNumber) { return new JournalEntry(office, glAccount, transactionId, manualEntry, transactionDate, journalEntryType.getValue(), amount, - description, entityType, entityId); + description, entityType, entityId, referenceNumber); } protected JournalEntry() { @@ -87,7 +90,7 @@ public class JournalEntry extends AbstractAuditableCustom { public JournalEntry(final Office office, final GLAccount glAccount, final String transactionId, final boolean manualEntry, final Date transactionDate, final Integer type, final BigDecimal amount, final String description, final Integer entityType, - final Long entityId) { + final Long entityId, final String referenceNumber) { this.office = office; this.glAccount = glAccount; this.reversalJournalEntry = null; @@ -100,6 +103,8 @@ public class JournalEntry extends AbstractAuditableCustom { this.description = StringUtils.defaultIfEmpty(description, null); this.entityType = entityType; this.entityId = entityId; + this.referenceNumber = referenceNumber; + } public boolean isDebitEntry() { @@ -134,4 +139,8 @@ public class JournalEntry extends AbstractAuditableCustom { this.reversed = reversed; } + public String getReferenceNumber() { + return this.referenceNumber; + } + } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/serialization/JournalEntryCommandFromApiJsonDeserializer.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/serialization/JournalEntryCommandFromApiJsonDeserializer.java index 83f6b915c..105d70523 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/serialization/JournalEntryCommandFromApiJsonDeserializer.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/serialization/JournalEntryCommandFromApiJsonDeserializer.java @@ -57,6 +57,8 @@ public final class JournalEntryCommandFromApiJsonDeserializer extends AbstractFr final String comments = this.fromApiJsonHelper.extractStringNamed(JournalEntryJsonInputParams.COMMENTS.getValue(), element); final LocalDate transactionDate = this.fromApiJsonHelper.extractLocalDateNamed( JournalEntryJsonInputParams.TRANSACTION_DATE.getValue(), element); + final String referenceNumber = this.fromApiJsonHelper.extractStringNamed( + JournalEntryJsonInputParams.REFERENCE_NUMBER.getValue(), element); final JsonObject topLevelJsonElement = element.getAsJsonObject(); final Locale locale = this.fromApiJsonHelper.extractLocaleParameter(topLevelJsonElement); @@ -73,7 +75,7 @@ public final class JournalEntryCommandFromApiJsonDeserializer extends AbstractFr debits = populateCreditsOrDebitsArray(topLevelJsonElement, locale, debits, JournalEntryJsonInputParams.DEBITS.getValue()); } } - return new JournalEntryCommand(officeId, transactionDate, comments, credits, debits); + return new JournalEntryCommand(officeId, transactionDate, comments, credits, debits,referenceNumber); } /** diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/AccountingProcessorHelper.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/AccountingProcessorHelper.java index 92aeb228b..b5443ffe7 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/AccountingProcessorHelper.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/AccountingProcessorHelper.java @@ -236,7 +236,7 @@ public class AccountingProcessorHelper { final String transactionId, final Date transactionDate, final BigDecimal amount) { final boolean manualEntry = false; final JournalEntry journalEntry = JournalEntry.createNew(office, account, transactionId, manualEntry, transactionDate, - JournalEntryType.CREDIT, amount, null, PortfolioProductType.LOAN.getValue(), loanId); + JournalEntryType.CREDIT, amount, null, PortfolioProductType.LOAN.getValue(), loanId, null); this.glJournalEntryRepository.saveAndFlush(journalEntry); } @@ -244,7 +244,7 @@ public class AccountingProcessorHelper { final String transactionId, final Date transactionDate, final BigDecimal amount) { final boolean manualEntry = false; final JournalEntry journalEntry = JournalEntry.createNew(office, account, transactionId, manualEntry, transactionDate, - JournalEntryType.DEBIT, amount, null, PortfolioProductType.LOAN.getValue(), loanId); + JournalEntryType.DEBIT, amount, null, PortfolioProductType.LOAN.getValue(), loanId, null); this.glJournalEntryRepository.saveAndFlush(journalEntry); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/JournalEntryReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/JournalEntryReadPlatformServiceImpl.java index 271a5f810..632e9d433 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/JournalEntryReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/JournalEntryReadPlatformServiceImpl.java @@ -42,7 +42,7 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat public String schema() { return " journalEntry.id as journalEntryId, glAccount.classification_enum as classification ," + " glAccount.name as glAccountName, glAccount.gl_code as glCode, journalEntry.account_id as glAccountId," - + " journalEntry.office_id as officeId, office.name as officeName, " + + " journalEntry.office_id as officeId, office.name as officeName, journalEntry.ref_num as referenceNumber, " + " journalEntry.manual_entry as manualEntry,journalEntry.entry_date as transactionDate, " + " journalEntry.type_enum as entryType,journalEntry.amount as amount, journalEntry.transaction_id as transactionId," + " journalEntry.entity_type_enum as entityType, journalEntry.entity_id as entityId, creatingUser.id as createdByUserId, " @@ -82,10 +82,11 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat final String createdByUserName = rs.getString("createdByUserName"); final String comments = rs.getString("comments"); final Boolean reversed = rs.getBoolean("reversed"); + final String referenceNumber = rs.getString("referenceNumber"); return new JournalEntryData(journalEntryId, officeId, officeName, glAccountName, glAccountId, glCode, accountType, transactionDate, entryType, amount, transactionId, manualEntry, entityType, entityId, createdByUserId, createdDate, - createdByUserName, comments, reversed); + createdByUserName, comments, reversed, referenceNumber); } } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/JournalEntryWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/JournalEntryWritePlatformServiceJpaRepositoryImpl.java index 5c45dd29f..b2f9170ba 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/JournalEntryWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/JournalEntryWritePlatformServiceJpaRepositoryImpl.java @@ -122,11 +122,11 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa if (journalEntry.isDebitEntry()) { reversalJournalEntry = JournalEntry.createNew(journalEntry.getOffice(), journalEntry.getGlAccount(), reversalTransactionId, manualEntry, journalEntry.getTransactionDate(), JournalEntryType.CREDIT, journalEntry.getAmount(), reversalComment, - null, null); + null, null, journalEntry.getReferenceNumber()); } else { reversalJournalEntry = JournalEntry.createNew(journalEntry.getOffice(), journalEntry.getGlAccount(), reversalTransactionId, manualEntry, journalEntry.getTransactionDate(), JournalEntryType.DEBIT, journalEntry.getAmount(), reversalComment, - null, null); + null, null, journalEntry.getReferenceNumber()); } // save the reversal entry this.glJournalEntryRepository.saveAndFlush(reversalJournalEntry); @@ -216,8 +216,10 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa if (!StringUtils.isBlank(singleDebitOrCreditEntryCommand.getComments())) { comments = singleDebitOrCreditEntryCommand.getComments(); } + + String referenceNumber = command.getReferenceNumber(); final JournalEntry glJournalEntry = JournalEntry.createNew(office, glAccount, transactionId, manualEntry, transactionDate, - type, singleDebitOrCreditEntryCommand.getAmount(), comments, null, null); + type, singleDebitOrCreditEntryCommand.getAmount(), comments, null, null, referenceNumber); this.glJournalEntryRepository.saveAndFlush(glJournalEntry); } } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/domain/CommandWrapper.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/domain/CommandWrapper.java index 435ffe5a3..914ff937e 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/domain/CommandWrapper.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/domain/CommandWrapper.java @@ -54,12 +54,13 @@ public class CommandWrapper { this.href = resourceGetUrl; this.json = null; this.transactionId = null; - + } public CommandWrapper(final Long officeId, final Long groupId, final Long clientId, final Long loanId, final Long savingsId, final String actionName, final String entityName, final Long entityId, final Long subentityId, final Long codeId, - final String supportedEntityType, final Long supportedEntityId, final String href, final String json, final String transactionId) { + final String supportedEntityType, final Long supportedEntityId, final String href, final String json, final String transactionId + ) { this.commandId = null; this.officeId = officeId; this.groupId = groupId; @@ -77,6 +78,7 @@ public class CommandWrapper { this.href = href; this.json = json; this.transactionId = transactionId; + } public Long commandId() { @@ -126,7 +128,8 @@ public class CommandWrapper { public String getTransactionId() { return this.transactionId; } - + + public String getEntityName() { return this.entityName; } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/CommandWrapperBuilder.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/CommandWrapperBuilder.java index b1abe2ab4..0df1e2f7b 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/CommandWrapperBuilder.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/CommandWrapperBuilder.java @@ -28,7 +28,7 @@ public class CommandWrapperBuilder { public CommandWrapper build() { return new CommandWrapper(this.officeId, this.groupId, this.clientId, this.loanId, this.savingsId, this.actionName, this.entityName, this.entityId, this.subentityId, this.codeId, this.supportedEntityType, this.supportedEntityId, this.href, - this.json, this.transactionId); + this.json, this.transactionId ); } public CommandWrapperBuilder withLoanId(final Long withLoanId) { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/JsonCommand.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/JsonCommand.java index aaa423eac..b174ced3e 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/JsonCommand.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/JsonCommand.java @@ -45,7 +45,6 @@ public final class JsonCommand { private final String supportedEntityType; private final Long supportedEntityId; private final String transactionId; - public static JsonCommand from(final String jsonCommand, final JsonElement parsedCommand, final FromJsonHelper fromApiJsonHelper, final String entityName, final Long resourceId, final Long subresourceId, final Long groupId, final Long clientId, final Long loanId, final Long savingsId, final Long codeId, final String supportedEntityType, final Long supportedEntityId,