Compare commits

...

2 Commits

Author SHA1 Message Date
abijah
c9ade62536 Very, very messy and broken. It does work somewhat, but I can see just what a mess it's going to be to carry it out, so I'm abandoning.
git-svn-id: file:///svn-source/pmgr/branches/reconcile_entry_to_receipt_20090629@187 97e9348a-65ac-dc4b-aefc-98561f571b83
2009-06-30 00:59:09 +00:00
abijah
4f0b5ffc28 Branch to work on another possible solution to this mess
git-svn-id: file:///svn-source/pmgr/branches/reconcile_entry_to_receipt_20090629@186 97e9348a-65ac-dc4b-aefc-98561f571b83
2009-06-30 00:57:11 +00:00
14 changed files with 423 additions and 269 deletions

View File

@@ -989,8 +989,15 @@ DROP TABLE IF EXISTS `pmgr_reconciliations`;
CREATE TABLE `pmgr_reconciliations` ( CREATE TABLE `pmgr_reconciliations` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`debit_ledger_entry_id` INT(10) UNSIGNED NOT NULL, `type` ENUM('DEBIT',
`credit_ledger_entry_id` INT(10) UNSIGNED NOT NULL, 'CREDIT')
NOT NULL,
-- Match up the ledger entry to the transaction that
-- reconciles it. For example, this could be a charge
-- matching up with a receipt.
`ledger_entry_id` INT(10) UNSIGNED NOT NULL,
`transaction_id` INT(10) UNSIGNED NOT NULL,
`amount` FLOAT(12,2) NOT NULL, `amount` FLOAT(12,2) NOT NULL,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)

View File

