Skip to content

Commit

Permalink
Merge pull request openMF#852 from rajuan/dedup
Browse files Browse the repository at this point in the history
Client Dedupliction with Weightages
  • Loading branch information
pramodn02 authored Feb 7, 2017
2 parents 4bef02f + b8d9b24 commit b932642
Show file tree
Hide file tree
Showing 10 changed files with 394 additions and 4 deletions.
23 changes: 23 additions & 0 deletions app/global-translations/locale-en.json
Original file line number Diff line number Diff line change
Expand Up @@ -5520,6 +5520,29 @@
"label.heading.editloanemipack":"Edit EMI Pack",
"label.input.filterbytext":"Filter by Text",
"label.heading.chooseloanemipack":"Choose EMI Pack",
"label.heading.possible.duplicate.matches":"There are possible duplicate matches, Review and choose Force Create to Activate",
"label.input.force.activate":"Force Activate",
"label.input.choose.client":"Choose Client for Compare",
"label.heading.current.client":"Current Client",
"label.heading.client.possible.match":"Client Possible Match",
"label.anchor.dedup":"Client Deduplication Weightages",
"label.anchor.dedup.description":"Manage Client attribute match weightages for Client Deduplication",
"label.heading.weightagesperson":"Weightages for Person",
"label.heading.weightagesentity":"Weightages for Entity",
"label.input.firstnameExact":"First Name Exact Match",
"label.input.firstnameLike":"First Name Like Match",
"label.input.middlenameExact":"Middle Name Exact Match",
"label.input.middlenameLike":"Middle Name Like Match",
"label.input.lastnameExact":"Last Name Exact Match",
"label.input.lastnameLike":"Last Name Like Match",
"label.input.fullnameExact":"Full Name Exact Match",
"label.input.fullnameLike":"Full Name Like Match",
"label.input.mobileNo":"Mobile Number Match",
"label.input.dateOfBirth":"Date of Birth Match",
"label.input.genderCvId":"Gender Match",
"label.input.incorpNo":"Incorporation Number Match",
"label.input.clientIdentifier":"Identifiers Match",
"label.heading.matchcriteria":"Matching Criteria",
"label.button.changeemipack":"Change EMI Pack",
"label.input.brokenperiodmethodtype":"Initial broken-period interest computation",
"label.heading.brokenperiodmethodtype":"Initial broken-period interest computation",
Expand Down
78 changes: 76 additions & 2 deletions app/scripts/controllers/client/ClientActionsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,21 @@

