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