From 0c0033d1f579064c4bccb32eae3dce122d46642e Mon Sep 17 00:00:00 2001 From: abijah Date: Sat, 11 Jul 2009 09:06:36 +0000 Subject: [PATCH] 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 --- controllers/ledger_entries_controller.php | 33 +++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/controllers/ledger_entries_controller.php b/controllers/ledger_entries_controller.php index 25cd6f6..6675547 100644 --- a/controllers/ledger_entries_controller.php +++ b/controllers/ledger_entries_controller.php @@ -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 : 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'));