update loan products api docs

This commit is contained in:
Keith Woodlock
2013-01-29 20:23:19 +00:00
parent e0036e8d2b
commit 08e804d03f
12 changed files with 519 additions and 618 deletions
+159 -207
View File
@@ -1921,6 +1921,10 @@ Request Body:
<tr><td class=fielddesc>
<span>Example Values:</span> Same as repayment period, Daily</td></tr></td></tr>
</tr>
<tr class=alt><td>accountingType</td></tr>
<tr><td class=fielddesc>
<span>Example Values:</span>NONE(1), CASH_BASED(2), ACCRUAL_BASED(3)</td></tr></td></tr>
</tr>
</table>
</div>
</div>
@@ -1936,36 +1940,30 @@ Request Body:
</div>
<div class="method-example">
<code class="method-declaration">GET https://Domain Name/api/v1/loanproducts</code>
<code class="method-response">[ {
<code class="method-response">[
{
"id": 1,
"name" : "Agricultural Loan",
"description" : "An agricultural loan given to farmers to help buy crop, stock and machinery. With an arrears tolerance setting of 1,000 CFA, loans are not marked as 'in arrears' or 'in bad standing' if the amount outstanding is less than this. Interest rate is described using monthly percentage rate (MPR) even though the loan typically lasts a year and requires one repayment (typically at time when farmer sells crop)",
"principal" : {
"currencyCode" : "XOF",
"digitsAfterDecimal" : 0,
"amount" : 100000,
"defaultName" : "CFA Franc BCEAO",
"nameCode" : "currency.XOF",
"displaySymbol" : "CFA",
"zero" : false,
"greaterThanZero" : true,
"displaySymbolValue" : "100000 CFA"
"name": "A new loan product for me",
"currency": {
"code": "USD",
"name": "US Dollar",
"decimalPlaces": 2,
"displaySymbol": "$",
"nameCode": "currency.USD",
"displayLabel": "US Dollar ($)"
},
"inArrearsTolerance" : {
"currencyCode" : "XOF",
"digitsAfterDecimal" : 0,
"amount" : 1000,
"defaultName" : "CFA Franc BCEAO",
"nameCode" : "currency.XOF",
"displaySymbol" : "CFA",
"zero" : false,
"greaterThanZero" : true,
"displaySymbolValue" : "1000 CFA"
"principal": 100000,
"numberOfRepayments": 12,
"loanTermFrequency": 12,
"repaymentEvery": 1,
"interestRatePerPeriod": 1.75,
"annualInterestRate": 21,
"accountingType": 1,
"loanTermFrequencyType": {
"id": 2,
"code": "loanTermFrequency.periodFrequencyType.months",
"value": "Months"
},
"numberOfRepayments" : 1,
"repaymentEvery" : 12,
"interestRatePerPeriod" : 1.750000,
"annualInterestRate" : 21.000000,
"repaymentFrequencyType": {
"id": 2,
"code": "repaymentFrequency.periodFrequencyType.months",
@@ -1977,9 +1975,9 @@ Request Body:
"value": "Per month"
},
"amortizationType": {
"id" : 1,
"code" : "amortizationType.equal.installments",
"value" : "Equal installments"
"id": 0,
"code": "amortizationType.equal.principal",
"value": "Equal principle payments"
},
"interestType": {
"id": 0,
@@ -1990,66 +1988,9 @@ Request Body:
"id": 1,
"code": "interestCalculationPeriodType.same.as.repayment.period",
"value": "Same as repayment period"
},
"createdOn" : 1334232874000,
"lastModifedOn" : 1334232874000
}, {
"id" : 2,
"name" : "Brunei Loan",
"principal" : {
"currencyCode" : "BND",
"digitsAfterDecimal" : 2,
"amount" : 76000.00,
"defaultName" : "Brunei Dollar",
"nameCode" : "currency.BND",
"displaySymbol" : "BND",
"zero" : false,
"greaterThanZero" : true,
"displaySymbolValue" : "76000.00 BND"
},
"inArrearsTolerance" : {
"currencyCode" : "BND",
"digitsAfterDecimal" : 2,
"amount" : 50.00,
"defaultName" : "Brunei Dollar",
"nameCode" : "currency.BND",
"displaySymbol" : "BND",
"zero" : false,
"greaterThanZero" : true,
"displaySymbolValue" : "50.00 BND"
},
"numberOfRepayments" : 10,
"repaymentEvery" : 1,
"interestRatePerPeriod" : 6.000000,
"annualInterestRate" : 72.000000,
"repaymentFrequencyType" : {
"id" : 1,
"code" : "repaymentFrequency.periodFrequencyType.weeks",
"value" : "Weeks"
},
"interestRateFrequencyType" : {
"id" : 2,
"code" : "interestRateFrequency.periodFrequencyType.months",
"value" : "Per month"
},
"amortizationType" : {
"id" : 1,
"code" : "amortizationType.equal.installments",
"value" : "Equal installments"
},
"interestType" : {
"id" : 0,
"code" : "interestType.declining.balance",
"value" : "Declining Balance"
},
"interestCalculationPeriodType" : {
"id" : 1,
"code" : "interestCalculationPeriodType.same.as.repayment.period",
"value" : "Same as repayment period"
},
"createdOn" : 1334513601000,
"lastModifedOn" : 1334513601000
}...]
}
}
]
</code>
</div>
</div>
@@ -2070,30 +2011,20 @@ Request Body:
<div class="method-example">
<code class="method-declaration">GET https://Domain Name/api/v1/loanproducts/template</code>
<code class="method-response">{
"principal" : {
"currencyCode" : "KES",
"digitsAfterDecimal" : 2,
"amount" : 0.00,
"defaultName" : "Kenyan Shilling",
"nameCode" : "currency.KES",
"displaySymbol" : "KSh",
"zero" : true,
"greaterThanZero" : false,
"displaySymbolValue" : "0.00 KSh"
"currency": {
"code": "USD",
"name": "US Dollar",
"decimalPlaces": 2,
"displaySymbol": "$",
"nameCode": "currency.USD",
"displayLabel": "US Dollar ($)"
},
"inArrearsTolerance" : {
"currencyCode" : "KES",
"digitsAfterDecimal" : 2,
"amount" : 0.00,
"defaultName" : "Kenyan Shilling",
"nameCode" : "currency.KES",
"displaySymbol" : "KSh",
"zero" : true,
"greaterThanZero" : false,
"displaySymbolValue" : "0.00 KSh"
"accountingType": 1,
"loanTermFrequencyType": {
"id": 2,
"code": "loanTermFrequency.periodFrequencyType.months",
"value": "Months"
},
"interestRatePerPeriod" : 0,
"annualInterestRate" : 0,
"repaymentFrequencyType": {
"id": 2,
"code": "repaymentFrequency.periodFrequencyType.months",
@@ -2119,98 +2050,125 @@ Request Body:
"code": "interestCalculationPeriodType.same.as.repayment.period",
"value": "Same as repayment period"
},
"currencyOptions" : [ {
"code" : "KES",
"name" : "Kenyan Shilling",
"decimalPlaces" : 2,
"displaySymbol" : "KSh",
"nameCode" : "currency.KES",
"displayLabel" : "Kenyan Shilling (KSh)"
}, {
"code" : "BND",
"name" : "Brunei Dollar",
"decimalPlaces" : 2,
"displaySymbol" : "BND",
"nameCode" : "currency.BND",
"displayLabel" : "Brunei Dollar (BND)"
}, {
"code" : "LBP",
"name" : "Lebanese Pound",
"decimalPlaces" : 2,
"displaySymbol" : "L£",
"nameCode" : "currency.LBP",
"displayLabel" : "Lebanese Pound (L£)"
}, {
"code" : "GHC",
"name" : "Ghana Cedi",
"decimalPlaces" : 2,
"displaySymbol" : "GHC",
"nameCode" : "currency.GHC",
"displayLabel" : "Ghana Cedi (GHC)"
}, {
"currencyOptions": [
{
"code": "USD",
"name": "US Dollar",
"decimalPlaces": 2,
"displaySymbol": "$",
"nameCode": "currency.USD",
"displayLabel": "US Dollar ($)"
}, {
"code" : "XOF",
"name" : "CFA Franc BCEAO",
"decimalPlaces" : 0,
"displaySymbol" : "CFA",
"nameCode" : "currency.XOF",
"displayLabel" : "CFA Franc BCEAO (CFA)"
} ],
"amortizationTypeOptions" : [ {
}
],
"transactionProcessingStrategyOptions": [
{
"id": 1,
"code": "mifos-standard-strategy",
"name": "Mifos style"
},
{
"id": 2,
"code": "heavensfamily-strategy",
"name": "Heavensfamily"
},
{
"id": 3,
"code": "creocore-strategy",
"name": "Creocore"
},
{
"id": 4,
"code": "rbi-india-strategy",
"name": "RBI (India)"
}
],
"amortizationTypeOptions": [
{
"id": 1,
"code": "amortizationType.equal.installments",
"value": "Equal installments"
}, {
},
{
"id": 0,
"code": "amortizationType.equal.principal",
"value": "Equal principle payments"
} ],
"interestTypeOptions" : [ {
}
],
"interestTypeOptions": [
{
"id": 1,
"code": "interestType.flat",
"value": "Flat"
}, {
},
{
"id": 0,
"code": "interestType.declining.balance",
"value": "Declining Balance"
} ],
"interestCalculationPeriodTypeOptions" : [ {
}
],
"interestCalculationPeriodTypeOptions": [
{
"id": 0,
"code": "interestCalculationPeriodType.daily",
"value": "Daily"
}, {
},
{
"id": 1,
"code": "interestCalculationPeriodType.same.as.repayment.period",
"value": "Same as repayment period"
} ],
"repaymentFrequencyTypeOptions" : [ {
}
],
"repaymentFrequencyTypeOptions": [
{
"id": 0,
"code": "repaymentFrequency.periodFrequencyType.days",
"value": "Days"
}, {
},
{
"id": 1,
"code": "repaymentFrequency.periodFrequencyType.weeks",
"value": "Weeks"
}, {
},
{
"id": 2,
"code": "repaymentFrequency.periodFrequencyType.months",
"value": "Months"
} ],
"interestRateFrequencyTypeOptions" : [ {
}
],
"interestRateFrequencyTypeOptions": [
{
"id": 2,
"code": "interestRateFrequency.periodFrequencyType.months",
"value": "Per month"
}, {
},
{
"id": 3,
"code": "interestRateFrequency.periodFrequencyType.years",
"value": "Per year"
} ]
}
],
"loanTermFrequencyTypeOptions": [
{
"id": 0,
"code": "loanTermFrequency.periodFrequencyType.days",
"value": "Days"
},
{
"id": 1,
"code": "loanTermFrequency.periodFrequencyType.weeks",
"value": "Weeks"
},
{
"id": 2,
"code": "loanTermFrequency.periodFrequencyType.months",
"value": "Months"
},
{
"id": 3,
"code": "loanTermFrequency.periodFrequencyType.years",
"value": "Years"
}
]
}
</code>
</div>
@@ -2231,34 +2189,27 @@ Request Body:
<code class="method-declaration">GET https://Domain Name/api/v1/loanproducts/{productId}</code>
<code class="method-response">{
"id": 1,
"name" : "Agricultural Loan",
"description" : "An agricultural loan given to farmers to help buy crop, stock and machinery. With an arrears tolerance setting of 1,000 CFA, loans are not marked as 'in arrears' or 'in bad standing' if the amount outstanding is less than this. Interest rate is described using monthly percentage rate (MPR) even though the loan typically lasts a year and requires one repayment (typically at time when farmer sells crop)",
"principal" : {
"currencyCode" : "XOF",
"digitsAfterDecimal" : 0,
"amount" : 100000,
"defaultName" : "CFA Franc BCEAO",
"nameCode" : "currency.XOF",
"displaySymbol" : "CFA",
"zero" : false,
"greaterThanZero" : true,
"displaySymbolValue" : "100000 CFA"
"name": "A new loan product for me",
"currency": {
"code": "USD",
"name": "US Dollar",
"decimalPlaces": 2,
"displaySymbol": "$",
"nameCode": "currency.USD",
"displayLabel": "US Dollar ($)"
},
"inArrearsTolerance" : {
"currencyCode" : "XOF",
"digitsAfterDecimal" : 0,
"amount" : 1000,
"defaultName" : "CFA Franc BCEAO",
"nameCode" : "currency.XOF",
"displaySymbol" : "CFA",
"zero" : false,
"greaterThanZero" : true,
"displaySymbolValue" : "1000 CFA"
"principal": 100000,
"numberOfRepayments": 12,
"loanTermFrequency": 12,
"repaymentEvery": 1,
"interestRatePerPeriod": 1.75,
"annualInterestRate": 21,
"accountingType": 1,
"loanTermFrequencyType": {
"id": 2,
"code": "loanTermFrequency.periodFrequencyType.months",
"value": "Months"
},
"numberOfRepayments" : 1,
"repaymentEvery" : 12,
"interestRatePerPeriod" : 1.750000,
"annualInterestRate" : 21.000000,
"repaymentFrequencyType": {
"id": 2,
"code": "repaymentFrequency.periodFrequencyType.months",
@@ -2270,9 +2221,9 @@ Request Body:
"value": "Per month"
},
"amortizationType": {
"id" : 1,
"code" : "amortizationType.equal.installments",
"value" : "Equal installments"
"id": 0,
"code": "amortizationType.equal.principal",
"value": "Equal principle payments"
},
"interestType": {
"id": 0,
@@ -2284,8 +2235,7 @@ Request Body:
"code": "interestCalculationPeriodType.same.as.repayment.period",
"value": "Same as repayment period"
},
"createdOn" : 1334232874000,
"lastModifedOn" : 1334232874000
"charges": []
}
</code>
</div>
@@ -2299,7 +2249,7 @@ Request Body:
<tr class="matrixHeadingBG"><td><div class="mifosXHeading2">Mandatory Fields</div></td></tr>
<tr class=alt><td>name, currencyCode, digitsAfterDecimal, principal, inArrearsTolerance, repaymentFrequencyType, repaymentEvery,
numberOfRepayments, interestRatePerPeriod, interestRateFrequencyType, amortizationType,
interestType, interestCalculationPeriodType</td></tr>
interestType, interestCalculationPeriodType, accountingType</td></tr>
</table>
</div>
<div class="method-example">
@@ -2309,12 +2259,10 @@ Content-Type: application/json
Request Body:
{
"name": "A new loan product for me",
"description": "A description not exceeding 500 characters.",
"currencyCode": "USD",
"digitsAfterDecimal": "2",
"locale": "en_GB",
"digitsAfterDecimal": "2",
"principal": "100,000.00",
"inArrearsTolerance": "1,000.00",
"repaymentFrequencyType": 2,
"repaymentEvery": "1",
"numberOfRepayments": "12",
@@ -2322,11 +2270,12 @@ Request Body:
"interestRateFrequencyType": 2,
"amortizationType": 1,
"interestType": 0,
"interestCalculationPeriodType": 1
"interestCalculationPeriodType": 1,
"accountingType": 1
}
</code>
<code class="method-response">{
"resourceId": 9
"resourceId": 1
}
</code>
</div>
@@ -2338,18 +2287,21 @@ Request Body:
<h4>Update a Loan Product</h4>
</div>
<div class="method-example">
<code class="method-declaration">POST https://Domain Name/api/v1/loanproducts/{loanId}</code>
<code class="method-request">POST loanproducts/1
<code class="method-declaration">PUT https://Domain Name/api/v1/loanproducts/{loanId}</code>
<code class="method-request">PUT loanproducts/1
Content-Type: application/json
Request Body:
{
"locale": "en_GB",
"principal": "100,000.00",
"inArrearsTolerance": "5,000.00"
"principal": "70,000.00"
}
</code>
<code class="method-response">{
"resourceId": 1
"resourceId": 1,
"changes": {
"principal": 70000,
"locale": "en_GB"
}
}
</code>
</div>
@@ -470,19 +470,11 @@ CREATE TABLE `m_product_loan` (
`number_of_repayments` smallint(5) NOT NULL,
`amortization_method_enum` smallint(5) NOT NULL,
`accounting_type` smallint(5) NOT NULL,
`createdby_id` bigint(20) DEFAULT NULL,
`created_date` datetime DEFAULT NULL,
`lastmodified_date` datetime DEFAULT NULL,
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
`loan_transaction_strategy_id` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `FKAUD0000000000003` (`createdby_id`),
KEY `FKAUD0000000000004` (`lastmodifiedby_id`),
KEY `FKA6A8A7D77240145` (`fund_id`),
KEY `FK_ltp_strategy` (`loan_transaction_strategy_id`),
CONSTRAINT `FKA6A8A7D77240145` FOREIGN KEY (`fund_id`) REFERENCES `m_fund` (`id`),
CONSTRAINT `FKAUD0000000000003` FOREIGN KEY (`createdby_id`) REFERENCES `m_appuser` (`id`),
CONSTRAINT `FKAUD0000000000004` FOREIGN KEY (`lastmodifiedby_id`) REFERENCES `m_appuser` (`id`),
CONSTRAINT `FK_ltp_strategy` FOREIGN KEY (`loan_transaction_strategy_id`) REFERENCES `ref_loan_transaction_processing_strategy` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -429,19 +429,11 @@ CREATE TABLE `m_client` (
`display_name` varchar(100) NOT NULL,
`image_key` varchar(500) DEFAULT NULL,
`joined_date` date DEFAULT NULL,
`createdby_id` bigint(20) DEFAULT NULL,
`created_date` datetime DEFAULT NULL,
`lastmodified_date` datetime DEFAULT NULL,
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
`is_deleted` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `account_no_UNIQUE` (`account_no`),
UNIQUE KEY `external_id` (`external_id`),
KEY `FKCE00CAB3E0DD567A` (`office_id`),
KEY `FKAUD0000000000001` (`createdby_id`),
KEY `FKAUD0000000000002` (`lastmodifiedby_id`),
CONSTRAINT `FKAUD0000000000001` FOREIGN KEY (`createdby_id`) REFERENCES `m_appuser` (`id`),
CONSTRAINT `FKAUD0000000000002` FOREIGN KEY (`lastmodifiedby_id`) REFERENCES `m_appuser` (`id`),
CONSTRAINT `FKCE00CAB3E0DD567A` FOREIGN KEY (`office_id`) REFERENCES `m_office` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=347 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -813,18 +805,10 @@ CREATE TABLE `m_group` (
`name` varchar(100) DEFAULT NULL,
`external_id` varchar(100) DEFAULT NULL,
`is_deleted` tinyint(1) NOT NULL DEFAULT '0',
`createdby_id` bigint(20) DEFAULT NULL,
`created_date` datetime DEFAULT NULL,
`lastmodified_date` datetime DEFAULT NULL,
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`),
UNIQUE KEY `external_id` (`external_id`),
KEY `FKJPWG000000000003` (`createdby_id`),
KEY `FKJPWG000000000004` (`lastmodifiedby_id`),
KEY `office_id` (`office_id`),
CONSTRAINT `FKJPWG000000000003` FOREIGN KEY (`createdby_id`) REFERENCES `m_appuser` (`id`),
CONSTRAINT `FKJPWG000000000004` FOREIGN KEY (`lastmodifiedby_id`) REFERENCES `m_appuser` (`id`),
CONSTRAINT `m_group_ibfk_1` FOREIGN KEY (`office_id`) REFERENCES `m_office` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -1471,19 +1455,11 @@ CREATE TABLE `m_product_loan` (
`number_of_repayments` smallint(5) NOT NULL,
`amortization_method_enum` smallint(5) NOT NULL,
`accounting_type` smallint(5) NOT NULL,
`createdby_id` bigint(20) DEFAULT NULL,
`created_date` datetime DEFAULT NULL,
`lastmodified_date` datetime DEFAULT NULL,
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
`loan_transaction_strategy_id` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `FKAUD0000000000003` (`createdby_id`),
KEY `FKAUD0000000000004` (`lastmodifiedby_id`),
KEY `FKA6A8A7D77240145` (`fund_id`),
KEY `FK_ltp_strategy` (`loan_transaction_strategy_id`),
CONSTRAINT `FKA6A8A7D77240145` FOREIGN KEY (`fund_id`) REFERENCES `m_fund` (`id`),
CONSTRAINT `FKAUD0000000000003` FOREIGN KEY (`createdby_id`) REFERENCES `m_appuser` (`id`),
CONSTRAINT `FKAUD0000000000004` FOREIGN KEY (`lastmodifiedby_id`) REFERENCES `m_appuser` (`id`),
CONSTRAINT `FK_ltp_strategy` FOREIGN KEY (`loan_transaction_strategy_id`) REFERENCES `ref_loan_transaction_processing_strategy` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -2058,4 +2034,4 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2013-01-29 12:54:03
-- Dump completed on 2013-01-29 20:18:19
@@ -1475,19 +1475,11 @@ CREATE TABLE `m_product_loan` (
`number_of_repayments` smallint(5) NOT NULL,
`amortization_method_enum` smallint(5) NOT NULL,
`accounting_type` smallint(5) NOT NULL,
`createdby_id` bigint(20) DEFAULT NULL,
`created_date` datetime DEFAULT NULL,
`lastmodified_date` datetime DEFAULT NULL,
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
`loan_transaction_strategy_id` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `FKAUD0000000000003` (`createdby_id`),
KEY `FKAUD0000000000004` (`lastmodifiedby_id`),
KEY `FKA6A8A7D77240145` (`fund_id`),
KEY `FK_ltp_strategy` (`loan_transaction_strategy_id`),
CONSTRAINT `FKA6A8A7D77240145` FOREIGN KEY (`fund_id`) REFERENCES `m_fund` (`id`),
CONSTRAINT `FKAUD0000000000003` FOREIGN KEY (`createdby_id`) REFERENCES `m_appuser` (`id`),
CONSTRAINT `FKAUD0000000000004` FOREIGN KEY (`lastmodifiedby_id`) REFERENCES `m_appuser` (`id`),
CONSTRAINT `FK_ltp_strategy` FOREIGN KEY (`loan_transaction_strategy_id`) REFERENCES `ref_loan_transaction_processing_strategy` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -1498,7 +1490,7 @@ CREATE TABLE `m_product_loan` (
LOCK TABLES `m_product_loan` WRITE;
/*!40000 ALTER TABLE `m_product_loan` DISABLE KEYS */;
INSERT INTO `m_product_loan` VALUES (1,'HKD',2,'700000.000000',NULL,'PORetailLoan',NULL,4,'5.000000',2,'21.000000',0,1,1,2,120,1,1,1,'2012-04-12 22:14:34','2012-12-12 08:10:01',24,1),(2,'LBP',2,'35000.000000','10.000000','Different Loan Type',NULL,NULL,'1.000000',2,'12.000000',0,1,2,1,10,1,1,1,'2012-07-17 03:20:34','2012-07-17 03:20:34',1,1),(3,'BND',2,'5000.000000','10.000000','Further Loan Product',NULL,2,'1.500000',2,'18.000000',0,1,1,2,6,0,1,1,'2012-07-17 03:21:38','2012-07-17 03:21:38',1,1),(4,'MMK',0,'50000.000000','0.000000','General','General micro-loan',3,'1.250000',2,'36.000000',1,1,1,2,12,1,1,1,'2012-07-19 15:34:27','2012-07-19 17:13:59',1,1),(5,'MMK',0,'50000.000000','0.000000','Agricultural','Agricultural micro-loan',4,'1.250000',2,'36.000000',1,1,12,2,2,1,1,1,'2012-07-19 15:36:16','2012-07-19 17:14:15',1,1),(6,'MMK',2,'100.000000','10.000000','testloan','testloan from client app',4,'10.000000',2,'120.000000',0,1,1,2,10,0,1,1,'2012-08-01 07:35:46','2012-08-01 07:35:46',1,1),(7,'XOF',0,'500.000000','2000.000000','new-lp-test-1','test creating new lp',3,'2.000000',2,'24.000000',0,1,1,2,12,1,1,1,'2012-09-02 10:47:10','2012-09-02 10:47:20',1,NULL),(8,'GHC',2,'30000.000000','0.000000','another-test-lp','another test updated.',1,'2.000000',2,'24.000000',0,1,1,2,12,1,1,1,'2012-09-02 11:04:41','2012-09-02 11:08:24',1,NULL),(9,'XOF',0,'120000.000000','0.000000','loan product1','loan product1',1,'8.000000',2,'96.000000',0,1,3,2,1233,0,1,1,'2012-09-25 09:31:22','2012-09-25 09:31:22',1,NULL),(10,'BND',2,'120000.000000','0.000000','loan product1','loan product1',2,'8.000000',2,'96.000000',0,1,3,2,1233,0,1,1,'2012-09-25 09:31:22','2012-09-25 09:35:17',1,NULL),(11,'XOF',2,'3333333.000000','0.000000','Collection100','aaa',4,'30.000000',2,'360.000000',0,1,1,2,2,1,1,11,'2012-09-25 09:44:52','2012-09-25 09:44:52',11,NULL),(12,'INR',2,'10000.000000',NULL,'A Flat Loan',NULL,3,'10.000000',3,'10.000000',1,1,1,2,10,1,1,1,'2012-11-02 22:37:14','2012-11-02 22:37:14',1,1),(13,'INR',2,'10000.000000',NULL,'A Flat Loan',NULL,3,'10.000000',3,'10.000000',1,1,1,2,10,1,1,1,'2012-11-02 22:37:14','2012-11-02 22:37:14',1,1),(14,'INR',2,'10000.000000',NULL,'A Flat Loan',NULL,3,'10.000000',3,'10.000000',1,1,1,2,10,1,1,1,'2012-11-02 22:37:14','2012-11-02 22:37:14',1,1),(15,'INR',2,'10000.000000',NULL,'A Flat Loan',NULL,3,'10.000000',3,'10.000000',1,1,1,2,10,1,1,1,'2012-11-02 22:37:14','2012-11-02 22:37:14',1,1),(16,'HKD',2,'10000.000000','10.000000','PlusOne Education Loan','Education loan for higher studies',4,'8.000000',3,'18.000000',0,1,1,2,24,1,1,1,'2012-11-15 05:15:40','2012-12-12 07:32:41',1,NULL),(17,'KES',2,'100000.000000',NULL,'Intrasoft Business Loan','Individual Business Loan',4,'10.000000',2,'24.000000',1,1,1,2,1,1,1,1,'2012-12-07 11:03:57','2013-01-14 10:46:42',25,1),(18,'HKD',2,'1000000.000000',NULL,'POInstalmentLoan','Instalment Loan',4,'5.000000',3,'60.000000',0,1,1,2,120,1,1,1,'2012-12-12 07:30:32','2012-12-12 07:36:04',1,1);
INSERT INTO `m_product_loan` VALUES (1,'HKD',2,'700000.000000',NULL,'PORetailLoan',NULL,4,'5.000000',2,'21.000000',0,1,1,2,120,1,1,1),(2,'LBP',2,'35000.000000','10.000000','Different Loan Type',NULL,NULL,'1.000000',2,'12.000000',0,1,2,1,10,1,1,1),(3,'BND',2,'5000.000000','10.000000','Further Loan Product',NULL,2,'1.500000',2,'18.000000',0,1,1,2,6,0,1,1),(4,'MMK',0,'50000.000000','0.000000','General','General micro-loan',3,'1.250000',2,'36.000000',1,1,1,2,12,1,1,1),(5,'MMK',0,'50000.000000','0.000000','Agricultural','Agricultural micro-loan',4,'1.250000',2,'36.000000',1,1,12,2,2,1,1,1),(6,'MMK',2,'100.000000','10.000000','testloan','testloan from client app',4,'10.000000',2,'120.000000',0,1,1,2,10,0,1,1),(7,'XOF',0,'500.000000','2000.000000','new-lp-test-1','test creating new lp',3,'2.000000',2,'24.000000',0,1,1,2,12,1,1,NULL),(8,'GHC',2,'30000.000000','0.000000','another-test-lp','another test updated.',1,'2.000000',2,'24.000000',0,1,1,2,12,1,1,NULL),(9,'XOF',0,'120000.000000','0.000000','loan product1','loan product1',1,'8.000000',2,'96.000000',0,1,3,2,1233,0,1,NULL),(10,'BND',2,'120000.000000','0.000000','loan product1','loan product1',2,'8.000000',2,'96.000000',0,1,3,2,1233,0,1,NULL),(11,'XOF',2,'3333333.000000','0.000000','Collection100','aaa',4,'30.000000',2,'360.000000',0,1,1,2,2,1,1,NULL),(12,'INR',2,'10000.000000',NULL,'A Flat Loan',NULL,3,'10.000000',3,'10.000000',1,1,1,2,10,1,1,1),(13,'INR',2,'10000.000000',NULL,'A Flat Loan',NULL,3,'10.000000',3,'10.000000',1,1,1,2,10,1,1,1),(14,'INR',2,'10000.000000',NULL,'A Flat Loan',NULL,3,'10.000000',3,'10.000000',1,1,1,2,10,1,1,1),(15,'INR',2,'10000.000000',NULL,'A Flat Loan',NULL,3,'10.000000',3,'10.000000',1,1,1,2,10,1,1,1),(16,'HKD',2,'10000.000000','10.000000','PlusOne Education Loan','Education loan for higher studies',4,'8.000000',3,'18.000000',0,1,1,2,24,1,1,NULL),(17,'KES',2,'100000.000000',NULL,'Intrasoft Business Loan','Individual Business Loan',4,'10.000000',2,'24.000000',1,1,1,2,1,1,1,1),(18,'HKD',2,'1000000.000000',NULL,'POInstalmentLoan','Instalment Loan',4,'5.000000',3,'60.000000',0,1,1,2,120,1,1,1);
/*!40000 ALTER TABLE `m_product_loan` ENABLE KEYS */;
UNLOCK TABLES;
@@ -2071,4 +2063,4 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2013-01-29 12:55:44
-- Dump completed on 2013-01-29 20:20:02
@@ -0,0 +1,11 @@
ALTER TABLE `m_product_loan`
DROP FOREIGN KEY `FKAUD0000000000004` ,
DROP FOREIGN KEY `FKAUD0000000000003` ;
ALTER TABLE `m_product_loan`
DROP COLUMN `lastmodifiedby_id` ,
DROP COLUMN `lastmodified_date` ,
DROP COLUMN `created_date` ,
DROP COLUMN `createdby_id` ,
DROP INDEX `FKAUD0000000000004`,
DROP INDEX `FKAUD0000000000003`;
@@ -34,10 +34,11 @@ import org.mifosplatform.infrastructure.core.serialization.ToApiJsonSerializer;
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
import org.mifosplatform.organisation.office.data.OfficeLookup;
import org.mifosplatform.organisation.office.service.OfficeReadPlatformService;
import org.mifosplatform.portfolio.client.command.ClientCommand;
import org.mifosplatform.portfolio.client.data.ClientAccountSummaryCollectionData;
import org.mifosplatform.portfolio.client.data.ClientData;
import org.mifosplatform.portfolio.client.serialization.ClientCommandFromApiJsonDeserializer;
import org.mifosplatform.portfolio.client.service.ClientReadPlatformService;
import org.mifosplatform.portfolio.savingsaccount.PortfolioApiDataConversionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
@@ -47,8 +48,9 @@ import org.springframework.stereotype.Component;
@Scope("singleton")
public class ClientsApiResource {
private final Set<String> CLIENT_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "accountNo", "officeId", "officeName", "externalId",
"firstname", "middlename", "lastname", "fullname", "joinedDate", "displayName", "clientOrBusinessName", "allowedOffices", "imagePresent"));
private final Set<String> CLIENT_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "accountNo", "officeId", "officeName",
"externalId", "firstname", "middlename", "lastname", "fullname", "joinedDate", "displayName", "clientOrBusinessName",
"allowedOffices", "imagePresent"));
private final PlatformSecurityContext context;
private final ClientReadPlatformService clientReadPlatformService;
@@ -56,24 +58,25 @@ public class ClientsApiResource {
private final ToApiJsonSerializer<ClientData> toApiJsonSerializer;
private final ToApiJsonSerializer<ClientAccountSummaryCollectionData> clientAccountSummaryToApiJsonSerializer;
private final ApiRequestParameterHelper apiRequestParameterHelper;
private final PortfolioApiDataConversionService apiDataConversionService;
private final PortfolioCommandsReadPlatformService commandSourceReadPlatformService;
private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
private final ClientCommandFromApiJsonDeserializer clientCommandFromApiJsonDeserializer;
@Autowired
public ClientsApiResource(final PlatformSecurityContext context, final ClientReadPlatformService readPlatformService,
final OfficeReadPlatformService officeReadPlatformService, final ToApiJsonSerializer<ClientData> toApiJsonSerializer,
final ClientCommandFromApiJsonDeserializer clientCommandFromApiJsonDeserializer,
final ToApiJsonSerializer<ClientAccountSummaryCollectionData> clientAccountSummaryToApiJsonSerializer,
final ApiRequestParameterHelper apiRequestParameterHelper, final PortfolioApiDataConversionService apiDataConversionService,
final ApiRequestParameterHelper apiRequestParameterHelper,
final PortfolioCommandsReadPlatformService commandsReadPlatformService,
final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService) {
this.context = context;
this.clientReadPlatformService = readPlatformService;
this.officeReadPlatformService = officeReadPlatformService;
this.toApiJsonSerializer = toApiJsonSerializer;
this.clientCommandFromApiJsonDeserializer = clientCommandFromApiJsonDeserializer;
this.clientAccountSummaryToApiJsonSerializer = clientAccountSummaryToApiJsonSerializer;
this.apiRequestParameterHelper = apiRequestParameterHelper;
this.apiDataConversionService = apiDataConversionService;
this.commandSourceReadPlatformService = commandsReadPlatformService;
this.commandsSourceWritePlatformService = commandsSourceWritePlatformService;
}
@@ -173,7 +176,10 @@ public class ClientsApiResource {
private ClientData handleRequestToIntegrateProposedChangesFromCommand(final Long clientId, final Long commandId,
final ClientData clientData) {
final CommandSourceData entry = this.commandSourceReadPlatformService.retrieveById(commandId);
final ClientData currentChange = this.apiDataConversionService.convertInternalJsonFormatToClientDataChange(clientId, entry.json());
final ClientCommand command = this.clientCommandFromApiJsonDeserializer.commandFromApiJson(entry.json());
final ClientData currentChange = ClientData.dataChangeInstance(clientId, command.getOfficeId(), command.getExternalId(),
command.getFirstname(), command.getMiddlename(), command.getLastname(), command.getFullname(), command.getJoiningDate());
final Collection<ClientData> dataChanges = null; // retrieveAllUnprocessedDataChanges(clientId);
return ClientData.integrateChanges(clientData, currentChange, dataChanges);
@@ -185,8 +191,10 @@ public class ClientsApiResource {
Collection<CommandSourceData> unprocessedChanges = this.commandSourceReadPlatformService.retrieveUnprocessChangesByEntityNameAndId(
"CLIENT", clientId);
for (CommandSourceData commandSourceData : unprocessedChanges) {
ClientData change = this.apiDataConversionService.convertInternalJsonFormatToClientDataChange(clientId,
commandSourceData.json());
final ClientCommand command = this.clientCommandFromApiJsonDeserializer.commandFromApiJson(commandSourceData.json());
final ClientData change = ClientData
.dataChangeInstance(clientId, command.getOfficeId(), command.getExternalId(), command.getFirstname(),
command.getMiddlename(), command.getLastname(), command.getFullname(), command.getJoiningDate());
dataChanges.add(change);
}
@@ -176,6 +176,9 @@ public class LoanProductsApiResource {
final boolean feeChargesOnly = true;
Collection<ChargeData> chargeOptions = this.chargeReadPlatformService.retrieveLoanApplicableCharges(feeChargesOnly);
chargeOptions.removeAll(productData.charges());
if (chargeOptions.isEmpty()) {
chargeOptions = null;
}
final Collection<CurrencyData> currencyOptions = currencyReadPlatformService.retrieveAllowedCurrencies();
final List<EnumOptionData> amortizationTypeOptions = dropdownReadPlatformService.retrieveLoanAmortizationTypeOptions();
@@ -187,13 +190,25 @@ public class LoanProductsApiResource {
final List<EnumOptionData> interestRateFrequencyTypeOptions = dropdownReadPlatformService
.retrieveInterestRateFrequencyTypeOptions();
final Collection<FundData> fundOptions = this.fundReadPlatformService.retrieveAllFunds();
Collection<FundData> fundOptions = this.fundReadPlatformService.retrieveAllFunds();
if (fundOptions.isEmpty()) {
fundOptions = null;
}
final Collection<TransactionProcessingStrategyData> transactionProcessingStrategyOptions = this.dropdownReadPlatformService
.retreiveTransactionProcessingStrategies();
final List<GLAccountData> assetAccountOptions = accountReadPlatformService.retrieveAllEnabledDetailGLAccounts(GLAccountType.ASSET);
final List<GLAccountData> incomeAccountOptions = accountReadPlatformService.retrieveAllEnabledDetailGLAccounts(GLAccountType.INCOME);;
final List<GLAccountData> expenseAccountOptions = accountReadPlatformService.retrieveAllEnabledDetailGLAccounts(GLAccountType.EXPENSE);;
List<GLAccountData> assetAccountOptions = accountReadPlatformService.retrieveAllEnabledDetailGLAccounts(GLAccountType.ASSET);
if (assetAccountOptions.isEmpty()) {
assetAccountOptions = null;
}
List<GLAccountData> incomeAccountOptions = accountReadPlatformService.retrieveAllEnabledDetailGLAccounts(GLAccountType.INCOME);
if (incomeAccountOptions.isEmpty()) {
incomeAccountOptions = null;
}
List<GLAccountData> expenseAccountOptions = accountReadPlatformService.retrieveAllEnabledDetailGLAccounts(GLAccountType.EXPENSE);
if (expenseAccountOptions.isEmpty()) {
expenseAccountOptions = null;
}
return new LoanProductData(productData, chargeOptions, currencyOptions, amortizationTypeOptions, interestTypeOptions,
interestCalculationPeriodTypeOptions, loanTermFrequencyTypeOptions, repaymentFrequencyTypeOptions,
@@ -5,7 +5,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.joda.time.DateTime;
import org.mifosplatform.accounting.api.data.GLAccountData;
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
import org.mifosplatform.organisation.monetary.data.CurrencyData;
@@ -52,9 +51,6 @@ public class LoanProductData {
private final Collection<ChargeData> charges;
private final DateTime createdOn;
private final DateTime lastModifedOn;
private final Collection<CurrencyData> currencyOptions;
private final Collection<FundData> fundOptions;
private final Collection<TransactionProcessingStrategyData> transactionProcessingStrategyOptions;
@@ -87,8 +83,6 @@ public class LoanProductData {
* Used when returning lookup information about loan product for dropdowns.
*/
public static LoanProductData lookup(final Long id, final String name) {
final DateTime createdOn = null;
final DateTime lastModifedOn = null;
final String description = null;
final CurrencyData currency = null;
final BigDecimal principal = null;
@@ -111,16 +105,13 @@ public class LoanProductData {
final Collection<ChargeData> charges = null;
final Integer accountingType = null;
return new LoanProductData(createdOn, lastModifedOn, id, name, description, currency, principal, tolerance, numberOfRepayments,
loanTermFrequency, repaymentEvery, interestRatePerPeriod, annualInterestRate, loanTermFrequencyType,
repaymentFrequencyType, interestRateFrequencyType, amortizationType, interestType, interestCalculationPeriodType, fundId,
fundName, transactionProcessingStrategyId, transactionProcessingStrategyName, charges, accountingType);
return new LoanProductData(id, name, description, currency, principal, tolerance, numberOfRepayments, loanTermFrequency,
repaymentEvery, interestRatePerPeriod, annualInterestRate, loanTermFrequencyType, repaymentFrequencyType,
interestRateFrequencyType, amortizationType, interestType, interestCalculationPeriodType, fundId, fundName,
transactionProcessingStrategyId, transactionProcessingStrategyName, charges, accountingType);
}
public static LoanProductData sensibleDefaultsForNewLoanProductCreation() {
final DateTime createdOn = null;
final DateTime lastModifedOn = null;
final Long id = null;
final String name = null;
final String description = null;
@@ -146,22 +137,20 @@ public class LoanProductData {
final Collection<ChargeData> charges = null;
final Integer accountingType = 1;
return new LoanProductData(createdOn, lastModifedOn, id, name, description, currency, principal, tolerance, numberOfRepayments,
loanTermFrequency, repaymentEvery, interestRatePerPeriod, annualInterestRate, loanTermFrequencyType,
repaymentFrequencyType, interestRateFrequencyType, amortizationType, interestType, interestCalculationPeriodType, fundId,
fundName, transactionProcessingStrategyId, transactionProcessingStrategyName, charges, accountingType);
return new LoanProductData(id, name, description, currency, principal, tolerance, numberOfRepayments, loanTermFrequency,
repaymentEvery, interestRatePerPeriod, annualInterestRate, loanTermFrequencyType, repaymentFrequencyType,
interestRateFrequencyType, amortizationType, interestType, interestCalculationPeriodType, fundId, fundName,
transactionProcessingStrategyId, transactionProcessingStrategyName, charges, accountingType);
}
public LoanProductData(final DateTime createdOn, final DateTime lastModifedOn, final Long id, final String name,
final String description, final CurrencyData currency, final BigDecimal principal, final BigDecimal tolerance,
final Integer numberOfRepayments, final Integer loanTermFrequency, final Integer repaymentEvery,
final BigDecimal interestRatePerPeriod, final BigDecimal annualInterestRate, final EnumOptionData loanTermFrequencyType,
final EnumOptionData repaymentFrequencyType, final EnumOptionData interestRateFrequencyType,
final EnumOptionData amortizationType, final EnumOptionData interestType, final EnumOptionData interestCalculationPeriodType,
final Long fundId, final String fundName, final Long transactionProcessingStrategyId,
final String transactionProcessingStrategyName, final Collection<ChargeData> charges, final Integer accountingType) {
this.createdOn = createdOn;
this.lastModifedOn = lastModifedOn;
public LoanProductData(final Long id, final String name, final String description, final CurrencyData currency,
final BigDecimal principal, final BigDecimal tolerance, final Integer numberOfRepayments, final Integer loanTermFrequency,
final Integer repaymentEvery, final BigDecimal interestRatePerPeriod, final BigDecimal annualInterestRate,
final EnumOptionData loanTermFrequencyType, final EnumOptionData repaymentFrequencyType,
final EnumOptionData interestRateFrequencyType, final EnumOptionData amortizationType, final EnumOptionData interestType,
final EnumOptionData interestCalculationPeriodType, final Long fundId, final String fundName,
final Long transactionProcessingStrategyId, final String transactionProcessingStrategyName,
final Collection<ChargeData> charges, final Integer accountingType) {
this.id = id;
this.name = name;
this.description = description;
@@ -210,8 +199,6 @@ public class LoanProductData {
final Collection<TransactionProcessingStrategyData> transactionProcessingStrategyOptions,
final List<GLAccountData> assetAccountOptions, final List<GLAccountData> incomeAccountOptions,
final List<GLAccountData> expenseAccountOptions) {
this.createdOn = productData.createdOn;
this.lastModifedOn = productData.lastModifedOn;
this.id = productData.id;
this.name = productData.name;
this.description = productData.description;
@@ -232,7 +219,7 @@ public class LoanProductData {
this.fundName = productData.fundName;
this.transactionProcessingStrategyId = productData.transactionProcessingStrategyId;
this.transactionProcessingStrategyName = productData.transactionProcessingStrategyName;
this.charges = productData.charges();
this.charges = nullIfEmpty(productData.charges());
this.accountingType = productData.accountingType;
this.chargeOptions = chargeOptions;
@@ -256,6 +243,14 @@ public class LoanProductData {
this.expenseAccountOptions = expenseAccountOptions;
}
private Collection<ChargeData> nullIfEmpty(final Collection<ChargeData> charges) {
Collection<ChargeData> chargesLocal = charges;
if (charges == null || charges.isEmpty()) {
chargesLocal = null;
}
return chargesLocal;
}
public Collection<ChargeData> charges() {
Collection<ChargeData> chargesLocal = new ArrayList<ChargeData>();
if (this.charges != null) {
@@ -348,14 +343,6 @@ public class LoanProductData {
return interestCalculationPeriodType;
}
public DateTime getCreatedOn() {
return createdOn;
}
public DateTime getLastModifedOn() {
return lastModifedOn;
}
public Collection<FundData> getFundOptions() {
return fundOptions;
}
@@ -479,5 +466,4 @@ public class LoanProductData {
public Integer getAccountingType() {
return this.accountingType;
}
}
@@ -17,12 +17,11 @@ import javax.persistence.Table;
import org.apache.commons.lang.StringUtils;
import org.mifosplatform.infrastructure.core.api.JsonCommand;
import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom;
import org.mifosplatform.organisation.monetary.domain.MonetaryCurrency;
import org.mifosplatform.portfolio.charge.domain.Charge;
import org.mifosplatform.portfolio.fund.domain.Fund;
import org.mifosplatform.portfolio.loanaccount.loanschedule.domain.AprCalculator;
import org.mifosplatform.useradministration.domain.AppUser;
import org.springframework.data.jpa.domain.AbstractPersistable;
/**
* Loan products allow for categorisation of an organisations loans into
@@ -35,7 +34,7 @@ import org.mifosplatform.useradministration.domain.AppUser;
*/
@Entity
@Table(name = "m_product_loan")
public class LoanProduct extends AbstractAuditableCustom<AppUser, Long> {
public class LoanProduct extends AbstractPersistable<Long> {
@ManyToOne
@JoinColumn(name = "fund_id", nullable = true)
@@ -5,7 +5,6 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collection;
import org.joda.time.DateTime;
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
@@ -29,10 +28,8 @@ public class LoanProductReadPlatformServiceImpl implements LoanProductReadPlatfo
private final ChargeReadPlatformService chargeReadPlatformService;
@Autowired
public LoanProductReadPlatformServiceImpl(
final PlatformSecurityContext context,
final ChargeReadPlatformService chargeReadPlatformService,
final TenantAwareRoutingDataSource dataSource) {
public LoanProductReadPlatformServiceImpl(final PlatformSecurityContext context,
final ChargeReadPlatformService chargeReadPlatformService, final TenantAwareRoutingDataSource dataSource) {
this.context = context;
this.chargeReadPlatformService = chargeReadPlatformService;
this.jdbcTemplate = new JdbcTemplate(dataSource);
@@ -47,7 +44,6 @@ public class LoanProductReadPlatformServiceImpl implements LoanProductReadPlatfo
final LoanProductMapper rm = new LoanProductMapper(charges);
final String sql = "select " + rm.loanProductSchema() + " where lp.id = ?";
return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { loanProductId });
} catch (EmptyResultDataAccessException e) {
@@ -74,7 +70,7 @@ public class LoanProductReadPlatformServiceImpl implements LoanProductReadPlatfo
final LoanProductLookupMapper rm = new LoanProductLookupMapper();
final String sql = "select " + rm.loanProductLookupSchema();
final String sql = "select " + rm.schema();
return this.jdbcTemplate.query(sql, rm, new Object[] {});
}
@@ -84,8 +80,7 @@ public class LoanProductReadPlatformServiceImpl implements LoanProductReadPlatfo
return LoanProductData.sensibleDefaultsForNewLoanProductCreation();
}
private static final class LoanProductMapper implements
RowMapper<LoanProductData> {
private static final class LoanProductMapper implements RowMapper<LoanProductData> {
private final Collection<ChargeData> charges;
@@ -101,7 +96,7 @@ public class LoanProductReadPlatformServiceImpl implements LoanProductReadPlatfo
+ "lp.annual_nominal_interest_rate as annualInterestRate, lp.interest_method_enum as interestMethod, lp.interest_calculated_in_period_enum as interestCalculationInPeriodMethod,"
+ "lp.repay_every as repaidEvery, lp.repayment_period_frequency_enum as repaymentPeriodFrequency, lp.number_of_repayments as numberOfRepayments, "
+ "lp.amortization_method_enum as amortizationMethod, lp.arrearstolerance_amount as tolerance, "
+ "lp.created_date as createdon, lp.lastmodified_date as modifiedon, lp.accounting_type as accountingType, "
+ "lp.accounting_type as accountingType, "
+ "curr.name as currencyName, curr.internationalized_name_code as currencyNameCode, curr.display_symbol as currencyDisplaySymbol "
+ " from m_product_loan lp "
+ " left join m_fund f on f.id = lp.fund_id"
@@ -110,8 +105,7 @@ public class LoanProductReadPlatformServiceImpl implements LoanProductReadPlatfo
}
@Override
public LoanProductData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum)
throws SQLException {
public LoanProductData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
final Long id = rs.getLong("id");
final String name = rs.getString("name");
@@ -127,8 +121,7 @@ public class LoanProductReadPlatformServiceImpl implements LoanProductReadPlatfo
final String currencyDisplaySymbol = rs.getString("currencyDisplaySymbol");
final Integer currencyDigits = JdbcSupport.getInteger(rs, "currencyDigits");
final CurrencyData currency = new CurrencyData(currencyCode,
currencyName, currencyDigits, currencyDisplaySymbol,
final CurrencyData currency = new CurrencyData(currencyCode, currencyName, currencyDigits, currencyDisplaySymbol,
currencyNameCode);
final BigDecimal principal = rs.getBigDecimal("principal");
@@ -156,31 +149,25 @@ public class LoanProductReadPlatformServiceImpl implements LoanProductReadPlatfo
final EnumOptionData interestType = LoanEnumerations.interestType(interestTypeId);
final int interestCalculationPeriodTypeId = JdbcSupport.getInteger(rs, "interestCalculationInPeriodMethod");
final EnumOptionData interestCalculationPeriodType = LoanEnumerations.interestCalculationPeriodType(interestCalculationPeriodTypeId);
final EnumOptionData interestCalculationPeriodType = LoanEnumerations
.interestCalculationPeriodType(interestCalculationPeriodTypeId);
final DateTime createdOn = JdbcSupport.getDateTime(rs, "createdon");
final DateTime lastModifedOn = JdbcSupport.getDateTime(rs, "modifiedon");
return new LoanProductData(createdOn, lastModifedOn, id, name,
description, currency, principal, tolerance,
numberOfRepayments, loanTermFrequency, repaymentEvery, interestRatePerPeriod,
annualInterestRate, loanTermFrequencyType, repaymentFrequencyType,
interestRateFrequencyType, amortizationType, interestType,
interestCalculationPeriodType, fundId, fundName, transactionStrategyId, transactionStrategyName, this.charges, accountingType);
return new LoanProductData(id, name, description, currency, principal, tolerance, numberOfRepayments, loanTermFrequency,
repaymentEvery, interestRatePerPeriod, annualInterestRate, loanTermFrequencyType, repaymentFrequencyType,
interestRateFrequencyType, amortizationType, interestType, interestCalculationPeriodType, fundId, fundName,
transactionStrategyId, transactionStrategyName, this.charges, accountingType);
}
}
private static final class LoanProductLookupMapper implements
RowMapper<LoanProductData> {
private static final class LoanProductLookupMapper implements RowMapper<LoanProductData> {
public String loanProductLookupSchema() {
public String schema() {
return "lp.id as id, lp.name as name from m_product_loan lp";
}
@Override
public LoanProductData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum)
throws SQLException {
public LoanProductData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
final Long id = rs.getLong("id");
final String name = rs.getString("name");
@@ -1,6 +1,5 @@
package org.mifosplatform.portfolio.savingsaccount;
import org.mifosplatform.portfolio.client.data.ClientData;
import org.mifosplatform.portfolio.group.command.GroupCommand;
import org.mifosplatform.portfolio.savingsaccount.command.SavingAccountApprovalCommand;
import org.mifosplatform.portfolio.savingsaccount.command.SavingAccountCommand;
@@ -21,8 +20,6 @@ public interface PortfolioApiDataConversionService {
DepositProductCommand convertJsonToDepositProductCommand(Long resourceIdentifier, String json);
ClientData convertInternalJsonFormatToClientDataChange(Long clientId, String json);
GroupCommand convertJsonToGroupCommand(Long resourceIdentifier, String json);
DepositAccountCommand convertJsonToDepositAccountCommand(Long resourceIdentifier, String json);
@@ -21,9 +21,6 @@ import org.mifosplatform.infrastructure.core.data.ApiParameterError;
import org.mifosplatform.infrastructure.core.exception.InvalidJsonException;
import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException;
import org.mifosplatform.infrastructure.core.exception.UnsupportedParameterException;
import org.mifosplatform.portfolio.client.command.ClientCommand;
import org.mifosplatform.portfolio.client.data.ClientData;
import org.mifosplatform.portfolio.client.serialization.ClientCommandFromApiJsonDeserializer;
import org.mifosplatform.portfolio.group.command.GroupCommand;
import org.mifosplatform.portfolio.savingsaccount.command.SavingAccountApprovalCommand;
import org.mifosplatform.portfolio.savingsaccount.command.SavingAccountCommand;
@@ -37,7 +34,6 @@ import org.mifosplatform.portfolio.savingsdepositaccount.command.DepositAccountW
import org.mifosplatform.portfolio.savingsdepositaccount.command.DepositStateTransitionApprovalCommand;
import org.mifosplatform.portfolio.savingsdepositaccount.command.DepositStateTransitionCommand;
import org.mifosplatform.portfolio.savingsdepositproduct.command.DepositProductCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.number.NumberFormatter;
import org.springframework.stereotype.Service;
@@ -56,23 +52,10 @@ public class PortfolioApiDataConversionServiceImpl implements PortfolioApiDataCo
*/
private final Gson gsonConverter;
private final ClientCommandFromApiJsonDeserializer clientCommandFromApiJsonDeserializer;
@Autowired
public PortfolioApiDataConversionServiceImpl(final ClientCommandFromApiJsonDeserializer clientCommandFromApiJsonDeserializer) {
this.clientCommandFromApiJsonDeserializer = clientCommandFromApiJsonDeserializer;
public PortfolioApiDataConversionServiceImpl() {
this.gsonConverter = new Gson();
}
@Override
public ClientData convertInternalJsonFormatToClientDataChange(final Long resourceIdentifier, final String json) {
final ClientCommand command = this.clientCommandFromApiJsonDeserializer.commandFromApiJson(json);
return ClientData.dataChangeInstance(resourceIdentifier, command.getOfficeId(), command.getExternalId(), command.getFirstname(),
command.getMiddlename(), command.getLastname(), command.getFullname(), command.getJoiningDate());
}
@Override
public GroupCommand convertJsonToGroupCommand(final Long resourceIdentifier, final String json) {
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
@@ -815,9 +798,9 @@ public class PortfolioApiDataConversionServiceImpl implements PortfolioApiDataCo
// currencyCode, currencyDigits
Set<String> supportedParams = new HashSet<String>(Arrays.asList("clientId", "productId", "externalId", "currencyCode",
"digitsAfterDecimal", "savingsDepositAmountPerPeriod", "recurringInterestRate", "savingInterestRate", "tenure",
"commencementDate", "locale", "dateFormat", "isLockinPeriodAllowed", "lockinPeriod", "lockinPeriodType",
"tenureType", "depositfrequency", "interestType", "interestCalculationMethod", "minimumBalanceForWithdrawal",
"isPartialDepositAllowed", "depositEvery","interestPostEvery","interestPostFrequency"));
"commencementDate", "locale", "dateFormat", "isLockinPeriodAllowed", "lockinPeriod", "lockinPeriodType", "tenureType",
"depositfrequency", "interestType", "interestCalculationMethod", "minimumBalanceForWithdrawal", "isPartialDepositAllowed",
"depositEvery", "interestPostEvery", "interestPostFrequency"));
checkForUnsupportedParameters(requestMap, supportedParams);
Set<String> modifiedParameters = new HashSet<String>();
@@ -849,11 +832,10 @@ public class PortfolioApiDataConversionServiceImpl implements PortfolioApiDataCo
return new SavingAccountCommand(modifiedParameters, resourceIdentifier, clientId, productId, externalId, currencyCode,
digitsAfterDecimalValue, savingsDepositAmount, recurringInterestRate, savingInterestRate, tenure, commencementDate,
tenureType, depositfrequency, interestType, minimumBalanceForWithdrawal, interestCalculationMethod,
isLockinPeriodAllowed, isPartialDepositAllowed, lockinPeriod, lockinPeriodType, depositEvery, interestPostEvery, interestPostFrequency);
tenureType, depositfrequency, interestType, minimumBalanceForWithdrawal, interestCalculationMethod, isLockinPeriodAllowed,
isPartialDepositAllowed, lockinPeriod, lockinPeriodType, depositEvery, interestPostEvery, interestPostFrequency);
}
@Override
public SavingStateTransitionsCommand convertJsonToSavingStateTransitionCommand(Long accountId, String json) {
@@ -883,15 +865,16 @@ public class PortfolioApiDataConversionServiceImpl implements PortfolioApiDataCo
Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
Map<String, Object> requestMap = gsonConverter.fromJson(json, typeOfMap);
Set<String> supportedParams = new HashSet<String>(Arrays.asList("locale", "dateFormat", "commencementDate", "savingsDepositAmountPerPeriod",
"minimumBalanceForWithdrawal", "recurringInterestRate", "savingInterestRate", "interestType", "tenure", "tenureType", "frequency", "payEvery", "note",
"interestPostEvery", "interestPostFrequency"));
Set<String> supportedParams = new HashSet<String>(Arrays.asList("locale", "dateFormat", "commencementDate",
"savingsDepositAmountPerPeriod", "minimumBalanceForWithdrawal", "recurringInterestRate", "savingInterestRate",
"interestType", "tenure", "tenureType", "frequency", "payEvery", "note", "interestPostEvery", "interestPostFrequency"));
checkForUnsupportedParameters(requestMap, supportedParams);
Set<String> modifiedParameters = new HashSet<String>();
LocalDate commencementDate = extractLocalDateParameter("commencementDate", requestMap, modifiedParameters);
BigDecimal savingsDepositAmountPerPeriod = extractBigDecimalParameter("savingsDepositAmountPerPeriod", requestMap, modifiedParameters);
BigDecimal savingsDepositAmountPerPeriod = extractBigDecimalParameter("savingsDepositAmountPerPeriod", requestMap,
modifiedParameters);
BigDecimal minimumBalanceForWithdrawal = extractBigDecimalParameter("minimumBalanceForWithdrawal", requestMap, modifiedParameters);
BigDecimal recurringInterestRate = extractBigDecimalParameter("recurringInterestRate", requestMap, modifiedParameters);
BigDecimal savingInterestRate = extractBigDecimalParameter("savingInterestRate", requestMap, modifiedParameters);
@@ -903,8 +886,9 @@ public class PortfolioApiDataConversionServiceImpl implements PortfolioApiDataCo
String note = extractStringParameter("note", requestMap, modifiedParameters);
Integer interestPostEvery = extractIntegerParameter("interestPostEvery", requestMap, modifiedParameters);
Integer interestPostFrequency = extractIntegerParameter("interestPostFrequency", requestMap, modifiedParameters);
return new SavingAccountApprovalCommand(accountId, commencementDate, savingsDepositAmountPerPeriod, minimumBalanceForWithdrawal, recurringInterestRate,
savingInterestRate, interestType, tenure, tenureType, frequency, payEvery, note, interestPostEvery, interestPostFrequency);
return new SavingAccountApprovalCommand(accountId, commencementDate, savingsDepositAmountPerPeriod, minimumBalanceForWithdrawal,
recurringInterestRate, savingInterestRate, interestType, tenure, tenureType, frequency, payEvery, note, interestPostEvery,
interestPostFrequency);
}
@Override
@@ -914,13 +898,15 @@ public class PortfolioApiDataConversionServiceImpl implements PortfolioApiDataCo
Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
Map<String, Object> requestMap = gsonConverter.fromJson(json, typeOfMap);
Set<String> supportedParams = new HashSet<String>(Arrays.asList("locale", "dateFormat", "depositDate", "savingsDepositAmountPerPeriod", "note"));
Set<String> supportedParams = new HashSet<String>(Arrays.asList("locale", "dateFormat", "depositDate",
"savingsDepositAmountPerPeriod", "note"));
checkForUnsupportedParameters(requestMap, supportedParams);
Set<String> modifiedParameters = new HashSet<String>();
LocalDate depositDate = extractLocalDateParameter("depositDate", requestMap, modifiedParameters);
BigDecimal savingsDepositAmountPerPeriod = extractBigDecimalParameter("savingsDepositAmountPerPeriod", requestMap, modifiedParameters);
BigDecimal savingsDepositAmountPerPeriod = extractBigDecimalParameter("savingsDepositAmountPerPeriod", requestMap,
modifiedParameters);
String note = extractStringParameter("note", requestMap, modifiedParameters);
return new SavingAccountDepositCommand(accountId, savingsDepositAmountPerPeriod, depositDate, note);
}