Made progress adapting the receipt code onto the latest db changes.
git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716/site@387 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -134,8 +134,13 @@ class StatementEntriesController extends AppController {
|
|||||||
function gridDataOrder(&$params, &$model, $index, $direction) {
|
function gridDataOrder(&$params, &$model, $index, $direction) {
|
||||||
$order = parent::gridDataOrder($params, $model, $index, $direction);
|
$order = parent::gridDataOrder($params, $model, $index, $direction);
|
||||||
|
|
||||||
if ($index === 'Transaction.stamp')
|
// After sorting by whatever the user wants, add these
|
||||||
$order[] = 'StatementEntry.id ' . $direction;
|
// defaults into the sort mechanism. If we're already
|
||||||
|
// sorting by one of them, it will only be redundant,
|
||||||
|
// and should cause no harm (possible a longer query?)
|
||||||
|
$order[] = 'Transaction.stamp ' . $direction;
|
||||||
|
$order[] = 'StatementEntry.effective_date ' . $direction;
|
||||||
|
$order[] = 'StatementEntry.id ' . $direction;
|
||||||
|
|
||||||
return $order;
|
return $order;
|
||||||
}
|
}
|
||||||
@@ -195,7 +200,7 @@ class StatementEntriesController extends AppController {
|
|||||||
('first',
|
('first',
|
||||||
array('contain' => array
|
array('contain' => array
|
||||||
('Transaction' => array('fields' => array('id', 'stamp')),
|
('Transaction' => array('fields' => array('id', 'stamp')),
|
||||||
'Account' => array('id', 'name', 'type', 'trackable'),
|
'Account' => array('id', 'name', 'type'),
|
||||||
'Customer' => array('fields' => array('id', 'name')),
|
'Customer' => array('fields' => array('id', 'name')),
|
||||||
'Lease' => array('fields' => array('id')),
|
'Lease' => array('fields' => array('id')),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -124,15 +124,12 @@ class TransactionsController extends AppController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($this->data['LedgerEntry'] AS &$entry) {
|
foreach($this->data['Entry'] AS &$entry) {
|
||||||
if (!isset($entry['acct'][$entry['account_id']]))
|
$entry['Tender'] = $entry['type'][$entry['tender_type_id']];
|
||||||
continue;
|
unset($entry['type']);
|
||||||
|
unset($entry['tender_type_id']);
|
||||||
$entry['MonetarySource'] = $entry['acct'][$entry['account_id']];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pr($this->data);
|
|
||||||
|
|
||||||
if (!$this->Transaction->addReceipt($this->data,
|
if (!$this->Transaction->addReceipt($this->data,
|
||||||
$this->data['Customer']['id'],
|
$this->data['Customer']['id'],
|
||||||
(isset($this->data['Lease']['id'])
|
(isset($this->data['Lease']['id'])
|
||||||
|
|||||||
@@ -105,8 +105,12 @@ class Customer extends AppModel {
|
|||||||
function unreconciledCharges($id, $query = null) {
|
function unreconciledCharges($id, $query = null) {
|
||||||
$this->queryInit($query);
|
$this->queryInit($query);
|
||||||
|
|
||||||
if (!isset($query['link']['StatementEntry']))
|
if (!isset($query['link']['Customer']))
|
||||||
$query['link']['StatementEntry'] = array();
|
$query['link']['Customer'] = array();
|
||||||
|
if (!isset($query['link']['Customer']['fields']))
|
||||||
|
$query['link']['Customer']['fields'] = array();
|
||||||
|
/* if (!isset($query['link']['StatementEntry'])) */
|
||||||
|
/* $query['link']['StatementEntry'] = array(); */
|
||||||
/* if (!isset($query['link']['StatementEntry']['Customer'])) */
|
/* if (!isset($query['link']['StatementEntry']['Customer'])) */
|
||||||
/* $query['link']['StatementEntry']['Customer'] = array(); */
|
/* $query['link']['StatementEntry']['Customer'] = array(); */
|
||||||
/* if (!isset($query['link']['StatementEntry']['Customer']['fields'])) */
|
/* if (!isset($query['link']['StatementEntry']['Customer']['fields'])) */
|
||||||
|
|||||||
@@ -5,6 +5,25 @@ class TenderType extends AppModel {
|
|||||||
'Tender',
|
'Tender',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
**************************************************************************
|
||||||
|
**************************************************************************
|
||||||
|
* function: accountID
|
||||||
|
* - Returns the intended account ID for receipt of the given tender
|
||||||
|
*/
|
||||||
|
function accountID($id) {
|
||||||
|
$this->cacheQueries = true;
|
||||||
|
$item = $this->find('first', array
|
||||||
|
('contain' => false,
|
||||||
|
'conditions' => array('TenderType.id' => $id),
|
||||||
|
));
|
||||||
|
$this->cacheQueries = false;
|
||||||
|
//pr(compact('id', 'item'));
|
||||||
|
return $item['TenderType']['account_id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
@@ -21,12 +40,6 @@ class TenderType extends AppModel {
|
|||||||
);
|
);
|
||||||
$this->cacheQueries = false;
|
$this->cacheQueries = false;
|
||||||
|
|
||||||
/* // Rearrange to be of the form (id => name) */
|
|
||||||
/* $rel_accounts = array(); */
|
|
||||||
/* foreach ($accounts AS $acct) { */
|
|
||||||
/* $rel_accounts[$acct['Account']['id']] = $acct['Account']['name']; */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
return $accounts;
|
return $accounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,6 +58,10 @@ class Transaction extends AppModel {
|
|||||||
foreach ($data['Entry'] AS &$entry) {
|
foreach ($data['Entry'] AS &$entry) {
|
||||||
$entry['type'] = 'PAYMENT';
|
$entry['type'] = 'PAYMENT';
|
||||||
$entry['crdr'] = 'DEBIT';
|
$entry['crdr'] = 'DEBIT';
|
||||||
|
if (isset($entry['Tender']['tender_type_id'])) {
|
||||||
|
$entry['account_id'] = $this->LedgerEntry->Tender->TenderType->
|
||||||
|
accountID($entry['Tender']['tender_type_id']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$ids = $this->addTransaction($data, $customer_id, $lease_id);
|
$ids = $this->addTransaction($data, $customer_id, $lease_id);
|
||||||
@@ -108,7 +112,7 @@ class Transaction extends AppModel {
|
|||||||
* - statement_entry_comment
|
* - statement_entry_comment
|
||||||
* - Tender
|
* - Tender
|
||||||
* - [MANDATORY]
|
* - [MANDATORY]
|
||||||
* - type (CASH, CHECK, etc)
|
* - tender_type_id
|
||||||
* - [OPTIONAL]
|
* - [OPTIONAL]
|
||||||
* - name
|
* - name
|
||||||
* (default: Entry Account Name & data1)
|
* (default: Entry Account Name & data1)
|
||||||
@@ -165,10 +169,7 @@ class Transaction extends AppModel {
|
|||||||
if (empty($entry['type']) ||
|
if (empty($entry['type']) ||
|
||||||
empty($entry['account_id']) ||
|
empty($entry['account_id']) ||
|
||||||
empty($entry['crdr']) ||
|
empty($entry['crdr']) ||
|
||||||
empty($entry['amount']) ||
|
empty($entry['amount'])
|
||||||
(isset($entry['Tender']) &&
|
|
||||||
(empty($entry['Tender']['type'])
|
|
||||||
))
|
|
||||||
) {
|
) {
|
||||||
pr("Entry verification failed");
|
pr("Entry verification failed");
|
||||||
return array('error' => true);
|
return array('error' => true);
|
||||||
@@ -187,7 +188,7 @@ class Transaction extends AppModel {
|
|||||||
if (isset($entry['Tender'])) {
|
if (isset($entry['Tender'])) {
|
||||||
|
|
||||||
// Verify required Tender data is present
|
// Verify required Tender data is present
|
||||||
if (empty($entry['Tender']['type'])) {
|
if (empty($entry['Tender']['tender_type_id'])) {
|
||||||
pr("Tender verification failed");
|
pr("Tender verification failed");
|
||||||
return array('error' => true);
|
return array('error' => true);
|
||||||
}
|
}
|
||||||
@@ -195,7 +196,7 @@ class Transaction extends AppModel {
|
|||||||
// Keep only relevent items
|
// Keep only relevent items
|
||||||
$entry['Tender'] =
|
$entry['Tender'] =
|
||||||
array_intersect_key($entry['Tender'],
|
array_intersect_key($entry['Tender'],
|
||||||
array_flip(array('type', 'name',
|
array_flip(array('tender_type_id', 'name',
|
||||||
'data1', 'data2', 'data3', 'data4',
|
'data1', 'data2', 'data3', 'data4',
|
||||||
'comment')));
|
'comment')));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,9 +42,9 @@ function verifyRequest(formData, jqForm, options) {
|
|||||||
// formData is an array; here we use $.param to convert it to a string to display it
|
// formData is an array; here we use $.param to convert it to a string to display it
|
||||||
// but the form plugin does this for you automatically when it submits the data
|
// but the form plugin does this for you automatically when it submits the data
|
||||||
//var_dump(formData);
|
//var_dump(formData);
|
||||||
$('#request-debug').html('<PRE>'+dump(formData)+'</PRE>');
|
//$('#request-debug').html('<PRE>'+dump(formData)+'</PRE>');
|
||||||
//$('#request-debug').html('Ommitted');
|
$('#request-debug').html('Ommitted');
|
||||||
return false;
|
//return false;
|
||||||
|
|
||||||
$('#response-debug').html('Loading <BLINK>...</BLINK>');
|
$('#response-debug').html('Loading <BLINK>...</BLINK>');
|
||||||
$('#output-debug').html('Loading <BLINK>...</BLINK>');
|
$('#output-debug').html('Loading <BLINK>...</BLINK>');
|
||||||
@@ -188,6 +188,11 @@ function addPaymentSource(flash) {
|
|||||||
$div .= ' STYLE="display:none;"';
|
$div .= ' STYLE="display:none;"';
|
||||||
$div .= '>';
|
$div .= '>';
|
||||||
|
|
||||||
|
$div .= ' <INPUT TYPE="hidden"';
|
||||||
|
$div .= ' NAME="data[Entry][%{id}][type]['.$type['id'].'][tender_type_id]"';
|
||||||
|
$div .= ' VALUE="'.$type['id'].'"';
|
||||||
|
$div .= '>';
|
||||||
|
|
||||||
for ($i=1; $i<=4; ++$i) {
|
for ($i=1; $i<=4; ++$i) {
|
||||||
if (!empty($type["data{$i}_name"])) {
|
if (!empty($type["data{$i}_name"])) {
|
||||||
$div .= '<DIV CLASS="input text required">';
|
$div .= '<DIV CLASS="input text required">';
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ echo $this->element('statement_entries', array
|
|||||||
'config' => array
|
'config' => array
|
||||||
('caption' => 'Account',
|
('caption' => 'Account',
|
||||||
'filter' => array('Customer.id' => $customer['Customer']['id']),
|
'filter' => array('Customer.id' => $customer['Customer']['id']),
|
||||||
'exclude' => array('Effective', 'Customer'),
|
'exclude' => array('Customer'),
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user