Compare commits
2 Commits
single_sit
...
alt_revers
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
011d1208e8 | ||
|
|
9dd09c4d2e |
@@ -189,6 +189,7 @@ class StatementEntriesController extends AppController {
|
|||||||
|
|
||||||
function reverse($id) {
|
function reverse($id) {
|
||||||
$this->StatementEntry->reverse($id);
|
$this->StatementEntry->reverse($id);
|
||||||
|
$this->render('/FAKE');
|
||||||
$this->redirect(array('action'=>'view', $id));
|
$this->redirect(array('action'=>'view', $id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class StatementEntry extends AppModel {
|
|||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
//var $default_log_level = array('log' => 30, 'show' => 15);
|
var $default_log_level = array('log' => 30, 'show' => 15);
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
@@ -198,6 +198,11 @@ class StatementEntry extends AppModel {
|
|||||||
if ($charge['type'] !== 'CHARGE')
|
if ($charge['type'] !== 'CHARGE')
|
||||||
INTERNAL_ERROR("Reversal item is not CHARGE.");
|
INTERNAL_ERROR("Reversal item is not CHARGE.");
|
||||||
|
|
||||||
|
// Build a transaction
|
||||||
|
$reversal = array('Transaction' => array(), 'Entry' => array());
|
||||||
|
$reversal['Transaction']['stamp'] = $stamp;
|
||||||
|
$reversal['Transaction']['comment'] = "Credit Note: Charge Reversal";
|
||||||
|
|
||||||
$voided_entry_transactions = array();
|
$voided_entry_transactions = array();
|
||||||
$reconciled = $this->reconciledEntries($id);
|
$reconciled = $this->reconciledEntries($id);
|
||||||
$this->pr(21, compact('reconciled'));
|
$this->pr(21, compact('reconciled'));
|
||||||
@@ -207,34 +212,29 @@ class StatementEntry extends AppModel {
|
|||||||
if ($entry['DisbursementEntry']['type'] === 'REVERSAL')
|
if ($entry['DisbursementEntry']['type'] === 'REVERSAL')
|
||||||
INTERNAL_ERROR("Charge has already been reversed");
|
INTERNAL_ERROR("Charge has already been reversed");
|
||||||
|
|
||||||
$voided_entry_transactions[$entry['DisbursementEntry']['transaction_id']]
|
/* $voided_entry_transactions[$entry['DisbursementEntry']['transaction_id']] */
|
||||||
= array_intersect_key($entry['DisbursementEntry'],
|
/* = array_intersect_key($entry['DisbursementEntry'], */
|
||||||
array('customer_id'=>1, 'lease_id'=>1));
|
/* array('customer_id'=>1, 'lease_id'=>1)); */
|
||||||
|
|
||||||
$this->del($entry['DisbursementEntry']['id']);
|
/* $reversal['Entry'][] = */
|
||||||
continue;
|
/* array_intersect_key($entry['DisbursementEntry'], */
|
||||||
|
/* array_flip(array('amount', 'account_id', 'charge_entry_id'))) */
|
||||||
$DE = new StatementEntry();
|
/* + array('type' => 'SURPLUS', */
|
||||||
$DE->id = $entry['DisbursementEntry']['id'];
|
/* 'comment' => 'Release of funds applied to reversed charge', */
|
||||||
$DE->saveField('type', 'VOID');
|
/* ); */
|
||||||
$DE->saveField('charge_entry_id', null);
|
|
||||||
}
|
}
|
||||||
$this->pr(17, compact('voided_entry_transactions'));
|
/* $this->pr(17, compact('voided_entry_transactions')); */
|
||||||
}
|
}
|
||||||
|
|
||||||
// Query the stats to get the remaining balance
|
// Query the stats to get the remaining balance
|
||||||
$stats = $this->stats($id);
|
$stats = $this->stats($id);
|
||||||
|
|
||||||
// Build a transaction
|
|
||||||
$reversal = array('Transaction' => array(), 'Entry' => array());
|
|
||||||
$reversal['Transaction']['stamp'] = $stamp;
|
|
||||||
$reversal['Transaction']['comment'] = "Credit Note: Charge Reversal";
|
|
||||||
|
|
||||||
// Add the charge reversal
|
// Add the charge reversal
|
||||||
$reversal['Entry'][] =
|
$reversal['Entry'][] =
|
||||||
array('amount' => $stats['Charge']['balance'],
|
array('charge_entry_id' => $id,
|
||||||
'account_id' => $charge['account_id'],
|
'amount' => -1 * $stats['Charge'][$balance ? 'balance' : 'total'],
|
||||||
'comment' => 'Charge Reversal',
|
'account_id' => $charge['account_id'],
|
||||||
|
'comment' => 'Charge Reversal',
|
||||||
);
|
);
|
||||||
|
|
||||||
// Record the reversal transaction
|
// Record the reversal transaction
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class Transaction extends AppModel {
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
//var $default_log_level = array('log' => 30, 'show' => 15);
|
var $default_log_level = array('log' => 30, 'show' => 30);
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
@@ -149,17 +149,12 @@ class Transaction extends AppModel {
|
|||||||
function addReversal($data, $charge_id, $customer_id, $lease_id = null) {
|
function addReversal($data, $charge_id, $customer_id, $lease_id = null) {
|
||||||
$this->prEnter(compact('data', 'charge_id', 'customer_id', 'lease_id'));
|
$this->prEnter(compact('data', 'charge_id', 'customer_id', 'lease_id'));
|
||||||
|
|
||||||
if (count($data['Entry']) != 1)
|
$data['Transaction'] += array('type' => 'CREDIT_NOTE');
|
||||||
INTERNAL_ERROR("Should be one Entry for addReversal");
|
foreach ($data['Entry'] AS &$entry)
|
||||||
|
$entry += array('type' => 'REVERSAL');
|
||||||
|
|
||||||
// Just make sure the disbursement(s) are marked as reversals
|
// In all other respects this is just an invoice
|
||||||
// and that they go to cover the specific charge.
|
$ids = $this->addInvoice($data, $customer_id, $lease_id);
|
||||||
$data['Transaction']['type'] = 'CREDIT_NOTE';
|
|
||||||
$data['Transaction']['disbursement_type'] = 'REVERSAL';
|
|
||||||
$data['Transaction']['assign_charge_entry_id'] = $charge_id;
|
|
||||||
|
|
||||||
// In all other respects this is just a receipt.
|
|
||||||
$ids = $this->addReceipt($data, $customer_id, $lease_id);
|
|
||||||
if (isset($ids['transaction_id']))
|
if (isset($ids['transaction_id']))
|
||||||
$ids['reversal_id'] = $ids['transaction_id'];
|
$ids['reversal_id'] = $ids['transaction_id'];
|
||||||
|
|
||||||
@@ -529,16 +524,17 @@ class Transaction extends AppModel {
|
|||||||
|
|
||||||
// (DISBURSEMENTS will have statement entries created below, when
|
// (DISBURSEMENTS will have statement entries created below, when
|
||||||
// assigning credits, and DEPOSITS don't have statement entries)
|
// assigning credits, and DEPOSITS don't have statement entries)
|
||||||
if (empty($transaction['customer_id']) ||
|
if (empty($entry['charge_entry_id']) &&
|
||||||
($transaction['account_id'] == $this->Account->accountReceivableAccountID() &&
|
(empty($transaction['customer_id']) ||
|
||||||
$transaction['crdr'] == 'CREDIT'))
|
($transaction['account_id'] == $this->Account->accountReceivableAccountID() &&
|
||||||
|
$transaction['crdr'] == 'CREDIT')))
|
||||||
$se = null;
|
$se = null;
|
||||||
|
|
||||||
// NSF transactions don't use LedgerEntries
|
// NSF transactions don't use LedgerEntries
|
||||||
// REVISIT <AP>: 20090731
|
// REVISIT <AP>: 20090731
|
||||||
// Doesn't seem right... probably doing this because of the
|
// Doesn't seem right... probably doing this because of the
|
||||||
// single A/R entry we add below for NSF
|
// single A/R entry we add below for NSF
|
||||||
if ($subtype === 'NSF')
|
if ($entry['type'] == 'SURPLUS' || $subtype === 'NSF')
|
||||||
$le1 = $le1_tender = $le2 = null;
|
$le1 = $le1_tender = $le2 = null;
|
||||||
|
|
||||||
// Replace combined entry with our new individual entries
|
// Replace combined entry with our new individual entries
|
||||||
|
|||||||
Reference in New Issue
Block a user