Merge pull request #52 from mifoscontributer/jeacct

Add predefined journal entries
This commit is contained in:
Nayan Ambali 2013-08-29 01:06:25 -07:00
commit cd9fdeb784
5 changed files with 119 additions and 39 deletions

View File

@ -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" :"------------------------------------------------------"

View File

@ -1,8 +1,8 @@
<form class="form-horizontal well" ng-controller="AccFreqPostingController" ng-submit="submit()">
<fieldset>
<legend>Add a journal entry</legend>
<legend>{{ 'label.journalentry.posting.title' | translate }}</legend>
<div class="control-group info">
<label class="control-label" for="loanofficer">Office</label>
<label class="control-label" for="officeId">{{ 'label.office' | translate }}</label>
<div class="controls">
<select class="input-xlarge" ng-model="formData.officeId">
<option ng-repeat="office in offices" value="{{office.id}}">{{office.name}}</option>
@ -10,75 +10,75 @@
</div>
</div>
<div class="control-group info">
<label class="control-label" for="office">Accounting Rules</label>
<label class="control-label" for="accountingRule">{{ 'label.journalentry.accounting.rules' | translate }}</label>
<div class="controls">
<select class="input-xlarge" ng-model="formData.rule" ng-options="rule.name for rule in rules" ></select>
</div>
</div>
<div class="control-group" ng-hide="formData.rule.allowMultipleDebitEntries || formData.rule.allowMultipleCreditEntries || formData.rule.creditAccounts.length > 0">
<label class="control-label" for="firstname">Amount</label>
<div class="controls">
<input type="text" class="input-xlarge" id="firstname" ng-model="formData.firstname">
<select class="input-xlarge" ng-model="formData.rule" ng-options="rule.name for rule in rules" ng-change="resetCrAndDb()"></select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="firstname">Effected GL Entries</label>
<label class="control-label">{{ 'label.journalentry.effected.entries' | translate }}</label>
<div class="controls">
<table width="100%">
<tr>
<td width="50%">
<strong>Credit</strong>
<strong>{{ 'label.journalentry.credit' | translate }}</strong>
</td>
<td width="50%">
<strong>Debit</strong>
<strong>{{ 'label.journalentry.debit' | translate }}</strong>
</td>
</tr>
<tr>
<td>
<span ng-hide="formData.rule.allowMultipleCreditEntries">
{{formData.rule.creditAccountHead.name}}
</span>
<span ng-show="formData.rule.creditAccounts.length > 0" >
<select class="input-small" ng-model="formData.creditAccount" ng-options="creditAccount.name for creditAccount in formData.rule.creditAccounts" ></select>
<input type="text" class="input-small" ng-model="formData.crAmount">
<a ng-show="formData.rule.allowMultipleCreditEntries">&nbsp;<i class="icon-plus icon-white"></i></a>
</span>
<div ng-show="formData.rule.creditAccounts.length > 0" >
<select class="input-small" ng-model="formData.creditAccountTemplate" ng-options="creditAccount.name for creditAccount in formData.rule.creditAccounts" ></select>
&nbsp; <input type="text" class="input-small" ng-model="formData.crAmountTemplate">
&nbsp; <a ng-click="addCrAccount()" ng-show="formData.rule.allowMultipleCreditEntries">&nbsp;<i class="icon-plus icon-white"></i></a>
</div>
<br>
<div ng-repeat="crAccount in formData.crAccounts">
<input type="text" class="input-small" ng-model="crAccount.crGlName" readonly>
<input type="text" class="input-small" ng-model="crAccount.crAmount">
<a ng-click="removeCrAccount($index)">&nbsp;<i class="icon-remove icon-white"></i></a>
</div>
</td>
<td>
<span ng-hide="formData.rule.allowMultipleDebitEntries">
{{formData.rule.debitAccountHead.name}}
</span>
<span ng-show="formData.rule.debitAccounts.length > 0" >
<select class="input-small" ng-model="formData.debitAccount" ng-options="debitAccount.name for debitAccount in formData.rule.debitAccounts" ></select>
<input type="text" class="input-small" ng-model="formData.dbAmount">
<a ng-show="formData.rule.allowMultipleDebitEntries">&nbsp;<i class="icon-plus icon-white"></i></a>
</span>
<div ng-show="formData.rule.debitAccounts.length > 0" >
<select class="input-small" ng-model="formData.debitAccountTemplate" ng-options="debitAccount.name for debitAccount in formData.rule.debitAccounts" ></select>
&nbsp; <input type="text" class="input-small" ng-model="formData.debitAmountTemplate">
&nbsp; <a ng-click="addDebitAccount()" ng-show="formData.rule.allowMultipleDebitEntries">&nbsp;<i class="icon-plus icon-white"></i></a>
</div>
<br>
<div ng-repeat="dbAccount in formData.dbAccounts">
<input type="text" class="input-small" ng-model="dbAccount.debitGlName" readonly>
<input type="text" class="input-small" ng-model="dbAccount.debitAmount">
<a ng-click="removeDebitAccount($index)">&nbsp;<i class="icon-remove icon-white"></i></a>
</div>
</td>
</tr>
</table>
</div>
</div>
<div class="control-group">
<label class="control-label" for="middlename">Referance Number</label>
<label class="control-label" for="referenceNumber">{{ 'label.journalentry.reference.number' | translate }}</label>
<div class="controls">
<input type="text" class="input-xlarge" id="middlename" ng-model="formData.middlename">
<input type="text" class="input-xlarge" id="referenceNumber" ng-model="formData.referenceNumber">
</div>
</div>
<div class="control-group">
<label class="control-label" for="lastname">Transaction Date</label>
<label class="control-label" for="transactionDate">{{ 'label.journalentry.transaction.date' | translate }}</label>
<div class="controls">
<input type="text" class="input-xlarge" id="lastname" ng-model="formData.lastname">
<input type="text" class="input-xlarge" id="transactionDate" ng-model="formData.transactionDate">
</div>
</div>
<div class="control-group">
<label class="control-label" for="active">Comments</label>
<label class="control-label" for="comments">{{ 'label.journalentry.comments' | translate }}</label>
<div class="controls">
<input type="text" class="input-xlarge" ng-model="formData.comments">
</div>
</div>
<div class="form-actions">
<button type="reset" class="btn">Cancel</button>
<button type="submit" class="btn btn-primary">Save</button>
<button type="reset" class="btn">{{ 'label.cancel' | translate }}</button>
<button type="submit" class="btn btn-primary">{{ 'label.save' | translate }}</button>
</div>
</fieldset>
</form>

View File

@ -27,8 +27,8 @@
</div>
<br/><br/>
<div class="pull-right">
<input type="text" data-ng-model="loginCredentials.username" placeholder="{{ 'label.username' | translate }}" class="input-small">
<input type="password" data-ng-model="loginCredentials.password" placeholder="{{ 'label.password' | translate }}" class="input-small">
<input type="text" data-ng-model="loginCredentials.username" placeholder="{{ 'label.username' | translate }}" class="input-small" required>
<input type="password" data-ng-model="loginCredentials.password" placeholder="{{ 'label.password' | translate }}" class="input-small" required>
<button class="btn btn-success" type="submit" data-ng-click="login()">{{ 'label.signin' | translate }}</button>
</div>
<div class="pull-right" data-ng-show="authenticationFailed">

View File

@ -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) {

View File

@ -79,6 +79,9 @@
}),
accountCoaTemplateResource: defineResource(apiVer + "/glaccounts/template", {}, {
get: {method: 'GET', params: {}}
}),
journalEntriesResource: defineResource(apiVer + "/journalentries", {}, {
get: {method: 'GET', params: {}}
})
};
}];