More work with security deposits, reversals, and balances. I've tried to work many different corner cases, but know that not everything has been tested. I think the next steps for testing will be to put in some real data.
git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716@499 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -128,7 +128,7 @@ class Transaction extends AppModel {
|
||||
// Just make sure the disbursement(s) are marked as waivers
|
||||
// and that they go to cover the specific charge.
|
||||
$data['Transaction']['disbursement_type'] = 'WAIVER';
|
||||
$data['Transaction']['charge_entry_id'] = $charge_id;
|
||||
$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);
|
||||
@@ -150,54 +150,19 @@ class Transaction extends AppModel {
|
||||
$this->prEnter(compact('data', 'charge_id', 'customer_id', 'lease_id'));
|
||||
|
||||
if (count($data['Entry']) != 1)
|
||||
die("INTERNAL ERROR: Should be one Entry for addWaiver");
|
||||
die("INTERNAL ERROR: Should be one Entry for addReversal");
|
||||
|
||||
// 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']['charge_entry_id'] = $charge_id;
|
||||
//$data['Entry'][0]['amount'] *= -1;
|
||||
//$data['Entry'][0]['type'] = 'DISBURSEMENT';
|
||||
$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']))
|
||||
$ids['reversal_id'] = $ids['transaction_id'];
|
||||
|
||||
/* $new_charge_id = $ids['entries'][0]['StatementEntry']['statement_entry_id']; */
|
||||
/* $this->StatementEntry->id = $new_charge_id; */
|
||||
/* $this->StatementEntry->saveField('charge_entry_id', $charge_id); */
|
||||
return $this->prReturn($ids);
|
||||
|
||||
|
||||
// Just make sure the transaction is marked as an INVOICE
|
||||
// and that it goes to cover the specific charge.
|
||||
//$data['Transaction']['type'] = 'INVOICE';
|
||||
$data['Transaction']['charge_entry_id'] = $charge_id;
|
||||
|
||||
// In all other respects this works just like a receipt.
|
||||
$ids = $this->addReceipt($data, $customer_id, $lease_id);
|
||||
if (isset($ids['transaction_id']))
|
||||
$ids['reversal_id'] = $ids['transaction_id'];
|
||||
|
||||
return $this->prReturn($ids);
|
||||
|
||||
// Establish the transaction as an Invoice Reversal
|
||||
$reversal =& $data['Transaction'];
|
||||
$reversal +=
|
||||
array('type' => 'INVOICE', //'CREDIT_NOTE',
|
||||
'crdr' => 'CREDIT',
|
||||
'account_id' => $this->Account->accountReceivableAccountID(),
|
||||
'customer_id' => $customer_id,
|
||||
'lease_id' => $lease_id,
|
||||
);
|
||||
|
||||
// Go through the statement entries and flag as reversals
|
||||
foreach ($data['Entry'] AS &$entry)
|
||||
$entry += array('type' => 'CHARGE', //'REVERSAL',
|
||||
'crdr' => 'DEBIT',
|
||||
);
|
||||
|
||||
$ids = $this->addTransaction($data['Transaction'], $data['Entry']);
|
||||
if (isset($ids['transaction_id']))
|
||||
$ids['reversal_id'] = $ids['transaction_id'];
|
||||
|
||||
return $this->prReturn($ids);
|
||||
}
|
||||
|
||||
@@ -650,8 +615,8 @@ class Transaction extends AppModel {
|
||||
($transaction['crdr'] == 'CREDIT'
|
||||
? $ret['transaction_id']
|
||||
: null),
|
||||
($transaction['crdr'] == 'CREDIT' && !empty($transaction['charge_entry_id'])
|
||||
? $transaction['charge_entry_id']
|
||||
($transaction['crdr'] == 'CREDIT' && !empty($transaction['assign_charge_entry_id'])
|
||||
? $transaction['assign_charge_entry_id']
|
||||
: null),
|
||||
(!empty($transaction['disbursement_type'])
|
||||
? $transaction['disbursement_type']
|
||||
|
||||
Reference in New Issue
Block a user