Chore: Removed redundant Running Total calculation from Ledger python view as it is not calculated client side.

This commit is contained in:
Amritanshu committed 2014-06-04 19:07:58 +05:30
1 parent 248a841695
commit 358b235d8f
3 files changed
+29 -35

No files matched your search

+12 -11
View File
@@ -47,20 +47,21 @@ var LedgerCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', 'ledger',
if (hidden.length !== 0) {
data = _.filter(data, function (item) {
return !_.any(hidden, function (hi) {
if (!item.hasOwnProperty('Url') && !hi.hasOwnProperty('Url')) {
return true;
} else if (item.hasOwnProperty('Url') !== hi.hasOwnProperty('Url')) {
return false;
}
return item.Url === hi.Url;
return item.ID === hi;
});
});
}
_.forEach(data, function (item) {
debit += item.Debit;
credit += item.Credit;
running = debit - credit;
if (item.Type !== 'Opening Balance') {
debit += item.Debit;
credit += item.Credit;
if (item.Posted) {
running += item.Debit - item.Credit;
}
} else {
running += item.Debit - item.Credit;
}
item.Running = running;
});
footer.Debit = debit;
@@ -92,8 +93,8 @@ var LedgerCtrl = ['$scope', '$routeParams', '$location', 'dateFilter', 'ledger',
if ($scope.selected > -1) {
$scope.$apply(function () {
var max = $scope.display.Body.length;
$scope.hidden.push(angular.copy($scope.display.Body[$scope.selected]));
if ($scope.selected === max -1) {
$scope.hidden.push($scope.display.Body[$scope.selected].ID);
if ($scope.selected === max - 1) {
$scope.selected = max - 2;
}
});