Skip to content

Commit

Permalink
Merge pull request openMF#789 from dhirenpratap/developtask2
Browse files Browse the repository at this point in the history
openMF#3238 Large JLG Loan changes
  • Loading branch information
pramodn02 authored Jan 13, 2017
2 parents 1eb1658 + b372bf8 commit f0855b7
Show file tree
Hide file tree
Showing 24 changed files with 2,444 additions and 34 deletions.
3 changes: 2 additions & 1 deletion app/global-translations/locale-en.json
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@
"#Menu Links": "..",
"label.menu.office": "Office",
"label.menu.loan.products": "Loan Products",
"label.button.eligibilitycheck":"Run Eligibility Check",

"#Anchors": "..",
"label.anchor.startpage": "Start Page",
Expand Down Expand Up @@ -5219,7 +5220,7 @@
"label.heading.criterias":"Criterias",

"label.heading.request.eligibility.check":"Eligibilty Check",
"label.heading.request.eligibility.tobe":"It is good to be",
"label.heading.request.eligibility.tobe":"Criteria Check result: ",
"label.heading.request.eligibility.detail":"Detail",

"label.input.defaultvalue":"Default Output",
Expand Down
1 change: 1 addition & 0 deletions app/scripts/controllers/client/ViewClientController.js
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,7 @@
});
};


