diff --git a/api-docs/apiLive.htm b/api-docs/apiLive.htm index 263200c9d..8c30f6102 100644 --- a/api-docs/apiLive.htm +++ b/api-docs/apiLive.htm @@ -9697,14 +9697,15 @@ No Request Body: A unique Identifier for a set - of related Credit and Debit entries that make up a "balanced" jounral Entry. - For a manual entry, this feild is a unique string.
+ of related Credit and Debit entries that make up + a "balanced" jounral Entry. For a manual entry, + this feild is a unique string.
For a system generated entry, the combination of transactionId and entityId is unique - portfolioGenerated + manualEntry Flag determines if an entry is @@ -9721,7 +9722,8 @@ No Request Body: Flag determines if this manual journal entry has been reversed using the Reverse a Journal Entry API.
+ journalentries_reverse">Reverse a Journal Entry + API.
Note: A journal entry is reversed by logging debits for all credits that make up the Journal entry and vice-versa @@ -9745,15 +9747,16 @@ No Request Body:
Integer optional
-
portfolioGenerated
+
manualEntriesOnly
Boolean optional
-
Flag determines if portfolio generated Journal - Entries (posted automatically by the system - during lifecycle of loan or saving products) - shall also be returned
- Set to "True" by default if not passed in explicity +
Flag determines if only manually created journal entries + are to be returned( journal entries created by + the system during lifecycle of loan or saving + products etc shall be excluded) +
+ Set to "false" by default if not passed in explicity
fromDate
@@ -9778,7 +9781,7 @@ No Request Body:
journalentries?transactionId=PB37X8Y21EQUY4S


