Compare commits
184 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 861eabc6b5 | |||
| 6baa7fa6e6 | |||
| 8cb45ad1d6 | |||
| ce4fa4131a | |||
| 80f8bd36d5 | |||
| 7aa1100cac | |||
| b9c1a81c3b | |||
| bd0bbd768d | |||
| 20b8908a00 | |||
| ab51fd32d2 | |||
| b780ebeb3e | |||
| 117e31af69 | |||
| 28b3f35318 | |||
| 2b8a525718 | |||
| dc6e399fea | |||
| 1508f963d3 | |||
| 3270ad9bf0 | |||
| febd216810 | |||
| c8b781804a | |||
| 3e5ac64108 | |||
| 9b6830468e | |||
| 063aec6c3c | |||
| a2ae522b2d | |||
| ba218fbeeb | |||
| 2e67695154 | |||
| a136fd5313 | |||
| 1e3774cad6 | |||
| 518f7836ac | |||
| 416e230da8 | |||
| cd416ea5fa | |||
| 001b156333 | |||
| df1e0daafd | |||
| 9331b0a412 | |||
| fae90c3fa9 | |||
| a83edef049 | |||
| 4ada3d5bac | |||
| ede1053de4 | |||
| ce9142ffe2 | |||
| 0270e5ea89 | |||
| 4d2b4779d4 | |||
| fe7d7c6b0f | |||
| 435b0614b2 | |||
| 708910870c | |||
| 8b067bf676 | |||
| 388dbc0540 | |||
| ce20a44836 | |||
| 1495bb3373 | |||
| eaea52a862 | |||
| 271207629b | |||
| edca01f98c | |||
| 23f4a29fc7 | |||
| 543e2daa43 | |||
| 3911b3303f | |||
| d859cb4dee | |||
| 39071b39fb | |||
| 3dcdcb03eb | |||
| 41636f5c75 | |||
| 1890a0490e | |||
| 2b9369b823 | |||
| 4ec3db7b58 | |||
| 9f876b78de | |||
| 31c603c757 | |||
| 4d49ad6516 | |||
| 015e6b082d | |||
| cdec4c3301 | |||
| 404323c6c1 | |||
| d5dbabd94a | |||
| c90830d41a | |||
| f6ca79d1a9 | |||
| 5fab94011b | |||
| af2d5c38f3 | |||
| 6b8d05f2a0 | |||
| 336ec3b643 | |||
| b4d640f7c2 | |||
| 90a16c721e | |||
| e7b4b21328 | |||
| 3be775f9b2 | |||
| 0278c77610 | |||
| 508a8b08aa | |||
| c5bd8b4b16 | |||
| a49b86898e | |||
| 55dd94681a | |||
| 2f91dd456a | |||
| e32a5e5d4c | |||
| cca48fe86a | |||
| 839d9c1697 | |||
| c80c66d958 | |||
| a2fa71038a | |||
| d3c7011fc8 | |||
| 2c224dbc62 | |||
| 13b2283d76 | |||
| 3d89da7a61 | |||
| 99263920a3 | |||
| 8ab8d087e6 | |||
| 18b928411b | |||
| 8d062ab92e | |||
| 147c1e7097 | |||
| 760420bdc5 | |||
| fb48baf575 | |||
| d60c9721ca | |||
| f8eb45a0b9 | |||
| 4277962e3b | |||
| a60d69ba52 | |||
| 55b896a9f0 | |||
| 9f8d4fa9b2 | |||
| 4988d2717f | |||
| 136d8e845a | |||
| 190a9259d4 | |||
| 374843aeee | |||
| 52032180f3 | |||
| d14b715a88 | |||
| 2a2d11ba0f | |||
| 2e07cb87a5 | |||
| bb5b563738 | |||
| f3ffa3c079 | |||
| 30b934823c | |||
| 948ae28616 | |||
| 30c6e0b0f4 | |||
| 46e3316ce1 | |||
| e1671a9fca | |||
| e586268dee | |||
| 24730fda1b | |||
| b6ec85205d | |||
| b6a0809350 | |||
| f42ce65768 | |||
| ef180e7dda | |||
| 4aa59a40a2 | |||
| 0c43a0f884 | |||
| e65db5c759 | |||
| 59b549955e | |||
| 603a08393e | |||
| 1db887cf38 | |||
| 4ebe1db2cc | |||
| f74073a2e1 | |||
| 3f6c526718 | |||
| 903209a47e | |||
| 23a81ae924 | |||
| 9db4dd737d | |||
| 52528f1c0e | |||
| 6bf06a3a3c | |||
| 387c1ae87b | |||
| 70812e0a0c | |||
| 7fae1bcaad | |||
| c041174b0c | |||
| 2a4b8079fb | |||
| 79bcf99fc5 | |||
| 9d09afca35 | |||
| f384e051bf | |||
| 2da7b6b2c0 | |||
| 2c85566ffc | |||
| db03c73b59 | |||
| 684f02ebc5 | |||
| 4e33c58246 | |||
| 9fc5562dd8 | |||
| 3cc8e95ff4 | |||
| 15930fae30 | |||
| dbe037fee8 | |||
| 5c6189cdef | |||
| 4a86d3dda0 | |||
| ec3d986c78 | |||
| e38e99c94e | |||
| aed2c6912c | |||
| 7433e6868c | |||
| 8393403443 | |||
| ed04f81dda | |||
| 4923712238 | |||
| ffe04ed6fd | |||
| 0021eb1768 | |||
| 0ef51ee30f | |||
| 28bf192853 | |||
| df846f9963 | |||
| f4007a0269 | |||
| 6b53d8a25a | |||
| 76a06d1655 | |||
| eeb8775820 | |||
| 2d9a85ad82 | |||
| 0da1080b86 | |||
| 2665d012c2 | |||
| c5d5e2c651 | |||
| c22be388cf | |||
| 220284d20f | |||
| 4502b73b2e | |||
| 3251ba340d | |||
| c9f9d0867b |
@@ -0,0 +1,3 @@
|
|||||||
|
@echo off
|
||||||
|
%~dp0\scripts\sitelink2pmgr.pl %~dp0\db\schema.sql %~dp0db\vss.mdb > NUL
|
||||||
|
echo Done!
|
||||||
+1226
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -78,6 +78,24 @@ class AppModel extends Model {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
**************************************************************************
|
||||||
|
**************************************************************************
|
||||||
|
* function: nameToID
|
||||||
|
* - Returns the ID of the named item
|
||||||
|
*/
|
||||||
|
function nameToID($name) {
|
||||||
|
$this->cacheQueries = true;
|
||||||
|
$item = $this->find('first', array
|
||||||
|
('recursive' => -1,
|
||||||
|
'conditions' => compact('name'),
|
||||||
|
));
|
||||||
|
$this->cacheQueries = false;
|
||||||
|
$item = current($item);
|
||||||
|
return $item['id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
+1
-31
@@ -162,41 +162,11 @@ class LedgerEntriesController extends AppController {
|
|||||||
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('Lease.id' => $params['custom']['lease_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']['transaction_id'])) {
|
if (isset($params['custom']['transaction_id'])) {
|
||||||
@@ -304,7 +274,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
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class StatementEntriesController extends AppController {
|
||||||
|
|
||||||
|
var $sidemenu_links = array();
|
||||||
|
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
**************************************************************************
|
||||||
|
**************************************************************************
|
||||||
|
* override: sideMenuLinks
|
||||||
|
* - Generates controller specific links for the side menu
|
||||||
|
*/
|
||||||
|
function sideMenuLinks() {
|
||||||
|
return array_merge(parent::sideMenuLinks(), $this->sidemenu_links);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
**************************************************************************
|
||||||
|
**************************************************************************
|
||||||
|
* virtuals: jqGridData
|
||||||
|
* - With the application controller handling the jqGridData action,
|
||||||
|
* these virtual functions ensure that the correct data is passed
|
||||||
|
* to jqGrid.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function jqGridDataTables(&$params, &$model) {
|
||||||
|
$link =
|
||||||
|
array(// Models
|
||||||
|
'LedgerEntry' =>
|
||||||
|
array('fields' => array('id'),
|
||||||
|
// Models
|
||||||
|
'Transaction' =>
|
||||||
|
array('fields' => array('id', 'stamp'),
|
||||||
|
),
|
||||||
|
|
||||||
|
'Ledger' =>
|
||||||
|
array('fields' => array('id', 'sequence'),
|
||||||
|
'conditions' => ("Ledger.id = IF(StatementEntry.type = 'CHARGE'," .
|
||||||
|
" LedgerEntry.credit_ledger_id," .
|
||||||
|
" LedgerEntry.debit_ledger_id)"),
|
||||||
|
// Models
|
||||||
|
'Account' => array('fields' => array('id', 'name'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
return array('link' => $link);
|
||||||
|
}
|
||||||
|
|
||||||
|
function jqGridDataFields(&$params, &$model) {
|
||||||
|
$fields = array('id', 'type', 'comment');
|
||||||
|
$fields[] = "IF(StatementEntry.type = 'CHARGE', StatementEntry.amount, NULL) AS 'charge'";
|
||||||
|
$fields[] = "IF(StatementEntry.type = 'PAYMENT', StatementEntry.amount, NULL) AS 'payment'";
|
||||||
|
$fields[] = "IF(StatementEntry.type = 'CHARGE', 1, -1) * StatementEntry.amount AS 'amount'";
|
||||||
|
return $fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
function jqGridDataConditions(&$params, &$model) {
|
||||||
|
$conditions = parent::jqGridDataConditions($params, $model);
|
||||||
|
|
||||||
|
if (isset($params['custom']['statement_id'])) {
|
||||||
|
$conditions[] =
|
||||||
|
array('StatementEntry.statement_id' => $params['custom']['statement_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $conditions;
|
||||||
|
}
|
||||||
|
|
||||||
|
function jqGridRecordLinks(&$params, &$model, &$records, $links) {
|
||||||
|
$links['Transaction'] = array('id');
|
||||||
|
$links['StatementEntry'] = array('id');
|
||||||
|
$links['Account'] = array('controller' => 'accounts', 'name');
|
||||||
|
$links['LedgerEntry'] = array('id');
|
||||||
|
return parent::jqGridRecordLinks($params, $model, $records, $links);
|
||||||
|
}
|
||||||
|
|
||||||
|
function jqGridRecordsPostProcess(&$params, &$model, &$records) {
|
||||||
|
parent::jqGridRecordsPostProcess($params, $model, $records);
|
||||||
|
|
||||||
|
$subtotal = 0;
|
||||||
|
foreach ($records AS &$record) {
|
||||||
|
$amount = $record['StatementEntry']['amount'];
|
||||||
|
$record['StatementEntry']['amount'] = $amount;
|
||||||
|
$record['StatementEntry']['subtotal'] = ($subtotal += $amount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
**************************************************************************
|
||||||
|
**************************************************************************
|
||||||
|
* action: view
|
||||||
|
* - Displays information about a specific entry
|
||||||
|
*/
|
||||||
|
|
||||||
|
function view($id = null) {
|
||||||
|
if (!$id) {
|
||||||
|
$this->Session->setFlash(__('Invalid Item.', true));
|
||||||
|
$this->redirect(array('controller' => 'accounts', 'action'=>'index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the StatementEntry and related fields
|
||||||
|
$entry = $this->StatementEntry->find
|
||||||
|
('first',
|
||||||
|
array('contain' => array(),
|
||||||
|
'conditions' => array('StatementEntry.id' => $id),
|
||||||
|
));
|
||||||
|
|
||||||
|
// Prepare to render.
|
||||||
|
$title = "Statement Entry #{$entry['StatementEntry']['id']}";
|
||||||
|
$this->set(compact('entry', 'title'));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -55,7 +55,7 @@ class UnitsController extends AppController {
|
|||||||
$link = array
|
$link = array
|
||||||
('link' =>
|
('link' =>
|
||||||
array(// Models
|
array(// Models
|
||||||
'UnitSize' => array('fields' => array('name')),
|
'UnitSize' => array('fields' => array('id', 'name')),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -93,6 +93,11 @@ class UnitsController extends AppController {
|
|||||||
return parent::jqGridDataOrder($params, $model, $index, $direction);
|
return parent::jqGridDataOrder($params, $model, $index, $direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function jqGridRecordLinks(&$params, &$model, &$records, $links) {
|
||||||
|
//$links['UnitSize'] = array('name');
|
||||||
|
$links['Unit'] = array('name', 'id');
|
||||||
|
return parent::jqGridRecordLinks($params, $model, $records, $links);
|
||||||
|
}
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
@@ -82,26 +82,13 @@ class Account extends AppModel {
|
|||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
* function: accountNameToID
|
* function: Account IDs
|
||||||
* - Returns the ID of the named account
|
* - Returns the ID of the desired account
|
||||||
*/
|
*/
|
||||||
function accountNameToID($name) {
|
|
||||||
$this->cacheQueries = true;
|
|
||||||
$account = $this->find('first', array
|
|
||||||
('recursive' => -1,
|
|
||||||
'conditions' => compact('name'),
|
|
||||||
));
|
|
||||||
$this->cacheQueries = false;
|
|
||||||
return $account['Account']['id'];
|
|
||||||
}
|
|
||||||
|
|
||||||
function securityDepositAccountID() { return $this->accountNameToID('Security Deposit'); }
|
function securityDepositAccountID() { return $this->nameToID('Security Deposit'); }
|
||||||
function rentAccountID() { return $this->accountNameToID('Rent'); }
|
function rentAccountID() { return $this->nameToID('Rent'); }
|
||||||
function accountReceivableAccountID() { return $this->accountNameToID('A/R'); }
|
function accountReceivableAccountID() { return $this->nameToID('A/R'); }
|
||||||
function invoiceAccountID() { return $this->accountReceivableAccountID(); }
|
|
||||||
function receiptAccountID() { return $this->accountReceivableAccountID(); }
|
|
||||||
//function invoiceAccountID() { return $this->accountNameToID('Invoice'); }
|
|
||||||
//function receiptAccountID() { return $this->accountNameToID('Receipt'); }
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
@@ -8,6 +8,7 @@ class Customer extends AppModel {
|
|||||||
);
|
);
|
||||||
|
|
||||||
var $belongsTo = array(
|
var $belongsTo = array(
|
||||||
|
'Statement',
|
||||||
'PrimaryContact' => array(
|
'PrimaryContact' => array(
|
||||||
'className' => 'Contact',
|
'className' => 'Contact',
|
||||||
),
|
),
|
||||||
@@ -43,13 +44,26 @@ class Customer extends AppModel {
|
|||||||
*/
|
*/
|
||||||
function accountId($id) {
|
function accountId($id) {
|
||||||
$this->cacheQueries = true;
|
$this->cacheQueries = true;
|
||||||
$customer = $this->find('first',
|
$item = $this->find('first',
|
||||||
array('contain' => false,
|
array('contain' => false,
|
||||||
'fields' => array('account_id'),
|
'fields' => array('account_id'),
|
||||||
'conditions' => array(array('Customer.id' => $id))));
|
'conditions' => compact('id')));
|
||||||
$this->cacheQueries = false;
|
$this->cacheQueries = false;
|
||||||
|
|
||||||
return $customer['Customer']['account_id'];
|
$item = current($item);
|
||||||
|
return $item['account_id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
function statementID($id) {
|
||||||
|
$this->cacheQueries = true;
|
||||||
|
$item = $this->find('first', array
|
||||||
|
('recursive' => -1,
|
||||||
|
'conditions' => compact('id'),
|
||||||
|
));
|
||||||
|
$this->cacheQueries = false;
|
||||||
|
|
||||||
|
$item = current($item);
|
||||||
|
return $item['statement_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -75,6 +89,7 @@ class Customer extends AppModel {
|
|||||||
return $ids;
|
return $ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
@@ -82,22 +97,10 @@ class Customer extends AppModel {
|
|||||||
* - Returns an array of security deposit entries
|
* - Returns an array of security deposit entries
|
||||||
*/
|
*/
|
||||||
function findSecurityDeposits($id, $link = null) {
|
function findSecurityDeposits($id, $link = null) {
|
||||||
/* pr(array('function' => 'Customer::findSecurityDeposits', */
|
return $this->Statement->findEntriesRelatedToAccount
|
||||||
/* 'args' => compact('id', 'link'), */
|
($this->statementId($id),
|
||||||
/* )); */
|
|
||||||
|
|
||||||
$entries = $this->Account->findLedgerEntriesRelatedToAccount
|
|
||||||
($this->Account->invoiceAccountID(),
|
|
||||||
$this->Account->securityDepositAccountID(),
|
$this->Account->securityDepositAccountID(),
|
||||||
true, array('LedgerEntry.customer_id' => $id), $link);
|
null, $link);
|
||||||
|
|
||||||
/* pr(array('function' => 'Customer::findSecurityDeposits', */
|
|
||||||
/* 'args' => compact('id', 'link'), */
|
|
||||||
/* 'vars' => compact('customer'), */
|
|
||||||
/* 'return' => compact('entries'), */
|
|
||||||
/* )); */
|
|
||||||
|
|
||||||
return $entries;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -191,16 +194,11 @@ class Customer extends AppModel {
|
|||||||
* - Returns summary data from the requested customer.
|
* - Returns summary data from the requested customer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function stats($id = null) {
|
function stats($id = null, $cond = null, $link = null) {
|
||||||
if (!$id)
|
if (!$id)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
$stats = $this->Account->stats($this->Account->accountReceivableAccountID(), true,
|
return $this->Statement->stats($this->statementID($id), $cond, $link);
|
||||||
array('LedgerEntry.customer_id' => $id));
|
|
||||||
|
|
||||||
// Pull to the top level and return
|
|
||||||
$stats = $stats['Ledger'];
|
|
||||||
return $stats;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -26,6 +26,7 @@ class Lease extends AppModel {
|
|||||||
'LeaseType',
|
'LeaseType',
|
||||||
'Unit',
|
'Unit',
|
||||||
'Customer',
|
'Customer',
|
||||||
|
'Statement',
|
||||||
'LateSchedule',
|
'LateSchedule',
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -40,13 +41,23 @@ class Lease extends AppModel {
|
|||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
* function: accountId
|
* function: accessors
|
||||||
* - Returns the accountId of the given lease
|
|
||||||
*/
|
*/
|
||||||
function accountId($id) {
|
function accountId($id) {
|
||||||
return $this->Account->invoiceAccountID();
|
return $this->Account->invoiceAccountID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function statementID($id) {
|
||||||
|
$this->cacheQueries = true;
|
||||||
|
$item = $this->find('first', array
|
||||||
|
('recursive' => -1,
|
||||||
|
'conditions' => compact('id'),
|
||||||
|
));
|
||||||
|
$this->cacheQueries = false;
|
||||||
|
$item = current($item);
|
||||||
|
return $item['statement_id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
@@ -83,21 +94,10 @@ class Lease extends AppModel {
|
|||||||
* - Returns an array of security deposit entries
|
* - Returns an array of security deposit entries
|
||||||
*/
|
*/
|
||||||
function findSecurityDeposits($id, $link = null) {
|
function findSecurityDeposits($id, $link = null) {
|
||||||
/* pr(array('function' => 'Lease::findSecurityDeposits', */
|
return $this->Statement->findEntriesRelatedToAccount
|
||||||
/* 'args' => compact('id', 'link'), */
|
($this->statementId($id),
|
||||||
/* )); */
|
|
||||||
|
|
||||||
$entries = $this->Account->findLedgerEntriesRelatedToAccount
|
|
||||||
($this->accountId($id),
|
|
||||||
$this->Account->securityDepositAccountID(),
|
$this->Account->securityDepositAccountID(),
|
||||||
true, array('LedgerEntry.lease_id' => $id), $link);
|
null, $link);
|
||||||
|
|
||||||
/* pr(array('function' => 'Lease::findSecurityDeposits', */
|
|
||||||
/* 'args' => compact('id', 'link'), */
|
|
||||||
/* 'vars' => compact('lease'), */
|
|
||||||
/* 'return' => compact('entries'), */
|
|
||||||
/* )); */
|
|
||||||
return $entries;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -142,16 +142,11 @@ class Lease extends AppModel {
|
|||||||
* - Returns summary data from the requested lease.
|
* - Returns summary data from the requested lease.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function stats($id = null) {
|
function stats($id = null, $cond = null, $link = null) {
|
||||||
if (!$id)
|
if (!$id)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
$stats = $this->Account->stats($this->Account->accountReceivableAccountID(), true,
|
return $this->Statement->stats($this->statementID($id), $cond, $link);
|
||||||
array('LedgerEntry.lease_id' => $id));
|
|
||||||
|
|
||||||
// Pull to the top level and return
|
|
||||||
$stats = $stats['Ledger'];
|
|
||||||
return $stats;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
<?php
|
||||||
|
class Statement extends AppModel {
|
||||||
|
|
||||||
|
var $hasMany = array(
|
||||||
|
'Lease',
|
||||||
|
'Customer',
|
||||||
|
'StatementEntry',
|
||||||
|
|
||||||
|
'ChargeStatementEntry' => array(
|
||||||
|
'className' => 'StatementEntry',
|
||||||
|
'conditions' => array('type' => 'CHARGE'),
|
||||||
|
),
|
||||||
|
'PaymentStatementEntry' => array(
|
||||||
|
'className' => 'StatementEntry',
|
||||||
|
'conditions' => array('type' => 'PAYMENT'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
**************************************************************************
|
||||||
|
**************************************************************************
|
||||||
|
* function: findStatementEntries
|
||||||
|
* - Returns an array of statement entries that belong to a given
|
||||||
|
* statement. There is extra work done... see the StatementEntry model.
|
||||||
|
*/
|
||||||
|
function findStatementEntries($id, $cond = null, $link = null) {
|
||||||
|
/* pr(array('function' => 'Statement::findStatementEntries', */
|
||||||
|
/* 'args' => compact('id', 'cond', 'link'), */
|
||||||
|
/* )); */
|
||||||
|
|
||||||
|
if (!isset($cond))
|
||||||
|
$cond = array();
|
||||||
|
|
||||||
|
$cond[] = array('Statement.id' => $id);
|
||||||
|
$entries = $this->find('all', array('link' => $link, 'conditions' => $cond));
|
||||||
|
|
||||||
|
/* pr(array('function' => 'Statement::findStatementEntries', */
|
||||||
|
/* 'args' => compact('id', 'cond', 'link'), */
|
||||||
|
/* 'return' => compact('entries'), */
|
||||||
|
/* )); */
|
||||||
|
return $entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
**************************************************************************
|
||||||
|
**************************************************************************
|
||||||
|
* function: findEntriesRelatedToAccount
|
||||||
|
* - Returns an array of statement entries that belong to the given
|
||||||
|
* account, and are related to a specific account.
|
||||||
|
*/
|
||||||
|
function findEntriesRelatedToAccount($id, $rel_ids, $cond = null, $link = null) {
|
||||||
|
/* pr(array('function' => 'Statement::findEntriesRelatedToAccount', */
|
||||||
|
/* 'args' => compact('id', 'rel_ids', 'cond', 'link'), */
|
||||||
|
/* )); */
|
||||||
|
|
||||||
|
if (!isset($cond))
|
||||||
|
$cond = array();
|
||||||
|
if (!isset($link))
|
||||||
|
$link = array();
|
||||||
|
if (!is_array($rel_ids))
|
||||||
|
$rel_ids = array($rel_ids);
|
||||||
|
|
||||||
|
$link['StatementEntry'] = array('LedgerEntry' => array('Ledger' => array('Account')));
|
||||||
|
$cond[] = array('Account.id' => $rel_ids);
|
||||||
|
|
||||||
|
$entries = $this->findStatementEntries($id, $cond, $link);
|
||||||
|
|
||||||
|
$stats = $this->stats($id, $cond, $link);
|
||||||
|
$entries = array('Entries' => $entries,
|
||||||
|
'summary' => $stats);
|
||||||
|
|
||||||
|
/* pr(array('function' => 'Statement::findEntriesRelatedToAccount', */
|
||||||
|
/* 'args' => compact('id', 'relid', 'cond', 'link'), */
|
||||||
|
/* 'return' => compact('entries'), */
|
||||||
|
/* )); */
|
||||||
|
return $entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
**************************************************************************
|
||||||
|
**************************************************************************
|
||||||
|
* function: stats
|
||||||
|
* - Returns summary data from the requested statement.
|
||||||
|
*/
|
||||||
|
function stats($id, $cond = null, $link = null) {
|
||||||
|
if (!isset($cond))
|
||||||
|
$cond = array();
|
||||||
|
if (!isset($link))
|
||||||
|
$link = array();
|
||||||
|
|
||||||
|
if (!isset($link['StatementEntry']))
|
||||||
|
$link['StatementEntry'] = array('fields' => array());
|
||||||
|
|
||||||
|
$cond[] = array('Statement.id' => $id);
|
||||||
|
|
||||||
|
$stats = $this->find
|
||||||
|
('first', array
|
||||||
|
('link' => $link,
|
||||||
|
|
||||||
|
'fields' =>
|
||||||
|
array("SUM(IF(StatementEntry.type = 'CHARGE',
|
||||||
|
StatementEntry.amount, NULL)) AS charges",
|
||||||
|
"SUM(IF(StatementEntry.type = 'PAYMENT',
|
||||||
|
StatementEntry.amount, NULL)) AS payments",
|
||||||
|
"SUM(IF(StatementEntry.type = 'CHARGE', 1, -1)
|
||||||
|
* IF(StatementEntry.amount, StatementEntry.amount, 0)
|
||||||
|
) AS balance",
|
||||||
|
"COUNT(StatementEntry.id) AS entries"),
|
||||||
|
|
||||||
|
'conditions' => $cond,
|
||||||
|
'group' => 'Statement.id',
|
||||||
|
));
|
||||||
|
|
||||||
|
// The fields are all tucked into the [0] index,
|
||||||
|
// and the rest of the array is useless (empty).
|
||||||
|
return $stats[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
class StatementEntry extends AppModel {
|
||||||
|
|
||||||
|
var $belongsTo = array(
|
||||||
|
'Statement',
|
||||||
|
'LedgerEntry',
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
Vendored
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
Vendored
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user