Added confirmation to the NSF functionality, as well as a timestamp field instead of forcing time=now.
git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716/site@513 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -115,15 +115,33 @@ class TendersController extends AppController {
|
||||
*/
|
||||
|
||||
function nsf($id = null) {
|
||||
if ($this->data) {
|
||||
$result = $this->Tender->nsf
|
||||
($this->data['Tender']['id'],
|
||||
$this->data['Transaction']['stamp'],
|
||||
$this->data['Transaction']['comment']);
|
||||
$this->redirect(array('controller' => 'tenders',
|
||||
'action' => 'view',
|
||||
$this->data['Tender']['id']));
|
||||
}
|
||||
|
||||
if (!$id) {
|
||||
$this->Session->setFlash(__('Invalid Item.', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
|
||||
$this->Tender->nsf($id);
|
||||
$this->redirect(array('action'=>'view', $id));
|
||||
$this->Tender->id = $id;
|
||||
$tender = $this->Tender->find
|
||||
('first', array
|
||||
('contain' => array('Customer', 'LedgerEntry' => array('Transaction')),
|
||||
));
|
||||
|
||||
// Prepare to render.
|
||||
$title = "Tender #{$tender['Tender']['id']} : {$tender['Tender']['name']} : NSF";
|
||||
$this->set(compact('tender', 'title'));
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
**************************************************************************
|
||||
@@ -138,6 +156,7 @@ class TendersController extends AppController {
|
||||
}
|
||||
|
||||
// Get the Tender and related fields
|
||||
$this->Tender->id = $id;
|
||||
$tender = $this->Tender->find
|
||||
('first', array
|
||||
('contain' => array('TenderType', 'Customer', 'LedgerEntry' => array('Transaction')),
|
||||
@@ -161,7 +180,7 @@ class TendersController extends AppController {
|
||||
}
|
||||
|
||||
// Prepare to render.
|
||||
$title = "Tender #{$tender['Tender']['id']}";
|
||||
$title = "Tender #{$tender['Tender']['id']} : {$tender['Tender']['name']}";
|
||||
$this->set(compact('tender', 'title'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,31 +80,10 @@ class Tender extends AppModel {
|
||||
**************************************************************************
|
||||
* function: nsf
|
||||
* - Flags the ledger entry as having insufficient funds
|
||||
*
|
||||
* Steps:
|
||||
* - Get information from Check (C1); for amount $A
|
||||
* - Find Bank Deposit matching to Tender
|
||||
* - New Transaction (T1)
|
||||
* - New Bank Deposit (D1)
|
||||
* - New Tender (N1); NSF; D1,
|
||||
* - Add new LedgerEntry (L1a); T1; debit:bank; -$A
|
||||
* - Add new LedgerEntry (L1b); T1; credit:NSF; -$A
|
||||
* - Add new LedgerEntry (L2a); T1; debit:NSF; -$A; N1
|
||||
* - Add new LedgerEntry (L2b); T1; credit:A/R; -$A
|
||||
* - For Tx associated with LE associated with C1:
|
||||
* - For each Disbursement SE of Tx:
|
||||
* - Add new StatementEntry (S1n); T1; DISBURSEMENT; -1*S1n.amount
|
||||
* - New Transaction (T2) (?????)
|
||||
* - Add new StatementEntry (S2); T2; CHARGE; NSF; $35
|
||||
* - Add new LedgerEntry (L3a); T2; credit:NSF-Fee; $35
|
||||
* - Add new LedgerEntry (L3b); T2; debit:A/R; $35
|
||||
* - Set C1.nsf_tx = T1
|
||||
* - Re-Reconcile (customer may have running credit)
|
||||
*/
|
||||
|
||||
function nsf($id, $stamp = null) {
|
||||
$this->prFunctionLevel(30);
|
||||
$this->prEnter(compact('id'));
|
||||
function nsf($id, $stamp = null, $comment = null) {
|
||||
$this->prEnter(compact('id', 'stamp', 'comment'));
|
||||
|
||||
// Get information about this NSF item.
|
||||
$this->id = $id;
|
||||
@@ -128,16 +107,15 @@ class Tender extends AppModel {
|
||||
unset($tender['NsfTransaction']);
|
||||
|
||||
$T = new Transaction();
|
||||
$result = $T->addNsf($tender, $stamp);
|
||||
if ($result['error'])
|
||||
return $this->prReturn(false);
|
||||
$result = $T->addNsf($tender, $stamp, $comment);
|
||||
if (empty($result['error'])) {
|
||||
// Flag the tender as NSF, using the items created from addNsf
|
||||
$this->id = $id;
|
||||
$this->saveField('nsf_transaction_id', $result['nsf_transaction_id']);
|
||||
$this->saveField('nsf_ledger_entry_id', $result['nsf_ledger_entry_id']);
|
||||
}
|
||||
|
||||
// Flag the tender as NSF, using the items created from addNsf
|
||||
$this->id = $id;
|
||||
$this->saveField('nsf_transaction_id', $result['nsf_transaction_id']);
|
||||
$this->saveField('nsf_ledger_entry_id', $result['nsf_ledger_entry_id']);
|
||||
|
||||
return $this->prReturn(true);
|
||||
return $this->prReturn($result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -673,8 +673,8 @@ class Transaction extends AppModel {
|
||||
* - Adds NSF transaction
|
||||
*/
|
||||
|
||||
function addNsf($tender, $stamp) {
|
||||
$this->prEnter(compact('tender', 'stamp'));
|
||||
function addNsf($tender, $stamp = null, $comment = null) {
|
||||
$this->prEnter(compact('tender', 'stamp', 'comment'));
|
||||
|
||||
$ret = array();
|
||||
|
||||
@@ -683,7 +683,8 @@ class Transaction extends AppModel {
|
||||
// and recording it in the NSF account. It has nothing to do
|
||||
// with the customer statement (charges, disbursements, credits, etc).
|
||||
$bounce_result = $this->addDeposit
|
||||
(array('Transaction' => array('crdr' => 'CREDIT'),
|
||||
(array('Transaction' => array('stamp' => $stamp,
|
||||
'crdr' => 'CREDIT'),
|
||||
'Entry' => array(array('tender_id' => null,
|
||||
'account_id' => $this->Account->nsfAccountID(),
|
||||
'crdr' => 'DEBIT',
|
||||
@@ -731,6 +732,7 @@ class Transaction extends AppModel {
|
||||
$rollback['Transaction']['crdr'] = 'CREDIT'; // Unused... keeps verifyTx happy
|
||||
$rollback['Transaction']['account_id'] = $this->Account->nsfAccountID();
|
||||
$rollback['Transaction']['customer_id'] = $tender['Tender']['customer_id'];
|
||||
$rollback['Transaction']['comment'] = $comment;
|
||||
|
||||
foreach ($nsf_ledger_entry['Transaction']['StatementEntry'] AS $disbursement) {
|
||||
if ($disbursement['type'] === 'SURPLUS') {
|
||||
@@ -746,7 +748,6 @@ class Transaction extends AppModel {
|
||||
'customer_id' => $disbursement['customer_id'],
|
||||
'lease_id' => $disbursement['lease_id'],
|
||||
'charge_entry_id' => $disbursement['charge_entry_id'],
|
||||
'effective_date' => $stamp,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
74
views/tenders/nsf.ctp
Normal file
74
views/tenders/nsf.ctp
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php /* -*- mode:PHP -*- */
|
||||
|
||||
echo '<div class="nsf input">' . "\n";
|
||||
|
||||
$customer = $tender['Customer'];
|
||||
$entry = $tender['LedgerEntry'];
|
||||
$transaction = $entry['Transaction'];
|
||||
|
||||
if (isset($tender['Tender']))
|
||||
$tender = $tender['Tender'];
|
||||
|
||||
// We're not actually using a grid to select the customer,
|
||||
// but selection-text makes for reasonable formatting
|
||||
echo ('<DIV CLASS="nsf grid-selection-text">' .
|
||||
'<TABLE>' . "\n");
|
||||
|
||||
echo ('<TR><TD style="padding-right: 1em;">' . $customer['name'] . '</TD>' .
|
||||
' <TD>' . '(Customer #' . $customer['id'] . ')' . '</TD>' .
|
||||
'</TR>' . "\n");
|
||||
|
||||
echo ('<TR><TD style="padding-right: 1em;">' . $tender['name'] . '</TD>' .
|
||||
' <TD>' . '(Tender #' . $tender['id'] . ')' . '</TD>' .
|
||||
'</TR>' . "\n");
|
||||
|
||||
echo ('<TR><TD style="padding-right: 1em;">Amount:</TD>' .
|
||||
' <TD>' . FormatHelper::currency($entry['amount']) . '</TD>' .
|
||||
'</TR>' . "\n");
|
||||
|
||||
echo ('</TABLE>' .
|
||||
'</DIV>' . "\n");
|
||||
|
||||
|
||||
echo $form->create(null, array('id' => 'nsf-form',
|
||||
'url' => array('action' => 'nsf'))) . "\n";
|
||||
|
||||
echo $form->input("Tender.id",
|
||||
array('type' => 'hidden',
|
||||
'value' => $tender['id'])) . "\n";
|
||||
|
||||
echo $this->element('form_table',
|
||||
array('class' => "item receipt transaction entry",
|
||||
//'with_name_after' => ':',
|
||||
'field_prefix' => 'Transaction',
|
||||
'fields' => array
|
||||
("stamp" => array('opts' => array('type' => 'text'),
|
||||
'between' => '<A HREF="#" ONCLICK="datepickerNow(\'TransactionStamp\'); return false;">Now</A>',
|
||||
),
|
||||
"comment" => array('opts' => array('size' => 50),
|
||||
),
|
||||
))) . "\n";
|
||||
|
||||
echo $form->end('Record Item as NSF');
|
||||
?>
|
||||
|
||||
<script type="text/javascript"><!--
|
||||
|
||||
// Reset the form
|
||||
function resetForm() {
|
||||
datepickerNow('TransactionStamp');
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
$("#TransactionStamp")
|
||||
.attr('autocomplete', 'off')
|
||||
.datepicker({ constrainInput: true,
|
||||
numberOfMonths: [1, 1],
|
||||
showCurrentAtPos: 0,
|
||||
dateFormat: 'mm/dd/yy' });
|
||||
|
||||
resetForm();
|
||||
});
|
||||
--></script>
|
||||
|
||||
</div>
|
||||
Reference in New Issue
Block a user