@@ -4,8 +4,6 @@ use DBI;
use Data::Dumper; use Data::Dumper;
use File::Copy; use File::Copy;
my $use_ir = 0;
# Internally adjust all numbers coming from the database to # Internally adjust all numbers coming from the database to
# be in inches. Not necessary to go to this detail, but the # be in inches. Not necessary to go to this detail, but the
# actual units used is irrelevant, provided everything is to # actual units used is irrelevant, provided everything is to
@@ -880,19 +878,6 @@ foreach $row (@{query($sdbh, $query)}) {
}; };
$credit_ledger_id = $newdb{'lookup'}{'charge_type'}{$row->{'ChargeDescription'}}{'ledger_id'}; $credit_ledger_id = $newdb{'lookup'}{'charge_type'}{$row->{'ChargeDescription'}}{'ledger_id'};
if ($use_ir) {
addRow('ledger_entries',
{ 'monetary_source_id' => $newdb{'ids'}{'monetary_source'}{'internal'},
'transaction_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'tx'},
'debit_ledger_id' => $newdb{'lookup'}{'account'}{'Invoice'}{'ledger_id'},
'credit_ledger_id' => $credit_ledger_id,
'customer_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'customer_id'},
'lease_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'lease_id'},
'amount' => $row->{'ChargeAmount'},
'comment' => "Charge: $row->{'ChargeID'}; Ledger: $row->{'LedgerID'}" });
$ledger_entry_id = $newdb{'tables'}{'ledger_entries'}{'autoid'};
$credit_ledger_id = $newdb{'lookup'}{'account'}{'Invoice'}{'ledger_id'};
}
addRow('ledger_entries', addRow('ledger_entries',
{ 'monetary_source_id' => $newdb{'ids'}{'monetary_source'}{'internal'}, { 'monetary_source_id' => $newdb{'ids'}{'monetary_source'}{'internal'},
@@ -907,33 +892,9 @@ foreach $row (@{query($sdbh, $query)}) {
$newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'ledger_entry_id'} $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'ledger_entry_id'}
= $newdb{'tables'}{'ledger_entries'}{'autoid'}; = $newdb{'tables'}{'ledger_entries'}{'autoid'};
if ($use_ir) {
# Reconcile the invoice account. Since this is from the perspective
# of the invoice, the entry crediting the charge is the debit, and
# the entry debiting A/R is the credit.
addRow('reconciliations',
{ 'debit_ledger_entry_id' => $ledger_entry_id,
'credit_ledger_entry_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'ledger_entry_id'},
'amount' => $row->{'ChargeAmount'},
});
}
next unless $row->{'TaxAmount'}; next unless $row->{'TaxAmount'};
$credit_ledger_id = $newdb{'lookup'}{'charge_type'}{'Tax'}{'ledger_id'}; $credit_ledger_id = $newdb{'lookup'}{'charge_type'}{'Tax'}{'ledger_id'};
if ($use_ir) {
addRow('ledger_entries',
{ 'monetary_source_id' => $newdb{'ids'}{'monetary_source'}{'internal'},
'transaction_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'tx'},
'debit_ledger_id' => $newdb{'lookup'}{'account'}{'Invoice'}{'ledger_id'},
'credit_ledger_id' => $credit_ledger_id,
'customer_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'customer_id'},
'lease_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'lease_id'},
'amount' => $row->{'TaxAmount'},
'comment' => undef });
$ledger_entry_id = $newdb{'tables'}{'ledger_entries'}{'autoid'};
$credit_ledger_id = $newdb{'lookup'}{'account'}{'Invoice'}{'ledger_id'};
}
addRow('ledger_entries', addRow('ledger_entries',
{ 'monetary_source_id' => $newdb{'ids'}{'monetary_source'}{'internal'}, { 'monetary_source_id' => $newdb{'ids'}{'monetary_source'}{'internal'},
@@ -948,16 +909,6 @@ foreach $row (@{query($sdbh, $query)}) {
$newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'tax_entry'} $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'tax_entry'}
= $newdb{'tables'}{'ledger_entries'}{'autoid'}; = $newdb{'tables'}{'ledger_entries'}{'autoid'};
if ($use_ir) {
# Reconcile the invoice account. Since this is from the perspective
# of the invoice, the entry crediting the charge is the debit, and
# the entry debiting A/R is the credit.
addRow('reconciliations',
{ 'debit_ledger_entry_id' => $ledger_entry_id,
'credit_ledger_entry_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'tax_entry'},
'amount' => $row->{'TaxAmount'},
});
}
} }
@@ -1052,22 +1003,6 @@ foreach $row (@{query($sdbh, $query)})
$row->{'PaymentID'}}{'account_name'} $row->{'PaymentID'}}{'account_name'}
}{'ledger_id'}; }{'ledger_id'};
if ($use_ir) {
addRow('ledger_entries',
{ 'monetary_source_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'monetary_source_id'},
'transaction_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{'tx'},
'debit_ledger_id' => $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'debit_ledger_id'},
'credit_ledger_id' => $newdb{'lookup'}{'account'}{'Receipt'}{'ledger_id'},
'customer_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'customer_id'},
'lease_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'lease_id'},
'amount' => $row->{'PaymentAmount'},
'comment' => "Receipt: $row->{'ReceiptNum'}; Charge: $row->{'ChargeID'}; Payment: $row->{'PaymentID'}" });
$newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'ledger_entry_id'}
= $newdb{'tables'}{'ledger_entries'}{'autoid'};
$newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'debit_ledger_id'}
= $newdb{'lookup'}{'account'}{'Receipt'}{'ledger_id'};
}
# Sitelink splits one physical payment into multiple "payments" to match each charge # Sitelink splits one physical payment into multiple "payments" to match each charge
# This is kludgy, but for our cases at least, brings those pseudo-payments back into # This is kludgy, but for our cases at least, brings those pseudo-payments back into
# a single one. It presumes that there is only one PaymentType per receipt. # a single one. It presumes that there is only one PaymentType per receipt.
@@ -1106,8 +1041,9 @@ foreach $row (@{query($sdbh, $query)})
# Reconcile the A/R account. Since this is from the perspective # Reconcile the A/R account. Since this is from the perspective
# of the A/R, charge is the debit, and payment is the credit # of the A/R, charge is the debit, and payment is the credit
addRow('reconciliations', addRow('reconciliations',
{ 'debit_ledger_entry_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'ledger_entry_id'}, { 'type' => 'DEBIT',
'credit_ledger_entry_id' => $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'ledger_entry_id'}, 'ledger_entry_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'ledger_entry_id'},
'transaction_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{'tx'},
'amount' => $reconcile_amount, 'amount' => $reconcile_amount,
}); });
@@ -1300,8 +1236,9 @@ sub fakeTesting {
foreach my $t (@{$e->{'track'}}) { foreach my $t (@{$e->{'track'}}) {
addRow('reconciliations', addRow('reconciliations',
{ 'debit_ledger_entry_id' => $t->{'debit'}, { 'type' => 'DEBIT',
'credit_ledger_entry_id' => $e->{'id'}, 'ledger_entry_id' => $t->{'debit'},
'transaction_id' => $tx->{'id'},
'amount' => $t->{'amount'} 'amount' => $t->{'amount'}
}); });
} }

View File

@@ -33,7 +33,7 @@ class LedgerEntriesController extends AppController {
} }
} }
function jqGridDataTables(&$params, &$model) { function jqGridDataCountTables(&$params, &$model) {
$link = $link =
array(// Models array(// Models
'Transaction' => 'Transaction' =>
@@ -95,8 +95,13 @@ class LedgerEntriesController extends AppController {
); );
} }
if (isset($params['custom']['account_id'])) { if (isset($params['custom']['account_id']) || isset($params['custom']['lease_id'])) {
if (isset($params['custom']['account_id']))
$account_id = $params['custom']['account_id']; $account_id = $params['custom']['account_id'];
else
$account_id =
$this->LedgerEntry->DebitLedger->Account->accountReceivableAccountID();
$link['Ledger'] = $link['Ledger'] =
array('fields' => array('id', 'sequence'), array('fields' => array('id', 'sequence'),
'conditions' => ("Ledger.id = IF(DebitLedger.account_id = $account_id," . 'conditions' => ("Ledger.id = IF(DebitLedger.account_id = $account_id," .
@@ -108,18 +113,57 @@ class LedgerEntriesController extends AppController {
); );
} }
if (isset($params['custom']['lease_id'])) {
$account_id = $params['custom']['lease_id'];
$link['Transaction']['ReconciledLedgerEntry'] =
array('fields' => array('id', 'Reconciliation.amount', 'Reconciliation.type'),
);
}
if (isset($params['custom']['reconcile_id'])) { if (isset($params['custom']['reconcile_id'])) {
$ftype = $params['custom']['account_ftype']; $ftype = $params['custom']['account_ftype'];
$ftype = $this->LedgerEntry->DebitLedger->Account->fundamentalOpposite($ftype); $ftype = $this->LedgerEntry->DebitLedger->Account->fundamentalOpposite($ftype);
$ftype = ucfirst($ftype); $link['ReconcilingTransaction'] =
$link[$ftype.'ReconciliationLedgerEntry'] = array('fields' => array('Reconciliation.amount'),
array('fields' => array('Reconciliation.amount')); 'conditions' => array('Reconciliation.type' => $ftype),
);
} }
return array('link' => $link); return array('link' => $link);
} }
function jqGridDataTables(&$params, &$model) {
return $this->jqGridDataCountTables($params, $model);
}
function jqGridDataFields(&$params, &$model) { function jqGridDataFields(&$params, &$model) {
if (isset($params['custom']['lease_id'])) {
$account_id =
$this->LedgerEntry->DebitLedger->Account->accountReceivableAccountID();
$fields = array('id', 'name', 'comment', 'amount');
$fields[] = ("IF(DebitLedger.account_id = $account_id," .
" SUM(IF(ReconciledLedgerEntry.amount IS NULL," .
" LedgerEntry.amount," .
" ReconciledLedgerEntry.amount))," .
" NULL) AS debit");
$fields[] = ("IF(CreditLedger.account_id = $account_id," .
" SUM(IF(ReconciledLedgerEntry.amount IS NULL," .
" LedgerEntry.amount," .
" ReconciledLedgerEntry.amount))," .
" NULL) AS credit");
$Account = new Account();
$account_ftype = ucfirst($Account->fundamentalType($account_id));
$fields[] = ("(IF({$account_ftype}Ledger.account_id = $account_id, 1, -1)" .
" * SUM(IF(ReconciledLedgerEntry.amount IS NULL," .
" LedgerEntry.amount," .
" ReconciledLedgerEntry.amount)))" .
" AS balance");
return $fields;
}
$ledger_id = (isset($params['custom']['ledger_id']) $ledger_id = (isset($params['custom']['ledger_id'])
? $params['custom']['ledger_id'] ? $params['custom']['ledger_id']
: null); : null);
@@ -143,13 +187,16 @@ class LedgerEntriesController extends AppController {
$conditions = parent::jqGridDataConditions($params, $model); $conditions = parent::jqGridDataConditions($params, $model);
if ($params['action'] === 'ledger') { if ($params['action'] === 'ledger' && isset($ledger_id)) {
$conditions[] = $model->ledgerContextConditions($ledger_id, $account_type); $conditions[] = $model->ledgerContextConditions($ledger_id, $account_type);
} }
if (isset($params['custom']['reconcile_id'])) { if (isset($params['custom']['reconcile_id'])) {
$ftype = $params['custom']['account_ftype']; $ftype = $params['custom']['account_ftype'];
//$ftype = $this->LedgerEntry->DebitLedger->Account->fundamentalOpposite($ftype); //$ftype = $this->LedgerEntry->DebitLedger->Account->fundamentalOpposite($ftype);
$conditions[] = array('Reconciliation.'.$ftype.'_ledger_entry_id' => $params['custom']['reconcile_id']); //$link['ReconcilingTransaction']['conditions'][] = array('Reconciliation.type' => $ftype);
$conditions[] = array('Reconciliation.ledger_entry_id' => $params['custom']['reconcile_id']);
} }
if (isset($params['custom']['account_id'])) { if (isset($params['custom']['account_id'])) {
@@ -157,46 +204,22 @@ class LedgerEntriesController extends AppController {
array('OR' => array('OR' =>
array(array('CreditAccount.id' => $params['custom']['account_id']), array(array('CreditAccount.id' => $params['custom']['account_id']),
array('DebitAccount.id' => $params['custom']['account_id']))); array('DebitAccount.id' => $params['custom']['account_id'])));
/* $conditions[] = */
/* array('Account.id' => $params['custom']['account_id']); */
} }
if (isset($params['custom']['customer_id'])) { if (isset($params['custom']['customer_id'])) {
$conditions[] = $conditions[] =
array('Customer.id' => $params['custom']['customer_id']); array('Customer.id' => $params['custom']['customer_id']);
/* $Account = new Account(); */
/* if (isset($params['custom']['account_ftype']) || */
/* isset($params['custom']['ledger_id'])) { */
/* $conditions[] = */
/* array('OR' => array('Account.id' => $Account->invoiceAccountID(), */
/* 'Account.id' => $Account->receiptAccountID())); */
/* } else { */
/* $conditions[] = */
/* array('OR' => array('DebitAccount.id' => $Account->invoiceAccountID(), */
/* //'CreditAccount.id' => $Account->invoiceAccountID(), */
/* //'DebitAccount.id' => $Account->receiptAccountID(), */
/* 'CreditAccount.id' => $Account->receiptAccountID(), */
/* )); */
/* } */
} }
if (isset($params['custom']['lease_id'])) { if (isset($params['custom']['lease_id'])) {
$conditions[] = $conditions[] =
array('Lease.id' => $params['custom']['lease_id']); array('OR' => array
(array('Lease.id' => $params['custom']['lease_id']),
/* $Account = new Account(); */ array('ReconciledLedgerEntry.lease_id' => $params['custom']['lease_id']),
/* if (isset($params['custom']['account_ftype']) || */ ));
/* isset($params['custom']['ledger_id'])) { */
/* $conditions[] = */
/* array('OR' => array('Account.id' => $Account->invoiceAccountID(), */
/* 'Account.id' => $Account->receiptAccountID())); */
/* } else { */
/* $conditions[] = */
/* array('OR' => array('DebitAccount.id' => $Account->invoiceAccountID(), */
/* //'CreditAccount.id' => $Account->invoiceAccountID(), */
/* //'DebitAccount.id' => $Account->receiptAccountID(), */
/* 'CreditAccount.id' => $Account->receiptAccountID(), */
/* )); */
/* } */
} }
if (isset($params['custom']['transaction_id'])) { if (isset($params['custom']['transaction_id'])) {
@@ -304,7 +327,7 @@ class LedgerEntriesController extends AppController {
'conditions' => array('LedgerEntry.id' => $id), 'conditions' => array('LedgerEntry.id' => $id),
)); ));
pr($entry); //pr($entry);
// Because 'DebitLedger' and 'CreditLedger' both relate to 'Account', // Because 'DebitLedger' and 'CreditLedger' both relate to 'Account',
// CakePHP will not include them in the LedgerEntry->find (or so it // CakePHP will not include them in the LedgerEntry->find (or so it
@@ -334,8 +357,8 @@ class LedgerEntriesController extends AppController {
$stats['credit_amount_remaining'] = $entry['LedgerEntry']['amount'] - $stats['credit_amount_reconciled']; $stats['credit_amount_remaining'] = $entry['LedgerEntry']['amount'] - $stats['credit_amount_reconciled'];
//pr($stats); //pr($stats);
$reconciled = $this->LedgerEntry->findReconciledLedgerEntries($id); $reconciled = $this->LedgerEntry->findReconcilingTransactions($id);
//pr($reconciled); //pr(compact('reconciled'));
// Prepare to render. // Prepare to render.
$title = "Ledger Entry #{$entry['LedgerEntry']['id']}"; $title = "Ledger Entry #{$entry['LedgerEntry']['id']}";

View File

@@ -41,6 +41,43 @@ class TransactionsController extends AppController {
* to jqGrid. * to jqGrid.
*/ */
function jqGridDataSetup(&$params) {
parent::jqGridDataSetup($params);
}
function jqGridDataTables(&$params, &$model) {
$link = array();
if (isset($params['custom']['reconcile_ledger_entry_id'])) {
$ftype = $params['custom']['reconcile_type'];
//$ftype = $this->Transaction->LedgerEntry->DebitLedger->Account->fundamentalOpposite($ftype);
$link['ReconciledLedgerEntry'] =
array('fields' => array('Reconciliation.amount'),
'conditions' => array('Reconciliation.type' => $ftype)
);
}
return array('link' => $link);
}
function jqGridDataFields(&$params, &$model) {
return parent::jqGridDataFields($params, $model);
}
function jqGridDataConditions(&$params, &$model) {
$conditions = parent::jqGridDataConditions($params, $model);
if (isset($params['custom']['reconcile_ledger_entry_id'])) {
/* $ftype = $params['custom']['reconcile_type']; */
/* $ftype = $this->LedgerEntry->DebitLedger->Account->fundamentalOpposite($ftype); */
/* $conditions[] = array('Reconciliation.type' => $ftype); */
$conditions[] = array('Reconciliation.ledger_entry_id'
=> $params['custom']['reconcile_ledger_entry_id']);
}
return $conditions;
}
function jqGridRecordLinks(&$params, &$model, &$records, $links) { function jqGridRecordLinks(&$params, &$model, &$records, $links) {
$links['Transaction'] = array('id'); $links['Transaction'] = array('id');
return parent::jqGridRecordLinks($params, $model, $records, $links); return parent::jqGridRecordLinks($params, $model, $records, $links);

View File

@@ -226,20 +226,20 @@ class Account extends AppModel {
? array($fundamental_type) ? array($fundamental_type)
: array('debit', 'credit')) AS $fund) { : array('debit', 'credit')) AS $fund) {
$ucfund = ucfirst($fund); $ucfund = ucfirst($fund);
$unreconciled[$fund]['entry'] = $this->find $unreconciled[$fund]['LedgerEntry'] = $this->find
('all', array ('all', array
('link' => array ('link' => array
('Ledger' => array ('Ledger' => array
('fields' => array(), ('fields' => array(),
"LedgerEntry" => array 'LedgerEntry' => array
('class' => "{$ucfund}LedgerEntry", ('class' => "{$ucfund}LedgerEntry",
'fields' => array('id', 'amount'), 'fields' => array('id', 'amount'),
"ReconciliationLedgerEntry" => array 'ReconcilingTransaction' => array
('class' => "{$ucfund}ReconciliationLedgerEntry", ('fields' => array
'fields' => array
("COALESCE(SUM(Reconciliation.amount),0) AS 'reconciled'", ("COALESCE(SUM(Reconciliation.amount),0) AS 'reconciled'",
"LedgerEntry.amount - COALESCE(SUM(Reconciliation.amount),0) AS 'balance'", "LedgerEntry.amount - COALESCE(SUM(Reconciliation.amount),0) AS 'balance'",
), ),
'conditions' => array('Reconciliation.type' => $fund),
), ),
), ),
), ),
@@ -251,7 +251,7 @@ class Account extends AppModel {
'fields' => array(), 'fields' => array(),
)); ));
$balance = 0; $balance = 0;
foreach ($unreconciled[$fund]['entry'] AS &$entry) { foreach ($unreconciled[$fund]['LedgerEntry'] AS &$entry) {
$entry = array_merge(array_diff_key($entry["LedgerEntry"], array(0=>true)), $entry = array_merge(array_diff_key($entry["LedgerEntry"], array(0=>true)),
$entry[0]); $entry[0]);
$balance += $entry['balance']; $balance += $entry['balance'];
@@ -279,7 +279,7 @@ class Account extends AppModel {
function reconcileNewLedgerEntry($id, $fundamental_type, $amount, $cond = null) { function reconcileNewLedgerEntry($id, $fundamental_type, $amount, $cond = null) {
$ofund = $this->fundamentalOpposite($fundamental_type); $ofund = $this->fundamentalOpposite($fundamental_type);
$unreconciled = array($ofund => array('entry'=>array(), 'balance'=>0)); $unreconciled = array($ofund => array('LedgerEntry'=>array(), 'balance'=>0));
$applied = 0; $applied = 0;
// if there is no money in the entry, it can reconcile nothing // if there is no money in the entry, it can reconcile nothing
@@ -287,14 +287,14 @@ class Account extends AppModel {
if ($amount > 0) { if ($amount > 0) {
$unreconciled = $this->findUnreconciledLedgerEntries($id, $ofund, $cond); $unreconciled = $this->findUnreconciledLedgerEntries($id, $ofund, $cond);
foreach ($unreconciled[$ofund]['entry'] AS $i => &$entry) { foreach ($unreconciled[$ofund]['LedgerEntry'] AS $i => &$entry) {
// Determine if amount is sufficient to cover the entry // Determine if amount is sufficient to cover the entry
if ($amount > $entry['balance']) if ($amount > $entry['balance'])
$apply = $entry['balance']; $apply = $entry['balance'];
elseif ($amount > 0) elseif ($amount > 0)
$apply = $amount; $apply = $amount;
else { else {
unset($unreconciled[$ofund]['entry'][$i]); unset($unreconciled[$ofund]['LedgerEntry'][$i]);
continue; continue;
} }

View File

@@ -85,6 +85,28 @@ class LinkableBehavior extends ModelBehavior {
protected $_defaults = array('type' => 'LEFT'); protected $_defaults = array('type' => 'LEFT');
function pr($lev, $mixed) {
if ($lev >= 5)
return;
pr($mixed);
return;
$trace = debug_backtrace(false);
//array_shift($trace);
$calls = array();
foreach ($trace AS $call) {
$call = array_intersect_key($call,
array('file'=>1,
'line'=>1,
//'class'=>1,
'function'=>1,
));
$calls[] = implode("; ", $call);
}
pr(array('debug' => $mixed, 'stack' => $calls));
}
/* /*
* This is a function for made recursive str_replaces in an array * This is a function for made recursive str_replaces in an array
* NOTE: The palacement of this function is terrible, but I don't * NOTE: The palacement of this function is terrible, but I don't
@@ -108,7 +130,10 @@ class LinkableBehavior extends ModelBehavior {
} }
public function beforeFind(&$Model, $query) { public function beforeFind(&$Model, $query) {
/* pr("Linkable::beforeFind() begin"); pr($query); */ $this->pr(10,
array('function' => 'Linkable::beforeFind',
'args' => array('Model->alias' => '$Model->alias') + compact('query'),
));
if (isset($query[$this->_key])) { if (isset($query[$this->_key])) {
$optionsDefaults = $this->_defaults + array('reference' => $optionsDefaults = $this->_defaults + array('reference' =>
array('class' => $Model->alias, array('class' => $Model->alias,
@@ -132,7 +157,10 @@ class LinkableBehavior extends ModelBehavior {
unset($iterator['defaults']); unset($iterator['defaults']);
} }
$iterations = Set::normalize($iterator); $iterations = Set::normalize($iterator);
/* pr(array('checkpoint' => 'Iterations', compact('iterations'))); */ $this->pr(25,
array('checkpoint' => 'Iterations',
compact('iterations'),
));
foreach ($iterations as $alias => $options) { foreach ($iterations as $alias => $options) {
if (is_null($options)) { if (is_null($options)) {
$options = array(); $options = array();
@@ -145,7 +173,15 @@ class LinkableBehavior extends ModelBehavior {
if (empty($options['class'])) if (empty($options['class']))
$options['class'] = $alias; $options['class'] = $alias;
/* pr(array('checkpoint' => 'Begin Model Work', compact('alias', 'options'))); */ if (!isset($options['conditions']))
$options['conditions'] = array();
elseif (!is_array($options['conditions']))
$options['conditions'] = array($options['conditions']);
$this->pr(20,
array('checkpoint' => 'Begin Model Work',
compact('alias', 'options'),
));
$modelClass = $options['class']; $modelClass = $options['class'];
$modelAlias = $options['alias']; $modelAlias = $options['alias'];
@@ -154,11 +190,13 @@ class LinkableBehavior extends ModelBehavior {
$_Model =& ClassRegistry::init($modelClass); // the incoming model to be linked in query $_Model =& ClassRegistry::init($modelClass); // the incoming model to be linked in query
$Reference =& ClassRegistry::init($referenceClass); // the already in query model that links to $_Model $Reference =& ClassRegistry::init($referenceClass); // the already in query model that links to $_Model
/* pr(array('checkpoint' => 'Aliases Established', */ $this->pr(12,
/* 'Model' => ($modelAlias .' : '. $modelClass . */ array('checkpoint' => 'Aliases Established',
/* ' ('. $_Model->alias .' : '. $_Model->name .')'), */ 'Model' => ($modelAlias .' : '. $modelClass .
/* 'Reference' => ($referenceAlias .' : '. $referenceClass . */ ' ('. $_Model->alias .' : '. $_Model->name .')'),
/* ' ('. $Reference->alias .' : '. $Reference->name .')'))); */ 'Reference' => ($referenceAlias .' : '. $referenceClass .
' ('. $Reference->alias .' : '. $Reference->name .')'),
));
$db =& $_Model->getDataSource(); $db =& $_Model->getDataSource();
@@ -169,20 +207,20 @@ class LinkableBehavior extends ModelBehavior {
// a relationship if one doesn't otherwise already exists. // a relationship if one doesn't otherwise already exists.
if (($associations = $Reference->getAssociated()) && if (($associations = $Reference->getAssociated()) &&
isset($associations[$_Model->alias])) { isset($associations[$_Model->alias])) {
/* pr("Reference defines association to _Model"); */ $this->pr(12, array('checkpoint' => "Reference defines association to _Model"));
$associatedThroughReference = 1; $associatedThroughReference = 1;
$type = $associations[$_Model->alias]; $type = $associations[$_Model->alias];
$association = $Reference->{$type}[$_Model->alias]; $association = $Reference->{$type}[$_Model->alias];
} }
elseif (($associations = $_Model->getAssociated()) && elseif (($associations = $_Model->getAssociated()) &&
isset($associations[$Reference->alias])) { isset($associations[$Reference->alias])) {
/* pr("_Model defines association to Reference"); */ $this->pr(12, array('checkpoint' => "_Model defines association to Reference"));
$type = $associations[$Reference->alias]; $type = $associations[$Reference->alias];
$association = $_Model->{$type}[$Reference->alias]; $association = $_Model->{$type}[$Reference->alias];
} }
else { else {
// No relationship... make our best effort to create one. // No relationship... make our best effort to create one.
/* pr("No assocation between _Model and Reference"); */ $this->pr(12, array('checkpoint' => "No assocation between _Model and Reference"));
$type = 'belongsTo'; $type = 'belongsTo';
$_Model->bind($Reference->alias); $_Model->bind($Reference->alias);
// Grab the association now, since we'll unbind in a moment. // Grab the association now, since we'll unbind in a moment.
@@ -212,12 +250,13 @@ class LinkableBehavior extends ModelBehavior {
$associationAlias, $associationAlias,
$association['conditions']); $association['conditions']);
/* pr(array('checkpoint' => 'Models Established - Check Associations', */ $this->pr(15,
/* 'primaryModel' => $primaryAlias .' : '. $primaryModel->name, */ array('checkpoint' => 'Models Established - Check Associations',
/* 'foreignModel' => $foreignAlias .' : '. $foreignModel->name, */ 'primaryModel' => $primaryAlias .' : '. $primaryModel->name,
/* compact('type', 'association'))); */ 'foreignModel' => $foreignAlias .' : '. $foreignModel->name,
compact('type', 'association'),
));
if (empty($options['conditions'])) {
if ($type === 'hasAndBelongsToMany') { if ($type === 'hasAndBelongsToMany') {
if (isset($association['with'])) if (isset($association['with']))
$linkClass = $association['with']; $linkClass = $association['with'];
@@ -231,6 +270,11 @@ class LinkableBehavior extends ModelBehavior {
else else
$linkAlias = $Link->alias; $linkAlias = $Link->alias;
$this->pr(17,
array('checkpoint' => 'Linking HABTM',
compact('linkClass', 'linkAlias'),
));
// Get the foreign key fields (for the link table) directly from // Get the foreign key fields (for the link table) directly from
// the defined model associations, if they exists. This is the // the defined model associations, if they exists. This is the
// users direct specification, and therefore definitive if present. // users direct specification, and therefore definitive if present.
@@ -279,6 +323,11 @@ class LinkableBehavior extends ModelBehavior {
$foreignKey = $primaryModel->escapeField($association['foreignKey'], $primaryAlias); $foreignKey = $primaryModel->escapeField($association['foreignKey'], $primaryAlias);
$primaryKey = $foreignModel->escapeField($foreignModel->primaryKey, $foreignAlias); $primaryKey = $foreignModel->escapeField($foreignModel->primaryKey, $foreignAlias);
$this->pr(17,
array('checkpoint' => 'Linking due to foreignKey',
compact('foreignKey', 'primaryKey'),
));
// Only differentiating to help show the logical flow. // Only differentiating to help show the logical flow.
// Either way works and this test can be tossed out // Either way works and this test can be tossed out
if (($type === 'hasMany' || $type === 'hasOne') ^ $associatedThroughReference) if (($type === 'hasMany' || $type === 'hasOne') ^ $associatedThroughReference)
@@ -287,10 +336,20 @@ class LinkableBehavior extends ModelBehavior {
$options['conditions'][] = "{$foreignKey} = {$primaryKey}"; $options['conditions'][] = "{$foreignKey} = {$primaryKey}";
} }
else { else {
$this->pr(17,
array('checkpoint' => 'Linking with no logic (expecting user defined)',
));
// No Foreign Key... nothing we can do. // No Foreign Key... nothing we can do.
$options['conditions'] = array();
} }
$this->pr(19,
array('checkpoint' => 'Conditions',
array('options[conditions]' => $options['conditions'],
'association[conditions]' => $association['conditions'],
),
));
// The user may have specified conditions directly in the model // The user may have specified conditions directly in the model
// for this join. Make sure to adhere to those conditions. // for this join. Make sure to adhere to those conditions.
if (isset($association['conditions']) && is_array($association['conditions'])) if (isset($association['conditions']) && is_array($association['conditions']))
@@ -298,7 +357,12 @@ class LinkableBehavior extends ModelBehavior {
elseif (!empty($association['conditions'])) elseif (!empty($association['conditions']))
$options['conditions'][] = $association['conditions']; $options['conditions'][] = $association['conditions'];
} $this->pr(19,
array('checkpoint' => 'Conditions2',
array('options[conditions]' => $options['conditions'],
),
));
if (empty($options['table'])) { if (empty($options['table'])) {
$options['table'] = $db->fullTableName($_Model, true); $options['table'] = $db->fullTableName($_Model, true);
} }
@@ -312,8 +376,6 @@ class LinkableBehavior extends ModelBehavior {
(empty($association['fields']) (empty($association['fields'])
? array() : $db->fields($_Model, $modelAlias, $association['fields']))); ? array() : $db->fields($_Model, $modelAlias, $association['fields'])));
/* pr(array('checkpoint' => 'Model Work Complete', compact('options', 'modelClass', 'modelAlias'))); */
$options[$this->_key] = am($options[$this->_key], array_diff_key($options, $optionsKeys)); $options[$this->_key] = am($options[$this->_key], array_diff_key($options, $optionsKeys));
$options = array_intersect_key($options, $optionsKeys); $options = array_intersect_key($options, $optionsKeys);
if (!empty($options[$this->_key])) { if (!empty($options[$this->_key])) {
@@ -325,13 +387,20 @@ class LinkableBehavior extends ModelBehavior {
'alias' => $modelAlias)))); 'alias' => $modelAlias))));
} }
$query['joins'][] = array_intersect_key($options, array('type' => true, 'alias' => true, 'table' => true, 'joins' => true, 'conditions' => true)); $query['joins'][] = array_intersect_key($options, array('type' => true, 'alias' => true, 'table' => true, 'joins' => true, 'conditions' => true));
$this->pr(19,
array('checkpoint' => 'Model Join Complete',
compact('options', 'modelClass', 'modelAlias', 'query'),
));
} }
++$cont; ++$cont;
$notDone = isset($iterators[$cont]); $notDone = isset($iterators[$cont]);
} while ($notDone); } while ($notDone);
} }
/* pr(array('checkpoint' => 'Linkable::beforeFind() end', */ $this->pr(20,
/* compact('query'))); */ array('function' => 'Linkable::beforeFind',
'return' => compact('query'),
));
return $query; return $query;
} }
} }

View File

@@ -147,7 +147,11 @@ class Lease extends AppModel {
return null; return null;
$stats = $this->Account->stats($this->Account->accountReceivableAccountID(), true, $stats = $this->Account->stats($this->Account->accountReceivableAccountID(), true,
array('LedgerEntry.lease_id' => $id)); array('OR' => array
(array('LedgerEntry.lease_id' => $id),
array('ReconciledLedgerEntry.lease_id' => $id),
),
));
// Pull to the top level and return // Pull to the top level and return
$stats = $stats['Ledger']; $stats = $stats['Ledger'];

View File

@@ -25,17 +25,11 @@ class LedgerEntry extends AppModel {
); );
var $hasAndBelongsToMany = array( var $hasAndBelongsToMany = array(
'DebitReconciliationLedgerEntry' => array( 'ReconcilingTransaction' => array(
'className' => 'LedgerEntry', 'className' => 'Transaction',
'joinTable' => 'reconciliations', 'joinTable' => 'reconciliations',
'foreignKey' => 'credit_ledger_entry_id', 'foreignKey' => 'transaction_id',
'associationForeignKey' => 'debit_ledger_entry_id', 'associationForeignKey' => 'ledger_entry_id',
),
'CreditReconciliationLedgerEntry' => array(
'className' => 'LedgerEntry',
'joinTable' => 'reconciliations',
'foreignKey' => 'debit_ledger_entry_id',
'associationForeignKey' => 'credit_ledger_entry_id',
), ),
); );
@@ -167,36 +161,36 @@ class LedgerEntry extends AppModel {
/************************************************************************** /**************************************************************************
************************************************************************** **************************************************************************
************************************************************************** **************************************************************************
* function: findReconciledLedgerEntries * function: findReconcilingTransactions
* - Returns ledger entries that are reconciled to the given entry. * - Returns transactions that reconcile the given entry
* (such as payments towards a charge). * (such as receipts that reconcile a charge).
*/ */
function findReconciledLedgerEntries($id = null, $fundamental_type = null) { function findReconcilingTransactions($id = null, $fundamental_type = null) {
foreach (($fundamental_type foreach (($fundamental_type
? array($fundamental_type) ? array($fundamental_type)
: array('debit', 'credit')) AS $fund) { : array('debit', 'credit')) AS $fund) {
$ucfund = ucfirst($fund); $reconciled[$fund]['LedgerEntry'] = $this->find
$reconciled[$fund]['entry'] = $this->find
('all', array ('all', array
('link' => array ('link' => array
("ReconciliationLedgerEntry" => array ('ReconcilingTransaction' => array
('class' => "{$ucfund}ReconciliationLedgerEntry", ('fields' => array
'fields' => array
('id', ('id',
"COALESCE(SUM(Reconciliation.amount),0) AS 'reconciled'", "COALESCE(SUM(Reconciliation.amount),0) AS 'reconciled'",
"LedgerEntry.amount - COALESCE(SUM(Reconciliation.amount),0) AS 'balance'", //"ReconcilingTransaction.amount - COALESCE(SUM(Reconciliation.amount),0) AS 'balance'",
"COALESCE(7) AS 'balance'",
),
'conditions' => array('Reconciliation.type' => $fund),
), ),
), ),
), 'group' => ('ReconcilingTransaction.id'),
'group' => ("ReconciliationLedgerEntry.id"),
'conditions' => array('LedgerEntry.id' => $id), 'conditions' => array('LedgerEntry.id' => $id),
'fields' => array(), 'fields' => array(),
)); ));
//pr($reconciled); //pr($reconciled);
$balance = 0; $balance = 0;
foreach ($reconciled[$fund]['entry'] AS &$entry) { foreach ($reconciled[$fund]['LedgerEntry'] AS &$entry) {
$entry = array_merge($entry["ReconciliationLedgerEntry"], $entry[0]); $entry = array_merge($entry["ReconcilingTransaction"], $entry[0]);
$balance += $entry['balance']; $balance += $entry['balance'];
} }
$reconciled[$fund]['balance'] = $balance; $reconciled[$fund]['balance'] = $balance;
@@ -212,27 +206,31 @@ class LedgerEntry extends AppModel {
* function: stats * function: stats
* - Returns summary data from the requested ledger entry * - Returns summary data from the requested ledger entry
*/ */
function stats($id) { function stats($id, $cond = null) {
if (!isset($cond))
$cond = array();
$cond[] = array('LedgerEntry.id' => $id);
$query = array $query = array
( (
'link' => array('ReconcilingTransaction'),
'fields' => array("SUM(Reconciliation.amount) AS 'reconciled'"), 'fields' => array("SUM(Reconciliation.amount) AS 'reconciled'"),
'conditions' => array(isset($cond) ? $cond : array(),
array('LedgerEntry.id' => $id)),
'group' => 'LedgerEntry.id', 'group' => 'LedgerEntry.id',
); );
// Get the applied amounts on the debit side // Get the applied amounts on the debit side
$query['link'] = $qcond = $cond;
array('DebitReconciliationLedgerEntry' => array('alias' => 'DRLE', 'DRLETransaction' => array('class' => 'Transaction'))); $qcond[] = array('Reconciliation.type' => 'DEBIT');
$query['conditions'] = $qcond;
$tmpstats = $this->find('first', $query); $tmpstats = $this->find('first', $query);
$stats['debit_amount_reconciled'] = $tmpstats[0]['reconciled']; $stats['debit_amount_reconciled'] = $tmpstats[0]['reconciled'];
// Get the applied amounts on the credit side // Get the applied amounts on the credit side
$query['link'] = $qcond = $cond;
array('CreditReconciliationLedgerEntry' => array('alias' => 'CRLE', 'CRLETransaction' => array('class' => 'Transaction'))); $qcond[] = array('Reconciliation.type' => 'CREDIT');
$query['conditions'] = $qcond;
$tmpstats = $this->find('first', $query); $tmpstats = $this->find('first', $query);
$stats['credit_amount_reconciled'] = $tmpstats[0]['reconciled']; $stats['credit_amount_reconciled'] = $tmpstats[0]['reconciled'];

View File

@@ -14,6 +14,14 @@ class Transaction extends AppModel {
'LedgerEntry', 'LedgerEntry',
); );
var $hasAndBelongsToMany = array(
'ReconciledLedgerEntry' => array(
'className' => 'LedgerEntry',
'joinTable' => 'reconciliations',
'foreignKey' => 'ledger_entry_id',
'associationForeignKey' => 'transaction_id',
),
);
function beforeSave() { function beforeSave() {
@@ -24,5 +32,40 @@ class Transaction extends AppModel {
return true; return true;
} }
/**************************************************************************
**************************************************************************
**************************************************************************
* function: findReconciledLedgerEntries
* - Returns ledger entries that are reconciled by the given
* transaction (such as charges reconciled by a receipt)
*/
function findReconciledLedgerEntries($id = null) {
$reconciled['LedgerEntry'] = $this->find
('all', array
('link' => array
('ReconciledLedgerEntry' => array
('fields' => array
('id',
"COALESCE(SUM(Reconciliation.amount),0) AS 'reconciled'",
"ReconciledLedgerEntry.amount - COALESCE(SUM(Reconciliation.amount),0) AS 'balance'",
),
),
),
'group' => ('ReconciledLedgerEntry.id'),
'conditions' => array('Transaction.id' => $id),
'fields' => array(),
));
//pr($reconciled);
$balance = 0;
foreach ($reconciled['LedgerEntry'] AS &$entry) {
$entry = array_merge($entry["ReconciledLedgerEntry"], $entry[0]);
$balance += $entry['balance'];
}
$reconciled['balance'] = $balance;
return $reconciled;
}
} }
?> ?>

View File

@@ -119,7 +119,7 @@ foreach ($jqGridColumns AS &$col) {
} }
elseif ($col['formatter'] === 'date') { elseif ($col['formatter'] === 'date') {
$default['formatoptions'] = array('newformat' => 'm/d/Y'); $default['formatoptions'] = array('newformat' => 'm/d/Y');
$default['width'] = 90; $default['width'] = 100;
$default['align'] = 'center'; $default['align'] = 'center';
} }
elseif ($col['formatter'] === 'name' || $col['formatter'] === 'longname') { elseif ($col['formatter'] === 'name' || $col['formatter'] === 'longname') {

View File

@@ -1,17 +1,24 @@
<?php /* -*- mode:PHP -*- */ <?php /* -*- mode:PHP -*- */
if (isset($account_ftype) || isset($ledger_id) || isset($account_id) || isset($ar_account)) { if (isset($account_ftype) || isset($ledger_id) || isset($lease_id) || isset($account_id) || isset($ar_account)) {
$single_account = true; $single_account = true;
} else { } else {
$single_account = false; $single_account = false;
} }
if (isset($ledger_id) || isset($account_id) || isset($ar_account)) { if (isset($ledger_id) || isset($lease_id) || isset($account_id) || isset($ar_account)) {
$single_amount = false; $single_amount = false;
} else { } else {
$single_amount = true; $single_amount = true;
} }
if (isset($lease_id) || isset($customer_id)) {
$references = false;
}
else {
$references = true;
}
if (isset($reconcile_id)) { if (isset($reconcile_id)) {
$applied_amount = true; $applied_amount = true;
} else { } else {
@@ -47,9 +54,13 @@ else {
$cols['Debit Account'] = array('index' => 'DebitAccount.name', 'formatter' => 'name'); $cols['Debit Account'] = array('index' => 'DebitAccount.name', 'formatter' => 'name');
$cols['Credit Account'] = array('index' => 'CreditAccount.name', 'formatter' => 'name'); $cols['Credit Account'] = array('index' => 'CreditAccount.name', 'formatter' => 'name');
} }
if ($references) {
$cols['Customer'] = array('index' => 'Customer.name', 'formatter' => 'longname'); $cols['Customer'] = array('index' => 'Customer.name', 'formatter' => 'longname');
$cols['Lease'] = array('index' => 'Lease.number', 'formatter' => 'id'); $cols['Lease'] = array('index' => 'Lease.number', 'formatter' => 'id');
$cols['Unit'] = array('index' => 'Unit.name', 'formatter' => 'name'); $cols['Unit'] = array('index' => 'Unit.name', 'formatter' => 'name');
}
$cols['Source'] = array('index' => 'MonetarySource.name', 'formatter' => 'name'); $cols['Source'] = array('index' => 'MonetarySource.name', 'formatter' => 'name');
$cols['Comment'] = array('index' => 'LedgerEntry.comment', 'formatter' => 'comment', 'width'=>150); $cols['Comment'] = array('index' => 'LedgerEntry.comment', 'formatter' => 'comment', 'width'=>150);

View File

@@ -1,17 +1,38 @@
<?php /* -*- mode:PHP -*- */ <?php /* -*- mode:PHP -*- */
if (isset($reconcile_ledger_entry_id)) {
$applied_amount = true;
} else {
$applied_amount = false;
}
$subtotal_amount = false;
// Define the table columns // Define the table columns
$cols = array(); $cols = array();
$cols['ID'] = array('index' => 'Transaction.id', 'formatter' => 'id'); $cols['ID'] = array('index' => 'Transaction.id', 'formatter' => 'id');
//$cols['Customer'] = array('index' => 'Customer.name', 'formatter' => 'longname'); //$cols['Customer'] = array('index' => 'Customer.name', 'formatter' => 'longname');
$cols['Timesamp'] = array('index' => 'Transaction.stamp', 'formatter' => 'date'); $cols['Timestamp'] = array('index' => 'Transaction.stamp', 'formatter' => 'date');
$cols['Through'] = array('index' => 'Transaction.through_date', 'formatter' => 'date'); $cols['Through'] = array('index' => 'Transaction.through_date', 'formatter' => 'date');
$cols['Due'] = array('index' => 'Transaction.due_date', 'formatter' => 'date'); $cols['Due'] = array('index' => 'Transaction.due_date', 'formatter' => 'date');
$cols['Comment'] = array('index' => 'Transaction.comment', 'formatter' => 'comment'); $cols['Comment'] = array('index' => 'Transaction.comment', 'formatter' => 'comment');
if ($applied_amount) {
$cols['Applied'] = array('index' => "Reconciliation.amount", 'formatter' => 'currency');
}
if ($subtotal_amount) {
$cols['Sub-Total'] = array('index' => 'subtotal', 'formatter' => 'currency', 'sortable' => false);
}
$jqGrid_options = array('jqGridColumns' => $cols, $jqGrid_options = array('jqGridColumns' => $cols,
'controller' => 'transactions', 'controller' => 'transactions',
'caption' => isset($caption) ? $caption : null); );
$jqGrid_options += compact('grid_div_id', 'grid_id', 'caption', 'grid_setup', 'limit');
$custom_post_data = compact('reconcile_type', 'reconcile_ledger_entry_id');
if (isset($transactions)) { if (isset($transactions)) {
$jqGrid_options += array('custom_ids' => $jqGrid_options += array('custom_ids' =>
@@ -20,8 +41,14 @@ if (isset($transactions)) {
$transactions), $transactions),
'limit' => 5); 'limit' => 5);
} }
elseif (isset($reconcile_ledger_entry_id)) {
$jqGrid_options += array('limit' => 5);
}
else { else {
$jqGrid_options += array('search_fields' => array('Due', 'Comment')); $jqGrid_options += array('search_fields' => array('Due', 'Comment'));
} }
$jqGrid_options += compact('custom_post_data');
$jqGrid_options['sort_column'] = 'Timestamp';
echo $this->element('jqGrid', $jqGrid_options); echo $this->element('jqGrid', $jqGrid_options);

View File

@@ -81,7 +81,7 @@ echo '<div CLASS="detail supporting">' . "\n";
echo $this->element('ledger_entries', echo $this->element('ledger_entries',
array('caption' => 'Account', array('caption' => 'Account',
'lease_id' => $lease['id'], 'lease_id' => $lease['id'],
'ar_account' => true, //'ar_account' => true,
)); ));

View File

@@ -112,22 +112,20 @@ echo '<div CLASS="detail supporting">' . "\n";
*/ */
if ($debit_ledger['Account']['trackable']) { if ($debit_ledger['Account']['trackable']) {
echo $this->element('ledger_entries', echo $this->element('transactions',
array('caption' => "Payments Received", array('caption' => "Payments Received",
'grid_div_id' => 'debit_reconciliation_ledger_entries', 'grid_div_id' => 'debit_reconciliation_ledger_entries',
'account_ftype' => 'debit', 'reconcile_type' => 'debit',
'reconcile_id' => $entry['id'], 'reconcile_ledger_entry_id' => $entry['id'],
//'ledger_entries' => $reconciled['debit']['entry'],
)); ));
} }
if ($credit_ledger['Account']['trackable']) { if ($credit_ledger['Account']['trackable']) {
echo $this->element('ledger_entries', echo $this->element('transactions',
array('caption' => "Charges Paid", array('caption' => "Charges Paid",
'grid_div_id' => 'credit_reconciliation_ledger_entries', 'grid_div_id' => 'credit_reconciliation_ledger_entries',
'account_ftype' => 'credit', 'reconcile_type' => 'credit',
'reconcile_id' => $entry['id'], 'reconcile_ledger_entry_id' => $entry['id'],
//'ledger_entries' => $reconciled['credit']['entry'],
)); ));
} }