Getting closer on the reversal issue. There is definitely more testing to do, and some tweaks as well, but this may be approximately what we will finally settle on.
git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716/site@565 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -181,8 +181,8 @@ class StatementEntry extends AppModel {
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
**************************************************************************
|
||||
* function: reverse
|
||||
* - Reverses the charges
|
||||
* function: reversable
|
||||
* - Returns true if the charge can be reversed; false otherwise
|
||||
*/
|
||||
function reversable($id) {
|
||||
$this->prEnter(compact('id'));
|
||||
@@ -194,15 +194,9 @@ class StatementEntry extends AppModel {
|
||||
return $this->prReturn(false);
|
||||
|
||||
// Determine anything reconciled against the charge
|
||||
$reconciled = $this->reconciledEntries($id);
|
||||
$this->pr(21, compact('reconciled'));
|
||||
|
||||
if (!empty($reconciled)) {
|
||||
// Double check that this charge has not already been reversed
|
||||
foreach ($reconciled['entries'] AS $entry)
|
||||
if ($entry['DisbursementEntry']['type'] === 'REVERSAL')
|
||||
return $this->prReturn(false);
|
||||
}
|
||||
$reverse_transaction_id = $this->field('reverse_transaction_id');
|
||||
if (!empty($reverse_transaction_id))
|
||||
return $this->prReturn(false);
|
||||
|
||||
return $this->prReturn(true);
|
||||
}
|
||||
@@ -222,28 +216,19 @@ class StatementEntry extends AppModel {
|
||||
|
||||
// Get the basic information about this charge
|
||||
$charge = $this->find('first', array('contain' => true));
|
||||
$charge = $charge['StatementEntry'];
|
||||
//$charge = $charge['StatementEntry'];
|
||||
|
||||
// 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']['total'],
|
||||
'account_id' => $charge['account_id'],
|
||||
'comment' => 'Charge Reversal',
|
||||
);
|
||||
$charge['paid'] = $stats['Charge']['disbursement'];
|
||||
|
||||
// Record the reversal transaction
|
||||
$result = $this->Transaction->addReversal
|
||||
($reversal,
|
||||
$id, $stats['Charge']['disbursement'],
|
||||
$charge['customer_id'], $charge['lease_id']);
|
||||
($charge, $stamp, 'Charge Reversal');
|
||||
|
||||
// Mark the charge as reversed
|
||||
$this->id = $id;
|
||||
$this->saveField('reverse_transaction_id', $result['transaction_id']);
|
||||
|
||||
return $this->prReturn($result);
|
||||
}
|
||||
@@ -416,8 +401,8 @@ class StatementEntry extends AppModel {
|
||||
array('StatementEntry',
|
||||
'LedgerEntry' =>
|
||||
array('conditions' =>
|
||||
array('LedgerEntry.account_id !=' =>
|
||||
$this->Account->accountReceivableAccountID()),
|
||||
array('LedgerEntry.account_id <> Transaction.account_id')
|
||||
//$this->Account->accountReceivableAccountID()),
|
||||
),
|
||||
),
|
||||
'conditions' => array('Transaction.id' => $receipt_id),
|
||||
|
||||
Reference in New Issue
Block a user