From 5f74453606db080ae96fafbd58b0a5df96b5362c Mon Sep 17 00:00:00 2001 From: nazeer1100126 Date: Fri, 17 Mar 2017 17:49:05 +0530 Subject: [PATCH] FINERACT-321 - Manual Journal entries should not allowed to reverse after accounting closure is done for that branch --- ...lEntryWritePlatformServiceJpaRepositoryImpl.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/JournalEntryWritePlatformServiceJpaRepositoryImpl.java b/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/JournalEntryWritePlatformServiceJpaRepositoryImpl.java index 207cdc9c6..b55601463 100755 --- a/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/JournalEntryWritePlatformServiceJpaRepositoryImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/JournalEntryWritePlatformServiceJpaRepositoryImpl.java @@ -325,6 +325,19 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa final boolean useDefaultComment = StringUtils.isBlank(reversalComment); validateCommentForReversal(reversalComment); + + //Before reversal validate accounting closure is done for that branch or not. + final Date journalEntriesTransactionDate = journalEntries.get(0).getTransactionDate(); + final GLClosure latestGLClosureByBranch = this.glClosureRepository.getLatestGLClosureByBranch(officeId); + if (latestGLClosureByBranch != null) { + if (latestGLClosureByBranch.getClosingDate().after(journalEntriesTransactionDate) + || latestGLClosureByBranch.getClosingDate().equals(journalEntriesTransactionDate)) { + final String accountName = null; + final String accountGLCode = null; + throw new JournalEntryInvalidException(GL_JOURNAL_ENTRY_INVALID_REASON.ACCOUNTING_CLOSED, + latestGLClosureByBranch.getClosingDate(), accountName, accountGLCode); + } + } for (final JournalEntry journalEntry : journalEntries) { JournalEntry reversalJournalEntry;