Fixed error in payment and receipt where duplicate entry resulted in corrupted voucher.

This commit is contained in:
Tanshu 2012-12-07 18:18:37 +05:30
parent 68897338f1
commit 7999d4cb9d
3 changed files with 15 additions and 21 deletions

View File

@ -1,6 +1,6 @@
CACHE MANIFEST
# version 2012-12-07.6
# version 2012-12-07.7
CACHE:
/partial/404.html

View File

@ -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;

View File

@ -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;