From 421623359ef0760ab8a785bc1fd2801873fc3f2d Mon Sep 17 00:00:00 2001 From: Vishwas Babu AJ Date: Mon, 27 May 2013 13:26:35 +0530 Subject: [PATCH] updated documentation for savings with accounting integration --- api-docs/apiLive.htm | 539 +++++++++++++++++- .../api/SavingsProductsApiResource.java | 21 +- .../savings/data/SavingsProductData.java | 34 +- 3 files changed, 547 insertions(+), 47 deletions(-) diff --git a/api-docs/apiLive.htm b/api-docs/apiLive.htm index 319c45136..d53245bc0 100644 --- a/api-docs/apiLive.htm +++ b/api-docs/apiLive.htm @@ -6963,8 +6963,9 @@ Request Body: accountingRule - Example Values:1=NONE, - 2=CASH_BASED, 3=ACCRUAL_BASED + Specifies if accounting is enabled for the particular + product and the type of the accounting rule to be used + Example Values:1=NONE,2=CASH_BASED, 3=ACCRUAL_BASED @@ -9732,6 +9733,13 @@ Content-Type: application/json lockinPeriodFrequencyType Optional: If provided, used along with lockinPeriodFrequency to indicate the length of time that the savings account is 'locked in' and withdrawals are not allowed. 0=Days, 1=Weeks, 2=Months, 3=Years e.g. 6 Months + + accountingRule + + Specifies if accounting is enabled for the particular + product and the type of the accounting rule to be used + Example Values:1=NONE,2=CASH_BASED + @@ -9766,6 +9774,11 @@ Content-Type: application/json "code": "savings.interest.period.savingsCompoundingInterestPeriodType.daily", "value": "Daily" }, + "interestPostingPeriodType": { + "id": 4, + "code": "savings.interest.posting.period.savingsInterestPostingPeriodType.monthly", + "value": "Monthly" + }, "interestCalculationType": { "id": 1, "code": "savingsInterestCalculationType.dailybalance", @@ -9776,6 +9789,11 @@ Content-Type: application/json "code": "savingsInterestCalculationDaysInYearType.days365", "value": "365 Days" }, + "accountingRule": { + "id": 1, + "code": "accountingRuleType.none", + "value": "NONE" + }, "currencyOptions": [ { "code": "USD", @@ -9828,6 +9846,28 @@ Content-Type: application/json "value": "No Compounding - Simple Interest" } ], + "interestPostingPeriodTypeOptions": [ + { + "id": 4, + "code": "savings.interest.posting.period.savingsInterestPostingPeriodType.monthly", + "value": "Monthly" + }, + { + "id": 5, + "code": "savings.interest.posting.period.savingsInterestPostingPeriodType.quarterly", + "value": "Quarterly" + }, + { + "id": 6, + "code": "savings.interest.posting.period.savingsInterestPostingPeriodType.biannual", + "value": "Semi-Annual" + }, + { + "id": 7, + "code": "savings.interest.posting.period.savingsInterestPostingPeriodType.annual", + "value": "Annually" + } + ], "interestCalculationTypeOptions": [ { "id": 1, @@ -9873,7 +9913,319 @@ Content-Type: application/json "code": "savings.lockin.savingsPeriodFrequencyType.years", "value": "Years" } - ] + ], + "withdrawalFeeTypeOptions": [ + { + "id": 1, + "code": "savingsWithdrawalFeesType.flat", + "value": "Flat" + }, + { + "id": 2, + "code": "savingsWithdrawalFeesType.percent.of.amount", + "value": "% of Amount" + } + ], + "paymentTypeOptions": [ + { + "id": 14, + "name": "Wire Transfer", + "position": 0 + }, + { + "id": 13, + "name": "Cash", + "position": 1 + } + ], + "accountingRuleOptions": [ + { + "id": 1, + "code": "accountingRuleType.none", + "value": "NONE" + }, + { + "id": 2, + "code": "accountingRuleType.cash", + "value": "CASH BASED" + }, + { + "id": 3, + "code": "accountingRuleType.accrual", + "value": "ACCRUAL BASED" + } + ], + "accountingMappingOptions": { + "liabilityAccountOptions": [ + { + "id": 15, + "name": "Savings Control", + "glCode": "50001", + "disabled": false, + "manualEntriesAllowed": true, + "type": { + "id": 2, + "code": "accountType.liability", + "value": "LIABILITY" + }, + "usage": { + "id": 1, + "code": "accountUsage.detail", + "value": "DETAIL" + }, + "nameDecorated": "Savings Control", + "tagId": { + "id": 0 + } + } + ], + "assetAccountOptions": [ + { + "id": 2, + "name": "Cash", + "glCode": "100001", + "disabled": false, + "manualEntriesAllowed": true, + "type": { + "id": 1, + "code": "accountType.asset", + "value": "ASSET" + }, + "usage": { + "id": 1, + "code": "accountUsage.detail", + "value": "DETAIL" + }, + "tagId": {} + }, + { + "id": 16, + "name": "Savings Reference", + "glCode": "100007", + "disabled": false, + "manualEntriesAllowed": true, + "type": { + "id": 1, + "code": "accountType.asset", + "value": "ASSET" + }, + "usage": { + "id": 1, + "code": "accountUsage.detail", + "value": "DETAIL" + }, + "nameDecorated": "Savings Reference", + "tagId": { + "id": 0 + } + }, + { + "id": 12, + "name": "HDFC Rajajinagar", + "glCode": "100015", + "disabled": false, + "manualEntriesAllowed": true, + "type": { + "id": 1, + "code": "accountType.asset", + "value": "ASSET" + }, + "usage": { + "id": 1, + "code": "accountUsage.detail", + "value": "DETAIL" + }, + "tagId": {} + }, + { + "id": 1, + "name": "Loan Portfolio", + "glCode": "10003", + "disabled": false, + "manualEntriesAllowed": true, + "type": { + "id": 1, + "code": "accountType.asset", + "value": "ASSET" + }, + "usage": { + "id": 1, + "code": "accountUsage.detail", + "value": "DETAIL" + }, + "tagId": {} + }, + { + "id": 7, + "name": "Interest Receivable", + "glCode": "10005", + "disabled": false, + "manualEntriesAllowed": true, + "type": { + "id": 1, + "code": "accountType.asset", + "value": "ASSET" + }, + "usage": { + "id": 1, + "code": "accountUsage.detail", + "value": "DETAIL" + }, + "tagId": {} + }, + { + "id": 8, + "name": "Penalties Receivable", + "glCode": "10008", + "disabled": false, + "manualEntriesAllowed": true, + "type": { + "id": 1, + "code": "accountType.asset", + "value": "ASSET" + }, + "usage": { + "id": 1, + "code": "accountUsage.detail", + "value": "DETAIL" + }, + "tagId": {} + }, + { + "id": 9, + "name": "Fee Receivable", + "glCode": "10009", + "disabled": false, + "manualEntriesAllowed": true, + "type": { + "id": 1, + "code": "accountType.asset", + "value": "ASSET" + }, + "usage": { + "id": 1, + "code": "accountUsage.detail", + "value": "DETAIL" + }, + "tagId": {} + } + ], + "expenseAccountOptions": [ + { + "id": 6, + "name": "Write Off Expenses", + "glCode": "60001", + "disabled": false, + "manualEntriesAllowed": true, + "type": { + "id": 5, + "code": "accountType.expense", + "value": "EXPENSE" + }, + "usage": { + "id": 1, + "code": "accountUsage.detail", + "value": "DETAIL" + }, + "tagId": {} + }, + { + "id": 13, + "name": "Employee Salary", + "glCode": "60002", + "disabled": false, + "manualEntriesAllowed": true, + "type": { + "id": 5, + "code": "accountType.expense", + "value": "EXPENSE" + }, + "usage": { + "id": 1, + "code": "accountUsage.detail", + "value": "DETAIL" + }, + "tagId": {} + }, + { + "id": 18, + "name": "Interest On Savings", + "glCode": "60003", + "disabled": false, + "manualEntriesAllowed": true, + "type": { + "id": 5, + "code": "accountType.expense", + "value": "EXPENSE" + }, + "usage": { + "id": 1, + "code": "accountUsage.detail", + "value": "DETAIL" + }, + "nameDecorated": "Interest On Savings", + "tagId": { + "id": 0 + } + } + ], + "incomeAccountOptions": [ + { + "id": 3, + "name": "Income from Interest", + "glCode": "40001", + "disabled": false, + "manualEntriesAllowed": true, + "type": { + "id": 4, + "code": "accountType.income", + "value": "INCOME" + }, + "usage": { + "id": 1, + "code": "accountUsage.detail", + "value": "DETAIL" + }, + "tagId": {} + }, + { + "id": 4, + "name": "Income from Fees", + "glCode": "40002", + "disabled": false, + "manualEntriesAllowed": true, + "type": { + "id": 4, + "code": "accountType.income", + "value": "INCOME" + }, + "usage": { + "id": 1, + "code": "accountUsage.detail", + "value": "DETAIL" + }, + "tagId": {} + }, + { + "id": 5, + "name": "Income from Penalties", + "glCode": "40004", + "disabled": false, + "manualEntriesAllowed": true, + "type": { + "id": 4, + "code": "accountType.income", + "value": "INCOME" + }, + "usage": { + "id": 1, + "code": "accountUsage.detail", + "value": "DETAIL" + }, + "tagId": {} + } + ] + } } @@ -9887,13 +10239,20 @@ Content-Type: application/json
Mandatory Fields
name, description, currencyCode, digitsAfterDecimal, nominalAnnualInterestRate, - interestCompoundingPeriodType, interestCalculationType, interestCalculationDaysInYearType + interestCompoundingPeriodType, interestCalculationType, interestCalculationDaysInYearType,accountingRule + + +
+ + + +
Mandatory Fields for Cash based accounting (accountingRule = 2)
savingsReferenceAccountId,savingsControlAccountId, interestOnSavingsAccountId, incomeFromFeeAccountId

