diff --git a/models/transaction.php b/models/transaction.php index de8c42e..09a2e27 100644 --- a/models/transaction.php +++ b/models/transaction.php @@ -106,6 +106,46 @@ class Transaction extends AppModel { } + /************************************************************************** + ************************************************************************** + ************************************************************************** + * function: addWaiver + * - Adds a new waiver + */ + + function addWaiver($data, $customer_id, $lease_id = null) { + $this->prEnter(compact('data', 'customer_id', 'lease_id')); + // REVISIT : 20090802 + // Completely un-implemented. Just copied from addReceipt + // and search-replace receipt with waiver. + return ('error' => true); + + // Establish the transaction as a waiver + $waiver =& $data['Transaction']; + $waiver['type'] = 'RECEIPT'; + $waiver['crdr'] = 'CREDIT'; + $waiver['account_id'] = $this->Account->accountReceivableAccountID(); + $waiver['customer_id'] = $customer_id; + $waiver['lease_id'] = $lease_id; + + // Go through the statement entries and flag as payments + foreach ($data['Entry'] AS &$entry) { + $entry['type'] = 'WAIVE'; + $entry['crdr'] = 'DEBIT'; + if (empty($entry['account_id']) && isset($entry['Tender']['tender_type_id'])) { + $entry['account_id'] = $this->LedgerEntry->Tender->TenderType-> + accountID($entry['Tender']['tender_type_id']); + } + } + + $ids = $this->addTransaction($data['Transaction'], $data['Entry']); + if (isset($ids['transaction_id'])) + $ids['waiver_id'] = $ids['transaction_id']; + + return $ids; + } + + /************************************************************************** ************************************************************************** ************************************************************************** @@ -428,7 +468,6 @@ class Transaction extends AppModel { $this->pr(20, compact('transaction', 'entries')); // Move forward, verifying and saving everything. - // REVISIT : 20090731 NSF was not verifying... let's find out why $ret = array(); if (!$this->verifyTransaction($transaction, $entries)) return $this->prReturn(array('error' => true) + $ret);