Chore: Variable renaming in JavaScript to camelCase
Feature: Keyboard navigation in Accounts, Employees and Product List. Chore: Removing unused JavasScript variables in function for JSHint
This commit is contained in:
1 parent
1989c54e92
commit
d99fc89e34
26 files changed
+371
-296
No files matched your search
@@ -1,15 +1,17 @@
|
||||
<h2>Accounts
|
||||
<div class="form-group col-md-9 pull-right">
|
||||
<div class="col-md-10">
|
||||
<input type="text" class="form-control" placeholder="Search: n:Name, a:Active, u:Units, g:Group, e:true for extended properties, " or ' for Quotes" ng-model="search">
|
||||
<input type="text" class="form-control"
|
||||
placeholder="Search: n:Name, a:Active, u:Units, g:Group, e:true for extended properties, " or ' for Quotes"
|
||||
ng-model="search">
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<a href="/Account" class="btn btn-success btn-block">Add <i
|
||||
class="glyphicon glyphicon-plus"></i></a>
|
||||
</div>
|
||||
<a href="/Account" class="btn btn-success btn-block">Add <i
|
||||
class="glyphicon glyphicon-plus"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</h2>
|
||||
<table class="table table-condensed table-bordered table-striped">
|
||||
<table class="table table-condensed table-bordered table-striped" keypress="shortcuts">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
@@ -20,7 +22,8 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="item in accounts">
|
||||
<tr id="{{$index}}" ng-repeat="item in accounts" ng-class="{warning:$index==selected}"
|
||||
ng-click="setSelected($index)">
|
||||
<td><a href="{{item.Url}}">{{item.Name}}</a></td>
|
||||
<td>{{item.Type}}</td>
|
||||
<td>{{item.IsActive}}</td>
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
<input type="text" class="form-control" placeholder="Search" ng-model="search">
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<a href="/Employee" class="btn btn-success btn-block">Add <i
|
||||
class="glyphicon glyphicon-plus"></i></a>
|
||||
</div>
|
||||
<a href="/Employee" class="btn btn-success btn-block">Add <i
|
||||
class="glyphicon glyphicon-plus"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</h2>
|
||||
<table class="table table-condensed table-bordered table-striped">
|
||||
<table class="table table-condensed table-bordered table-striped" keypress="shortcuts">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Code</th>
|
||||
@@ -22,8 +22,9 @@
|
||||
<th>Leaving Date</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="tbodyMain">
|
||||
<tr ng-repeat="item in employees">
|
||||
<tbody>
|
||||
<tr id="{{$index}}" ng-repeat="item in employees" ng-class="{warning:$index==selected}"
|
||||
ng-click="setSelected($index)">
|
||||
<td>{{item.Code}}</td>
|
||||
<td><a href="{{item.Url}}">{{item.Name}}</a></td>
|
||||
<td>{{item.Designation}}</td>
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr id="{{$index}}" ng-repeat="item in display.Body" ng-class="{danger:!item.Posted && $index!=selected, warning:$index==selected}"
|
||||
<tr id="{{$index}}" ng-repeat="item in ledger" ng-class="{danger:!item.Posted && $index!=selected, warning:$index==selected}"
|
||||
ng-click="setSelected($index)">
|
||||
<td class="no-wrap">{{item.Date}}</td>
|
||||
<td><a href="{{item.Url}}">{{item.Name}}</a></td>
|
||||
@@ -64,13 +64,13 @@
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td class="no-wrap">{{display.Footer.Date}}</td>
|
||||
<td class="no-wrap"></td>
|
||||
<td>Closing Balance</td>
|
||||
<td>Closing Balance</td>
|
||||
<td></td>
|
||||
<td class="text-right no-wrap">{{display.Footer.Debit | currency}}</td>
|
||||
<td class="text-right no-wrap">{{display.Footer.Credit | currency}}</td>
|
||||
<td class="text-right no-wrap">{{display.Footer.Running | accounting}}</td>
|
||||
<td class="text-right no-wrap">{{footer.Debit | currency}}</td>
|
||||
<td class="text-right no-wrap">{{footer.Credit | currency}}</td>
|
||||
<td class="text-right no-wrap">{{footer.Running | accounting}}</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</h2>
|
||||
<table class="table table-condensed table-bordered table-striped">
|
||||
<table class="table table-condensed table-bordered table-striped" keypress="shortcuts">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-right">Code</th>
|
||||
@@ -21,7 +21,8 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="item in products">
|
||||
<tr id="{{$index}}" ng-repeat="item in products" ng-class="{warning:$index==selected}"
|
||||
ng-click="setSelected($index)">
|
||||
<td class="text-right">{{item.Code}}</td>
|
||||
<td><a href="{{item.Url}}">{{item.Name}} ({{showExtended ? item.Fraction + ' ' + item.FractionUnits + ' = 1 ' : ''}}{{item.Units}})</a></td>
|
||||
<td class="text-right">{{item.Price | currency}}</td>
|
||||
|
||||
@@ -44,6 +44,31 @@ var AccountListCtrl = ['$scope', '$location', '$routeParams', 'Tokenizer', 'acco
|
||||
});
|
||||
}
|
||||
}, 350);
|
||||
|
||||
$scope.selected = -1;
|
||||
$scope.setSelected = function (index) {
|
||||
$scope.selected = Math.min(Math.max(0, index), $scope.accounts.length - 1);
|
||||
};
|
||||
$scope.shortcuts = {
|
||||
'up': function (e) {
|
||||
if ($scope.selected > 0) {
|
||||
$scope.$apply(function () {
|
||||
$scope.selected = Math.min(Math.max(0, $scope.selected - 1), $scope.accounts.length - 1);
|
||||
});
|
||||
$("#" + $scope.selected).scrollintoview();
|
||||
e.preventDefault();
|
||||
}
|
||||
},
|
||||
'down': function (e) {
|
||||
if ($scope.selected < $scope.accounts.length - 1) {
|
||||
$scope.$apply(function () {
|
||||
$scope.selected = Math.min(Math.max(0, $scope.selected + 1), $scope.accounts.length - 1);
|
||||
});
|
||||
$("#" + $scope.selected).scrollintoview();
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
};
|
||||
}];
|
||||
AccountListCtrl.resolve = {
|
||||
accounts: ['Account', function (Account) {
|
||||
@@ -58,19 +83,19 @@ var AccountCtrl = ['$scope', '$location', '$modal', 'account', 'accountTypes', '
|
||||
$scope.costCenters = costCenters;
|
||||
|
||||
$scope.save = function () {
|
||||
$scope.account.$save(function (u, putResponseHeaders) {
|
||||
$scope.account.$save(function () {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$location.path('/Accounts');
|
||||
}, function (data, status) {
|
||||
}, function (data) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.delete = function () {
|
||||
$scope.account.$delete(function (u, putResponseHeaders) {
|
||||
$scope.account.$delete(function () {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$location.path('/Accounts');
|
||||
}, function (data, status) {
|
||||
}, function (data) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
+40
-34
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
var overlord_directive = angular.module('overlord.directive', []);
|
||||
overlord_directive.directive('fadey', function () {
|
||||
var overlordDirective = angular.module('overlord.directive', []);
|
||||
overlordDirective.directive('fadey', function () {
|
||||
return {
|
||||
restrict: 'A',
|
||||
link: function (scope, element, attrs) {
|
||||
@@ -22,7 +22,7 @@ overlord_directive.directive('fadey', function () {
|
||||
};
|
||||
});
|
||||
|
||||
overlord_directive.directive('ngGrowl', ['growl', '$parse', function (growl, $parse) {
|
||||
overlordDirective.directive('ngGrowl', ['growl', '$parse', function (growl, $parse) {
|
||||
return {
|
||||
restrict: 'A',
|
||||
link: function (scope, element, attrs) {
|
||||
@@ -34,7 +34,7 @@ overlord_directive.directive('ngGrowl', ['growl', '$parse', function (growl, $pa
|
||||
};
|
||||
}]);
|
||||
|
||||
overlord_directive.directive('aceEditor', ['$parse', function ($parse) {
|
||||
overlordDirective.directive('aceEditor', ['$parse', function ($parse) {
|
||||
var ACE_EDITOR_CLASS = 'ace-editor';
|
||||
|
||||
function loadAceEditor(element, mode) {
|
||||
@@ -64,13 +64,15 @@ overlord_directive.directive('aceEditor', ['$parse', function ($parse) {
|
||||
$(editorElement).css("border", "1px solid #ddd");
|
||||
$(editorElement).css("border-radius", "4px");
|
||||
|
||||
if (!ngModel) return; // do nothing if no ngModel
|
||||
if (!ngModel) {
|
||||
return; // do nothing if no ngModel
|
||||
}
|
||||
|
||||
var getter = $parse(attrs['ngModel']);
|
||||
var getter = $parse(attrs.ngModel);
|
||||
var setter = getter.assign;
|
||||
|
||||
editor.getSession().setValue(getter(scope));
|
||||
scope.$watch(attrs['ngModel'], function (newValue) {
|
||||
scope.$watch(attrs.ngModel, function (newValue) {
|
||||
if (editor.getValue() !== newValue) {
|
||||
editor.getSession().setValue(newValue);
|
||||
}
|
||||
@@ -87,16 +89,16 @@ overlord_directive.directive('aceEditor', ['$parse', function ($parse) {
|
||||
};
|
||||
}]);
|
||||
|
||||
overlord_directive.directive('chosen', ['$parse', function ($parse) {
|
||||
overlordDirective.directive('chosen', ['$parse', function ($parse) {
|
||||
var linker = function (scope, element, attrs) {
|
||||
var model = attrs['ngModel'],
|
||||
list = attrs['chosen'],
|
||||
createFunction = attrs['createFunction'],
|
||||
var model = attrs.ngModel,
|
||||
list = attrs.chosen,
|
||||
createFunction = attrs.createFunction,
|
||||
options = {};
|
||||
|
||||
if (angular.isUndefined(createFunction)) {
|
||||
options['create_option'] = function (data) {
|
||||
var fn = $parse(attrs['createFunction'] + '("' + data + '")');
|
||||
options.create_option = function (data) {
|
||||
var fn = $parse(attrs.createFunction + '("' + data + '")');
|
||||
scope.$apply(function () {
|
||||
fn(scope);
|
||||
});
|
||||
@@ -120,30 +122,34 @@ overlord_directive.directive('chosen', ['$parse', function ($parse) {
|
||||
};
|
||||
}]);
|
||||
|
||||
overlord_directive.directive('keypress', [function () {
|
||||
overlordDirective.directive('keypress', [function () {
|
||||
return function (scope, element, attrs) {
|
||||
var attribute = scope.$eval(attrs.keypress || '{}');
|
||||
for (var k in attribute) {
|
||||
(function (k) {
|
||||
Mousetrap.bind(k, attribute[k]);
|
||||
})(k);
|
||||
var keypress = scope.$eval(attrs.keypress || '{}');
|
||||
for (var k in keypress) {
|
||||
if (keypress.hasOwnProperty(k)) {
|
||||
(function (k, val) {
|
||||
Mousetrap.bind(k, val);
|
||||
})(k, keypress[k]);
|
||||
}
|
||||
}
|
||||
element.on('$destroy', function () {
|
||||
for (var k in attribute) {
|
||||
(function (k) {
|
||||
Mousetrap.unbind(k);
|
||||
})(k);
|
||||
for (var k in keypress) {
|
||||
if (keypress.hasOwnProperty(k)) {
|
||||
(function (k) {
|
||||
Mousetrap.unbind(k);
|
||||
})(k);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
}]);
|
||||
|
||||
overlord_directive.directive('onReturn', ['$parse', function ($parse) {
|
||||
overlordDirective.directive('onReturn', ['$parse', function ($parse) {
|
||||
return {
|
||||
compile: function ($element, attr) {
|
||||
var fn = $parse(attr["onReturn"]);
|
||||
return function (scope, element, attr) {
|
||||
var fn = $parse(attr.onReturn);
|
||||
return function (scope, element) {
|
||||
element.on("keypress", function (event) {
|
||||
if (event.which === 13) {
|
||||
scope.$apply(function () {
|
||||
@@ -158,7 +164,7 @@ overlord_directive.directive('onReturn', ['$parse', function ($parse) {
|
||||
}]);
|
||||
|
||||
|
||||
overlord_directive.directive('tanSse', ['$parse', function ($parse) {
|
||||
overlordDirective.directive('tanSse', ['$parse', function ($parse) {
|
||||
return{
|
||||
restrict: 'EM',
|
||||
link: function ($scope, element, attrs) {
|
||||
@@ -190,7 +196,7 @@ overlord_directive.directive('tanSse', ['$parse', function ($parse) {
|
||||
};
|
||||
}]);
|
||||
|
||||
overlord_directive.directive('tanClick', ['$parse', '$timeout', function ($parse, $timeout) {
|
||||
overlordDirective.directive('tanClick', ['$parse', '$timeout', function ($parse, $timeout) {
|
||||
return {
|
||||
compile: function ($element, attr) {
|
||||
var fn = $parse(attr.tanClick);
|
||||
@@ -216,7 +222,7 @@ overlord_directive.directive('tanClick', ['$parse', '$timeout', function ($parse
|
||||
};
|
||||
}]);
|
||||
|
||||
overlord_directive.directive('chartDiscreteBar', ['$parse', function ($parse) {
|
||||
overlordDirective.directive('chartDiscreteBar', ['$parse', function ($parse) {
|
||||
return {
|
||||
restrict: 'A',
|
||||
link: function (scope, element, attrs) {
|
||||
@@ -246,7 +252,7 @@ overlord_directive.directive('chartDiscreteBar', ['$parse', function ($parse) {
|
||||
};
|
||||
}]);
|
||||
|
||||
overlord_directive.directive('chartMultiBar', ['$parse', function ($parse) {
|
||||
overlordDirective.directive('chartMultiBar', ['$parse', function ($parse) {
|
||||
return {
|
||||
restrict: 'A',
|
||||
link: function (scope, element, attrs) {
|
||||
@@ -267,7 +273,7 @@ overlord_directive.directive('chartMultiBar', ['$parse', function ($parse) {
|
||||
};
|
||||
}]);
|
||||
|
||||
overlord_directive.directive('chartLine', ['$parse', function ($parse) {
|
||||
overlordDirective.directive('chartLine', ['$parse', function ($parse) {
|
||||
return {
|
||||
restrict: 'A',
|
||||
link: function (scope, element, attrs) {
|
||||
@@ -290,7 +296,7 @@ overlord_directive.directive('chartLine', ['$parse', function ($parse) {
|
||||
};
|
||||
}]);
|
||||
|
||||
overlord_directive.directive('chartPie', ['$parse', function ($parse) {
|
||||
overlordDirective.directive('chartPie', ['$parse', function ($parse) {
|
||||
return {
|
||||
restrict: 'A',
|
||||
link: function (scope, element, attrs) {
|
||||
@@ -328,7 +334,7 @@ overlord_directive.directive('chartPie', ['$parse', function ($parse) {
|
||||
};
|
||||
}]);
|
||||
|
||||
overlord_directive.directive('chartLinePlusBar', ['$parse', function ($parse) {
|
||||
overlordDirective.directive('chartLinePlusBar', ['$parse', function ($parse) {
|
||||
return {
|
||||
restrict: 'A',
|
||||
link: function (scope, element, attrs) {
|
||||
@@ -368,7 +374,7 @@ overlord_directive.directive('chartLinePlusBar', ['$parse', function ($parse) {
|
||||
};
|
||||
}]);
|
||||
|
||||
overlord_directive.directive('fileUpload', function () {
|
||||
overlordDirective.directive('fileUpload', function () {
|
||||
return {
|
||||
scope: true, //create a new scope
|
||||
link: function (scope, el, attrs) {
|
||||
|
||||
+16
-16
@@ -1,11 +1,11 @@
|
||||
'use strict';
|
||||
|
||||
var overlord_filter = angular.module('overlord.filter', []);
|
||||
overlord_filter.filter('debit', function () {
|
||||
var overlordFilter = angular.module('overlord.filter', []);
|
||||
overlordFilter.filter('debit', function () {
|
||||
return function (input) {
|
||||
if (input == -1) {
|
||||
if (input === -1) {
|
||||
return 'Cr';
|
||||
} else if (input == 1) {
|
||||
} else if (input === 1) {
|
||||
return 'Dr';
|
||||
} else {
|
||||
return '';
|
||||
@@ -13,26 +13,26 @@ overlord_filter.filter('debit', function () {
|
||||
};
|
||||
});
|
||||
|
||||
overlord_filter.filter('posted', function () {
|
||||
overlordFilter.filter('posted', function () {
|
||||
return function (input) {
|
||||
return input === true ? 'Posted' : 'Post';
|
||||
};
|
||||
});
|
||||
|
||||
overlord_filter.filter('md', function () {
|
||||
overlordFilter.filter('md', function () {
|
||||
var converter = new Showdown.converter();
|
||||
return function (input) {
|
||||
return converter.makeHtml(input || '');
|
||||
};
|
||||
});
|
||||
|
||||
overlord_filter.filter('save_button', function () {
|
||||
overlordFilter.filter('save_button', function () {
|
||||
return function (input) {
|
||||
return (!input) ? 'Save' : 'Update';
|
||||
};
|
||||
});
|
||||
|
||||
overlord_filter.filter('journalDebit', function () {
|
||||
overlordFilter.filter('journalDebit', function () {
|
||||
return function (input, debit) {
|
||||
var list = [];
|
||||
if (!angular.isUndefined(input)) {
|
||||
@@ -46,7 +46,7 @@ overlord_filter.filter('journalDebit', function () {
|
||||
};
|
||||
});
|
||||
|
||||
overlord_filter.filter('localTime', function () {
|
||||
overlordFilter.filter('localTime', function () {
|
||||
var months = {
|
||||
Jan: 1,
|
||||
Feb: 2,
|
||||
@@ -61,7 +61,7 @@ overlord_filter.filter('localTime', function () {
|
||||
Nov: 11,
|
||||
Dec: 12
|
||||
};
|
||||
var months_reverse = {
|
||||
var monthsReverse = {
|
||||
1: 'Jan',
|
||||
2: 'Feb',
|
||||
3: 'Mar',
|
||||
@@ -92,12 +92,12 @@ overlord_filter.filter('localTime', function () {
|
||||
}
|
||||
var date = new Date(parseInt(d[2]), months[d[1]] - 1, parseInt(d[0]), parseInt(d[3]), parseInt(d[4])).getTime();
|
||||
date = new Date(date - (new Date().getTimezoneOffset() * 60000));
|
||||
var output = padNumber(date.getDate()) + '-' + months_reverse[date.getMonth() + 1] + '-' + date.getFullYear() + ' ' + padNumber(date.getHours()) + ':' + padNumber(date.getMinutes());
|
||||
var output = padNumber(date.getDate()) + '-' + monthsReverse[date.getMonth() + 1] + '-' + date.getFullYear() + ' ' + padNumber(date.getHours()) + ':' + padNumber(date.getMinutes());
|
||||
return output;
|
||||
};
|
||||
});
|
||||
|
||||
overlord_filter.filter('percent', ['numberFilter', function (numberFilter) {
|
||||
overlordFilter.filter('percent', ['numberFilter', function (numberFilter) {
|
||||
return function (input) {
|
||||
if (!angular.isNumber(input)) {
|
||||
return input;
|
||||
@@ -106,13 +106,13 @@ overlord_filter.filter('percent', ['numberFilter', function (numberFilter) {
|
||||
};
|
||||
}]);
|
||||
|
||||
overlord_filter.filter('asDate', ['dateFilter', function (dateFilter) {
|
||||
overlordFilter.filter('asDate', ['dateFilter', function (dateFilter) {
|
||||
return function (input) {
|
||||
return angular.isDate(input) ? dateFilter(input, 'dd-MMM-yyyy') : input
|
||||
return angular.isDate(input) ? dateFilter(input, 'dd-MMM-yyyy') : input;
|
||||
};
|
||||
}]);
|
||||
|
||||
overlord_filter.filter('clr', function () {
|
||||
overlordFilter.filter('clr', function () {
|
||||
return function (input) {
|
||||
if (input === '\u20B9\u00A00.00' || input === '0.00') {
|
||||
return '';
|
||||
@@ -121,7 +121,7 @@ overlord_filter.filter('clr', function () {
|
||||
};
|
||||
});
|
||||
|
||||
overlord_filter.filter('accounting', ['currencyFilter', function (currencyFilter) {
|
||||
overlordFilter.filter('accounting', ['currencyFilter', function (currencyFilter) {
|
||||
return function (amount) {
|
||||
amount = currencyFilter(amount);
|
||||
if (amount === '') {
|
||||
|
||||
+80
-121
@@ -1,12 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
var overlord_service = angular.module('overlord.service', ['ngResource']);
|
||||
var overlordService = angular.module('overlord.service', ['ngResource']);
|
||||
|
||||
overlord_service.factory('IssueGrid', ['$resource', function ($resource) {
|
||||
overlordService.factory('IssueGrid', ['$resource', function ($resource) {
|
||||
return $resource('/api/Issues/Services/:date');
|
||||
}]);
|
||||
|
||||
overlord_service.factory('Voucher', ['$resource', function ($resource) {
|
||||
overlordService.factory('Voucher', ['$resource', function ($resource) {
|
||||
return $resource('/api/Voucher/:id',
|
||||
{id: '@VoucherID'}, {
|
||||
post: {method: 'POST', params: {post: true}},
|
||||
@@ -50,7 +50,7 @@ overlord_service.factory('Voucher', ['$resource', function ($resource) {
|
||||
});
|
||||
}]);
|
||||
|
||||
overlord_service.factory('Account', ['$resource', function ($resource) {
|
||||
overlordService.factory('Account', ['$resource', function ($resource) {
|
||||
return $resource('/api/Account/:id',
|
||||
{id: '@LedgerID'}, {
|
||||
query: {method: 'GET', params: {list: true}, isArray: true},
|
||||
@@ -58,14 +58,14 @@ overlord_service.factory('Account', ['$resource', function ($resource) {
|
||||
});
|
||||
}]);
|
||||
|
||||
overlord_service.factory('Recipe', ['$resource', function ($resource) {
|
||||
overlordService.factory('Recipe', ['$resource', function ($resource) {
|
||||
return $resource('/api/Recipe/:id',
|
||||
{id: '@RecipeID'}, {
|
||||
query: {method: 'GET', params: {list: true}, isArray: true}
|
||||
});
|
||||
}]);
|
||||
|
||||
overlord_service.factory('Employee', ['$resource', function ($resource) {
|
||||
overlordService.factory('Employee', ['$resource', function ($resource) {
|
||||
return $resource('/api/Employee/:id',
|
||||
{id: '@LedgerID'}, {
|
||||
query: {method: 'GET', params: {list: true}, isArray: true},
|
||||
@@ -73,30 +73,30 @@ overlord_service.factory('Employee', ['$resource', function ($resource) {
|
||||
});
|
||||
}]);
|
||||
|
||||
overlord_service.factory('Ledger', ['$resource', function ($resource) {
|
||||
overlordService.factory('Ledger', ['$resource', function ($resource) {
|
||||
return $resource('/api/Ledger/:id');
|
||||
}]);
|
||||
|
||||
overlord_service.factory('Reconcile', ['$resource', function ($resource) {
|
||||
overlordService.factory('Reconcile', ['$resource', function ($resource) {
|
||||
return $resource('/api/Reconcile/:id', {id: '@Account.LedgerID'});
|
||||
}]);
|
||||
|
||||
overlord_service.factory('ProductLedger', ['$resource', function ($resource) {
|
||||
overlordService.factory('ProductLedger', ['$resource', function ($resource) {
|
||||
return $resource('/api/ProductLedger/:id');
|
||||
}]);
|
||||
|
||||
overlord_service.factory('CostCenter', ['$resource', function ($resource) {
|
||||
overlordService.factory('CostCenter', ['$resource', function ($resource) {
|
||||
return $resource('/api/CostCenter/:id',
|
||||
{id: '@CostCenterID'}, {
|
||||
query: {method: 'GET', params: {list: true}, isArray: true}
|
||||
});
|
||||
}]);
|
||||
|
||||
overlord_service.factory('AccountType', ['$resource', function ($resource) {
|
||||
overlordService.factory('AccountType', ['$resource', function ($resource) {
|
||||
return $resource('/api/AccountTypes');
|
||||
}]);
|
||||
|
||||
overlord_service.factory('User', ['$resource', function ($resource) {
|
||||
overlordService.factory('User', ['$resource', function ($resource) {
|
||||
return $resource('/api/User/:id',
|
||||
{id: '@UserID'}, {
|
||||
query: {method: 'GET', params: {list: true}, isArray: true},
|
||||
@@ -104,21 +104,21 @@ overlord_service.factory('User', ['$resource', function ($resource) {
|
||||
});
|
||||
}]);
|
||||
|
||||
overlord_service.factory('Group', ['$resource', function ($resource) {
|
||||
overlordService.factory('Group', ['$resource', function ($resource) {
|
||||
return $resource('/api/Group/:id',
|
||||
{id: '@GroupID'}, {
|
||||
query: {method: 'GET', params: {list: true}, isArray: true}
|
||||
});
|
||||
}]);
|
||||
|
||||
overlord_service.factory('Client', ['$resource', function ($resource) {
|
||||
overlordService.factory('Client', ['$resource', function ($resource) {
|
||||
return $resource('/api/Client/:id',
|
||||
{id: '@ClientID'}, {
|
||||
query: {method: 'GET', params: {list: true}, isArray: true}
|
||||
});
|
||||
}]);
|
||||
|
||||
overlord_service.factory('Product', ['$resource', function ($resource) {
|
||||
overlordService.factory('Product', ['$resource', function ($resource) {
|
||||
return $resource('/api/Product/:id',
|
||||
{id: '@ProductID'}, {
|
||||
query: {method: 'GET', params: {list: true}, isArray: true},
|
||||
@@ -126,153 +126,111 @@ overlord_service.factory('Product', ['$resource', function ($resource) {
|
||||
});
|
||||
}]);
|
||||
|
||||
overlord_service.factory('Batch', ['$resource', function ($resource) {
|
||||
overlordService.factory('Batch', ['$resource', function ($resource) {
|
||||
return $resource('/api/Batch', {}, {
|
||||
autocomplete: {method: 'GET', params: {term: ''}, isArray: true}
|
||||
});
|
||||
}]);
|
||||
|
||||
overlord_service.factory('ProductGroup', ['$resource', function ($resource) {
|
||||
overlordService.factory('ProductGroup', ['$resource', function ($resource) {
|
||||
return $resource('/api/ProductGroup/:id',
|
||||
{id: '@ProductGroupID'}, {
|
||||
query: {method: 'GET', params: {list: true}, isArray: true}
|
||||
});
|
||||
}]);
|
||||
|
||||
overlord_service.factory('CostCenter', ['$resource', function ($resource) {
|
||||
overlordService.factory('CostCenter', ['$resource', function ($resource) {
|
||||
return $resource('/api/CostCenter/:id',
|
||||
{id: '@CostCenterID'}, {
|
||||
query: {method: 'GET', params: {list: true}, isArray: true}
|
||||
});
|
||||
}]);
|
||||
|
||||
overlord_service.factory('TrialBalance', ['$resource', function ($resource) {
|
||||
overlordService.factory('TrialBalance', ['$resource', function ($resource) {
|
||||
return $resource('/api/TrialBalance/:date');
|
||||
}]);
|
||||
|
||||
overlord_service.factory('ClosingStock', ['$resource', function ($resource) {
|
||||
overlordService.factory('ClosingStock', ['$resource', function ($resource) {
|
||||
return $resource('/api/ClosingStock/:date');
|
||||
}]);
|
||||
|
||||
overlord_service.factory('CashFlow', ['$resource', function ($resource) {
|
||||
overlordService.factory('CashFlow', ['$resource', function ($resource) {
|
||||
return $resource('/api/CashFlow/:id');
|
||||
}]);
|
||||
|
||||
overlord_service.factory('Daybook', ['$resource', function ($resource) {
|
||||
overlordService.factory('Daybook', ['$resource', function ($resource) {
|
||||
return $resource('/api/Daybook');
|
||||
}]);
|
||||
|
||||
overlord_service.factory('Unposted', ['$resource', function ($resource) {
|
||||
overlordService.factory('Unposted', ['$resource', function ($resource) {
|
||||
return $resource('/api/Unposted');
|
||||
}]);
|
||||
|
||||
overlord_service.factory('ProfitLoss', ['$resource', function ($resource) {
|
||||
overlordService.factory('ProfitLoss', ['$resource', function ($resource) {
|
||||
return $resource('/api/ProfitLoss');
|
||||
}]);
|
||||
|
||||
overlord_service.factory('StockMovement', ['$resource', function ($resource) {
|
||||
overlordService.factory('StockMovement', ['$resource', function ($resource) {
|
||||
return $resource('/api/StockMovement');
|
||||
}]);
|
||||
|
||||
overlord_service.factory('BalanceSheet', ['$resource', function ($resource) {
|
||||
overlordService.factory('BalanceSheet', ['$resource', function ($resource) {
|
||||
return $resource('/api/BalanceSheet/:date');
|
||||
}]);
|
||||
|
||||
overlord_service.factory('NetTransactions', ['$resource', function ($resource) {
|
||||
overlordService.factory('NetTransactions', ['$resource', function ($resource) {
|
||||
return $resource('/api/NetTransactions');
|
||||
}]);
|
||||
|
||||
overlord_service.factory('Purchases', ['$resource', function ($resource) {
|
||||
overlordService.factory('Purchases', ['$resource', function ($resource) {
|
||||
return $resource('/api/Purchases');
|
||||
}]);
|
||||
|
||||
overlord_service.factory('PurchaseEntries', ['$resource', function ($resource) {
|
||||
overlordService.factory('PurchaseEntries', ['$resource', function ($resource) {
|
||||
return $resource('/api/PurchaseEntries');
|
||||
}]);
|
||||
|
||||
overlord_service.factory('RawMaterialCost', ['$resource', function ($resource) {
|
||||
overlordService.factory('RawMaterialCost', ['$resource', function ($resource) {
|
||||
return $resource('/api/RawMaterialCost/:id');
|
||||
}]);
|
||||
|
||||
overlord_service.factory('Auth', ['$resource', function ($resource) {
|
||||
overlordService.factory('Auth', ['$resource', function ($resource) {
|
||||
return $resource('/api/Auth', {}, {
|
||||
login: {method: 'GET', params: {list: true}, isArray: true}
|
||||
});
|
||||
}]);
|
||||
|
||||
overlord_service.factory('Attendance', ['$resource', function ($resource) {
|
||||
overlordService.factory('Attendance', ['$resource', function ($resource) {
|
||||
return $resource('/api/Attendance/:date', {date: '@Date'});
|
||||
}]);
|
||||
|
||||
overlord_service.factory('AttendanceTypes', ['$resource', function ($resource) {
|
||||
overlordService.factory('AttendanceTypes', ['$resource', function ($resource) {
|
||||
return $resource('/api/AttendanceTypes');
|
||||
}]);
|
||||
|
||||
overlord_service.factory('EmployeeAttendance', ['$resource', function ($resource) {
|
||||
overlordService.factory('EmployeeAttendance', ['$resource', function ($resource) {
|
||||
return $resource('/api/EmployeeAttendance/:id', {id: '@Employee.LedgerID'});
|
||||
}]);
|
||||
|
||||
overlord_service.factory('Account', ['$resource', function ($resource) {
|
||||
overlordService.factory('Account', ['$resource', function ($resource) {
|
||||
return $resource('/api/Account/:id',
|
||||
{id: '@LedgerID'}, {
|
||||
query: {method: 'GET', params: {list: true}, isArray: true},
|
||||
autocomplete: {method: 'GET', params: {term: ''}, isArray: true}
|
||||
});
|
||||
}]);
|
||||
overlord_service.factory('Message', ['$resource', function ($resource) {
|
||||
overlordService.factory('Message', ['$resource', function ($resource) {
|
||||
return $resource('/api/Message/:id',
|
||||
{id: '@ThreadID'}, {
|
||||
query: {method: 'GET', params: {list: true}}
|
||||
});
|
||||
}]);
|
||||
|
||||
overlord_service.factory('Tag', ['$resource', function ($resource) {
|
||||
overlordService.factory('Tag', ['$resource', function ($resource) {
|
||||
return $resource('/api/Tags');
|
||||
}]);
|
||||
|
||||
overlord_service.service('EventSource', function () {
|
||||
this.status = 'Disconnected';
|
||||
this.Open = function (url) {
|
||||
if (url) {
|
||||
this.url = url;
|
||||
}
|
||||
if (this.url) {
|
||||
this.source = new EventSource(url);
|
||||
if (this.status !== 'Open') {
|
||||
this.source.addEventListener('open', function (e) {
|
||||
this.status = 'Open';
|
||||
}, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
this.DataCallback = function (callback) {
|
||||
this.source.addEventListener('message', function (e) {
|
||||
var data = JSON.parse(e.data);
|
||||
callback(e);
|
||||
}, false);
|
||||
};
|
||||
this.source.addEventListener('error', function (e) {
|
||||
if (e.readyState === EventSource.CLOSED) {
|
||||
this.status = 'Error';
|
||||
}
|
||||
}, false);
|
||||
this.ErrorCallback = function (callback) {
|
||||
this.source.addEventListener('error', callback, false);
|
||||
};
|
||||
|
||||
this.EventCallback = function (event, callback) {
|
||||
this.source.addEventListener(event, callback, false);
|
||||
};
|
||||
|
||||
this.Close = function () {
|
||||
if (this.status === 'Open') {
|
||||
this.source.close();
|
||||
this.status = 'Closed';
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
overlord_service.factory('Tokenizer', ['$filter', function ($filter) {
|
||||
overlordService.factory('Tokenizer', ['$filter', function ($filter) {
|
||||
var parseFilterString = function (q, searchInfo) {
|
||||
// '[^']+'|"[^"]+"|[^ ]+ == Match a space delimited string or quoted string. ms for short
|
||||
// ((ms\s*:\s*ms)|ms) == Match string : Match string OR Match string
|
||||
@@ -298,15 +256,19 @@ overlord_service.factory('Tokenizer', ['$filter', function ($filter) {
|
||||
return a >= b;
|
||||
},
|
||||
'==': function (a, b) {
|
||||
return a == b;
|
||||
return a === b;
|
||||
},
|
||||
'!=': function (a, b) {
|
||||
return a != b;
|
||||
return a !== b;
|
||||
}
|
||||
},
|
||||
comparators = {
|
||||
'text': function (obj, text) {
|
||||
return obj.toLowerCase().indexOf(text) > -1;
|
||||
if (text.indexOf('!') === 0) {
|
||||
return obj.toLowerCase().indexOf(text.substr(1)) <= -1;
|
||||
} else {
|
||||
return obj.toLowerCase().indexOf(text) > -1;
|
||||
}
|
||||
},
|
||||
'boolean': function (obj, text) {
|
||||
return obj === isTrue(text);
|
||||
@@ -319,7 +281,7 @@ overlord_service.factory('Tokenizer', ['$filter', function ($filter) {
|
||||
return obj.toString().indexOf(text) > -1;
|
||||
}
|
||||
},
|
||||
'true': function (obj, text) {
|
||||
'true': function () {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -339,8 +301,19 @@ overlord_service.factory('Tokenizer', ['$filter', function ($filter) {
|
||||
return {'Col': comparator.Col, 'Comparator': comparators[comparator.Comparator], 'Value': value};
|
||||
}
|
||||
|
||||
function toArray(matches) {
|
||||
return _.reduce(matches, function (accumulator, item) {
|
||||
function opLength(operator) {
|
||||
var i,
|
||||
ops = ['<=', '<', '>=', '>', '==', '!='];
|
||||
for (i = 0; i < ops.length; i++) {
|
||||
if (operator.indexOf(ops[i]) === 0) {
|
||||
return ops[i].length;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
_(q.match(re))
|
||||
.reduce(function (accumulator, item) {
|
||||
var key,
|
||||
value;
|
||||
if (item.indexOf(':') === -1) {
|
||||
@@ -360,36 +333,22 @@ overlord_service.factory('Tokenizer', ['$filter', function ($filter) {
|
||||
accumulator.push({Key: key, Value: value});
|
||||
}
|
||||
return accumulator;
|
||||
}, []);
|
||||
}
|
||||
}, [])
|
||||
.forEach(function (item) {
|
||||
var key = item.Key,
|
||||
value = item.Value;
|
||||
|
||||
function opLength(operator) {
|
||||
var i,
|
||||
ops = ['<=', '<', '>=', '>', '==', '!='];
|
||||
for (i = 0; i < ops.length; i++) {
|
||||
if (operator.indexOf(ops[i]) == 0) {
|
||||
return ops[i].length;
|
||||
if (key === '' && value.length > 1 && is(value.charAt(0), '+-') && value.substr(1) in sorter) {
|
||||
sorting.push(value.charAt(0) + sorter[value.substr(1).toLowerCase()]);
|
||||
} else {
|
||||
key = key || defaultKey;
|
||||
if (key in comparator) {
|
||||
matches.push(pushObject(comparator[key], value));
|
||||
} else if (key in flagger) {
|
||||
flags[key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
_(q.match(re))
|
||||
_.forEach(toArray(q.match(re)), function (item) {
|
||||
var key = item.Key,
|
||||
value = item.Value;
|
||||
|
||||
if (key === '' && value.length > 1 && is(value.charAt(0), '+-') && value.substr(1) in sorter) {
|
||||
sorting.push(value.charAt(0) + sorter[value.substr(1).toLowerCase()]);
|
||||
} else {
|
||||
key = key || defaultKey;
|
||||
if (key in comparator) {
|
||||
matches.push(pushObject(comparator[key], value));
|
||||
} else if (key in flagger) {
|
||||
flags[key] = value;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
return {'q': matches, 'o': sorting, 'f': flags};
|
||||
};
|
||||
var doFilter = _.memoize(function (q, array, matches) {
|
||||
@@ -408,7 +367,7 @@ overlord_service.factory('Tokenizer', ['$filter', function ($filter) {
|
||||
return {parseFilterString: parseFilterString, doFilter: doFilter};
|
||||
}]);
|
||||
|
||||
overlord_service.factory("ReaderPromise", ["$q", function ($q) {
|
||||
overlordService.factory("ReaderPromise", ["$q", function ($q) {
|
||||
var onLoad = function (reader, deferred) {
|
||||
return function () {
|
||||
deferred.resolve(reader.result);
|
||||
@@ -442,8 +401,8 @@ overlord_service.factory("ReaderPromise", ["$q", function ($q) {
|
||||
};
|
||||
|
||||
var readAsDataURL = function (file, scope) {
|
||||
var deferred = $q.defer();
|
||||
var reader = getReader(deferred, scope);
|
||||
var deferred = $q.defer(),
|
||||
reader = getReader(deferred, scope);
|
||||
reader.readAsDataURL(file);
|
||||
return deferred.promise;
|
||||
};
|
||||
@@ -453,8 +412,8 @@ overlord_service.factory("ReaderPromise", ["$q", function ($q) {
|
||||
};
|
||||
}]);
|
||||
|
||||
overlord_service.factory("uploadedImageResizer", ["$q", "ReaderPromise", function ($q, ReaderPromise) {
|
||||
function ResizeImage(file, MAX_WIDTH, MAX_HEIGHT) {
|
||||
overlordService.factory("uploadedImageResizer", ["$q", "ReaderPromise", function ($q, ReaderPromise) {
|
||||
function resizeImage(file, MAX_WIDTH, MAX_HEIGHT) {
|
||||
var image = file,
|
||||
canvas = document.createElement('canvas'),
|
||||
ctx = canvas.getContext("2d"),
|
||||
@@ -495,8 +454,8 @@ overlord_service.factory("uploadedImageResizer", ["$q", "ReaderPromise", functio
|
||||
}
|
||||
ReaderPromise.readAsDataURL(uploadedFile.file).then(function (result) {
|
||||
file.Original = result;
|
||||
file.Thumbnail = ResizeImage(result, 100, 150);
|
||||
file.Resized = ResizeImage(result, 825, 1170);
|
||||
file.Thumbnail = resizeImage(result, 100, 150);
|
||||
file.Resized = resizeImage(result, 825, 1170);
|
||||
});
|
||||
oldFiles.push(file);
|
||||
};
|
||||
|
||||
@@ -9,9 +9,9 @@ var AttendanceCtrl = ['$scope', '$location', 'asDateFilter', 'Attendance', 'atte
|
||||
};
|
||||
$scope.save = function () {
|
||||
$scope.info.Date = asDate($scope.info.Date);
|
||||
return $scope.info.$save(function (u, putResponseHeaders) {
|
||||
return $scope.info.$save(function (u) {
|
||||
$scope.toasts.push({Type: 'Success', Message: u.Code});
|
||||
}, function (data, status) {
|
||||
}, function (data) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
@@ -14,19 +14,19 @@ var ClientCtrl = ['$scope', '$location', '$modal', 'client', function ($scope, $
|
||||
$scope.client = client;
|
||||
|
||||
$scope.save = function () {
|
||||
$scope.client.$save(function (u, putResponseHeaders) {
|
||||
$scope.client.$save(function () {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$location.path('/Clients');
|
||||
}, function (data, status) {
|
||||
}, function (data) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.delete = function () {
|
||||
$scope.client.$delete(function (u, putResponseHeaders) {
|
||||
$scope.client.$delete(function () {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$location.path('/Clients');
|
||||
}, function (data, status) {
|
||||
}, function (data) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
@@ -45,7 +45,7 @@ var EmployeeFunctionsCtrl = ['$scope', '$http', 'asDateFilter', function ($scope
|
||||
transformRequest: angular.identity
|
||||
}).success(function () {
|
||||
$scope.toasts.push({Type: 'Success', Message: 'Data uploaded'});
|
||||
}).error(function (data, status, headers, config) {
|
||||
}).error(function (data) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data});
|
||||
});
|
||||
};
|
||||
|
||||
@@ -3,14 +3,6 @@
|
||||
var EmployeeListCtrl = ['$scope', '$location', '$routeParams', 'Tokenizer', 'employees', function ($scope, $location, $routeParams, Tokenizer, employees) {
|
||||
$scope.search = $routeParams.q || '';
|
||||
$scope.info = employees;
|
||||
var re = /((([^ ]+):\s*('[^':]+'|"[^":]+"|[^ ]+))|[^ ]+[^: '"]*)/g;
|
||||
|
||||
$scope.isTrue = function (value) {
|
||||
value = value.toLowerCase();
|
||||
return !_.any(['f', 'fa', 'fal', 'fals', 'false', 'n', 'no', '0'], function (item) {
|
||||
return item === value;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.$watch('search', function (newValue, oldValue) {
|
||||
$scope.filterEmployees(newValue);
|
||||
@@ -54,6 +46,31 @@ var EmployeeListCtrl = ['$scope', '$location', '$routeParams', 'Tokenizer', 'emp
|
||||
});
|
||||
}
|
||||
}, 350);
|
||||
|
||||
$scope.selected = -1;
|
||||
$scope.setSelected = function (index) {
|
||||
$scope.selected = Math.min(Math.max(0, index), $scope.employees.length - 1);
|
||||
};
|
||||
$scope.shortcuts = {
|
||||
'up': function (e) {
|
||||
if ($scope.selected > 0) {
|
||||
$scope.$apply(function () {
|
||||
$scope.selected = Math.min(Math.max(0, $scope.selected - 1), $scope.employees.length - 1);
|
||||
});
|
||||
$("#" + $scope.selected).scrollintoview();
|
||||
e.preventDefault();
|
||||
}
|
||||
},
|
||||
'down': function (e) {
|
||||
if ($scope.selected < $scope.employees.length - 1) {
|
||||
$scope.$apply(function () {
|
||||
$scope.selected = Math.min(Math.max(0, $scope.selected + 1), $scope.employees.length - 1);
|
||||
});
|
||||
$("#" + $scope.selected).scrollintoview();
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
};
|
||||
}];
|
||||
|
||||
EmployeeListCtrl.resolve = {
|
||||
@@ -92,7 +109,7 @@ var EmployeeCtrl = ['$scope', '$routeParams', '$location', 'asDateFilter', '$mod
|
||||
backdrop: true,
|
||||
templateUrl: '/template/modal/confirm.html',
|
||||
controller: ['$scope', '$modalInstance', function ($scope, $modalInstance) {
|
||||
$scope.title = "Delete Account";
|
||||
$scope.title = "Delete Employee";
|
||||
$scope.body = "Are you sure? This cannot be undone.";
|
||||
$scope.isDelete = true;
|
||||
$scope.ok = function () {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
overlord_service.factory('growl', ['$http', '$compile', '$timeout', function ($http, $compile, $timeout) {
|
||||
overlordService.factory('growl', ['$http', '$compile', '$timeout', function ($http, $compile, $timeout) {
|
||||
var growl = {};
|
||||
growl.default_options = {
|
||||
offset: {
|
||||
|
||||
@@ -65,7 +65,7 @@ var JournalCtrl = ['$scope', '$location', 'asDateFilter', '$modal', 'uploadedIma
|
||||
if (!angular.isArray(journals)) {
|
||||
return;
|
||||
}
|
||||
var amount = journals.reduce(function (previousValue, currentValue, index, array) {
|
||||
var amount = journals.reduce(function (previousValue, currentValue) {
|
||||
return previousValue + (currentValue.Amount * currentValue.Debit);
|
||||
}, 0);
|
||||
$scope.amount = Math.abs(amount);
|
||||
|
||||
@@ -36,13 +36,13 @@ var LedgerCtrl = ['$scope', '$routeParams', '$location', 'asDateFilter', 'ledger
|
||||
};
|
||||
|
||||
$scope.$watch('hidden', function () {
|
||||
$scope.display = $scope.doFilter($scope.info, $scope.hidden);
|
||||
var filtered = $scope.doFilter($scope.hidden, $scope.info.Body);
|
||||
$scope.ledger = filtered.Body;
|
||||
$scope.footer = filtered.Footer;
|
||||
}, true);
|
||||
|
||||
$scope.doFilter = _.memoize(function (input, hidden) {
|
||||
var ledger = angular.copy(input),
|
||||
data = ledger.Body,
|
||||
footer = ledger.Footer,
|
||||
$scope.doFilter = _.memoize(function (hidden, input) {
|
||||
var data = angular.copy(input),
|
||||
debit = 0, credit = 0, running = 0;
|
||||
|
||||
if (hidden.length !== 0) {
|
||||
@@ -65,11 +65,15 @@ var LedgerCtrl = ['$scope', '$routeParams', '$location', 'asDateFilter', 'ledger
|
||||
}
|
||||
item.Running = running;
|
||||
});
|
||||
footer.Debit = debit;
|
||||
footer.Credit = credit;
|
||||
footer.Running = running;
|
||||
return {Body: data, Footer: footer};
|
||||
}, function (input, hidden) {
|
||||
return {
|
||||
Body: data,
|
||||
Footer: {
|
||||
Debit: debit,
|
||||
Credit: credit,
|
||||
Running: running
|
||||
}
|
||||
};
|
||||
}, function (hidden) {
|
||||
return hidden.sort().join(' ');
|
||||
});
|
||||
|
||||
@@ -77,26 +81,26 @@ var LedgerCtrl = ['$scope', '$routeParams', '$location', 'asDateFilter', 'ledger
|
||||
'up': function (e) {
|
||||
if ($scope.selected > 0) {
|
||||
$scope.$apply(function () {
|
||||
$scope.selected = $scope.selected -= 1;
|
||||
$scope.selected = Math.min(Math.max(0, $scope.selected - 1), $scope.ledger.length - 1);
|
||||
});
|
||||
$("#" + $scope.selected).scrollintoview({duration: 'fast'});
|
||||
$("#" + $scope.selected).scrollintoview();
|
||||
e.preventDefault();
|
||||
}
|
||||
},
|
||||
'down': function (e) {
|
||||
if ($scope.selected < $scope.display.Body.length - 1) {
|
||||
if ($scope.selected < $scope.ledger.length - 1) {
|
||||
$scope.$apply(function () {
|
||||
$scope.selected = $scope.selected += 1;
|
||||
$scope.selected = Math.min(Math.max(0, $scope.selected + 1), $scope.ledger.length - 1);
|
||||
});
|
||||
$("#" + $scope.selected).scrollintoview({duration: 'fast'});
|
||||
$("#" + $scope.selected).scrollintoview();
|
||||
e.preventDefault();
|
||||
}
|
||||
},
|
||||
'alt+r': function (e) {
|
||||
if ($scope.selected > -1) {
|
||||
$scope.$apply(function () {
|
||||
var max = $scope.display.Body.length;
|
||||
$scope.hidden.push($scope.display.Body[$scope.selected].ID);
|
||||
var max = $scope.ledger.length;
|
||||
$scope.hidden.push($scope.ledger[$scope.selected].ID);
|
||||
if ($scope.selected === max - 1) {
|
||||
$scope.selected = max - 2;
|
||||
}
|
||||
@@ -109,6 +113,7 @@ var LedgerCtrl = ['$scope', '$routeParams', '$location', 'asDateFilter', 'ledger
|
||||
$scope.$apply(function () {
|
||||
$location.path(path).search('StartDate', null).search('FinishDate', null);
|
||||
});
|
||||
e.preventDefault();
|
||||
},
|
||||
'alt+u': function (e) {
|
||||
if ($scope.hidden.length !== 0) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
overlord_service.factory('mdService', ['$http', '$compile', '$timeout', function ($http, $compile, $timeout) {
|
||||
overlordService.factory('mdService', ['$http', '$compile', '$timeout', function ($http, $compile, $timeout) {
|
||||
var growl = {};
|
||||
growl.default_options = {
|
||||
offset: {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
var NetTransactionsCtrl = ['$scope', '$location', 'asDateFilter', 'net_transactions', function ($scope, $location, asDate, net_transactions) {
|
||||
$scope.info = net_transactions;
|
||||
var NetTransactionsCtrl = ['$scope', '$location', 'asDateFilter', 'netTransactions', function ($scope, $location, asDate, netTransactions) {
|
||||
$scope.info = netTransactions;
|
||||
$scope.show = function () {
|
||||
var startDate = asDate($scope.info.StartDate),
|
||||
finishDate = asDate($scope.info.FinishDate);
|
||||
@@ -11,7 +11,7 @@ var NetTransactionsCtrl = ['$scope', '$location', 'asDateFilter', 'net_transacti
|
||||
}];
|
||||
|
||||
NetTransactionsCtrl.resolve = {
|
||||
net_transactions: ['$route', 'NetTransactions', function ($route, NetTransactions) {
|
||||
netTransactions: ['$route', 'NetTransactions', function ($route, NetTransactions) {
|
||||
var startDate = $route.current.params.StartDate,
|
||||
finishDate = $route.current.params.FinishDate;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
var ProductLedgerCtrl = ['$scope', '$routeParams', '$location', 'asDateFilter', 'product_ledger', 'ProductLedger', 'Product', function ($scope, $routeParams, $location, asDate, product_ledger, ProductLedger, Product) {
|
||||
$scope.info = product_ledger;
|
||||
var ProductLedgerCtrl = ['$scope', '$routeParams', '$location', 'asDateFilter', 'productLedger', 'ProductLedger', 'Product', function ($scope, $routeParams, $location, asDate, productLedger, ProductLedger, Product) {
|
||||
$scope.info = productLedger;
|
||||
$scope.show = function () {
|
||||
var id = $scope.info.Product.ProductID,
|
||||
startDate = asDate($scope.info.StartDate),
|
||||
@@ -28,7 +28,7 @@ var ProductLedgerCtrl = ['$scope', '$routeParams', '$location', 'asDateFilter',
|
||||
$('#txtProduct').focus();
|
||||
}];
|
||||
ProductLedgerCtrl.resolve = {
|
||||
product_ledger: ['$route', 'ProductLedger', function ($route, ProductLedger) {
|
||||
productLedger: ['$route', 'ProductLedger', function ($route, ProductLedger) {
|
||||
var id = $route.current.params.id,
|
||||
startDate = $route.current.params.StartDate,
|
||||
finishDate = $route.current.params.FinishDate;
|
||||
|
||||
@@ -5,8 +5,8 @@ var ProductListCtrl = ['$scope', '$location', '$routeParams', 'Tokenizer', 'prod
|
||||
$scope.showExtended = false;
|
||||
$scope.info = products;
|
||||
|
||||
$scope.$watch('search', function (newValue, oldValue) {
|
||||
$scope.filterProducts(newValue);
|
||||
$scope.$watch('search', function (value) {
|
||||
$scope.filterProducts(value);
|
||||
}, true);
|
||||
|
||||
$scope.$on('$destroy', function () {
|
||||
@@ -37,7 +37,6 @@ var ProductListCtrl = ['$scope', '$location', '$routeParams', 'Tokenizer', 'prod
|
||||
'e': 'boolean'
|
||||
}
|
||||
};
|
||||
|
||||
$scope.filterProducts = _.debounce(function (q) {
|
||||
if (q !== $scope._search) {
|
||||
$scope._search = q;
|
||||
@@ -54,6 +53,31 @@ var ProductListCtrl = ['$scope', '$location', '$routeParams', 'Tokenizer', 'prod
|
||||
});
|
||||
}
|
||||
}, 350);
|
||||
|
||||
$scope.selected = -1;
|
||||
$scope.setSelected = function (index) {
|
||||
$scope.selected = Math.min(Math.max(0, index), $scope.products.length - 1);
|
||||
};
|
||||
$scope.shortcuts = {
|
||||
'up': function (e) {
|
||||
if ($scope.selected > 0) {
|
||||
$scope.$apply(function () {
|
||||
$scope.selected = Math.min(Math.max(0, $scope.selected - 1), $scope.products.length - 1);
|
||||
});
|
||||
$("#" + $scope.selected).scrollintoview();
|
||||
e.preventDefault();
|
||||
}
|
||||
},
|
||||
'down': function (e) {
|
||||
if ($scope.selected < $scope.products.length - 1) {
|
||||
$scope.$apply(function () {
|
||||
$scope.selected = Math.min(Math.max(0, $scope.selected + 1), $scope.products.length - 1);
|
||||
});
|
||||
$("#" + $scope.selected).scrollintoview();
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
};
|
||||
}];
|
||||
|
||||
ProductListCtrl.resolve = {
|
||||
@@ -67,19 +91,19 @@ var ProductCtrl = ['$scope', '$location', '$window', '$modal', 'product', 'produ
|
||||
$scope.productGroups = productGroups;
|
||||
|
||||
$scope.save = function () {
|
||||
$scope.product.$save(function (u, putResponseHeaders) {
|
||||
$scope.product.$save(function (u) {
|
||||
$scope.toasts.push({Type: 'Success', Message: u.Code});
|
||||
$window.history.back();
|
||||
}, function (data, status) {
|
||||
}, function (data) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.delete = function () {
|
||||
$scope.product.$delete(function (u, putResponseHeaders) {
|
||||
$scope.product.$delete(function () {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$window.history.back();
|
||||
}, function (data, status) {
|
||||
}, function (data) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
@@ -62,15 +62,17 @@ var PurchaseReturnCtrl = ['$scope', '$location', 'asDateFilter', '$modal', 'uplo
|
||||
this.voucher.Inventories.splice(index, 1);
|
||||
};
|
||||
|
||||
$scope.$watch('voucher.Inventories', function (inventories, oldValue) {
|
||||
var amount = 0;
|
||||
$scope.$watch('voucher.Inventories', function (inventories) {
|
||||
var amount = 0,
|
||||
i,
|
||||
l;
|
||||
if (!angular.isUndefined(inventories)) {
|
||||
for (var i = 0, l = inventories.length; i < l; i++) {
|
||||
for (i = 0, l = inventories.length; i < l; i++) {
|
||||
amount += Number(inventories[i].Amount);
|
||||
}
|
||||
}
|
||||
if (!angular.isUndefined($scope.voucher.Journals)) {
|
||||
for (var i = 0, l = $scope.voucher.Journals.length; i < l; i++) {
|
||||
for (i = 0, l = $scope.voucher.Journals.length; i < l; i++) {
|
||||
if ($scope.voucher.Journals[i].Debit === 1) {
|
||||
$scope.voucher.Journals[i].Amount = amount;
|
||||
break;
|
||||
@@ -86,7 +88,7 @@ var PurchaseReturnCtrl = ['$scope', '$location', 'asDateFilter', '$modal', 'uplo
|
||||
return !$scope.perms['Purchase Return'];
|
||||
} else if (voucher.Posted && !$scope.perms['Edit Posted Vouchers']) {
|
||||
return true;
|
||||
} else if (voucher.User.UserID != $scope.auth.UserID && !$scope.perms["Edit Other User's Vouchers"]) {
|
||||
} else if (voucher.User.UserID !== $scope.auth.UserID && !$scope.perms["Edit Other User's Vouchers"]) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -95,27 +97,27 @@ var PurchaseReturnCtrl = ['$scope', '$location', 'asDateFilter', '$modal', 'uplo
|
||||
|
||||
$scope.save = function () {
|
||||
$scope.voucher.Date = asDate($scope.voucher.Date);
|
||||
return $scope.voucher.$save({type: 'Purchase Return'}, function (u, putResponseHeaders) {
|
||||
return $scope.voucher.$save({type: 'Purchase Return'}, function (u) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$location.path('/Return/' + u.VoucherID);
|
||||
}, function (data, status) {
|
||||
}, function (data) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.delete = function () {
|
||||
$scope.voucher.$delete(function (u, putResponseHeaders) {
|
||||
$scope.voucher.$delete(function () {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$location.path('/Return').replace();
|
||||
}, function (data, status) {
|
||||
}, function (data) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.post = function () {
|
||||
return $scope.voucher.$post(function (u, putResponseHeaders) {
|
||||
return $scope.voucher.$post(function () {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
}, function (data, status) {
|
||||
}, function (data) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
@@ -77,12 +77,12 @@ var RecipeCtrl = ['$scope', '$location', '$window', '$modal', 'asDateFilter', 'P
|
||||
this.recipe.RecipeItems.splice(index, 1);
|
||||
};
|
||||
|
||||
$scope.$watch('recipe.RecipeItems', function (recipeItems, oldValue) {
|
||||
$scope.$watch('recipe.RecipeItems', function (recipeItems) {
|
||||
if (!angular.isArray(recipeItems)) {
|
||||
return;
|
||||
}
|
||||
$scope.costPrice = recipeItems.reduce(function (sum, item, index, array) {
|
||||
var rate = item.Price / (item.Product.Fraction * item.Product.ProductYield)
|
||||
$scope.costPrice = recipeItems.reduce(function (sum, item) {
|
||||
var rate = item.Price / (item.Product.Fraction * item.Product.ProductYield);
|
||||
return sum + (item.Quantity * rate);
|
||||
}, 0);
|
||||
}, true);
|
||||
|
||||
@@ -94,36 +94,28 @@ var SalaryDeductionCtrl = ['$scope', '$location', 'asDateFilter', '$modal', 'vou
|
||||
return !$scope.perms['Salary Deduction'];
|
||||
} else if (voucher.Posted && !$scope.perms['Edit Posted Vouchers']) {
|
||||
return true;
|
||||
} else if (voucher.User.UserID != $scope.auth.UserID && !$scope.perms["Edit Other User's Vouchers"]) {
|
||||
} else if (voucher.User.UserID !== $scope.auth.UserID && !$scope.perms["Edit Other User's Vouchers"]) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
$scope.get = function (voucherid) {
|
||||
$scope.voucher = Voucher.get({VoucherID: voucherid}, function (u, putResponseHeaders) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
}, function (data, status) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.save = function () {
|
||||
$scope.voucher.Date = asDate($scope.voucher.Date);
|
||||
$scope.voucher.$save({type: 'Salary Deduction'}, function (u, putResponseHeaders) {
|
||||
$scope.voucher.$save({type: 'Salary Deduction'}, function (u) {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$location.path('/SalaryDeduction/' + u.VoucherID);
|
||||
}, function (data, status) {
|
||||
}, function (data) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.delete = function () {
|
||||
$scope.voucher.$delete(function (u, putResponseHeaders) {
|
||||
$scope.voucher.$delete(function () {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$location.path('/SalaryDeduction').replace();
|
||||
}, function (data, status) {
|
||||
}, function (data) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
@@ -66,7 +66,7 @@ var SettingsCtrl = ['$scope', '$http', 'asDateFilter', '$modal', 'lockInfo', 'Pr
|
||||
}
|
||||
$scope.rebaseDate = asDate($scope.rebaseDate);
|
||||
$http({method: 'POST', url: '/api/Rebase/' + $scope.rebaseDate}).
|
||||
success(function (data) {
|
||||
success(function () {
|
||||
$scope.toasts.push({Type: 'Success', Message: 'Data rebased!'});
|
||||
}).
|
||||
error(function (errorMessage) {
|
||||
@@ -111,7 +111,7 @@ var SettingsCtrl = ['$scope', '$http', 'asDateFilter', '$modal', 'lockInfo', 'Pr
|
||||
var stockDate = asDate($scope.stockDate);
|
||||
var qty = Number($scope.qty);
|
||||
$http({method: 'POST', url: '/api/ResetStock/' + $scope.product.ProductID, params: {StockDate: stockDate, ResetDate: resetDate, Quantity: qty}}).
|
||||
success(function (data) {
|
||||
success(function () {
|
||||
$scope.toasts.push({Type: 'Success', Message: 'Data rebased!'});
|
||||
}).
|
||||
error(function (errorMessage) {
|
||||
@@ -125,7 +125,7 @@ var SettingsCtrl = ['$scope', '$http', 'asDateFilter', '$modal', 'lockInfo', 'Pr
|
||||
|
||||
SettingsCtrl.resolve = {
|
||||
lockInfo: ['$http', function ($http) {
|
||||
return $http.get('/api/LockInfo', {}).then(function (data, status, headers, config) {
|
||||
return $http.get('/api/LockInfo', {}).then(function (data) {
|
||||
return data;
|
||||
});
|
||||
}]
|
||||
|
||||
@@ -14,19 +14,19 @@ var UserCtrl = ['$scope', '$location', 'user', function ($scope, $location, user
|
||||
$scope.user = user;
|
||||
|
||||
$scope.save = function () {
|
||||
$scope.user.$save(function (u, putResponseHeaders) {
|
||||
$scope.user.$save(function () {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$location.path('/Users');
|
||||
}, function (data, status) {
|
||||
}, function (data) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.delete = function () {
|
||||
$scope.user.$delete(function (u, putResponseHeaders) {
|
||||
$scope.user.$delete(function () {
|
||||
$scope.toasts.push({Type: 'Success', Message: ''});
|
||||
$location.path('/Users');
|
||||
}, function (data, status) {
|
||||
}, function (data) {
|
||||
$scope.toasts.push({Type: 'Danger', Message: data.data});
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
import datetime
|
||||
from decimal import Decimal
|
||||
import uuid
|
||||
|
||||
from pyramid.security import authenticated_userid
|
||||
from pyramid.view import view_config
|
||||
from sqlalchemy import func, and_
|
||||
from sqlalchemy import func, and_, distinct
|
||||
from sqlalchemy.orm import aliased
|
||||
import transaction
|
||||
|
||||
from brewman.models import DBSession
|
||||
from brewman.models.master import LedgerBase, CostCenter, Product, LedgerType
|
||||
from brewman.models.master import LedgerBase, CostCenter, Ledger, Employee
|
||||
from brewman.models.validation_exception import TryCatchFunction
|
||||
from brewman.models.voucher import Journal, Voucher, VoucherType, Batch, Inventory, SalaryDeduction, Fingerprint, Attendance
|
||||
from brewman.models.voucher import Journal, Voucher, VoucherType, Batch, Inventory, SalaryDeduction, Fingerprint, \
|
||||
Attendance, DbImage
|
||||
|
||||
|
||||
__author__ = 'tanshu'
|
||||
|
||||
@@ -20,9 +24,9 @@ def rebase(request):
|
||||
date = request.matchdict.get('date', None)
|
||||
date = datetime.datetime.strptime(date, '%d-%b-%Y')
|
||||
user_id = uuid.UUID(authenticated_userid(request))
|
||||
voucher_l = opening_ledgers(date, user_id)
|
||||
voucher_l, accounts = opening_ledgers(date, user_id)
|
||||
voucher_b, batches = opening_batches(date, user_id)
|
||||
delete_data(date, batches)
|
||||
delete_data(date)
|
||||
DBSession.add(voucher_l)
|
||||
for j in voucher_l.journals:
|
||||
DBSession.add(j)
|
||||
@@ -31,13 +35,14 @@ def rebase(request):
|
||||
DBSession.add(j)
|
||||
for i in voucher_b.inventories:
|
||||
DBSession.add(i)
|
||||
cleanup_lint(date, accounts, batches)
|
||||
transaction.commit()
|
||||
return {}
|
||||
|
||||
|
||||
def opening_ledgers(date, user_id):
|
||||
running_total = 0
|
||||
|
||||
accounts = []
|
||||
sum_func = func.sum(Journal.signed_amount)
|
||||
query = DBSession.query(LedgerBase, sum_func) \
|
||||
.join(Journal, Voucher.journals).join(LedgerBase, Journal.ledger) \
|
||||
@@ -50,18 +55,17 @@ def opening_ledgers(date, user_id):
|
||||
type=VoucherType.by_name('Opening Ledgers'))
|
||||
for ledger, amount in query:
|
||||
amount = round(Decimal(amount), 2)
|
||||
if not ledger.type_object().balance_sheet:
|
||||
pass
|
||||
if amount != 0:
|
||||
if ledger.type_object.balance_sheet and ledger.id != LedgerBase.suspense() and amount != 0:
|
||||
running_total += amount
|
||||
journal = Journal(amount=abs(amount), debit=-1 if amount < 0 else 1, ledger_id=ledger.id,
|
||||
cost_center_id=ledger.costcenter_id)
|
||||
voucher.journals.append(journal)
|
||||
accounts.append(ledger.id)
|
||||
if running_total != 0:
|
||||
journal = Journal(amount=abs(amount), debit=-1 if amount * -1 < 0 else 1, ledger_id=LedgerBase.suspense(),
|
||||
cost_center_id=CostCenter.cost_center_overall())
|
||||
voucher.journals.append(journal)
|
||||
return voucher
|
||||
return voucher, accounts
|
||||
|
||||
|
||||
def opening_batches(date, user_id):
|
||||
@@ -93,16 +97,56 @@ def opening_batches(date, user_id):
|
||||
return voucher, batches
|
||||
|
||||
|
||||
def delete_data(date, batches):
|
||||
def delete_data(date):
|
||||
sub_voucher = aliased(Voucher)
|
||||
sub_query = DBSession.query(sub_voucher.id).filter(sub_voucher.date < date).subquery()
|
||||
|
||||
Inventory.__table__.delete(Inventory.voucher_id.in_(sub_query)).execute()
|
||||
SalaryDeduction.__table__.delete(SalaryDeduction.voucher_id.in_(sub_query)).execute()
|
||||
Journal.__table__.delete(Journal.voucher_id.in_(sub_query)).execute()
|
||||
DbImage.__table__.delete(and_(DbImage.resource_type == 'voucher', DbImage.resource_id.in_(sub_query))).execute()
|
||||
Voucher.__table__.delete(Voucher.date < date).execute()
|
||||
|
||||
Batch.__table__.delete(and_(~Batch.inventories.any(), ~Batch.id.in_(batches))).execute()
|
||||
|
||||
def cleanup_lint(date, accounts, batches):
|
||||
# Insert executes on the end so keep list of batches and journals
|
||||
|
||||
Batch.__table__.delete(
|
||||
and_(
|
||||
~Batch.id.in_(DBSession.query(distinct(Inventory.batch_id)).subquery()),
|
||||
~Batch.id.in_(batches)
|
||||
)
|
||||
).execute()
|
||||
|
||||
Fingerprint.__table__.delete(Fingerprint.date < date).execute()
|
||||
Attendance.__table__.delete(Attendance.date < date).execute()
|
||||
|
||||
Employee.__table__.delete(
|
||||
and_(
|
||||
~Employee.id.in_(DBSession.query(distinct(Journal.ledger_id)).subquery()),
|
||||
~Employee.id.in_(accounts),
|
||||
Employee.id.in_(
|
||||
DBSession.query(LedgerBase.id).filter(
|
||||
LedgerBase.is_fixture == False
|
||||
).filter(
|
||||
LedgerBase.is_active == False
|
||||
).subquery()),
|
||||
Employee.leaving_date < date
|
||||
)
|
||||
).execute()
|
||||
|
||||
LedgerBase.__table__.delete(
|
||||
and_(
|
||||
~LedgerBase.id.in_(DBSession.query(Employee.id).subquery()),
|
||||
LedgerBase.ledger_type == Employee.__mapper_args__['polymorphic_identity']
|
||||
)
|
||||
).execute()
|
||||
|
||||
Ledger.__table__.delete(
|
||||
and_(
|
||||
~Ledger.id.in_(DBSession.query(distinct(Journal.ledger_id)).subquery()),
|
||||
~Ledger.id.in_(accounts),
|
||||
Ledger.is_fixture == False,
|
||||
Ledger.ledger_type == Ledger.__mapper_args__['polymorphic_identity']
|
||||
)
|
||||
).execute()
|
||||
@@ -26,7 +26,7 @@ def html(request):
|
||||
@view_config(request_method='GET', route_name='api_ledger', renderer='json', permission='Ledger')
|
||||
def show_blank(request):
|
||||
return {'StartDate': session_period_start(request),
|
||||
'FinishDate': session_period_finish(request), 'Ledger': None, 'Body': [], 'Footer': {}}
|
||||
'FinishDate': session_period_finish(request), 'Ledger': None, 'Body': []}
|
||||
|
||||
|
||||
@view_config(request_method='GET', route_name='api_ledger_id', renderer='json', permission='Ledger')
|
||||
@@ -38,7 +38,7 @@ def show_data(request):
|
||||
finish_date = request.GET.get('FinishDate', session_period_finish(request))
|
||||
info = {'StartDate': start_date, 'FinishDate': finish_date,
|
||||
'Ledger': {'LedgerID': ledger.id, 'Name': ledger.name},
|
||||
'Body': [], 'Footer': {}}
|
||||
'Body': []}
|
||||
build_report(request, info)
|
||||
return info
|
||||
|
||||
@@ -80,8 +80,6 @@ def build_report(request, info):
|
||||
'Url': get_edit_url(request, voucher), 'Type': VoucherType.by_id(voucher.type).name,
|
||||
'Narration': voucher.narration, 'Debit': debit, 'Credit': credit, 'Posted': voucher.posted})
|
||||
|
||||
info['Footer'] = {'Date': finish_date}
|
||||
|
||||
|
||||
def opening_balance(ledger_id, start_date):
|
||||
opening = DBSession.query(func.sum(Journal.amount * Journal.debit)) \
|
||||
@@ -98,6 +96,4 @@ def opening_balance(ledger_id, start_date):
|
||||
debit = opening
|
||||
credit = 0
|
||||
return {'Date': start_date, 'ID': 'OB', 'Name': 'Opening Balance', 'Type': 'Opening Balance',
|
||||
'Narration': '', 'Debit': debit, 'Credit': credit, 'Posted': True}
|
||||
|
||||
|
||||
'Narration': '', 'Debit': debit, 'Credit': credit, 'Posted': True}
|
||||
Reference in new issue
Block a user