Fixed error in payment and receipt where duplicate entry resulted in corrupted voucher.
This commit is contained in:
parent
68897338f1
commit
7999d4cb9d
@ -1,6 +1,6 @@
|
||||
CACHE MANIFEST
|
||||
|
||||
# version 2012-12-07.6
|
||||
# version 2012-12-07.7
|
||||
|
||||
CACHE:
|
||||
/partial/404.html
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user