Added an automatic $35 nsf charge when marking an item as nsf. This required removing the lease_id requirement when adding a transaction, since the charge is not associated with a lease, just a customer. The requirement was artificial anyway; imagine selling POS items to folks that don't even lease from us...

git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716/site@447 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-31 03:07:34 +00:00
parent 46744a24d3
commit 5dc5f087ba
2 changed files with 58 additions and 6 deletions

View File

@@ -191,10 +191,54 @@ class Tender extends AppModel {
if ($result['error']) if ($result['error'])
die("Unable to save Bounce transaction"); die("Unable to save Bounce transaction");
// REVISIT <AP>: 20090730 /* [data] => Array */
// Add NSF Charge /* ( */
/* [Transaction] => Array */
/* ( */
/* [stamp] => 07/30/2009 17:17 */
/* [comment] => */
/* [type] => INVOICE */
/* [crdr] => DEBIT */
/* [account_id] => 3 */
/* [customer_id] => */
/* [lease_id] => 43 */
/* ) */
/* $nsf_fee_account_id = $A->nsfChargeAccountID(); */ /* [Entry] => Array */
/* ( */
/* [1] => Array */
/* ( */
/* [account_id] => 17 */
/* [effective_date] => 07/30/2009 */
/* [through_date] => */
/* [amount] => 35 */
/* [comment] => */
/* [type] => CHARGE */
/* [crdr] => CREDIT */
/* ) */
/* ) */
/* ) */
// Add NSF Charge
$result = $this->NsfTransaction->addInvoice
(array('Transaction' =>
array('stamp' => $nsf_deposit['stamp'],
),
'Entry' =>
array
(array('account_id' => $this->LedgerEntry->Account->nsfChargeAccountID(),
'effective_date' => $nsf_deposit['stamp'],
// REVISIT <AP>: 20090730
// BAD, BAD, BAD... who would actually
// hardcode a value like this???? ;-)
'amount' => 35,
'comment' => "NSF: " . $tender['Tender']['name'],
),
),
),
$tender['Tender']['customer_id']);
$this->pr(20, compact('result'));
return $this->prReturn(true); return $this->prReturn(true);
} }

View File

@@ -37,6 +37,8 @@ class Transaction extends AppModel {
); );
//var $default_log_level = 30;
/************************************************************************** /**************************************************************************
************************************************************************** **************************************************************************
************************************************************************** **************************************************************************
@@ -45,6 +47,8 @@ class Transaction extends AppModel {
*/ */
function addInvoice($data, $customer_id, $lease_id = null) { function addInvoice($data, $customer_id, $lease_id = null) {
$this->prEnter(compact('data', 'customer_id', 'lease_id'));
// Establish the transaction as an invoice // Establish the transaction as an invoice
$invoice =& $data['Transaction']; $invoice =& $data['Transaction'];
$invoice['type'] = 'INVOICE'; $invoice['type'] = 'INVOICE';
@@ -75,6 +79,8 @@ class Transaction extends AppModel {
*/ */
function addReceipt($data, $customer_id, $lease_id = null) { function addReceipt($data, $customer_id, $lease_id = null) {
$this->prEnter(compact('data', 'customer_id', 'lease_id'));
// Establish the transaction as a receipt // Establish the transaction as a receipt
$receipt =& $data['Transaction']; $receipt =& $data['Transaction'];
$receipt['type'] = 'RECEIPT'; $receipt['type'] = 'RECEIPT';
@@ -108,6 +114,8 @@ class Transaction extends AppModel {
*/ */
function addDeposit($data, $account_id) { function addDeposit($data, $account_id) {
$this->prEnter(compact('data', 'account_id'));
// Establish the transaction as a deposit // Establish the transaction as a deposit
$deposit =& $data['Transaction']; $deposit =& $data['Transaction'];
$deposit['type'] = 'DEPOSIT'; $deposit['type'] = 'DEPOSIT';
@@ -156,6 +164,8 @@ class Transaction extends AppModel {
*/ */
function addClose($data) { function addClose($data) {
$this->prEnter(compact('data'));
// Establish the transaction as a close // Establish the transaction as a close
$close =& $data['Transaction']; $close =& $data['Transaction'];
$close['type'] = 'CLOSE'; $close['type'] = 'CLOSE';
@@ -220,9 +230,7 @@ class Transaction extends AppModel {
&& (empty($transaction['account_id']) || && (empty($transaction['account_id']) ||
empty($transaction['crdr']))) || empty($transaction['crdr']))) ||
(in_array($transaction['type'], array('INVOICE', 'RECEIPT')) (in_array($transaction['type'], array('INVOICE', 'RECEIPT'))
&& empty($transaction['customer_id'])) || && empty($transaction['customer_id']))
(in_array($transaction['type'], array('INVOICE'))
&& empty($transaction['lease_id']))
) { ) {
return $this->prReturn(false); return $this->prReturn(false);
} }