- +
Optional Fields
minRequiredOpeningBalance, lockinPeriodFrequency, lockinPeriodFrequencyType
minRequiredOpeningBalance, lockinPeriodFrequency, lockinPeriodFrequencyType, paymentChannelToFundSourceMappings
@@ -9909,8 +10268,50 @@ Request Body: "locale": "en", "nominalAnnualInterestRate": "5.0", "interestCompoundingPeriodType": 1, + "interestPostingPeriodType":4, "interestCalculationType": 1, - "interestCalculationDaysInYearType": "365" + "interestCalculationDaysInYearType": "365", + "accountingRule":"1" +} + + +{ + "resourceId": 1 +} + + POST savingsproducts +Content-Type: application/json +Request Body: +{ + "locale": "en", + "name": "New Passbook Savings ", + "description": "A savings product", + "currencyCode": "USD", + "digitsAfterDecimal": "2", + "nominalAnnualInterestRate": "15", + "interestCompoundingPeriodType": "1", + "interestPostingPeriodType": "4", + "interestCalculationType": "1", + "interestCalculationDaysInYearType": "365", + "minRequiredOpeningBalance": "50", + "lockinPeriodFrequency": "4", + "lockinPeriodFrequencyType": "1", + "withdrawalFeeAmount": "12", + "withdrawalFeeType": "1", + "monthDayFormat": "dd MMM", + "annualFeeAmount": "12", + "annualFeeOnMonthDay": "01 May", + "accountingRule": "2", + "savingsReferenceAccountId": "16", + "savingsControlAccountId": "15", + "interestOnSavingsAccountId": "18", + "incomeFromFeeAccountId": "4", + "paymentChannelToFundSourceMappings": [ + { + "paymentTypeId": "14", + "fundSourceAccountId": "2" + } + ] } @@ -9937,8 +10338,8 @@ Request Body: { "id": 1, - "name": "Passbook Savings", - "description": "Daily compounding using Daily Balance, 5% per year, 365 days in year", + "name": "First Product", + "description": "A cool saving product", "currency": { "code": "USD", "name": "US Dollar", @@ -9947,11 +10348,16 @@ Request Body: "nameCode": "currency.USD", "displayLabel": "US Dollar ($)" }, - "nominalAnnualInterestRate": 5, + "nominalAnnualInterestRate": 50.000000, "interestCompoundingPeriodType": { - "id": 1, - "code": "savings.interest.period.savingsCompoundingInterestPeriodType.daily", - "value": "Daily" + "id": 4, + "code": "savings.interest.period.savingsCompoundingInterestPeriodType.monthly", + "value": "Monthly" + }, + "interestPostingPeriodType": { + "id": 4, + "code": "savings.interest.posting.period.savingsInterestPostingPeriodType.monthly", + "value": "Monthly" }, "interestCalculationType": { "id": 1, @@ -9962,7 +10368,42 @@ Request Body: "id": 365, "code": "savingsInterestCalculationDaysInYearType.days365", "value": "365 Days" - } + }, + "minRequiredOpeningBalance": 20.000000, + "lockinPeriodFrequency": 1, + "lockinPeriodFrequencyType": { + "id": 1, + "code": "savings.lockin.savingsPeriodFrequencyType.weeks", + "value": "Weeks" + }, + "withdrawalFeeAmount": 12.000000, + "withdrawalFeeType": { + "id": 1, + "code": "savingsWithdrawalFeesType.flat", + "value": "Flat" + }, + "annualFeeAmount": 100.000000, + "annualFeeOnMonthDay": [ + 5, + 1 + ], + "accountingRule": { + "id": 2, + "code": "accountingRuleType.cash", + "value": "CASH BASED" + }, + "accountingMappings": { + "savingsReferenceAccountId": 16, + "incomeFromFeeAccountId": 4, + "interestOnSavingsAccountId": 18, + "savingsControlAccountId": 15 + }, + "paymentChannelToFundSourceMappings": [ + { + "paymentTypeId": 14, + "fundSourceAccountId": 2 + } + ] }
@@ -10658,12 +11099,12 @@ No Request Body: { - "accountId": 2, - "accountNo": "000000002", + "accountId": 1, + "accountNo": "000000001", "date": [ 2013, - 3, - 22 + 5, + 27 ], "currency": { "code": "USD", @@ -10672,7 +11113,19 @@ No Request Body: "displaySymbol": "$", "nameCode": "currency.USD", "displayLabel": "US Dollar ($)" - } + }, + "paymentTypeOptions": [ + { + "id": 14, + "name": "Wire Transfer", + "position": 0 + }, + { + "id": 13, + "name": "Cash", + "position": 1 + } + ] } @@ -10690,18 +11143,31 @@ No Request Body: Content-Type: application/json No Request Body: { - "dateFormat": "dd MMMM yyyy", - "locale": "en", - "transactionDate": "02 March 2011", - "transactionAmount": "256.67" + "locale": "en", + "dateFormat": "dd MMMM yyyy", + "transactionDate": "27 May 2013", + "transactionAmount": "500", + "paymentTypeId": "14", + "accountNumber": "acc123", + "checkNumber": "che123", + "routingCode": "rou123", + "receiptNumber": "rec123", + "bankNumber": "ban123" } { "officeId": 1, - "clientId": 1, + "clientId": 2, "savingsId": 1, - "resourceId": 1 + "resourceId": 47, + "changes": { + "accountNumber": "acc123", + "checkNumber": "che123", + "routingCode": "rou123", + "receiptNumber": "rec123", + "bankNumber": "ban123" + } } @@ -10718,18 +11184,31 @@ No Request Body: Content-Type: application/json No Request Body: { - "dateFormat": "dd MMMM yyyy", - "locale": "en", - "transactionDate": "02 March 2011", - "transactionAmount": "99.50" + "locale": "en", + "dateFormat": "dd MMMM yyyy", + "transactionDate": "27 May 2013", + "transactionAmount": "500", + "paymentTypeId": "14", + "accountNumber": "acc123", + "checkNumber": "che123", + "routingCode": "rou123", + "receiptNumber": "rec123", + "bankNumber": "ban123" } { "officeId": 1, - "clientId": 1, + "clientId": 2, "savingsId": 1, - "resourceId": 2 + "resourceId": 48, + "changes": { + "accountNumber": "acc123", + "checkNumber": "che123", + "routingCode": "rou123", + "receiptNumber": "rec123", + "bankNumber": "ban123" + } } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/api/SavingsProductsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/api/SavingsProductsApiResource.java index 9c562c2b0..828546f0e 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/api/SavingsProductsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/api/SavingsProductsApiResource.java @@ -7,7 +7,6 @@ package org.mifosplatform.portfolio.savings.api; import java.util.ArrayList; import java.util.Collection; -import java.util.HashMap; import java.util.List; import java.util.Map; @@ -144,17 +143,17 @@ public class SavingsProductsApiResource { final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters()); - Map accountingMappings = null; - Collection paymentChannelToFundSourceMappings = null; if (savingProductData.hasAccountingEnabled()) { - accountingMappings = accountMappingReadPlatformService.fetchAccountMappingDetailsForSavingsProduct(productId, - savingProductData.accountingRuleTypeId()); - paymentChannelToFundSourceMappings = accountMappingReadPlatformService + Map accountingMappings = accountMappingReadPlatformService.fetchAccountMappingDetailsForSavingsProduct( + productId, savingProductData.accountingRuleTypeId()); + Collection paymentChannelToFundSourceMappings = accountMappingReadPlatformService .fetchPaymentTypeToFundSourceMappingsForSavingsProduct(productId); + savingProductData = SavingsProductData.withAccountingDetails(savingProductData, accountingMappings, + paymentChannelToFundSourceMappings); } if (settings.isTemplate()) { - savingProductData = handleTemplateRelatedData(savingProductData, accountingMappings, paymentChannelToFundSourceMappings); + savingProductData = handleTemplateRelatedData(savingProductData); } return this.toApiJsonSerializer @@ -169,14 +168,13 @@ public class SavingsProductsApiResource { context.authenticatedUser().validateHasReadPermission(SavingsApiConstants.SAVINGS_PRODUCT_RESOURCE_NAME); - SavingsProductData savingProduct = handleTemplateRelatedData(null, new HashMap(), null); + SavingsProductData savingProduct = handleTemplateRelatedData(null); final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters()); return this.toApiJsonSerializer.serialize(settings, savingProduct, SavingsApiConstants.SAVINGS_PRODUCT_RESPONSE_DATA_PARAMETERS); } - private SavingsProductData handleTemplateRelatedData(final SavingsProductData savingsProduct, - final Map accountingMappings, final Collection paymentChannelToFundSourceMappings) { + private SavingsProductData handleTemplateRelatedData(final SavingsProductData savingsProduct) { final EnumOptionData interestCompoundingPeriodType = SavingsEnumerations .compoundingInterestPeriodType(SavingsCompoundingInterestPeriodType.DAILY); @@ -224,8 +222,7 @@ public class SavingsProductsApiResource { SavingsProductData savingsProductToReturn = null; if (savingsProduct != null) { - savingsProductToReturn = SavingsProductData.withTemplate(savingsProduct, accountingMappings, - paymentChannelToFundSourceMappings, currencyOptions, interestCompoundingPeriodTypeOptions, + savingsProductToReturn = SavingsProductData.withTemplate(savingsProduct, currencyOptions, interestCompoundingPeriodTypeOptions, interestPostingPeriodTypeOptions, interestCalculationTypeOptions, interestCalculationDaysInYearTypeOptions, lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, paymentTypeOptions, accountingRuleOptions, accountingMappingOptions); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsProductData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsProductData.java index 8f786102b..36aafbf09 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsProductData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsProductData.java @@ -42,9 +42,7 @@ public class SavingsProductData { // accounting private final EnumOptionData accountingRule; - @SuppressWarnings("unused") private final Map accountingMappings; - @SuppressWarnings("unused") private final Collection paymentChannelToFundSourceMappings; // template @@ -107,9 +105,8 @@ public class SavingsProductData { * Returns a {@link SavingsProductData} that contains and exist * {@link SavingsProductData} data with further template data for dropdowns. */ - public static SavingsProductData withTemplate(final SavingsProductData existingProduct, final Map accountingMappings, - final Collection paymentChannelToFundSourceMappings, - final Collection currencyOptions, final Collection interestCompoundingPeriodTypeOptions, + public static SavingsProductData withTemplate(final SavingsProductData existingProduct, final Collection currencyOptions, + final Collection interestCompoundingPeriodTypeOptions, final Collection interestPostingPeriodTypeOptions, final Collection interestCalculationTypeOptions, final Collection interestCalculationDaysInYearTypeOptions, @@ -117,6 +114,33 @@ public class SavingsProductData { final Collection paymentTypeOptions, final Collection accountingRuleOptions, final Map> accountingMappingOptions) { + return new SavingsProductData(existingProduct.id, existingProduct.name, existingProduct.description, existingProduct.currency, + existingProduct.nominalAnnualInterestRate, existingProduct.interestCompoundingPeriodType, + existingProduct.interestPostingPeriodType, existingProduct.interestCalculationType, + existingProduct.interestCalculationDaysInYearType, existingProduct.minRequiredOpeningBalance, + existingProduct.lockinPeriodFrequency, existingProduct.lockinPeriodFrequencyType, existingProduct.withdrawalFeeAmount, + existingProduct.withdrawalFeeType, existingProduct.accountingRule, existingProduct.annualFeeAmount, + existingProduct.annualFeeOnMonthDay, existingProduct.accountingMappings, + existingProduct.paymentChannelToFundSourceMappings, currencyOptions, interestCompoundingPeriodTypeOptions, + interestPostingPeriodTypeOptions, interestCalculationTypeOptions, interestCalculationDaysInYearTypeOptions, + lockinPeriodFrequencyTypeOptions, withdrawalFeeTypeOptions, paymentTypeOptions, accountingRuleOptions, + accountingMappingOptions); + } + + public static SavingsProductData withAccountingDetails(final SavingsProductData existingProduct, + final Map accountingMappings, final Collection paymentChannelToFundSourceMappings) { + + final Collection currencyOptions = null; + final Collection interestCompoundingPeriodTypeOptions = null; + final Collection interestPostingPeriodTypeOptions = null; + final Collection interestCalculationTypeOptions = null; + final Collection interestCalculationDaysInYearTypeOptions = null; + final Collection lockinPeriodFrequencyTypeOptions = null; + final Collection withdrawalFeeTypeOptions = null; + final Collection paymentTypeOptions = null; + final Collection accountingRuleOptions = null; + final Map> accountingMappingOptions = null; + return new SavingsProductData(existingProduct.id, existingProduct.name, existingProduct.description, existingProduct.currency, existingProduct.nominalAnnualInterestRate, existingProduct.interestCompoundingPeriodType, existingProduct.interestPostingPeriodType, existingProduct.interestCalculationType,