diff --git a/brewman/brewman/static/offline.appcache b/brewman/brewman/static/offline.appcache index 36a7c834..10f73873 100644 --- a/brewman/brewman/static/offline.appcache +++ b/brewman/brewman/static/offline.appcache @@ -1,6 +1,6 @@ CACHE MANIFEST -# version 2012-12-07.6 +# version 2012-12-07.7 CACHE: /partial/404.html diff --git a/brewman/brewman/static/scripts/payment.js b/brewman/brewman/static/scripts/payment.js index 89a6be4d..de510f7a 100644 --- a/brewman/brewman/static/scripts/payment.js +++ b/brewman/brewman/static/scripts/payment.js @@ -14,17 +14,14 @@ function PaymentCtrl($scope, $location, voucher, ledgers) { $scope.addJournal = function () { var oldJournal = getOldJournal($scope.ledger.LedgerID, this.voucher.Journals); - if (typeof oldJournal !== 'undefined') { - var amount = (oldJournal.Debit * oldJournal.Amount) + (parseInt($scope.debit) * Number($scope.amount)); - if (amount < 0) { - oldJournal.Debit = -1; - oldJournal.Amount = amount * -1; - } else { - oldJournal.Debit = 1; - oldJournal.Amount = amount; - } - } else { + if (typeof oldJournal === 'undefined') { this.voucher.Journals.push({Debit:1, Amount:Number($scope.amount), Ledger:$scope.ledger}); + } else { + if (oldJournal.Debit === 1) { + oldJournal.Amount = oldJournal.Amount + Number($scope.amount); + } else { + return; + } } delete $scope.ledger; delete $scope.amount; diff --git a/brewman/brewman/static/scripts/receipt.js b/brewman/brewman/static/scripts/receipt.js index 623cc22d..2a3cd63c 100644 --- a/brewman/brewman/static/scripts/receipt.js +++ b/brewman/brewman/static/scripts/receipt.js @@ -13,17 +13,14 @@ function ReceiptCtrl($scope, $routeParams, $location, voucher, ledgers, Voucher) $scope.addJournal = function () { var oldJournal = getOldJournal($scope.ledger.LedgerID, this.voucher.Journals); - if (typeof oldJournal !== 'undefined') { - var amount = (oldJournal.Debit * oldJournal.Amount) + (parseInt($scope.debit) * Number($scope.amount)); - if (amount < 0) { - oldJournal.Debit = -1; - oldJournal.Amount = amount * -1; - } else { - oldJournal.Debit = 1; - oldJournal.Amount = amount; - } - } else { + if (typeof oldJournal === 'undefined') { this.voucher.Journals.push({Debit:-1, Amount:Number($scope.amount), Ledger:$scope.ledger}); + } else { + if (oldJournal.Debit === -1) { + oldJournal.Amount = oldJournal.Amount + Number($scope.amount); + } else { + return; + } } delete $scope.ledger; delete $scope.amount;