From 9cff637e16cacb6896056f5c8c6ab300b1822d9a Mon Sep 17 00:00:00 2001 From: goutham-M Date: Thu, 23 May 2013 15:53:10 +0530 Subject: [PATCH] update documentation for Accounting changes --- api-docs/apiLive.htm | 389 +++++++++++++++++- .../api/JournalEntryJsonInputParams.java | 2 +- .../command/JournalEntryCommand.java | 24 +- ...alEntryCommandFromApiJsonDeserializer.java | 9 +- ...WritePlatformServiceJpaRepositoryImpl.java | 6 +- 5 files changed, 408 insertions(+), 22 deletions(-) diff --git a/api-docs/apiLive.htm b/api-docs/apiLive.htm index 1b8ca4f21..cc84995f5 100644 --- a/api-docs/apiLive.htm +++ b/api-docs/apiLive.htm @@ -751,6 +751,22 @@ Update a Charge Delete a Charge + + Accounting Rules + accountingrules + Create a Accounting Rule + List Accounting Rules + + + + + + accountingrules/{accountingrulesId} + + Retrieve a Accounting Rule + Update a Accounting Rule + Delete a Accounting Rule + @@ -1279,6 +1295,10 @@ reports/template Retrieve Report Template + + + accountingrules/template + Retrieve Accounting Rule Template @@ -9360,6 +9380,315 @@ Content-Type: application/json + +   +
+
+

Accounting Rules

+

+ Its additional option for MFIs to define their own accounting rules. + Its typically used to perform daily accounting postings of journal entries. +

+

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

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Field Descriptions
name
Name of the accounting rule
description
The description about the accounting rule.
officeId
The officeId of the office/branch for this accounting rule is applicable.
debitAccountHead
Debit account for creating accounting rule
creditAccountHead
Credit account for creating accounting rule
+
+
+ +   +
+
+

Retrieve Accounting Rule Details Template

+

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: +

    +
  • Field Defaults
  • +
  • Allowed Value Lists
  • +
+

+

Example Request:

+
accountingrules/template
+
+
+ +GET https://DomainName/api/v1/accountingrules/template + + +{ + "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" + } + }] +} + +
+
+ +   +
+
+

Create/Define a Accounting rule

+

Define a new Accounting rule.

+
+
+ +POST https://DomainName/api/v1/accountingrules + + +POST accountingrules +Content-Type: application/json +Request Body: +{ + "name": "test", + "officeId": "1", + "debitAccountHead": "21", + "creditAccountHead": "9", + "description": "Employee salary" +} + + +{ + "officeId":1, + "resourceId":1 +} + +
+
+ +   +
+
+

Retrieve Accounting Rules

+

Returns the list of defined accounting rules.

+

Example Requests:

+
accountingrules
+
+
+ +GET https://DomainName/api/v1/accountingrules + + +[{ + "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 + } +}] + +
+
+ +   +
+
+

Retrieve a Accounting rule

+

Returns the details of a defined Accounting rule.

+

Example Requests:

+
accountingrules/1
+
+
+ +GET https://DomainName/api/v1/accountingrules/{accountingruleId} + + +{ + "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 + } +} + +
+
+ +   +
+
+

Update a Accounting Rule

+

Updates the details of a Accounting rule.

+
+
+ +PUT https://DomainName/api/v1/accountingrules/{accountingruleId} + + +PUT accountingrules/1 +Content-Type: application/json +Request Body: +{ + "name": "Employee Salary posting rule" +} + + +{ + "resourceId": 1, + "changes": { + "name": "Employee Salary posting rule" + } +} + +
+
+ +   +
+
+

Delete a Accounting Rule

+

Deletes a Accounting rule.

+
+
+ +DELETE https://DomainName/api/v1/accountingrules/{accountingruleId} + + +DELETE accountingrules/1 +Content-Type: application/json + + { "resourceId": 1 } +
+
+  
@@ -13423,6 +13752,20 @@ No Request Body: An additional field that is used to store additional information about the entry (Ex: chequeNo) + + useAccountingRule + + + This flag denotes the journal entry should post on basis of Predefined accounting rule or general Journal Entry procudure.
If the flag is true the journal entry is posted on basis of predefined accounting rule. + + + + accountingRule + + + Denotes the accounting rule id for posting journal entries, this parameter should pass in request body when useAccountingRule is true. + +
@@ -13623,7 +13966,7 @@ GET https://DomainName/api/v1/journalentries?transactionId=PB37X8Y21EQUY4S
Mandatory Fields
- officeId, transactionDate + officeId, transactionDate, useAccountingRule @@ -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" +} + + +POST https://DomainName/api/v1/journalentries + + +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" +} + + +{ + "officeId":1, + "transactionId":"RS9MCISID4WK1ZM" } @@ -14679,7 +15048,23 @@ GET https://DomainName/api/v1/search?query=000000111 - + + + Accounting Rules + accountingrules + Create a Accounting Rule + List Accounting Rules + + + + + + accountingrules/{accountingrulesId} + + Retrieve a Accounting Rule + Update a Accounting Rule + Delete a Accounting Rule + 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 344fc4d6a..6c9d96c7e 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 @@ -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; 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 923df25dc..729b93ef3 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 @@ -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; + } } \ 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 d441b4325..bc22cda16 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 @@ -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); } /** 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 2fd1dc289..6d131bbac 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 @@ -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();