Added mechanism to reverse a ledger entry. For now I've restricted it to those ledger entries that have not already been reconciled in some way. More thought will have to go into this, especially with respect to tenants who have pre-paid and then move out early.

git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629/site@309 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-11 09:06:36 +00:00
parent d683895413
commit 0c0033d1f5

View File

@@ -266,6 +266,18 @@ class LedgerEntriesController extends AppController {
}
/**************************************************************************
**************************************************************************
**************************************************************************
* action: reverse the ledger entry
*/
function reverse($id) {
$id = $this->LedgerEntry->reverse($id);
$this->redirect(array('action'=>'view', $id));
}
/**************************************************************************
**************************************************************************
**************************************************************************
@@ -342,6 +354,27 @@ class LedgerEntriesController extends AppController {
$reconciled = $this->LedgerEntry->findReconciledLedgerEntries($id);
//pr($reconciled);
// REVISIT <AP>: 20090711
// It's not clear whether we should be able to reverse charges that have
// already been paid/cleared/reconciled. Certainly, that will be the
// case when someone has pre-paid and then moves out early. However, this
// will work well for items accidentally charged but not yet paid for.
if ((!$entry['DebitLedger']['Account']['trackable'] ||
$stats['debit']['amount_reconciled'] == 0) &&
(!$entry['CreditLedger']['Account']['trackable'] ||
$stats['credit']['amount_reconciled'] == 0))
{
// Set up dynamic menu items
$this->sidemenu_links[] =
array('name' => 'Operations', 'header' => true);
$this->sidemenu_links[] =
array('name' => 'Reverse',
'url' => array('action' => 'reverse',
$id));
}
// Prepare to render.
$title = "Double Ledger Entry #{$entry['LedgerEntry']['id']}";
$this->set(compact('entry', 'title', 'reconciled', 'stats'));