Made progress adapting the receipt code onto the latest db changes.
git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716@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) {
|
||||
$order = parent::gridDataOrder($params, $model, $index, $direction);
|
||||
|
||||
if ($index === 'Transaction.stamp')
|
||||
$order[] = 'StatementEntry.id ' . $direction;
|
||||
// After sorting by whatever the user wants, add these
|
||||
// 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;
|
||||
}
|
||||
@@ -195,7 +200,7 @@ class StatementEntriesController extends AppController {
|
||||
('first',
|
||||
array('contain' => array
|
||||
('Transaction' => array('fields' => array('id', 'stamp')),
|
||||
'Account' => array('id', 'name', 'type', 'trackable'),
|
||||
'Account' => array('id', 'name', 'type'),
|
||||
'Customer' => array('fields' => array('id', 'name')),
|
||||
'Lease' => array('fields' => array('id')),
|
||||
),
|
||||
|
||||
@@ -124,15 +124,12 @@ class TransactionsController extends AppController {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach($this->data['LedgerEntry'] AS &$entry) {
|
||||
if (!isset($entry['acct'][$entry['account_id']]))
|
||||
continue;
|
||||
|
||||
$entry['MonetarySource'] = $entry['acct'][$entry['account_id']];
|
||||
foreach($this->data['Entry'] AS &$entry) {
|
||||
$entry['Tender'] = $entry['type'][$entry['tender_type_id']];
|
||||
unset($entry['type']);
|
||||
unset($entry['tender_type_id']);
|
||||
}
|
||||
|
||||
pr($this->data);
|
||||
|
||||
if (!$this->Transaction->addReceipt($this->data,
|
||||
$this->data['Customer']['id'],
|
||||
(isset($this->data['Lease']['id'])
|
||||
|
||||
@@ -105,8 +105,12 @@ class Customer extends AppModel {
|
||||
function unreconciledCharges($id, $query = null) {
|
||||
$this->queryInit($query);
|
||||
|
||||
if (!isset($query['link']['StatementEntry']))
|
||||
$query['link']['StatementEntry'] = array();
|
||||
if (!isset($query['link']['Customer']))
|
||||
$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'])) */
|
||||
/* $query['link']['StatementEntry']['Customer'] = array(); */
|
||||
/* if (!isset($query['link']['StatementEntry']['Customer']['fields'])) */
|
||||
|
||||
@@ -5,6 +5,25 @@ class TenderType extends AppModel {
|
||||
'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;
|
||||
|
||||
/* // 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,10 @@ class Transaction extends AppModel {
|
||||
foreach ($data['Entry'] AS &$entry) {
|
||||
$entry['type'] = 'PAYMENT';
|
||||
$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);
|
||||
@@ -108,7 +112,7 @@ class Transaction extends AppModel {
|
||||
* - statement_entry_comment
|
||||
* - Tender
|
||||
* - [MANDATORY]
|
||||
* - type (CASH, CHECK, etc)
|
||||
* - tender_type_id
|
||||
* - [OPTIONAL]
|
||||
* - name
|
||||
* (default: Entry Account Name & data1)
|
||||
@@ -165,10 +169,7 @@ class Transaction extends AppModel {
|
||||
if (empty($entry['type']) ||
|
||||
empty($entry['account_id']) ||
|
||||
empty($entry['crdr']) ||
|
||||
empty($entry['amount']) ||
|
||||
(isset($entry['Tender']) &&
|
||||
(empty($entry['Tender']['type'])
|
||||
))
|
||||
empty($entry['amount'])
|
||||
) {
|
||||
pr("Entry verification failed");
|
||||
return array('error' => true);
|
||||
@@ -187,7 +188,7 @@ class Transaction extends AppModel {
|
||||
if (isset($entry['Tender'])) {
|
||||
|
||||
// Verify required Tender data is present
|
||||
if (empty($entry['Tender']['type'])) {
|
||||
if (empty($entry['Tender']['tender_type_id'])) {
|
||||
pr("Tender verification failed");
|
||||
return array('error' => true);
|
||||
}
|
||||
@@ -195,7 +196,7 @@ class Transaction extends AppModel {
|
||||
// Keep only relevent items
|
||||
$entry['Tender'] =
|
||||
array_intersect_key($entry['Tender'],
|
||||
array_flip(array('type', 'name',
|
||||
array_flip(array('tender_type_id', 'name',
|
||||
'data1', 'data2', 'data3', 'data4',
|
||||
'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
|
||||
// but the form plugin does this for you automatically when it submits the data
|
||||
//var_dump(formData);
|
||||
$('#request-debug').html('<PRE>'+dump(formData)+'</PRE>');
|
||||
//$('#request-debug').html('Ommitted');
|
||||
return false;
|
||||
//$('#request-debug').html('<PRE>'+dump(formData)+'</PRE>');
|
||||
$('#request-debug').html('Ommitted');
|
||||
//return false;
|
||||
|
||||
$('#response-debug').html('Loading <BLINK>...</BLINK>');
|
||||
$('#output-debug').html('Loading <BLINK>...</BLINK>');
|
||||
@@ -188,6 +188,11 @@ function addPaymentSource(flash) {
|
||||
$div .= ' STYLE="display:none;"';
|
||||
$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) {
|
||||
if (!empty($type["data{$i}_name"])) {
|
||||
$div .= '<DIV CLASS="input text required">';
|
||||
|
||||
@@ -82,7 +82,7 @@ echo $this->element('statement_entries', array
|
||||
'config' => array
|
||||
('caption' => 'Account',
|
||||
'filter' => array('Customer.id' => $customer['Customer']['id']),
|
||||
'exclude' => array('Effective', 'Customer'),
|
||||
'exclude' => array('Customer'),
|
||||
)));
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user