Skip to content

Commit

Permalink
Merge pull request #194 from goutham-M/mifosx-changes
Browse files Browse the repository at this point in the history
date picker and charges changes added
  • Loading branch information
Nayan committed Oct 19, 2013
2 parents 2fd3842 + 4fb0baf commit 3a7ab13
Show file tree
Hide file tree
Showing 27 changed files with 336 additions and 164 deletions.
2 changes: 1 addition & 1 deletion app/global-translations/locale-en.json
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@

"#Savings Related":".........",
"label.select.saving.product":"--Select saving product--",
"label.select.one":"--Select--",
"label.select.one":"--Select one--",
"link.new.savings.application":"Saving Application",
"label.edit.saving.application":"Edit Saving Application",
"label.activatedOn":"Activated On:",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
scope.submit = function() {
this.formData.locale = "en";
this.formData.dateFormat = "dd MMMM yyyy";
if (this.formData.transferDate) this.formData.transferDate = dateFilter(this.formData.transferDate,'dd MMMM yyyy');
this.formData.fromOfficeId = scope.transfer.fromClient.id;
this.formData.fromClientId = scope.transfer.fromClient.officeId;
resourceFactory.accountTransferResource.save(this.formData,function(data){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@
break;
case "modifytransaction":
break;
case "deleteloancharge":
scope.showDelete = true;
scope.showNoteField = false;
scope.showDateField = false;
break;
}

scope.cancel = function() {
Expand All @@ -131,6 +136,10 @@
resourceFactory.loanTrxnsResource.save(params, this.formData, function(data){
location.path('/viewloanaccount/' + data.loanId);
});
} else if(scope.action == "deleteloancharge") {
resourceFactory.LoanAccountResource.delete({loanId : routeParams.id, resourceType : 'charges', chargeId : routeParams.chargeId}, this.formData, function(data) {
location.path('/viewloanaccount/' + data.loanId);
});
} else {
params.loanId=scope.accountId;
resourceFactory.LoanAccountResource.save(params, this.formData, function(data){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@
resourceFactory.LoanAccountResource.getLoanAccountDetails({loanId: routeParams.id, associations: 'all'}, function(data) {
scope.loandetails = data;
scope.status = data.status.value;
scope.chargeAction = data.status.value == "Submitted and pending approval" ? true : false;

if(scope.loandetails.charges) {
scope.charges = scope.loandetails.charges;
scope.chargeTableShow = true;
} else {
scope.chargeTableShow = false;
}

scope.$broadcast('LoanAccountDataLoadingCompleteEvent');
if(scope.status=="Submitted and pending approval" || scope.status=="Active" || scope.status=="Approved" ){
scope.choice = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
isLoanOfficer: true,
officeId : scope.offices[0].id,
};
scope.test = "<p>Hello</p>"
});

scope.submit = function() {
Expand Down
33 changes: 32 additions & 1 deletion app/scripts/controllers/product/CreateChargeController.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,42 @@
mifosX.controllers = _.extend(module, {
CreateChargeController: function(scope, resourceFactory,location) {
scope.template = [];
resourceFactory.chargeTemplateResource.get(function(data) {
scope.formData = {};
resourceFactory.chargeTemplateResource.getChargeTemplates(function(data) {
scope.template = data;
scope.showChargePaymentByField = true;
scope.chargeCalculationTypeOptions = data.chargeCalculationTypeOptions;
scope.chargeTimeTypeOptions = data.chargeTimeTypeOptions;
});

scope.chargeAppliesToSelected = function(chargeAppliesId) {
if (chargeAppliesId == 1) {
scope.showChargePaymentByField = true;
scope.chargeCalculationTypeOptions = scope.template.loanChargeCalculationTypeOptions;
scope.chargeTimeTypeOptions = scope.template.loanChargeTimeTypeOptions;
} else {
scope.showChargePaymentByField = false;
scope.chargeCalculationTypeOptions = scope.template.savingsChargeCalculationTypeOptions;
scope.chargeTimeTypeOptions = scope.template.savingsChargeTimeTypeOptions;
}
}

scope.setChoice = function(){
if(this.formData.active){
scope.choice = 1;
}
else if(!this.formData.active){
scope.choice = 0;
}
};

scope.submit = function() {
if (!scope.showChargePaymentByField) {
delete this.formData.chargePaymentMode;
}
this.formData.active = this.formData.active || false;
this.formData.locale = 'en';
this.formData.monthDayFormat = 'dd MMM';
resourceFactory.chargeResource.save(this.formData,function(data){
location.path('/viewcharge/' + data.resourceId);
});
Expand Down
4 changes: 2 additions & 2 deletions app/scripts/controllers/product/ViewChargeController.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(function(module) {
mifosX.controllers = _.extend(module, {
ViewChargeController: function(scope, routeParams , resourceFactory ) {
ViewChargeController: function(scope, routeParams , resourceFactory, location) {
scope.charge = [];
scope.choice = 0;
resourceFactory.chargeResource.get({chargeId: routeParams.id} , function(data) {
Expand All @@ -20,7 +20,7 @@
}
}
});
mifosX.ng.application.controller('ViewChargeController', ['$scope', '$routeParams','ResourceFactory', mifosX.controllers.ViewChargeController]).run(function($log) {
mifosX.ng.application.controller('ViewChargeController', ['$scope', '$routeParams','ResourceFactory', '$location', mifosX.controllers.ViewChargeController]).run(function($log) {
$log.info("ViewChargeController initialized");
});
}(mifosX.controllers || {}));
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(function(module) {
mifosX.controllers = _.extend(module, {
AddNewSavingsChargeController: function(scope, resourceFactory, location, routeParams) {
AddNewSavingsChargeController: function(scope, resourceFactory, location, routeParams, dateFilter) {
scope.offices = [];
resourceFactory.savingsResource.get({accountId : routeParams.id, resourceType : 'charges', template : 'template'}, function(data) {
resourceFactory.savingsChargeResource.get({accountId : routeParams.id, resourceType : 'template'}, function(data) {
scope.chargeOptions = data.chargeOptions;
});

Expand All @@ -23,15 +23,16 @@
if(scope.withDrawCharge == true) {
delete this.formData.feeOnMonthDay;
} else {
this.formData.feeOnMonthDay = scope.feeOnMonthDay == undefined ? "" : scope.feeOnMonthDay;
this.formData.monthDayFormat = "dd MMM";
if (this.formData.feeOnMonthDay) this.formData.feeOnMonthDay = dateFilter(this.formData.feeOnMonthDay,'dd MMMM');
}
resourceFactory.savingsChargeResource.save({accountId : routeParams.id}, this.formData, function(data) {
location.path('/viewsavingaccount/'+routeParams.id);
});
};
}
});
mifosX.ng.application.controller('AddNewSavingsChargeController', ['$scope', 'ResourceFactory', '$location', '$routeParams', mifosX.controllers.AddNewSavingsChargeController]).run(function($log) {
mifosX.ng.application.controller('AddNewSavingsChargeController', ['$scope', 'ResourceFactory', '$location', '$routeParams', 'dateFilter', mifosX.controllers.AddNewSavingsChargeController]).run(function($log) {
$log.info("AddNewSavingsChargeController initialized");
});
}(mifosX.controllers || {}));
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(function(module) {
mifosX.controllers = _.extend(module, {
CreateSavingAccountController: function(scope, resourceFactory, location, routeParams) {
CreateSavingAccountController: function(scope, resourceFactory, location, routeParams, dateFilter) {
scope.products = [];
scope.fieldOfficers = [];
scope.formData = {};
Expand Down Expand Up @@ -61,6 +61,7 @@
}

scope.submit = function() {
this.formData.submittedOnDate = dateFilter(scope.date.submittedOnDate,'dd MMMM yyyy');
this.formData.locale = 'en';
this.formData.dateFormat = 'dd MMMM yyyy';
this.formData.monthDayFormat= "dd MMM";
Expand All @@ -87,7 +88,7 @@
};
}
});
mifosX.ng.application.controller('CreateSavingAccountController', ['$scope', 'ResourceFactory', '$location', '$routeParams', mifosX.controllers.CreateSavingAccountController]).run(function($log) {
mifosX.ng.application.controller('CreateSavingAccountController', ['$scope', 'ResourceFactory', '$location', '$routeParams', 'dateFilter', mifosX.controllers.CreateSavingAccountController]).run(function($log) {
$log.info("CreateSavingAccountController initialized");
});
}(mifosX.controllers || {}));
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(function(module) {
mifosX.controllers = _.extend(module, {
EditSavingAccountController: function(scope, resourceFactory, location, routeParams) {
EditSavingAccountController: function(scope, resourceFactory, location, routeParams, dateFilter) {
scope.products = [];
scope.fieldOfficers = [];
scope.formData = {};
Expand All @@ -22,6 +22,10 @@
scope.formData.productId = data.savingsProductId;
scope.products = data.productOptions;
if(data.fieldOfficerId != 0)scope.formData.fieldOfficerId = data.fieldOfficerId;
if(data.timeline) {
var submittedOnDate = dateFilter(data.timeline.submittedOnDate, 'dd MMMM yyyy');
scope.formData.submittedOnDate = new Date(submittedOnDate);
}
scope.fieldOfficers = data.fieldOfficerOptions;
scope.formData.nominalAnnualInterestRate = data.nominalAnnualInterestRate;
scope.formData.minRequiredOpeningBalance = data.minRequiredOpeningBalance;
Expand Down Expand Up @@ -88,6 +92,7 @@
}

scope.submit = function() {
if(this.formData.submittedOnDate) this.formData.submittedOnDate = dateFilter(this.formData.submittedOnDate,'dd MMMM yyyy');
this.formData.locale = 'en';
this.formData.dateFormat = 'dd MMMM yyyy';
this.formData.monthDayFormat= "dd MMM";
Expand All @@ -110,7 +115,7 @@
};
}
});
mifosX.ng.application.controller('EditSavingAccountController', ['$scope', 'ResourceFactory', '$location', '$routeParams', mifosX.controllers.EditSavingAccountController]).run(function($log) {
mifosX.ng.application.controller('EditSavingAccountController', ['$scope', 'ResourceFactory', '$location', '$routeParams', 'dateFilter', mifosX.controllers.EditSavingAccountController]).run(function($log) {
$log.info("EditSavingAccountController initialized");
});
}(mifosX.controllers || {}));
69 changes: 60 additions & 9 deletions app/scripts/controllers/savings/SavingAccountActionsController.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
(function(module) {
mifosX.controllers = _.extend(module, {
SavingAccountActionsController: function(scope, resourceFactory, location, routeParams) {
SavingAccountActionsController: function(scope, resourceFactory, location, routeParams, dateFilter) {

scope.action = routeParams.action || "";
scope.accountId = routeParams.id;
scope.savingAccountId = routeParams.id;
scope.formData = {};

// Transaction UI Related
scope.isTransaction = false;
scope.showPaymentDetails =false;
scope.paymentTypes = [];

switch (scope.action) {
case "approve":
console.log("approve");
scope.title = 'label.approve.saving.account';
scope.labelName = 'label.saving.account.approvedOnDate';
scope.modelName = 'approvedOnDate';
Expand Down Expand Up @@ -71,10 +70,17 @@
scope.showPaymentDetails = false;
break;
case "applyAnnualFees":
resourceFactory.savingsResource.get({accountId : routeParams.id, resourceType : 'charges', chargeId : routeParams.chargeId}, function(data) {
scope.formData.amount = data.amount;
if (data.dueDate) var dueDate = dateFilter(data.dueDate, 'dd MMMM yyyy');
scope.formData.dueDate = new Date(dueDate);
});
scope.title = 'label.saving.account.apply.annualFee';
scope.labelName = 'label.saving.account.annualFeeTransactionDate';
scope.modelName = 'annualFeeTransactionDate';
scope.modelName = 'dueDate';
scope.showDateField = true;
scope.showAnnualAmountField = true;
scope.showAmountField = false;
scope.showNoteField = false;
break;
case "close":
Expand Down Expand Up @@ -106,11 +112,29 @@
scope.showPaymentDetails = false;
break;
case "editsavingcharge":
scope.labelName = 'label.amount';
scope.modelName = "amount";
scope.showAmountField = true;
resourceFactory.savingsResource.get({accountId : routeParams.id, resourceType : 'charges', chargeId : routeParams.chargeId}, function(data) {
scope.formData.amount = data.amount;
if (data.feeOnMonthDay) {
scope.dateArray = [];
scope.dateArray.push(2013)
for (var i in data.feeOnMonthDay) {
scope.dateArray.push(data.feeOnMonthDay[i]);
}
console.log(dateFilter(scope.dateArray, 'dd MMMM yyyy'));
var feeOnMonthDay = dateFilter(scope.dateArray, 'dd MMMM yyyy');
scope.formData.feeOnMonthDayFullDate = new Date(feeOnMonthDay);
scope.labelName = 'label.saving.account.transactionDate';
scope.modelName = 'feeOnMonthDayFullDate';
scope.showDateField = true;
scope.showAnnualAmountField = true;
scope.showAmountField = false;
} else {
scope.labelName = 'label.amount';
scope.modelName = 'amount';
scope.showDateField = false;
scope.showAnnualAmountField = false;
scope.showAmountField = true;
}
});
break;
case "deletesavingcharge":
Expand All @@ -125,15 +149,27 @@
this.formData.dateFormat = 'dd MMMM yyyy';
}
if (scope.action == "deposit" || scope.action == "withdrawal" || scope.action == "modifytransaction") {
if(scope.action == "withdrawal") {
if (this.formData.transactionDate) this.formData.transactionDate = dateFilter(this.formData.transactionDate,'dd MMMM yyyy');
} else if(scope.action == "deposit") {
if (this.formData.transactionDate) this.formData.transactionDate = dateFilter(this.formData.transactionDate,'dd MMMM yyyy');
}
if(scope.action == "modifytransaction") {
params.command = 'modify';
if (this.formData.transactionDate) this.formData.transactionDate = dateFilter(this.formData.transactionDate,'dd MMMM yyyy');
params.transactionId = routeParams.transactionId;
}
params.savingsId = scope.accountId;
resourceFactory.savingsTrxnsResource.save(params, this.formData, function(data){
location.path('/viewsavingaccount/' + data.savingsId);
});
} else if(scope.action == "editsavingcharge") {
if (this.formData.feeOnMonthDayFullDate) {
this.formData.feeOnMonthDay = dateFilter(this.formData.feeOnMonthDayFullDate,'dd MMMM yyyy');
this.formData.monthDayFormat = "dd MMM";
this.formData.feeOnMonthDay = this.formData.feeOnMonthDay.substring(0, this.formData.feeOnMonthDay.length - 5);
delete this.formData.feeOnMonthDayFullDate;
}
resourceFactory.savingsResource.update({accountId : routeParams.id, resourceType : 'charges', chargeId : routeParams.chargeId}, this.formData, function(data) {
location.path('/viewsavingaccount/' + data.savingsId);
});
Expand All @@ -142,15 +178,30 @@
location.path('/viewsavingaccount/' + data.savingsId);
});
} else {
params.accountId=scope.accountId;
params.accountId=scope.accountId;
if(scope.action == "approve") {
if (this.formData.approvedOnDate) this.formData.approvedOnDate = dateFilter(this.formData.approvedOnDate,'dd MMMM yyyy');
} else if(scope.action == "withdrawnByApplicant") {
if (this.formData.withdrawnOnDate) this.formData.withdrawnOnDate = dateFilter(this.formData.withdrawnOnDate,'dd MMMM yyyy');
}else if(scope.action == "reject") {
if (this.formData.rejectedOnDate) this.formData.rejectedOnDate = dateFilter(this.formData.rejectedOnDate,'dd MMMM yyyy');
} else if(scope.action == "activate"){
if (this.formData.activatedOnDate) this.formData.activatedOnDate = dateFilter(this.formData.activatedOnDate,'dd MMMM yyyy');
}else if(scope.action == "applyAnnualFees"){
params = {accountId : routeParams.id, resourceType : 'charges', chargeId : routeParams.chargeId, command : 'paycharge'};
if (this.formData.dueDate) this.formData.dueDate = dateFilter(this.formData.dueDate,'dd MMMM yyyy');
}else if(scope.action == "close"){
if (this.formData.closedOnDate) this.formData.closedOnDate = dateFilter(this.formData.closedOnDate,'dd MMMM yyyy');
}

resourceFactory.savingsResource.save(params, this.formData, function(data){
location.path('/viewsavingaccount/' + data.savingsId);
});
}
};
}
});
mifosX.ng.application.controller('SavingAccountActionsController', ['$scope', 'ResourceFactory', '$location', '$routeParams', mifosX.controllers.SavingAccountActionsController]).run(function($log) {
mifosX.ng.application.controller('SavingAccountActionsController', ['$scope', 'ResourceFactory', '$location', '$routeParams', 'dateFilter', mifosX.controllers.SavingAccountActionsController]).run(function($log) {
$log.info("SavingAccountActionsController initialized");
});
}(mifosX.controllers || {}));
16 changes: 12 additions & 4 deletions app/scripts/controllers/savings/ViewSavingDetailsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
});
break;
case "applyAnnualFees":
location.path('/savingaccount/' + accountId + '/applyAnnualFees');
location.path('/savingaccountcharge/' + accountId + '/applyAnnualFees/' + scope.annualChargeId);
break;
case "transferFunds":
if (scope.savingaccountdetails.clientId) {
Expand All @@ -74,6 +74,7 @@
if(scope.status=="Submitted and pending approval" || scope.status=="Active" || scope.status=="Approved" ){
scope.choice = true;
}
scope.chargeAction = data.status.value == "Submitted and pending approval" ? true : false;
if(scope.savingaccountdetails.charges) {
scope.charges = scope.savingaccountdetails.charges;
scope.chargeTableShow = true;
Expand Down Expand Up @@ -136,9 +137,6 @@
options: [{
name:"button.postInterest"
},
{
name:"button.applyAnnualFees"
},
{
name:"button.transferFunds"
},
Expand All @@ -147,6 +145,16 @@
}]

};
if(data.charges) {
for (var i in scope.charges) {
if(scope.charges[i].name == "Annual fee - INR") {
scope.buttons.options.push({
name:"button.applyAnnualFees"
});
scope.annualChargeId = scope.charges[i].id;
}
}
}
}
});

Expand Down
Loading

0 comments on commit 3a7ab13

Please sign in to comment.