Fixed the problem with zero dollar balance forward entries when closing a ledger.
git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716@422 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -164,6 +164,7 @@ class Transaction extends AppModel {
|
||||
$close['lease_id'] = null;
|
||||
|
||||
$ledger_ids = array();
|
||||
$data['Entry'] = array();
|
||||
foreach ($data['Ledger'] AS $ledger) {
|
||||
$ledger_id = $ledger['old_ledger_id'];
|
||||
$new_ledger_id = $ledger['new_ledger_id'];
|
||||
@@ -176,7 +177,7 @@ class Transaction extends AppModel {
|
||||
$ledger_ids[] = $ledger_id;
|
||||
|
||||
// No need to generate ledger entries if there is no balance
|
||||
if (empty($ledger['amount']))
|
||||
if (empty($ledger['amount']) || $ledger['amount'] == 0)
|
||||
continue;
|
||||
|
||||
// Add an entry to carry the ledger balance forward
|
||||
@@ -311,7 +312,8 @@ class Transaction extends AppModel {
|
||||
/* => compact('data'))); */
|
||||
|
||||
// Verify that we have a transaction and entries
|
||||
if (empty($data['Transaction']) || empty($data['Entry']))
|
||||
if (empty($data['Transaction']) ||
|
||||
($data['Transaction']['type'] !== 'CLOSE' && empty($data['Entry'])))
|
||||
return array('error' => true);
|
||||
|
||||
// Extract the transaction to a local variable
|
||||
|
||||
Reference in New Issue
Block a user