switch (scope.action) {
case "activate":
resourceFactory.clientResource.get({clientId: routeParams.id}, function (data) {
resourceFactory.clientResourceTemplate.getActivateTemplate({clientId: routeParams.id, command : 'activate'}, function (data) {
scope.client = data;
if (data.timeline.submittedOnDate) {
scope.mindate = new Date(data.timeline.submittedOnDate);
}
if(scope.client.possibleClientMatches){
resourceFactory.clientIdenfierResource.getAll({clientId:scope.client.id}, function(data){
if(data){
scope.clientIdentities = data.sort(function(a,b) {
return (a.documentType.id > b.documentType.id) ? 1
: ((b.documentType.id > a.documentType.id) ? -1 : 0);} );
scope.client.identitiesCompiled = compileDocuments(scope.clientIdentities);
}
});
}
});
scope.labelName = 'label.input.activationdate';
scope.breadcrumbName = 'label.anchor.activate';
Expand Down Expand Up @@ -176,6 +186,70 @@
location.path('/viewclient/' + routeParams.id);
}

scope.matchClient = function(clientId){
if(scope.client.possibleClientMatches){
var len = scope.client.possibleClientMatches.length;
for(var i=0; i<len; i++){
if(scope.client.possibleClientMatches[i].id === clientId){
scope.possibleMatch = scope.client.possibleClientMatches[i];
break;
}
}
}
if(scope.possibleMatch){
scope.client.identitiesCompiled = compileDocuments(scope.clientIdentities);
resourceFactory.clientIdenfierResource.getAll({clientId:scope.possibleMatch.id}, function(data){
if(data){
scope.possibleMatchIdentities = data.sort(function(a,b) {
return (a.documentType.id > b.documentType.id) ? 1
: ((b.documentType.id > a.documentType.id) ? -1 : 0);} );
scope.possibleMatch.identitiesCompiled = "";
var len = scope.possibleMatchIdentities.length;
for(var i=0; i<scope.clientIdentities.length; i++){
var index = containsDocumentType(scope.possibleMatchIdentities,scope.clientIdentities[i]);
if(index < 0){
scope.possibleMatch.identitiesCompiled += "&nbsp;<br/>";
}else{
scope.possibleMatch.identitiesCompiled = scope.possibleMatch.identitiesCompiled
.concat('<b>',scope.possibleMatchIdentities[index].documentType.name, '</b> : ',
scope.possibleMatchIdentities[index].documentKey, '<br/>');
scope.possibleMatchIdentities.splice(index,1);
}
}
scope.possibleMatch.identitiesCompiled += compileDocuments(scope.possibleMatchIdentities);
for(var i=0; i < scope.clientIdentities.length; i++){
if(scope.possibleMatch.identitiesCompiled.indexOf(scope.clientIdentities[i].documentKey) >= 0){
scope.possibleMatch.identitiesCompiled = scope.possibleMatch.identitiesCompiled
.replace(scope.clientIdentities[i].documentKey,
'<span class=highlight>'+scope.clientIdentities[i].documentKey+'</span>');
scope.client.identitiesCompiled = scope.client.identitiesCompiled
.replace(scope.clientIdentities[i].documentKey,
'<span class=highlight>'+scope.clientIdentities[i].documentKey+'</span>');
}
}
}
});
}
}

function compileDocuments(data) {
var len = data.length;
var str = "";
for (var i = 0; i < len; i++) {
str = str.concat('<b>', data[i].documentType.name, '</b> : ', data[i].documentKey,'<br/>');
}
return str;
}

function containsDocumentType(a, obj) {
for (var i = 0; i < a.length; i++) {
if (a[i].documentType.id === obj.documentType.id) {
return i;
}
}
return -1;
}

scope.submit = function () {
this.formData.locale = scope.optlang.code;
this.formData.dateFormat = scope.df;
Expand All @@ -185,7 +259,7 @@

if (scope.action == "activate") {
var queryParams = {clientId: routeParams.id, command: 'activate'};
if(scope.forcedSubmit){
if(scope.forcedSubmit || scope.forceActivate){
queryParams = {clientId: routeParams.id, command: 'forceActivate'};
}
resourceFactory.clientResource.save(queryParams, this.formData, function (data) {
Expand Down
41 changes: 41 additions & 0 deletions app/scripts/controllers/configurations/DedupController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
(function (module) {
mifosX.controllers = _.extend(module, {
DedupController: function (scope, resourceFactory, location, route) {
scope.data = {};
scope.editPerson = false;
scope.editEntity = false;
resourceFactory.dedupResource.get(function (data) {
scope.data = data;
if(data[0].legalForm === 1){
scope.person = data[0];
}else{
scope.entity = data[0];
}

if(data[1].legalForm === 1){
scope.person = data[1];
}else{
scope.entity = data[1];
}
});

scope.updatePerson = function () {
scope.person.locale = scope.optlang.code;
resourceFactory.dedupResource.update({id:1}, scope.person, function(data){
route.reload();
})
};

scope.updateEntity = function () {
scope.entity.locale = scope.optlang.code;
resourceFactory.dedupResource.update({id:2}, scope.entity, function(data){
route.reload();
})
};

}
});
mifosX.ng.application.controller('DedupController', ['$scope', 'ResourceFactory', '$location', '$route', mifosX.controllers.DedupController]).run(function ($log) {
$log.info("DedupController initialized");
});
}(mifosX.controllers || {}));
3 changes: 2 additions & 1 deletion app/scripts/mifosXComponents.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,8 @@ define(['Q', 'underscore', 'mifosX'], function (Q) {
'organization/funds/ViewFundController',
'organization/funds/EditFundController',
'organization/funds/AssignFundController',
'main/AdvancedSearchController'
'main/AdvancedSearchController',
'configurations/DedupController'
],
filters: [
'StatusLookup',
Expand Down
3 changes: 3 additions & 0 deletions app/scripts/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -1457,6 +1457,9 @@
.when('/addloanemipacks/:loanProductId', {
templateUrl: 'views/products/loanemipacks/addloanemipacks.html'
})
.when('/dedup', {
templateUrl: 'views/administration/dedup.html'
})
.when('/editloanemipacks/:loanProductId/:loanEMIPackId', {
templateUrl: 'views/products/loanemipacks/editloanemipacks.html'
})
Expand Down
10 changes: 9 additions & 1 deletion app/scripts/services/ResourceFactoryProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
getAllClientDocuments: {method: 'GET', params: {}, isArray: true},
update: { method: 'PUT'}
}),
clientResourceTemplate: defineResource(apiVer + "/clients/:clientId/template", {clientId: '@clientId', command: '@command'}, {
getActivateTemplate: {method: 'GET', params: {command : 'activate'}}
}),
clientChargesResource: defineResource(apiVer + "/clients/:clientId/charges/:resourceType", {clientId: '@clientId', resourceType: '@resourceType'}, {
getCharges: {method: 'GET'},
waive:{method:'POST' , params:{command : 'waive'}}
Expand Down Expand Up @@ -98,7 +101,8 @@
get: {method: 'GET', params: {}}
}),
clientIdenfierResource: defineResource(apiVer + "/clients/:clientId/identifiers/:id", {clientId: '@clientId', id: '@id'}, {
get: {method: 'GET', params: {}}
get: {method: 'GET', params: {}},
getAll:{method: 'GET', params: {}, isArray:true}
}),
surveyTemplateResource: defineResource(apiVer + "/surveys/template", {}, {
get: {method: 'GET', params: {}}
Expand Down Expand Up @@ -500,6 +504,10 @@
get: {method: 'GET', params: {}},
update: {method: 'PUT', params: {}}
}),
dedupResource: defineResource(apiVer + "/clientdedup/weightages/:id", {id: '@id'}, {
get: {method: 'GET', params: {}, isArray: true},
update: {method: 'PUT', params: {}}
}),
cacheResource: defineResource(apiVer + "/caches", {}, {
get: {method: 'GET', params: {}, isArray: true},
update: {method: 'PUT', params: {}}
Expand Down
4 changes: 4 additions & 0 deletions app/styles/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -1622,4 +1622,8 @@ figure {

.statusreject {
color:red;
}

.highlight {
background-color:#98FB98;
}
Loading

0 comments on commit b932642

Please sign in to comment.