update documentation for Accounting changes

This commit is contained in:
goutham-M
2013-05-23 15:53:10 +05:30
parent 683ba2ad76
commit 9cff637e16
5 changed files with 408 additions and 22 deletions
+387 -2
View File
@@ -751,6 +751,22 @@
<td><a href="#charges_update">Update a Charge</a></td>
<td><a href="#charges_delete">Delete a Charge</a></td>
</tr>
<tr>
<td><a href="#accountingrules">Accounting Rules</a></td>
<td>accountingrules</td>
<td><a href="#accountingrules_create">Create a Accounting Rule</a></td>
<td><a href="#accountingrules_list">List Accounting Rules</a></td>
<td></td>
<td></td>
</tr>
<tr class="alt">
<td></td>
<td>accountingrules/{accountingrulesId}</td>
<td></td>
<td><a href="#accountingrules_retrieve">Retrieve a Accounting Rule</a></td>
<td><a href="#accountingrules_update">Update a Accounting Rule</a></td>
<td><a href="#accountingrules_delete">Delete a Accounting Rule</a></td>
</tr>
</table>
</div>
</div>
@@ -1279,6 +1295,10 @@
<tr>
<td>reports/template</td>
<td><a href="#reports_template">Retrieve Report Template</a></td>
</tr>
<tr>
<td>accountingrules/template</td>
<td><a href="#accountingrules_template">Retrieve Accounting Rule Template</a></td>
</tr>
</table>
</div>
@@ -9360,6 +9380,315 @@ Content-Type: application/json
</div>
</div>
<!--Accounting Rules section starts here-->
<a id="accountingrules" name="accountingrules" class="old-syle-anchor">&nbsp;</a>
<div class="method-section">
<div class="method-description">
<h3>Accounting Rules</h3>
<p>
Its additional option for MFIs to define their own accounting rules.
Its typically used to perform daily accounting postings of journal entries.
</p>
<p>For an accounting rule debit account and credit account is fixed, so that we can avoid
the selection of credit and debit accounts every time for default journal entries</p>
<table class=matrixHeading>
<tr class="matrixHeadingBG">
<td><div class="mifosXHeading2">Field Descriptions</div></td>
</tr>
<tr class=alt>
<td>name</td>
</tr>
<tr>
<td class=fielddesc>Name of the accounting rule</td>
</tr>
<tr class=alt>
<td>description</td>
</tr>
<tr>
<td class=fielddesc>The description about the accounting rule.</td>
</tr>
<tr class=alt>
<td>officeId</td>
</tr>
<tr>
<td class=fielddesc>The officeId of the office/branch for this accounting rule is applicable.</td>
</tr>
<tr class=alt>
<td>debitAccountHead</td>
</tr>
<tr>
<td class=fielddesc>Debit account for creating accounting rule</td>
</tr>
<tr class=alt>
<td>creditAccountHead</td>
</tr>
<tr>
<td class=fielddesc>Credit account for creating accounting rule</td>
</tr>
</table>
</div>
</div>
<a id="accountingrules_template" name="accountingrules_template"
class="old-syle-anchor">&nbsp;</a>
<div class="method-section">
<div class="method-description">
<h4>Retrieve Accounting Rule Details Template</h4>
<p>This is a convenience resource. It can be useful when
building maintenance user interface screens for client
applications. The template data returned consists of any or all
of:
<ul>
<li class=normalli>Field Defaults</li>
<li class=normalli>Allowed Value Lists</li>
</ul>
</p>
<p>Example Request:</p>
<div class=apiClick>accountingrules/template</div>
</div>
<div class="method-example">
<code class="method-declaration">
GET https://DomainName/api/v1/accountingrules/template
</code>
<code class="method-response">
{
"systemDefined": false,
"allowedOffices": [{
"id": 1,
"name": "Head Office",
"nameDecorated": "Head Office"
}],
"allowedAccounts": [{
"id": 21,
"name": "Cash 2",
"parentId": 18,
"glCode": "20011",
"disabled": false,
"manualEntriesAllowed": true,
"type": {
"id": 1,
"code": "accountType.asset",
"value": "ASSET"
},
"usage": {
"id": 1,
"code": "accountUsage.detail",
"value": "DETAIL"
},
"description": "Cash",
"nameDecorated": "............Cash 2",
"tagId": {
"id": 10,
"name": "asset tag"
}
},
{
"id": 9,
"name": "Employee Salary",
"parentId": 8,
"glCode": "456674",
"disabled": false,
"manualEntriesAllowed": true,
"type": {
"id": 5,
"code": "accountType.expense",
"value": "EXPENSE"
},
"usage": {
"id": 1,
"code": "accountUsage.detail",
"value": "DETAIL"
},
"nameDecorated": "Employee Salary",
"tagId": {
"id": 14,
"name": "Expenses Tag"
}
}]
}
</code>
</div>
</div>
<a id="accountingrules_create" name="accountingrules_create" class="old-syle-anchor">&nbsp;</a>
<div class="method-section">
<div class="method-description">
<h4>Create/Define a Accounting rule</h4>
<p>Define a new Accounting rule.</p>
</div>
<div class="method-example">
<code class="method-declaration">
POST https://DomainName/api/v1/accountingrules
</code>
<code class="method-request">
POST accountingrules
Content-Type: application/json
Request Body:
{
"name": "test",
"officeId": "1",
"debitAccountHead": "21",
"creditAccountHead": "9",
"description": "Employee salary"
}
</code>
<code class="method-response">
{
"officeId":1,
"resourceId":1
}
</code>
</div>
</div>
<a id="accountingrules_list" name="accountingrules_list" class="old-syle-anchor">&nbsp;</a>
<div class="method-section">
<div class="method-description">
<h4>Retrieve Accounting Rules</h4>
<p>Returns the list of defined accounting rules.</p>
<p>Example Requests:</p>
<div class=apiClick>accountingrules</div>
</div>
<div class="method-example">
<code class="method-declaration">
GET https://DomainName/api/v1/accountingrules
</code>
<code class="method-response">
[{
"id": 1,
"officeId": 1,
"officeName": "Head Office",
"name": "test",
"description": "Employee salary",
"systemDefined": false,
"debitAccountHead": {
"id": 21,
"name": "Cash 2",
"glCode": "20011",
"disabled": false,
"manualEntriesAllowed": false
},
"creditAccountHead": {
"id": 9,
"name": "Employee Salary",
"glCode": "456674",
"disabled": false,
"manualEntriesAllowed": false
}
},
{
"id": 2,
"officeId": 1,
"officeName": "Head Office",
"name": "A L1",
"description": "aafff",
"systemDefined": false,
"debitAccountHead": {
"id": 3,
"name": "A L",
"glCode": "10003",
"disabled": false,
"manualEntriesAllowed": false
},
"creditAccountHead": {
"id": 4,
"name": "car loan",
"glCode": "10004",
"disabled": false,
"manualEntriesAllowed": false
}
}]
</code>
</div>
</div>
<a id="accountingrules_retrieve" name="accountingrules_retrieve"
class="old-syle-anchor">&nbsp;</a>
<div class="method-section">
<div class="method-description">
<h4>Retrieve a Accounting rule</h4>
<p>Returns the details of a defined Accounting rule.</p>
<p>Example Requests:</p>
<div class=apiClick>accountingrules/1</div>
</div>
<div class="method-example">
<code class="method-declaration">
GET https://DomainName/api/v1/accountingrules/{accountingruleId}
</code>
<code class="method-response">
{
"id": 1,
"officeId": 1,
"officeName": "Head Office",
"name": "test",
"description": "Employee salary",
"systemDefined": false,
"debitAccountHead": {
"id": 21,
"name": "Cash 2",
"glCode": "20011",
"disabled": false,
"manualEntriesAllowed": false
},
"creditAccountHead": {
"id": 9,
"name": "Employee Salary",
"glCode": "456674",
"disabled": false,
"manualEntriesAllowed": false
}
}
</code>
</div>
</div>
<a id="accountingrules_update" name="accountingrules_update" class="old-syle-anchor">&nbsp;</a>
<div class="method-section">
<div class="method-description">
<h4>Update a Accounting Rule</h4>
<p>Updates the details of a Accounting rule.</p>
</div>
<div class="method-example">
<code class="method-declaration">
PUT https://DomainName/api/v1/accountingrules/{accountingruleId}
</code>
<code class="method-request">
PUT accountingrules/1
Content-Type: application/json
Request Body:
{
"name": "Employee Salary posting rule"
}
</code>
<code class="method-response">
{
"resourceId": 1,
"changes": {
"name": "Employee Salary posting rule"
}
}
</code>
</div>
</div>
<a id="accountingrules_delete" name="accountingrules_delete" class="old-syle-anchor">&nbsp;</a>
<div class="method-section">
<div class="method-description">
<h4>Delete a Accounting Rule</h4>
<p>Deletes a Accounting rule.</p>
</div>
<div class="method-example">
<code class="method-declaration">
DELETE https://DomainName/api/v1/accountingrules/{accountingruleId}
</code>
<code class="method-request">
DELETE accountingrules/1
Content-Type: application/json
</code>
<code class="method-response">{ "resourceId": 1 } </code>
</div>
</div>
<!-- start of saving products api docs -->
<a id="savingsproducts" name="savingsproducts" class="old-syle-anchor">&nbsp;</a>
<div class="method-section">
@@ -13423,6 +13752,20 @@ No Request Body:
<td class=fielddesc>An additional field that is used to store additional information about the entry (Ex: chequeNo)
</td>
</tr>
<tr class=alt>
<td>useAccountingRule</td>
</tr>
<tr>
<td class=fielddesc>This flag denotes the journal entry should post on basis of Predefined accounting rule or general Journal Entry procudure. <br>If the flag is true the journal entry is posted on basis of predefined accounting rule.
</td>
</tr>
<tr class=alt>
<td>accountingRule</td>
</tr>
<tr>
<td class=fielddesc>Denotes the accounting rule id for posting journal entries, this parameter should pass in request body when <b>useAccountingRule</b> is true.
</td>
</tr>
</table>
</div>
</div>
@@ -13623,7 +13966,7 @@ GET https://DomainName/api/v1/journalentries?transactionId=PB37X8Y21EQUY4S
<td><div class="mifosXHeading2">Mandatory Fields</div></td>
</tr>
<tr class=alt>
<td>officeId, transactionDate
<td>officeId, transactionDate, useAccountingRule
</td>
</tr>
<tr>
@@ -13677,6 +14020,7 @@ Request Body:
"officeId": 1,
"transactionDate": "06 December 2012",
"comments": "Gifts for staff",
"useAccountingRule": "false",
"locale": "en" ,
"dateFormat": "dd MMMM yyyy",
"credits":[{"glAccountId":1,
@@ -13695,6 +14039,31 @@ Request Body:
{
"officeId": 1,
"transactionId": "DNEEMS2LPD0NJ9O"
}
</code>
<code class="method-declaration">
POST https://DomainName/api/v1/journalentries
</code>
<code class="method-request">
POST journalentries
Content-Type: application/json
Request Body:
{
"locale": "en",
"dateFormat": "dd MMMM yyyy",
"officeId": "1",
"transactionDate": "23 May 2013",
"referenceNumber": "547",
"comments": "asdf",
"useAccountingRule": "true",
"accountingRule": "2",
"amount": "547"
}
</code>
<code class="method-response">
{
"officeId":1,
"transactionId":"RS9MCISID4WK1ZM"
}
</code>
</div>
@@ -14679,7 +15048,23 @@ GET https://DomainName/api/v1/search?query=000000111
<td></td>
<td></td>
<td></td>
</tr>
</tr>
<tr class="alt">
<td><a href="#accountingrules">Accounting Rules</a></td>
<td>accountingrules</td>
<td><a href="#accountingrules_create">Create a Accounting Rule</a></td>
<td><a href="#accountingrules_list">List Accounting Rules</a></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td>accountingrules/{accountingrulesId}</td>
<td></td>
<td><a href="#accountingrules_retrieve">Retrieve a Accounting Rule</a></td>
<td><a href="#accountingrules_update">Update a Accounting Rule</a></td>
<td><a href="#accountingrules_delete">Delete a Accounting Rule</a></td>
</tr>
</table>
</div>
@@ -13,7 +13,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"), REFERENCE_NUMBER("referenceNumber"),IS_PREDEFINED_RULE_ENTRY("isPredefinedRuleEntry"),ACCOUNTING_RULE("accountingRule"), AMOUNT("amount");
"dateFormat"), REFERENCE_NUMBER("referenceNumber"), USE_ACCOUNTING_RULE("useAccountingRule"), ACCOUNTING_RULE("accountingRule"), AMOUNT("amount");
private final String value;
@@ -23,7 +23,7 @@ public class JournalEntryCommand {
private final LocalDate transactionDate;
private final String comments;
private final String referenceNumber;
private final Boolean isPredefinedRuleEntry;
private final Boolean useAccountingRule;
private final Long accountingRuleId;
private final BigDecimal amount;
@@ -32,26 +32,26 @@ public class JournalEntryCommand {
public JournalEntryCommand(final Long officeId, final LocalDate transactionDate, final String comments,
final SingleDebitOrCreditEntryCommand[] credits, final SingleDebitOrCreditEntryCommand[] debits,
final String referenceNumber, final Boolean isPredefinedRuleEntry, final Long accountingRuleId, final BigDecimal amount) {
final String referenceNumber, final Boolean useAccountingRule, final Long accountingRuleId, final BigDecimal amount) {
this.officeId = officeId;
this.transactionDate = transactionDate;
this.comments = comments;
this.credits = credits;
this.debits = debits;
this.referenceNumber = referenceNumber;
this.isPredefinedRuleEntry = isPredefinedRuleEntry;
this.useAccountingRule = useAccountingRule;
this.accountingRuleId = accountingRuleId;
this.amount = amount;
}
public JournalEntryCommand(final Long officeId, final LocalDate transactionDate, final String comments, final String referenceNumber,
final Boolean isPredefinedRuleEntry, final Long accountingRuleId, final BigDecimal amount) {
this(officeId, transactionDate, comments, null, null, referenceNumber, isPredefinedRuleEntry, accountingRuleId, amount);
final Boolean useAccountingRule, final Long accountingRuleId, final BigDecimal amount) {
this(officeId, transactionDate, comments, null, null, referenceNumber, useAccountingRule, accountingRuleId, amount);
}
public JournalEntryCommand(Long officeId, LocalDate transactionDate, String comments, SingleDebitOrCreditEntryCommand[] credits,
SingleDebitOrCreditEntryCommand[] debits, String referenceNumber, Boolean isPredefinedRuleEntry) {
this(officeId, transactionDate, comments, credits, debits, referenceNumber, isPredefinedRuleEntry, null,null);
SingleDebitOrCreditEntryCommand[] debits, String referenceNumber, Boolean useAccountingRule) {
this(officeId, transactionDate, comments, credits, debits, referenceNumber, useAccountingRule, null,null);
}
public void validateForCreate() {
@@ -66,11 +66,11 @@ public class JournalEntryCommand {
baseDataValidator.reset().parameter("comments").value(this.comments).ignoreIfNull().notExceedingLengthOf(500);
baseDataValidator.reset().parameter("isPredefinedRuleEntry").value(this.isPredefinedRuleEntry).notNull();
baseDataValidator.reset().parameter("useAccountingRule").value(this.useAccountingRule).notNull();
baseDataValidator.reset().parameter("referenceNumber").value(this.referenceNumber).ignoreIfNull().notExceedingLengthOf(100);
if (!this.isPredefinedRuleEntry) {
if (!this.useAccountingRule) {
baseDataValidator.reset().parameter("credits").value(this.credits).notNull();
@@ -147,8 +147,8 @@ public class JournalEntryCommand {
return this.referenceNumber;
}
public Boolean getIsPredefinedRuleEntry() {
return this.isPredefinedRuleEntry;
}
public Boolean getUseAccountingRule() {
return this.useAccountingRule;
}
}
@@ -59,15 +59,16 @@ public final class JournalEntryCommandFromApiJsonDeserializer extends AbstractFr
JournalEntryJsonInputParams.TRANSACTION_DATE.getValue(), element);
final String referenceNumber = this.fromApiJsonHelper.extractStringNamed(
JournalEntryJsonInputParams.REFERENCE_NUMBER.getValue(), element);
final Boolean isPredefinedRuleEntry = this.fromApiJsonHelper.extractBooleanNamed(JournalEntryJsonInputParams.IS_PREDEFINED_RULE_ENTRY.getValue(), element);
final Boolean isPredefinedRuleEntry = this.fromApiJsonHelper.extractBooleanNamed(JournalEntryJsonInputParams.USE_ACCOUNTING_RULE.getValue(), element);
final Boolean useAccountingRule = isPredefinedRuleEntry==null?false:isPredefinedRuleEntry;
final JsonObject topLevelJsonElement = element.getAsJsonObject();
final Locale locale = this.fromApiJsonHelper.extractLocaleParameter(topLevelJsonElement);
if(isPredefinedRuleEntry) {
if(useAccountingRule) {
final Long accountingRuleId = this.fromApiJsonHelper.extractLongNamed(JournalEntryJsonInputParams.ACCOUNTING_RULE.getValue(), element);
final BigDecimal amount = this.fromApiJsonHelper.extractBigDecimalNamed(JournalEntryJsonInputParams.AMOUNT.getValue(), element, locale);
return new JournalEntryCommand(officeId, transactionDate, comments, referenceNumber, isPredefinedRuleEntry, accountingRuleId, amount);
return new JournalEntryCommand(officeId, transactionDate, comments, referenceNumber, useAccountingRule, accountingRuleId, amount);
}
SingleDebitOrCreditEntryCommand[] credits = null;
@@ -82,7 +83,7 @@ public final class JournalEntryCommandFromApiJsonDeserializer extends AbstractFr
debits = populateCreditsOrDebitsArray(topLevelJsonElement, locale, debits, JournalEntryJsonInputParams.DEBITS.getValue());
}
}
return new JournalEntryCommand(officeId, transactionDate, comments, credits, debits, referenceNumber, isPredefinedRuleEntry);
return new JournalEntryCommand(officeId, transactionDate, comments, credits, debits, referenceNumber, useAccountingRule);
}
/**
@@ -88,7 +88,7 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
final Office office = this.officeRepository.findOne(officeId);
if (office == null) { throw new OfficeNotFoundException(officeId); }
final boolean isPredefinedRuleEntry = command.booleanPrimitiveValueOfParameterNamed(JournalEntryJsonInputParams.IS_PREDEFINED_RULE_ENTRY.getValue());
final boolean useAccountingRule = command.booleanPrimitiveValueOfParameterNamed(JournalEntryJsonInputParams.USE_ACCOUNTING_RULE.getValue());
validateBusinessRulesForJournalEntries(journalEntryCommand);
@@ -98,7 +98,7 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
final String referenceNumber = journalEntryCommand.getReferenceNumber();
final boolean manualEntry = true;
if (isPredefinedRuleEntry) {
if (useAccountingRule) {
final Long accountingRuleId = command.longValueOfParameterNamed(JournalEntryJsonInputParams.ACCOUNTING_RULE.getValue());
final BigDecimal amount = command.bigDecimalValueOfParameterNamed(JournalEntryJsonInputParams.AMOUNT.getValue());
@@ -218,7 +218,7 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
if (latestGLClosure.getClosingDate().after(transactionDate) || latestGLClosure.getClosingDate().equals(transactionDate)) { throw new JournalEntryInvalidException(
GL_JOURNAL_ENTRY_INVALID_REASON.ACCOUNTING_CLOSED, latestGLClosure.getClosingDate(), null, null); }
}
if(!command.getIsPredefinedRuleEntry()) {
if(!command.getUseAccountingRule()) {
/*** check if credits and debits are valid **/
final SingleDebitOrCreditEntryCommand[] credits = command.getCredits();
final SingleDebitOrCreditEntryCommand[] debits = command.getDebits();