I'm still in the middle of moving onto a ledger based system. However, I'm am now changing how transactions and entries relate back to the customer. I'll be using a ledger for each lease (for rent, late charges, security deposits, etc), and a ledger for each customer (for POS, non-specific deposits such as reservations or covering mulitple units, bad debt writeoff, and possibly customer credits, when not obviously lease specific). This coming change might not be in the right direction, so I want to capture the work as is right now. This change set is not fully functional. Many operations do work, but there are obviously transaction problems with units and customers.

git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605/site@71 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-06-06 20:18:56 +00:00
parent ce24abc812
commit 677458e942
52 changed files with 2367 additions and 1469 deletions

View File

@@ -0,0 +1,129 @@
<?php
class TransactionsController extends AppController {
var $paginate = array('limit' => 100,
'group' => 'Transaction.id',
'order' => array('Transaction.stamp' => 'ASC'));
var $sidemenu_links =
array(array('name' => 'Transactions', 'header' => true),
array('name' => 'Cleared', 'url' => array('controller' => 'transactions', 'action' => 'cleared')),
array('name' => 'Unresolved', 'url' => array('controller' => 'transactions', 'action' => 'unresolved')),
);
/**************************************************************************
**************************************************************************
**************************************************************************
* override: sideMenuLinks
* - Generates controller specific links for the side menu
*/
function sideMenuLinks() {
return array_merge(parent::sideMenuLinks(), $this->sidemenu_links);
}
/**************************************************************************
**************************************************************************
**************************************************************************
* action: index
* - Lists all transactions
*/
function index() {
$this->all();
}
/**************************************************************************
**************************************************************************
**************************************************************************
* action: cleared
* - Lists cleared transactions
*/
function cleared() {
$this->all();
}
/**************************************************************************
**************************************************************************
**************************************************************************
* action: unresolved
* - Lists unresolved transactions
*/
function unresolved() {
$this->all();
}
/**************************************************************************
**************************************************************************
**************************************************************************
* action: all
* - Lists all transactions
*/
function all() {
$this->paginate = array_merge
($this->paginate,
array('link' =>
array(// Models
'Customer',
'LedgerEntry' => array('DebitLedger', 'CreditLedger')
),
));
$title = 'All Transactions';
$this->set('title', $title); $this->set('heading', $title);
$this->set('transactions', $this->paginate());
$this->render('index');
}
/**************************************************************************
**************************************************************************
**************************************************************************
* action: view
* - Displays information about a specific transaction
*/
function view($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid Item.', true));
$this->redirect(array('action'=>'index'));
}
$this->Transaction->Behaviors->attach('Containable');
$this->Transaction->contain
(array(// Models
'LedgerEntry' => array(//Models
'DebitLedger',
'CreditLedger',
),
)
);
$transaction = $this->Transaction->read(null, $id);
pr($transaction);
$debit_amount = 0;
$credit_amount = 0;
foreach($transaction['LedgerEntry'] AS $entry) {
$debit_amount += $entry['amount'];
$credit_amount += $entry['amount'];
}
/* $this->sidemenu_links[] = */
/* array('name' => 'Operations', 'header' => true); */
/* $this->sidemenu_links[] = */
/* array('name' => 'Move-Out', 'url' => array('controller' => 'transactions', 'action' => 'move-out')); */
$title = 'Transaction #' . $transaction['Transaction']['id'];
$this->set(compact('transaction', 'title',
'debit_amount',
'credit_amount'));
}
}