UGD_FinalDoc

This page documents the final Template Service & User Generated Documents API etc. Some of this was on other related pages during development, but it's just being pulled together here. We expect this will eventually be integrated into the API Documentation (and may some end-user documentation for the UI, if there is any?) - by who & when?

Template Service API

TBD Andreas, do you want to fill this in some time? Probably just cut & paste from that other page...

Template Service Example/Demo

May be our first blog post with the initial live screencast demo is of interest. TBD Related Postman Collection Scripts are here. Here are the steps used (remember to set Content-type: application/json):

1. Create first template (without Mappers): POST this to https://localhost:8443/mifosng-provider/api/v1/templates?username=mifos&password=password&tenantIdentifier=default (and note the returned resourceId):

    {"text":"I, <b>{{client.fullname}}</b> adhere to the terms laid out by <b>{{tenantName}}</b> and enroll on <b>{{client.activationDate}}</b>",
"name":"Demo Template without Mappers"}

2. Use first template (without Mappers); POST this to https://localhost:8443/mifosng-provider/api/v1/templates/1?username=mifos&password=password&tenantIdentifier=default

    {"client": {"fullname": "John Doe", "activationDate": "2013/08/11"}, "tenantName": "your MFI"}

3. Create second template (with Mifos internal Mapper): POST this to https://localhost:8443/mifosng-provider/api/v1/templates?username=mifos&password=password&tenantIdentifier=default

    { "name":"Demo Template with a Mapper",
"mappers": {"client":"clients/{{clientId}}?tenantIdentifier=default"},
"text": "I, <b>{{client.firstname}} {{client.lastname}}</b> adhere to the terms laid out by MFI <b>{{tenantIdentifier}}</b>
and enroll on <b>{{client.activationDate}}</b>. {{additionalNonPersistedTextForCustomMessage}}" }

4. Use second template (with Mifos internal Mapper); POST this to https://localhost:8443/mifosng-provider/api/v1/templates/2?username=mifos&password=password&tenantIdentifier=default

    {"clientId": "1", "additionalNonPersistedTextForCustomMessage": "Thank you"}

5. Create third template (with two Mappers, and using a helper function): POST this to https://localhost:8443/mifosng-provider/api/v1/templates?username=mifos&password=password&tenantIdentifier=default

    {"name": "Third demo Template, with now and two Mappers", 
"mappers": { "client":"clients/{{clientId}}?tenantIdentifier={{tenantIdentifier}}",
"weather":"http://api.openweathermap.org/data/2.5/weather?q=Bangalore&units=metric"},
"text": "I, <b>{{client.firstname}} {{client.lastname}}</b> adhere to the terms laid out by... <b>{{tenantIdentifier}}</b>
and enrolled on <b>{{client.activationDate}}</b>
<p>The current temparature in Bangalore (or some other information obtained from Mifos from another system with a REST interface, say some CRM)
is {{weather.main.temp}} °C!
<p><i>(document printed on {{static.now}})</i>" }

6. Use second template (with two Mappers, and using a helper function); POST this to https://localhost:8443/mifosng-provider/api/v1/templates/3?username=mifos&password=password&tenantIdentifier=default 

    {"clientId": "1"}

 


User Generated Documents UI End-User usage documentation

TBD

User Generated Document Out-of-the-Box (OOB) Example #1: Loan Schedule table + Image

This isn't 100% final yet. because fields are missing... who can help us get this 100% done?

This can be loaded into a Mifos X demo DB either by manually copy/pasting the name/mappers/text src, or via a some REST tool like Postman (remember to set Content-type: application/json).

It should then go into Git to be "pre-loaded" into DB - as the first example template (of hopefully more to come?) :
{
  "name": "Example Loan Schedule",
  "entity": "loan",
  "type": "Document",
  "text": "
<p><img alt="" src="{{image.src}}" style="width: 100px; height: 100px;" />&nbsp;</p>
<table border="0" cellpadding="1" cellspacing="1" style="height:112px; width:720px">
	<tbody>
		<tr>
			<td colspan="6" style="background-color:rgb(66, 139, 202)">MFI Information</td>
		</tr>
		<tr>
			<td colspan="2">Branch:</td>
			<td>Center:</td>
			<td colspan="3">Center ID: {{loan.clientOfficeId}}</td>
		</tr>
		<tr>
			<td colspan="2">Client ID: {{loan.clientID}}</td>
			<td>System ID:</td>
			<td colspan="3">&nbsp;</td>
		</tr>
		<tr>
			<td colspan="2">Recruited By:</td>
			<td colspan="4" style="text-align:right">Loan officer: {{loan.loanOfficerName}}</td>
		</tr>
		<tr>
			<td colspan="2">&nbsp;</td>
			<td colspan="4">&nbsp;</td>
		</tr>
		<tr>
			<td colspan="6" style="background-color:rgb(66, 139, 202)">Member&#39;s Information</td>
		</tr>
		<tr>
			<td>Client Name:{{loan.clientName}}</td>
			<td>Spouse Name:</td>
			<td colspan="4">Government ID:</td>
		</tr>
		<tr>
			<td colspan="2">Address:</td>
			<td colspan="4">&nbsp;</td>
		</tr>
		<tr>
			<td colspan="2">Telephone:</td>
			<td colspan="4">&nbsp;</td>
		</tr>
		<tr>
			<td colspan="2">&nbsp;</td>
			<td colspan="4">&nbsp;</td>
		</tr>
		<tr>
			<td colspan="6" style="background-color:rgb(66, 139, 202)">Loan Information</td>
		</tr>
		<tr>
			<td colspan="6"><strong>Loan ID: {{loan.id}}</strong></td>
		</tr>
		<tr>
			<td>Amount: {{loan.principal}}</td>
			<td>Disbursal {{loan.actualDisbursementDate}}</td>
			<td>Fees:{{loan.feeChargesAtDisbursementCharged}}</td>
			<td colspan="3" rowspan="1">Annual Subscription Fee:</td>
		</tr>
		<tr>
			<td>Total EMI:</td>
			<td>Rate of Interest: {{loan.interestRatePerPeriod}}</td>
			<td colspan="4" rowspan="1">&nbsp;</td>
		</tr>
	</tbody>
</table>

<p>&nbsp;</p>

<table border="1" cellpadding="0" cellspacing="0" style="width:720px">
	<tbody>
		<tr>
			<td style="text-align:center"><strong>Installment</strong></td>
			<td style="text-align:center"><strong>DueDate</strong></td>
			<td style="text-align:center"><strong>Principal</strong></td>
			<td style="text-align:center"><strong>Interest</strong></td>
			<td style="text-align:center"><strong>Fees</strong></td>
			<td style="text-align:center"><strong>Total</strong></td>
			<td style="text-align:center"><strong>Amt Rec.</strong></td>
			<td style="text-align:center"><strong>Sign RO</strong></td>
			<td style="text-align:center"><strong>Sign Client</strong></td>
		</tr>
		{{#loan.repaymentSchedule.periods}}
		<tr>
			<td>{{period}}</td>
			<td><date>{{dueDate}}</date></td>
			<td>{{principalDisbursed}}</td>
			<td><date format="yy-mm-dd">{{dueDate}}</date></td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
		</tr>
		{{/loan.repaymentSchedule.periods}}
	</tbody>
</table>
",
  "mappers": [
    {
      "mapperorder": 0,
      "mapperkey": "loan",
      "mappervalue": "loans/{{loanId}}?associations=all&tenantIdentifier=default",
      "id": 42
    },
    {
      "mapperorder": 1,
      "mapperkey": "client",
      "mappervalue": "clients/{{loan.clientId}}?tenantIdentifier={{tenantIdentifier}}",
      "id": 43
    },
    {
      "mapperorder": 2,
      "mapperkey": "image",
      "mappervalue": "clients/{{loan.clientId}}/images?tenantIdentifier=default",
      "id": 44
    }
  ],
  "id": 4
}