diff --git a/global-translations/locale-en.json b/global-translations/locale-en.json
index 1d44dc20..9dd11455 100644
--- a/global-translations/locale-en.json
+++ b/global-translations/locale-en.json
@@ -193,7 +193,17 @@
"app erros start" :"----------------------------------------------------",
"error.login.failed":"Please try again, your credentials are not valid",
-
+ "#Journal Entry Predefined Postings":"........",
+ "label.journalentry.posting.title":"Add journal entry",
+ "label.journalentry.accounting.rules":"Accounting Rules",
+ "label.journalentry.effected.entries":"Effected GL Entries",
+ "label.journalentry.credit":"Credit",
+ "label.journalentry.debit":"Debit",
+ "label.journalentry.reference.number":"Referance Number",
+ "label.journalentry.transaction.date":"Transaction Date",
+ "label.journalentry.comments":"Comments",
+ "label.save":"Save",
+ "label.cancel":"Cancel",
"app erros end" :"------------------------------------------------------"
diff --git a/html/accounting/freqposting.html b/html/accounting/freqposting.html
index d2483638..6dd34cba 100644
--- a/html/accounting/freqposting.html
+++ b/html/accounting/freqposting.html
@@ -1,8 +1,8 @@
diff --git a/index.html b/index.html
index c8454e97..87520c33 100644
--- a/index.html
+++ b/index.html
@@ -27,8 +27,8 @@
-
-
+
+
diff --git a/js/controllers/AccFreqPostingController.js b/js/controllers/AccFreqPostingController.js
index a4d6b2f0..a827acbd 100644
--- a/js/controllers/AccFreqPostingController.js
+++ b/js/controllers/AccFreqPostingController.js
@@ -2,6 +2,10 @@
mifosX.controllers = _.extend(module, {
AccFreqPostingController: function(scope, resourceFactory, location) {
+ scope.formData = {};
+ scope.formData.crAccounts = [];
+ scope.formData.dbAccounts = [];
+
resourceFactory.accountingRulesResource.getAllRules({associations : 'all'}, function(data){
scope.rules = data;
});
@@ -9,6 +13,69 @@
resourceFactory.officeResource.getAllOffices(function(data){
scope.offices = data;
});
+
+ //event for rule change
+ scope.resetCrAndDb = function () {
+ scope.formData.crAccounts = [];
+ scope.formData.dbAccounts = [];
+ }
+
+ //events for credits
+ scope.addCrAccount = function () {
+ if(scope.formData.crAmountTemplate != undefined){
+ scope.formData.crAccounts.push({crGlAccountId: scope.formData.creditAccountTemplate.id, crGlcode: scope.formData.creditAccountTemplate.glCode, crGlName : scope.formData.creditAccountTemplate.name , crAmount : scope.formData.crAmountTemplate});
+ scope.formData.crAmountTemplate = undefined;
+ }
+ }
+
+ scope.removeCrAccount = function(index) {
+ scope.formData.crAccounts.splice(index,1);
+ }
+
+ //events for debits
+ scope.addDebitAccount = function () {
+ if(scope.formData.debitAmountTemplate != undefined){
+ scope.formData.dbAccounts.push({debitGlAccountId: scope.formData.debitAccountTemplate.id, debitGlcode: scope.formData.debitAccountTemplate.glCode, debitGlName : scope.formData.debitAccountTemplate.name , debitAmount : scope.formData.debitAmountTemplate});
+ scope.formData.debitAmountTemplate = undefined;
+ }
+ }
+
+ scope.removeDebitAccount = function(index) {
+ scope.formData.dbAccounts.splice(index,1);
+ }
+
+ scope.submit = function() {
+ var jeTransaction = new Object();
+ jeTransaction.locale = 'en';
+ jeTransaction.dateFormat = 'dd MMMM yyyy';
+ jeTransaction.officeId=this.formData.officeId;
+ jeTransaction.transactionDate = this.formData.transactionDate;
+ jeTransaction.referenceNumber = this.formData.referenceNumber;
+ jeTransaction.comments = this.formData.comments;
+ jeTransaction.accountingRule = this.formData.rule.id;
+
+ //Construct credits array
+ jeTransaction.credits = [];
+ for (var i = 0; i < this.formData.crAccounts.length; i++) {
+ var temp = new Object();
+ temp.glAccountId = this.formData.crAccounts[i].crGlAccountId;
+ temp.amount = this.formData.crAccounts[i].crAmount;
+ jeTransaction.credits.push(temp);
+ }
+
+ //construct debits array
+ jeTransaction.debits = [];
+ for (var i = 0; i < this.formData.dbAccounts.length; i++) {
+ var temp = new Object();
+ temp.glAccountId = this.formData.dbAccounts[i].debitGlAccountId;
+ temp.amount = this.formData.dbAccounts[i].debitAmount;
+ jeTransaction.debits.push(temp);
+ }
+
+ resourceFactory.journalEntriesResource.save(jeTransaction,function(data){
+ location.path('/accounting');
+ });
+ }
}
});
mifosX.ng.application.controller('AccFreqPostingController', ['$scope', 'ResourceFactory', '$location', mifosX.controllers.AccFreqPostingController]).run(function($log) {
diff --git a/js/services/ResourceFactoryProvider.js b/js/services/ResourceFactoryProvider.js
index 384af0cb..44a0f902 100644
--- a/js/services/ResourceFactoryProvider.js
+++ b/js/services/ResourceFactoryProvider.js
@@ -79,6 +79,9 @@
}),
accountCoaTemplateResource: defineResource(apiVer + "/glaccounts/template", {}, {
get: {method: 'GET', params: {}}
+ }),
+ journalEntriesResource: defineResource(apiVer + "/journalentries", {}, {
+ get: {method: 'GET', params: {}}
})
};
}];