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:
abijah
2009-07-30 02:17:49 +00:00
parent 55c5c9e9e6
commit adddfecada
3 changed files with 6 additions and 4 deletions

View File

@@ -167,7 +167,7 @@ class TransactionsController extends AppController {
// have their corresponding account ledgers closed.
$type_ids = $close_type_ids = array();
foreach ($this->data['TenderType'] AS $type_id => $type) {
if (!$type['checked'])
if (empty($type['checked']))
continue;
$type_ids[] = $type_id;

View File

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