Compare commits

..

1 Commits

Author SHA1 Message Date
abijah
82a010496d Releasing v0.3.0
git-svn-id: file:///svn-source/pmgr/tags/v0.3.0@999 97e9348a-65ac-dc4b-aefc-98561f571b83
2010-07-02 22:20:55 +00:00
6 changed files with 27 additions and 91 deletions

View File

@@ -278,14 +278,8 @@ class AppController extends Controller {
$this->addSideMenuLink('Unit Summary', $this->addSideMenuLink('Unit Summary',
array('controller' => 'units', 'action' => 'overview'), null, array('controller' => 'units', 'action' => 'overview'), null,
'REPORT'); 'REPORT');
$this->addSideMenuLink('Monthly Income', $this->addSideMenuLink('Monthly Charges',
array('controller' => 'statement_entries', 'action' => 'incomebymonth'), null, array('controller' => 'statement_entries', 'action' => 'chargesbymonth'), null,
'REPORT');
$this->addSideMenuLink('Monthly Expenses',
array('controller' => 'statement_entries', 'action' => 'expensebymonth'), null,
'REPORT');
$this->addSideMenuLink('Monthly Net',
array('controller' => 'statement_entries', 'action' => 'netbymonth'), null,
'REPORT'); 'REPORT');
} }
else { else {
@@ -954,24 +948,13 @@ class AppController extends Controller {
'value' => $params['filtValue']); 'value' => $params['filtValue']);
} }
// Translate a user specified date into the SQL date format
foreach ($searches AS &$search) {
if (preg_match('/(_date|stamp)$/', $search['field']) &&
preg_match('%(\d{1,2})[-/](\d{1,2})[-/](\d{2,4})%', $search['value'], $matches)) {
$search['value'] = sprintf('%04d%02d%02d',
$matches[3] + ($matches[3] < 50 ? 2000 : ($matches[3] < 100 ? 1900 : 0)),
$matches[2], $matches[1]);
}
}
unset($search);
$ops = array('eq' => array('op' => null, 'pre' => '', 'post' => ''), $ops = array('eq' => array('op' => null, 'pre' => '', 'post' => ''),
'ne' => array('op' => '<>', 'pre' => '', 'post' => ''), 'ne' => array('op' => '<>', 'pre' => '', 'post' => ''),
'lt' => array('op' => '<', 'pre' => '', 'post' => ''), 'lt' => array('op' => '<', 'pre' => '', 'post' => ''),
'le' => array('op' => '<=', 'pre' => '', 'post' => ''), 'le' => array('op' => '<=', 'pre' => '', 'post' => ''),
'gt' => array('op' => '>', 'pre' => '', 'post' => ''), 'gt' => array('op' => '>', 'pre' => '', 'post' => ''),
'ge' => array('op' => '>=', 'pre' => '', 'post' => ''), 'ge' => array('op' => '>=', 'pre' => '', 'post' => ''),
'in' => array('op' => 'IN', 'pre' => '(', 'post' => ')'), 'in' => array('op' => 'IN', 'pre' => '(', 'post' => ')'),
'bw' => array('op' => 'LIKE', 'pre' => '', 'post' => '%'), 'bw' => array('op' => 'LIKE', 'pre' => '', 'post' => '%'),
'ew' => array('op' => 'LIKE', 'pre' => '%', 'post' => ''), 'ew' => array('op' => 'LIKE', 'pre' => '%', 'post' => ''),
'cn' => array('op' => 'LIKE', 'pre' => '%', 'post' => '%'), 'cn' => array('op' => 'LIKE', 'pre' => '%', 'post' => '%'),
@@ -1174,7 +1157,7 @@ class AppController extends Controller {
} }
function gridDataOutputSummary(&$params, &$model, $pagination) { function gridDataOutputSummary(&$params, &$model, $pagination) {
if ($params['debug']) if ($params['debug'])
echo " <params><![CDATA[\n" . print_r($params, true) . "\n]]></params>\n"; echo " <params><![CDATA[\n" . print_r($params, true) . "\n]]></params>\n";
echo " <page>{$pagination['page']}</page>\n"; echo " <page>{$pagination['page']}</page>\n";
echo " <total>{$pagination['total']}</total>\n"; echo " <total>{$pagination['total']}</total>\n";

View File

@@ -260,65 +260,38 @@ class StatementEntriesController extends AppController {
/************************************************************************** /**************************************************************************
************************************************************************** **************************************************************************
************************************************************************** **************************************************************************
* action: incexpbymonth * action: chargesbymonth
* - Displays income and/or expenses by month * - Displays charges by month
*/ */
function incexpbymonth($accts, $security_deposits, $months) { function chargesbymonth($months = 12) {
$datefrom = 'DATE(NOW() - INTERVAL '.($months-1).' MONTH - INTERVAL DAY(NOW())-1 DAY)';
$dateto = 'NOW()';
/* $datefrom = '"2009-01-01"'; */
/* $dateto = '"2011-12-31"'; */
$result = $this->StatementEntry->find $result = $this->StatementEntry->find
('all', ('all',
array('link' => array('Account' => array('fields' => 'name')), array('link' => array('Account' => array('fields' => 'name')),
'fields' => array_merge(array('MONTHNAME(effective_date) AS month', 'fields' => array_merge(array('MONTHNAME(effective_date) AS month',
'YEAR(effective_date) AS year'), 'YEAR(effective_date) AS year'),
$this->StatementEntry->chargeDisbursementFields(true)), $this->StatementEntry->chargeDisbursementFields(true)),
'conditions' => array('Account.type' => $accts, 'conditions' => array('Account.type' => 'INCOME',
"effective_date >= $datefrom", 'effective_date >= DATE(NOW() - INTERVAL '.($months-1).' MONTH - INTERVAL DAY(NOW())-1 DAY)',
"effective_date <= $dateto", 'effective_date <= NOW()',
), ),
'group' => array('YEAR(effective_date)', 'MONTH(effective_date)', 'Account.id'), 'group' => array('YEAR(effective_date)', 'MONTH(effective_date)', 'Account.id'),
'order' => array('YEAR(effective_date) DESC', 'MONTH(effective_date) DESC', 'Account.type', 'order' => array('YEAR(effective_date) DESC', 'MONTH(effective_date) DESC', 'Account.name'),
'IF(Account.id = '.$this->StatementEntry->Account->rentAccountID().', "---", Account.name)'),
)); ));
if ($security_deposits) { $overview = array('months' => array(), 'charges' => 0);
$sdresult = $this->StatementEntry->Transaction->LedgerEntry->find foreach ($result AS $row) {
('all',
array('link' => array('Transaction' => array('StatementEntry' => array('fields' => 'effective_date'),
'fields' => array()),
'Account' => array('fields' => 'name')),
'fields' => array_merge(array('MONTHNAME(effective_date) AS month',
'YEAR(effective_date) AS year'),
$this->StatementEntry->Transaction->LedgerEntry->debitCreditFields(true)),
'conditions' => array('LedgerEntry.account_id' => $this->StatementEntry->Account->securityDepositAccountID(),
"effective_date >= $datefrom",
"effective_date <= $dateto",
'StatementEntry.id = (SELECT MIN(id) FROM pmgr_statement_entries WHERE transaction_id = `Transaction`.id)'
),
'group' => array('YEAR(effective_date)', 'MONTH(effective_date)', 'Account.id'),
'order' => array('YEAR(effective_date) DESC', 'MONTH(effective_date) DESC', 'Account.type', 'Account.name'),
));
} else {
$sdresult = array();
}
$overview = array('months' => array(), 'amount' => 0);
foreach (array_merge($result, $sdresult) AS $row) {
$mname = $row[0]['month'] .', '. $row[0]['year']; $mname = $row[0]['month'] .', '. $row[0]['year'];
if (empty($overview['months'][$mname])) if (empty($overview['months'][$mname]))
$overview['months'][$mname] = array('name' => $mname, $overview['months'][$mname] = array('name' => $mname,
'subs' => array(), 'subs' => array(),
'amount' => 0); 'charges' => 0);
$month = &$overview['months'][$mname]; $month = &$overview['months'][$mname];
$month['subs'][] = array('name' => $row['Account']['name'], $month['subs'][] = array('name' => $row['Account']['name'],
'amount' => $row[0]['balance']); 'charges' => $row[0]['balance']);
$month['amount'] += $row[0]['balance']; $month['charges'] += $row[0]['balance'];
$overview['amount'] += $row[0]['balance']; $overview['charges'] += $row[0]['balance'];
} }
// Enable the Reports menu section // Enable the Reports menu section
@@ -326,26 +299,8 @@ class StatementEntriesController extends AppController {
// Prepare to render. // Prepare to render.
$this->set('months', $months); $this->set('months', $months);
$this->set('title', 'Monthly Charges');
$this->set(compact('overview')); $this->set(compact('overview'));
$this->render('chargesbymonth');
}
function incomebymonth($months = 12) {
$this->set('title', 'Monthly Gross Income');
$this->set('reptype', 'Gross Income');
$this->incexpbymonth(array('INCOME'), true, $months);
}
function expensebymonth($months = 12) {
$this->set('title', 'Gross Monthly Expenses');
$this->set('reptype', 'Gross Expenses');
$this->incexpbymonth(array('EXPENSE'), false, $months);
}
function netbymonth($months = 12) {
$this->set('title', 'Net Monthly Income');
$this->set('reptype', 'Net Income');
$this->incexpbymonth(array('INCOME', 'EXPENSE'), true, $months);
} }

View File

@@ -330,15 +330,13 @@ class Customer extends AppModel {
} }
// Remove any contacts which are already destination customer contacts // Remove any contacts which are already destination customer contacts
$new_contacts = array_diff($contacts, array_keys($dst_contacts)); $contacts = array_diff($contacts, array_keys($dst_contacts));
$all_contacts = array_merge($new_contacts, array_keys($dst_contacts));
$this->pr(17, compact('new_contacts', 'all_contacts'));
// For now, we'll assume the operation will succeed. // For now, we'll assume the operation will succeed.
$ret = true; $ret = true;
// Add each desired source customer contact to the destination customer // Add each desired source customer contact to the destination customer
foreach ($new_contacts AS $contact_id) { foreach ($contacts AS $contact_id) {
$CM = new ContactsCustomer(); $CM = new ContactsCustomer();
if (!$CM->save(array('customer_id' => $dst_id) if (!$CM->save(array('customer_id' => $dst_id)
+ $src_contacts[$contact_id], false)) { + $src_contacts[$contact_id], false)) {
@@ -374,7 +372,7 @@ class Customer extends AppModel {
$this->delete($src_id); $this->delete($src_id);
// Delete all the orphaned customers // Delete all the orphaned customers
foreach (array_diff(array_keys($src_contacts), $all_contacts) AS $contact_id) { foreach (array_diff(array_keys($src_contacts), $contacts) AS $contact_id) {
// Delete un-used or duplicate contacts // Delete un-used or duplicate contacts
// REVISIT <AP> 20100702: // REVISIT <AP> 20100702:
// Not sure if we really want to do this. // Not sure if we really want to do this.

View File

@@ -544,7 +544,7 @@ class Lease extends AppModel {
function conditionDelinquent($table_name = 'Lease') { function conditionDelinquent($table_name = 'Lease') {
if (empty($table_name)) $t = ''; else $t = $table_name . '.'; if (empty($table_name)) $t = ''; else $t = $table_name . '.';
return ("({$t}close_date IS NULL AND" . return ("({$t}close_date IS NULL AND" .
" NOW() > DATE_ADD({$t}paid_through_date, INTERVAL 1 DAY))"); " NOW() > DATE_ADD({$t}paid_through_date, INTERVAL 10 DAY))");
} }
function delinquentDaysSQL($table_name = 'Lease') { function delinquentDaysSQL($table_name = 'Lease') {

View File

@@ -66,7 +66,7 @@ function customerContactDiv($obj, $values = null, $primary = false) {
'</DIV>' . "\n" . '</DIV>' . "\n" .
// BEGIN contact-div // BEGIN contact-div
'<div id="contact-%{id}-contact-div">' . "\n" . '<div id="contact-%{id}-contact-div"' . "\n" .
$obj->element $obj->element
('form_table', ('form_table',

View File

@@ -10,11 +10,11 @@ echo '<div class="statement_entry overview">' . "\n";
*/ */
$rows = array(); $rows = array();
$rows[] = array("$months Month Total", FormatHelper::currency($overview['amount'])); $rows[] = array("$months Month Charges", FormatHelper::currency($overview['charges']));
echo $this->element('table', echo $this->element('table',
array('class' => 'item statement_entry detail', array('class' => 'item statement_entry detail',
'caption' => $reptype, 'caption' => 'Monthly Charges',
'rows' => $rows, 'rows' => $rows,
'column_class' => array('field', 'value'))); 'column_class' => array('field', 'value')));
@@ -38,11 +38,11 @@ foreach ($overview['months'] AS $month) {
$odd = 1; $odd = 1;
foreach ($month['subs'] AS $sub) { foreach ($month['subs'] AS $sub) {
$row_class[] = array('subitem', $odd ? 'oddrow' : 'evenrow'); $row_class[] = array('subitem', $odd ? 'oddrow' : 'evenrow');
$rows[] = array($sub['name'], FormatHelper::currency($sub['amount'])); $rows[] = array($sub['name'], FormatHelper::currency($sub['charges']));
$odd = !$odd; $odd = !$odd;
} }
$row_class[] = 'grand'; $row_class[] = 'grand';
$rows[] = array('Total for '.$month['name'], FormatHelper::currency($month['amount'])); $rows[] = array('Total for '.$month['name'], FormatHelper::currency($month['charges']));
} }
echo $this->element('table', echo $this->element('table',