-
journalentries?officeId=1&glAccountId=17&portfolioGenerated=false&fromDate=2012-01-01&toDate=2013-01-01
+
journalentries?officeId=1&glAccountId=17&manualEntriesOnly=true&fromDate=2012-01-01&toDate=2013-01-01
@@ -9810,7 +9813,7 @@ GET https://DomainName/api/v1/journalentries?transactionId=PB37X8Y21EQUY4S }, "amount": 120, "transactionId": "PB37X8Y21EQUY4S", - "portfolioGenerated": false, + "manualEntry": true, "createdByUserId": 1, "createdDate": [ 2012, @@ -9844,7 +9847,7 @@ GET https://DomainName/api/v1/journalentries?transactionId=PB37X8Y21EQUY4S }, "amount": 120, "transactionId": "PB37X8Y21EQUY4S", - "portfolioGenerated": false, + "manualEntry": true, "createdByUserId": 1, "createdDate": [ 2012, @@ -9905,8 +9908,10 @@ GET https://DomainName/api/v1/journalentries?transactionId=PB37X8Y21EQUY4S Details of the debits contained - in the journal entry. Each debit entry contains the following items
- glAccountId: Identifier of the general ledger account against which the debit entry shall be + in the journal entry. Each debit entry contains the + following items
+ glAccountId: Identifier of the general ledger account + against which the debit entry shall be made
amount: Amount of money debited
@@ -9993,7 +9998,7 @@ GET https://DomainName/api/v1/journalentries/{entryId} }, "amount": 900, "transactionId": "13", - "portfolioGenerated": true, + "manualEntry": true, "createdByUserId": 1, "createdDate": [ 2012, diff --git a/mifosng-db/patches/12-journal-entry-updates.sql b/mifosng-db/patches/12-journal-entry-updates.sql new file mode 100755 index 000000000..f4500a62a --- /dev/null +++ b/mifosng-db/patches/12-journal-entry-updates.sql @@ -0,0 +1,11 @@ +ALTER TABLE `acc_gl_journal_entry` + CHANGE COLUMN `portfolio_generated` `manual_entry` TINYINT(1) NOT NULL DEFAULT '0' AFTER `reversed`; + +update acc_gl_journal_entry +set acc_gl_journal_entry.manual_entry=1 +where acc_gl_journal_entry.entity_type is null; + +update acc_gl_journal_entry +set acc_gl_journal_entry.manual_entry=0 +where acc_gl_journal_entry.entity_type is not null; + 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 a81272c5f..2921dab46 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,7 @@ 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", - "portfolioGenerated", "entityType", "entityId", "createdByUserId", "createdDate", "createdByUserName", "comments", "reversed")); + "manualEntry", "entityType", "entityId", "createdByUserId", "createdDate", "createdByUserName", "comments", "reversed")); private final String resourceNameForPermission = "JOURNALENTRY"; @@ -72,7 +72,7 @@ public class JournalEntriesApiResource { @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) public String retrieveAllJournalEntries(@Context final UriInfo uriInfo, @QueryParam("officeId") final Long officeId, - @QueryParam("glAccountId") final Long glAccountId, @QueryParam("portfolioGenerated") final Boolean portfolioGenerated, + @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) { @@ -90,7 +90,7 @@ public class JournalEntriesApiResource { } if (StringUtils.isBlank(transactionId)) { glJournalEntryDatas = this.journalEntryReadPlatformService.retrieveAllGLJournalEntries(officeId, glAccountId, - portfolioGenerated, fromDate, toDate); + onlyManualEntries, fromDate, toDate); } else { glJournalEntryDatas = this.journalEntryReadPlatformService.retrieveRelatedJournalEntries(transactionId); } 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 7d8987d08..479498d1c 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 @@ -41,7 +41,7 @@ public class JournalEntryData { @SuppressWarnings("unused") private final String transactionId; @SuppressWarnings("unused") - private final Boolean portfolioGenerated; + private final Boolean manualEntry; @SuppressWarnings("unused") private final String entityType; @SuppressWarnings("unused") @@ -60,7 +60,7 @@ public class JournalEntryData { 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 portfolioGenerated, final String entityType, final Long entityId, final Long createdByUserId, + final Boolean manualEntry, final String entityType, final Long entityId, final Long createdByUserId, final LocalDate createdDate, final String createdByUserName, final String comments, final Boolean reversed) { this.id = id; this.officeId = officeId; @@ -73,7 +73,7 @@ public class JournalEntryData { this.entryType = entryType; this.amount = amount; this.transactionId = transactionId; - this.portfolioGenerated = portfolioGenerated; + this.manualEntry = manualEntry; this.entityType = entityType; this.entityId = entityId; this.createdByUserId = createdByUserId; 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 abfb24dec..0ec0ba9ee 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 @@ -49,8 +49,8 @@ public class JournalEntry extends AbstractAuditableCustom { private boolean reversed = false; @SuppressWarnings("unused") - @Column(name = "portfolio_generated", nullable = false) - private boolean portfolioGenerated = false; + @Column(name = "manual_entry", nullable = false) + private boolean manualEntry = false; @Column(name = "entry_date") @Temporal(TemporalType.DATE) @@ -75,9 +75,9 @@ public class JournalEntry extends AbstractAuditableCustom { private Long entityId; public static JournalEntry createNew(final Office office, final GLAccount glAccount, final String transactionId, - final boolean portfolioGenerated, final Date transactionDate, final JournalEntryType journalEntryType, final BigDecimal amount, + final boolean manualEntry, final Date transactionDate, final JournalEntryType journalEntryType, final BigDecimal amount, final String description, final String entityType, final Long entityId) { - return new JournalEntry(office, glAccount, transactionId, portfolioGenerated, transactionDate, journalEntryType.getValue(), amount, + return new JournalEntry(office, glAccount, transactionId, manualEntry, transactionDate, journalEntryType.getValue(), amount, description, entityType, entityId); } @@ -85,7 +85,7 @@ public class JournalEntry extends AbstractAuditableCustom { // } - public JournalEntry(final Office office, final GLAccount glAccount, final String transactionId, final boolean portfolioGenerated, + 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 String entityType, final Long entityId) { this.office = office; @@ -93,7 +93,7 @@ public class JournalEntry extends AbstractAuditableCustom { this.reversalJournalEntry = null; this.transactionId = transactionId; this.reversed = false; - this.portfolioGenerated = portfolioGenerated; + this.manualEntry = manualEntry; this.transactionDate = transactionDate; this.type = type; this.amount = amount; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/domain/JournalEntryRepository.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/domain/JournalEntryRepository.java index 8f1b54211..1bfddc564 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/domain/JournalEntryRepository.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/domain/JournalEntryRepository.java @@ -15,6 +15,6 @@ import org.springframework.data.repository.query.Param; public interface JournalEntryRepository extends JpaRepository, JpaSpecificationExecutor, JournalEntryRepositoryCustom { - @Query("from JournalEntry journalEntry where journalEntry.transactionId= :transactionId and journalEntry.reversed is false and journalEntry.portfolioGenerated is false") + @Query("from JournalEntry journalEntry where journalEntry.transactionId= :transactionId and journalEntry.reversed is false and journalEntry.manualEntry is true") List findUnReversedManualJournalEntriesByTransactionId(@Param("transactionId") String transactionId); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/JournalEntryReadPlatformService.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/JournalEntryReadPlatformService.java index b6ab22353..df25841e5 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/JournalEntryReadPlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/JournalEntryReadPlatformService.java @@ -12,7 +12,7 @@ import org.mifosplatform.accounting.journalentry.data.JournalEntryData; public interface JournalEntryReadPlatformService { - List retrieveAllGLJournalEntries(Long officeId, Long glAccountId, Boolean portfolioGenerated, Date fromDate, + List retrieveAllGLJournalEntries(Long officeId, Long glAccountId, Boolean onlyManualEntries, Date fromDate, Date toDate); List retrieveRelatedJournalEntries(String transactionId); 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 c58429e04..6bb5ea510 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 @@ -43,7 +43,7 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat 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.portfolio_generated as portfolioGenerated,journalEntry.entry_date as transactionDate, " + + " 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 as entityType, journalEntry.entity_id as entityId, creatingUser.id as createdByUserId, " + " creatingUser.username as createdByUserName, journalEntry.description as comments, " @@ -65,7 +65,7 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat final int accountTypeId = JdbcSupport.getInteger(rs, "classification"); final EnumOptionData accountType = AccountingEnumerations.gLAccountType(accountTypeId); final LocalDate transactionDate = JdbcSupport.getLocalDate(rs, "transactionDate"); - final Boolean portfolioGenerated = rs.getBoolean("portfolioGenerated"); + final Boolean manualEntry = rs.getBoolean("manualEntry"); final BigDecimal amount = rs.getBigDecimal("amount"); final int entryTypeId = JdbcSupport.getInteger(rs, "entryType"); final EnumOptionData entryType = AccountingEnumerations.journalEntryType(entryTypeId); @@ -79,14 +79,14 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat final Boolean reversed = rs.getBoolean("reversed"); return new JournalEntryData(journalEntryId, officeId, officeName, glAccountName, glAccountId, glCode, accountType, - transactionDate, entryType, amount, transactionId, portfolioGenerated, entityType, entityId, createdByUserId, + transactionDate, entryType, amount, transactionId, manualEntry, entityType, entityId, createdByUserId, createdDate, createdByUserName, comments, reversed); } } @Override public List retrieveAllGLJournalEntries(final Long officeId, final Long glAccountId, - final Boolean portfolioGenerated, final Date fromDate, final Date toDate) { + final Boolean onlyManualEntries, final Date fromDate, final Date toDate) { final GLJournalEntryMapper rm = new GLJournalEntryMapper(); String sql = "select " + rm.schema(); @@ -130,15 +130,13 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat } } - if (portfolioGenerated != null) { - if (portfolioGenerated) { - sql += " and journalEntry.portfolio_generated = 1"; - } else { - sql += " and journalEntry.portfolio_generated = 0"; - } + if (onlyManualEntries != null) { + if (onlyManualEntries) { + sql += " and journalEntry.manual_entry = 1"; + } } - sql += " order by journalEntry.entry_date desc,journalEntry.transaction_id"; + sql += " order by journalEntry.entry_date desc,journalEntry.id desc"; final Object[] finalObjectArray = Arrays.copyOf(objectArray, arrayPos); return this.jdbcTemplate.query(sql, rm, finalObjectArray); 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 c4e1f67ac..92fd10edc 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 @@ -116,6 +116,7 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa if (journalEntries.size() <= 1) { throw new JournalEntriesNotFoundException(command.getTransactionId()); } final String reversalTransactionId = generateTransactionId(); + final boolean manualEntry = true; for (final JournalEntry journalEntry : journalEntries) { JournalEntry reversalJournalEntry; @@ -123,12 +124,12 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa + " and transaction Id " + command.getTransactionId(); if (journalEntry.isDebitEntry()) { reversalJournalEntry = JournalEntry.createNew(journalEntry.getOffice(), journalEntry.getGlAccount(), reversalTransactionId, - false, journalEntry.getTransactionDate(), JournalEntryType.CREDIT, journalEntry.getAmount(), reversalComment, null, - null); + manualEntry, journalEntry.getTransactionDate(), JournalEntryType.CREDIT, journalEntry.getAmount(), reversalComment, + null, null); } else { reversalJournalEntry = JournalEntry.createNew(journalEntry.getOffice(), journalEntry.getGlAccount(), reversalTransactionId, - false, journalEntry.getTransactionDate(), JournalEntryType.DEBIT, journalEntry.getAmount(), reversalComment, null, - null); + manualEntry, journalEntry.getTransactionDate(), JournalEntryType.DEBIT, journalEntry.getAmount(), reversalComment, + null, null); } // save the reversal entry this.glJournalEntryRepository.saveAndFlush(reversalJournalEntry); @@ -381,6 +382,7 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa private void saveAllDebitOrCreditEntries(final JournalEntryCommand command, final Office office, final Date transactionDate, final SingleDebitOrCreditEntryCommand[] singleDebitOrCreditEntryCommands, final String transactionId, final JournalEntryType type) { + final boolean manualEntry = true; for (final SingleDebitOrCreditEntryCommand singleDebitOrCreditEntryCommand : singleDebitOrCreditEntryCommands) { final GLAccount glAccount = this.glAccountRepository.findOne(singleDebitOrCreditEntryCommand.getGlAccountId()); if (glAccount == null) { throw new GLAccountNotFoundException(singleDebitOrCreditEntryCommand.getGlAccountId()); } @@ -400,8 +402,8 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa if (!StringUtils.isBlank(singleDebitOrCreditEntryCommand.getComments())) { comments = singleDebitOrCreditEntryCommand.getComments(); } - final JournalEntry glJournalEntry = JournalEntry.createNew(office, glAccount, transactionId, false, transactionDate, type, - singleDebitOrCreditEntryCommand.getAmount(), comments, null, null); + final JournalEntry glJournalEntry = JournalEntry.createNew(office, glAccount, transactionId, manualEntry, transactionDate, + type, singleDebitOrCreditEntryCommand.getAmount(), comments, null, null); this.glJournalEntryRepository.saveAndFlush(glJournalEntry); } }