scope.calculateOccupationTotal = function(){
var total = 0;
angular.forEach(scope.incomeAndExpenses, function(data){
Expand Down
18 changes: 11 additions & 7 deletions app/scripts/controllers/task/SingleTaskController.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
initTask();

scope.doTaskAction = function (actionId) {
if(actionId === 'approve' && scope.taskData.taskActivity.identifier.toLowerCase() === 'loanapplicationapproval'){
if(actionId === 'approve' && (scope.taskData.taskActivity.identifier.toLowerCase() === 'loanapplicationapproval'||
scope.taskData.taskActivity.identifier.toLowerCase() === 'cam')){
scope.$broadcast('activityApprove');
}else{
scope.possibleActions = [];
Expand Down Expand Up @@ -115,22 +116,25 @@
});
}

scope.$on('activityDone', function (event, data) {
scope.activityDone = function (data) {
if(scope.taskData.status.value == 'initiated'){
//scope.doTaskAction(1);
//activate the action button if required
}

});
};

scope.$on('activityEdit', function (event, data) {
scope.activityEdit = function (data) {
scope.doTaskAction('taskedit');
});
};

scope.$on('activityApproveDone', function (event, data) {
scope.activityApproveDone = function (data) {
doActionAndRefresh('approve');
});
};

scope.taskCriteriaCheck = function(){
scope.doTaskAction('criteriacheck');
};

scope.triggerCriteriaResult = function(){
if(scope.showCriteriaResult){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
initTask();

scope.submit = function () {
scope.$emit("activityDone",{});
scope.activityDone();
}
}
});
Expand Down
726 changes: 726 additions & 0 deletions app/scripts/controllers/task/activity/camActivityController.js

Large diffs are not rendered by default.

219 changes: 219 additions & 0 deletions app/scripts/controllers/task/activity/cashflowActivityController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
(function (module) {
mifosX.controllers = _.extend(module, {
cashflowActivityController: function (scope, resourceFactory, API_VERSION, location, http, routeParams, API_VERSION, $upload, $rootScope) {

scope.showSummary = true;
scope.showAddClientoccupationdetailsForm = false;
scope.showEditClientoccupationdetailsForm = false;
scope.showAddClientassetdetailsForm = false;
scope.showEditClientassetdetailsForm = false;
scope.showAddClienthouseholddetailsForm = false;
scope.showEditClienthouseholddetailsForm = false;

function hideAll(){
scope.showSummary = false;
scope.showAddClientoccupationdetailsForm = false;
scope.showEditClientoccupationdetailsForm = false;
scope.showAddClientassetdetailsForm = false;
scope.showEditClientassetdetailsForm = false;
scope.showAddClienthouseholddetailsForm = false;
scope.showEditClienthouseholddetailsForm = false;
};

function initTask(){
scope.clientId = scope.taskconfig['clientId'];
scope.showSummary = true;
refreshAndShowSummaryView();
};

initTask();

function incomeAndexpense(){
resourceFactory.incomeExpenseAndHouseHoldExpense.getAll({clientId: scope.clientId},function(data){
scope.incomeAndExpenses = data;
scope.totalIncomeOcc = scope.calculateOccupationTotal();
scope.totalIncomeAsset = scope.calculateTotalAsset();
scope.totalHouseholdExpense = scope.calculateTotalExpense();
scope.showSummaryView();
});
};

scope.calculateOccupationTotal = function(){
var total = 0;
angular.forEach(scope.incomeAndExpenses, function(data){
if(!_.isUndefined(data.incomeExpenseData.cashFlowCategoryData.categoryEnum) && data.incomeExpenseData.cashFlowCategoryData.categoryEnum.id == 1){
if(!_.isUndefined(data.totalIncome) && !_.isNull(data.totalIncome)){
total = total + data.totalIncome;
}
}
});
return total;
};

scope.calculateTotalAsset = function(){
var total = 0;
angular.forEach(scope.incomeAndExpenses, function(data){
if(!_.isUndefined(data.incomeExpenseData.cashFlowCategoryData.categoryEnum) && data.incomeExpenseData.cashFlowCategoryData.categoryEnum.id == 2){
if(!_.isUndefined(data.totalIncome) && !_.isNull(data.totalIncome)){
total = total + data.totalIncome;
}
}
});
return total;
};

scope.calculateTotalExpense = function(){
var total = 0;
angular.forEach(scope.incomeAndExpenses, function(data){
if(!_.isUndefined(data.incomeExpenseData.cashFlowCategoryData.typeEnum) && data.incomeExpenseData.cashFlowCategoryData.typeEnum.id == 2){
if(!_.isUndefined(data.totalExpense) && !_.isNull(data.totalExpense)){
total = total + data.totalExpense;
}
}
});
return total;
};

scope.showSummaryView = function(){
hideAll();
scope.showSummary = true;
};

function refreshAndShowSummaryView(){
incomeAndexpense();
};

//edit

scope.editClientoccupationdetails = function (incomeExpenseId) {
hideAll();
scope.showEditClientoccupationdetailsForm = true;
initEditClientoccupationdetails(incomeExpenseId);
};

scope.editClientassetdetails = function (incomeExpenseId) {
hideAll();
scope.showEditClientassetdetailsForm = true;
initEditClientoccupationdetails(incomeExpenseId);
};

scope.editClienthouseholddetails = function (incomeExpenseId) {
hideAll();
scope.showEditClienthouseholddetailsForm = true;
initEditClientoccupationdetails(incomeExpenseId);
};

function initEditClientoccupationdetails(incomeExpenseId) {
scope.incomeAndExpenseId = incomeExpenseId;
scope.formData = {};
scope.formData.isMonthWiseIncome = false;
scope.isQuantifierNeeded = false;

resourceFactory.cashFlowCategoryResource.getAll({isFetchIncomeExpenseDatas: true}, function (data) {
scope.occupations = data;
});

resourceFactory.incomeExpenseAndHouseHoldExpense.get({
clientId: scope.clientId,
incomeAndExpenseId: scope.incomeAndExpenseId
}, function (data) {
angular.forEach(scope.occupations, function (occ) {
if (occ.id == data.incomeExpenseData.cashflowCategoryId) {
scope.occupationOption = occ;
}
});
scope.formData.incomeExpenseId = data.incomeExpenseData.id;
scope.formData.quintity = data.quintity;
scope.formData.totalIncome = data.totalIncome;
scope.formData.totalExpense = data.totalExpense;
scope.formData.isPrimaryIncome = data.isPrimaryIncome;
scope.isQuantifierNeeded = data.incomeExpenseData.isQuantifierNeeded
scope.quantifierLabel = data.incomeExpenseData.quantifierLabel;
});
};

// create activity
scope.addClientoccupationdetails = function () {
hideAll();
scope.showAddClientoccupationdetailsForm = true;
initAddClientoccupationdetails();
};

scope.addClientassetdetails = function () {
hideAll();
scope.showAddClientassetdetailsForm = true;
initAddClientoccupationdetails();
};

scope.addClienthouseholddetails = function () {
hideAll();
scope.showAddClienthouseholddetailsForm = true;
initAddClientoccupationdetails();
};

function initAddClientoccupationdetails(){
scope.formData = {};
scope.subOccupations = [];
scope.formData.clientMonthWiseIncomeExpense = [];
scope.formData.isMonthWiseIncome = false;
scope.isQuantifierNeeded = false;
scope.quantifierLabel = undefined;

resourceFactory.cashFlowCategoryResource.getAll({isFetchIncomeExpenseDatas: true}, function(data){
scope.occupations = data;
});
};

scope.slectedOccupation = function(occupationId, subOccupationId){
_.each(scope.occupations, function (occupation) {
if(occupation.id == occupationId){
_.each(occupation.incomeExpenseDatas, function(iterate){
if(iterate.cashflowCategoryId == occupationId && iterate.isQuantifierNeeded == true && iterate.id == subOccupationId){
scope.quantifierLabel = iterate.quantifierLabel;
scope.isQuantifierNeeded = iterate.isQuantifierNeeded;
} else {
scope.isQuantifierNeeded = false;
}
})
}

});
};

scope.subOccupationNotAvailable = function(occupationId){
_.each(scope.occupationOption, function(occupation){
if(occupation == occupationId && _.isUndefined(occupation.incomeExpenseDatas)){
scope.isQuantifierNeeded = false;
return scope.isQuantifierNeeded;
}
})
};

scope.addClientoccupationdetailsSubmit = function () {
scope.formData.locale = "en";
resourceFactory.incomeExpenseAndHouseHoldExpense.save({clientId: scope.clientId},scope.formData, function (data) {
refreshAndShowSummaryView();
});
};

scope.addClientassetdetailsSubmit = function () {
scope.addClientoccupationdetailsSubmit();
};

scope.addClienthouseholddetailsSubmit = function () {
scope.addClientoccupationdetailsSubmit();
};

scope.editClientoccupationdetailsSubmit = function () {
scope.formData.locale = "en";
resourceFactory.incomeExpenseAndHouseHoldExpense.update({clientId: scope.clientId, incomeAndExpenseId: scope.incomeAndExpenseId},
scope.formData, function (data) {
refreshAndShowSummaryView();
});
};
}
});
mifosX.ng.application.controller('cashflowActivityController', ['$scope', 'ResourceFactory', 'API_VERSION', '$location', '$http', '$routeParams', 'API_VERSION', '$upload', '$rootScope', mifosX.controllers.cashflowActivityController]).run(function ($log) {
$log.info("cashflowActivityController initialized");
});
}(mifosX.controllers || {}));
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
if (!scope.$$phase) {
scope.$apply();
}
scope.$emit("activityDone",{});
scope.activityDone();
getClientDocuments();
});
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
(function (module) {
mifosX.controllers = _.extend(module, {
criteriacheckActivityController: function (scope, resourceFactory, API_VERSION, location, http, routeParams, API_VERSION, $upload, $rootScope, dateFilter) {

function initTask(){

};

initTask();

scope.submit = function () {
scope.activityDone();
};

scope.runCriteriaCheck = function(){
scope.taskCriteriaCheck();
};
}
});
mifosX.ng.application.controller('criteriacheckActivityController', ['$scope', 'ResourceFactory', 'API_VERSION', '$location', '$http', '$routeParams', 'API_VERSION', '$upload', '$rootScope' ,'dateFilter', mifosX.controllers.criteriacheckActivityController]).run(function ($log) {
$log.info("criteriacheckActivityController initialized");
});
}(mifosX.controllers || {}));
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@
}
}
resourceFactory.DataTablesResource.save(params, this.formData, function (data) {
scope.$emit("activityDone", {});
scope.activityDone();
scope.getDetails();
});
};
Expand Down Expand Up @@ -306,7 +306,7 @@
var reqparams = {datatablename: scope.tableName, entityId: scope.entityId, genericResultSet: 'true'};
resourceFactory.DataTablesResource.update(reqparams, this.formData, function (data) {
scope.getDetails();
scope.$emit("activityEdit", {});
scope.activityEdit();
});
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
function initTask(){
scope.clientId = scope.taskconfig['clientId'];
existingLoans();
scope.$emit("activityDone",{});
scope.activityDone();
};

initTask();

function existingLoans(){
resourceFactory.clientExistingLoan.getAll({clientId: scope.clientId}, function(data){
console.log(data);
// console.log(data);
scope.existingLoans = data;
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
}else if(scope.formData.status.id === 200){
showEditForm();
}else if(scope.formData.status.id > 200){
scope.$emit("activityDone",{});
scope.activityDone();
}
});
}
Expand Down Expand Up @@ -426,7 +426,7 @@
command: 'approve'
}, this.submitData, function (data) {
scope.status = 'SUMMARY';
scope.$emit("activityApproveDone",{});
scope.activityApproveDone();
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@
loanApplicationReferenceId: scope.loanApplicationReferenceId,
command: 'disburse'
}, this.formRequestData, function (data) {
scope.$emit("activityDone",{});
scope.activityDone();
getLoanAccountDetails(data.changes.loanId);
});
};
Expand Down
Loading

0 comments on commit f0855b7

Please sign in to comment.