minor update to journal entries
This commit is contained in:
+21
-16
@@ -9697,14 +9697,15 @@ No Request Body:
|
||||
</tr>
|
||||
<tr>
|
||||
<td class=fielddesc>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.<br/>
|
||||
of related Credit and Debit entries that make up
|
||||
a "balanced" jounral Entry. For a manual entry,
|
||||
this feild is a unique string.<br/>
|
||||
For a system generated entry, the combination
|
||||
of transactionId and entityId is unique
|
||||
</td>
|
||||
</tr>
|
||||
<tr class=alt>
|
||||
<td>portfolioGenerated</td>
|
||||
<td>manualEntry</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class=fielddesc>Flag determines if an entry is
|
||||
@@ -9721,7 +9722,8 @@ No Request Body:
|
||||
<tr>
|
||||
<td class=fielddesc>Flag determines if this manual
|
||||
journal entry has been reversed using the <a href="
|
||||
journalentries_reverse">Reverse a Journal Entry</a> API. <br/>
|
||||
journalentries_reverse">Reverse a Journal Entry</a>
|
||||
API. <br/>
|
||||
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:
|
||||
<dd>
|
||||
Integer <span>optional</span>
|
||||
</dd>
|
||||
<dt>portfolioGenerated</dt>
|
||||
<dt>manualEntriesOnly</dt>
|
||||
<dd>
|
||||
Boolean <span>optional</span>
|
||||
</dd>
|
||||
<dd>Flag determines if portfolio generated Journal
|
||||
Entries (posted automatically by the system
|
||||
during lifecycle of loan or saving products)
|
||||
shall also be returned <br/>
|
||||
Set to "True" by default if not passed in explicity
|
||||
<dd>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)
|
||||
<br/>
|
||||
Set to "false" by default if not passed in explicity
|
||||
</dd>
|
||||
<dt>fromDate</dt>
|
||||
<dd>
|
||||
@@ -9778,7 +9781,7 @@ No Request Body:
|
||||
<div class=apiClick>journalentries?transactionId=PB37X8Y21EQUY4S</div>
|
||||
<br>
|
||||
<br>
|
||||
<div class=apiClick>journalentries?officeId=1&glAccountId=17&portfolioGenerated=false&fromDate=2012-01-01&toDate=2013-01-01</div>
|
||||
<div class=apiClick>journalentries?officeId=1&glAccountId=17&manualEntriesOnly=true&fromDate=2012-01-01&toDate=2013-01-01</div>
|
||||
</div>
|
||||
<div class="method-example">
|
||||
<code class="method-declaration">
|
||||
@@ -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
|
||||
</tr>
|
||||
<tr>
|
||||
<td class=fielddesc>Details of the debits contained
|
||||
in the journal entry. Each debit entry contains the following items <br/>
|
||||
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 <br/>
|
||||
glAccountId: Identifier of the general ledger account
|
||||
against which the debit entry shall be
|
||||
made <br/>
|
||||
amount: Amount of money debited
|
||||
<br/>
|
||||
@@ -9993,7 +9998,7 @@ GET https://DomainName/api/v1/journalentries/{entryId}
|
||||
},
|
||||
"amount": 900,
|
||||
"transactionId": "13",
|
||||
"portfolioGenerated": true,
|
||||
"manualEntry": true,
|
||||
"createdByUserId": 1,
|
||||
"createdDate": [
|
||||
2012,
|
||||
|
||||
+11
@@ -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;
|
||||
|
||||
+3
-3
@@ -45,7 +45,7 @@ public class JournalEntriesApiResource {
|
||||
|
||||
private static final Set<String> RESPONSE_DATA_PARAMETERS = new HashSet<String>(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);
|
||||
}
|
||||
|
||||
+3
-3
@@ -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;
|
||||
|
||||
+6
-6
@@ -49,8 +49,8 @@ public class JournalEntry extends AbstractAuditableCustom<AppUser, Long> {
|
||||
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<AppUser, Long> {
|
||||
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<AppUser, Long> {
|
||||
//
|
||||
}
|
||||
|
||||
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<AppUser, Long> {
|
||||
this.reversalJournalEntry = null;
|
||||
this.transactionId = transactionId;
|
||||
this.reversed = false;
|
||||
this.portfolioGenerated = portfolioGenerated;
|
||||
this.manualEntry = manualEntry;
|
||||
this.transactionDate = transactionDate;
|
||||
this.type = type;
|
||||
this.amount = amount;
|
||||
|
||||
+1
-1
@@ -15,6 +15,6 @@ import org.springframework.data.repository.query.Param;
|
||||
public interface JournalEntryRepository extends JpaRepository<JournalEntry, Long>, JpaSpecificationExecutor<JournalEntry>,
|
||||
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<JournalEntry> findUnReversedManualJournalEntriesByTransactionId(@Param("transactionId") String transactionId);
|
||||
}
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ import org.mifosplatform.accounting.journalentry.data.JournalEntryData;
|
||||
|
||||
public interface JournalEntryReadPlatformService {
|
||||
|
||||
List<JournalEntryData> retrieveAllGLJournalEntries(Long officeId, Long glAccountId, Boolean portfolioGenerated, Date fromDate,
|
||||
List<JournalEntryData> retrieveAllGLJournalEntries(Long officeId, Long glAccountId, Boolean onlyManualEntries, Date fromDate,
|
||||
Date toDate);
|
||||
|
||||
List<JournalEntryData> retrieveRelatedJournalEntries(String transactionId);
|
||||
|
||||
+9
-11
@@ -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<JournalEntryData> 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);
|
||||
|
||||
+8
-6
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user