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:
@@ -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')));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user