Discovered that the use of the term 'Payment' has been a misnomer. A company uses the term payment to indicate the monies it pays to _others_. Changing this leaves us without a good replacement term, but disbursement really seems to fit the bill. As comfortable as the term payment was, it was odd in many respects and disbursement does seem more appropriate. I'm sure there are several lingering bugs from this massive search/replace exercise, but this is a decent baseline for the change.
git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716/site@488 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -19,9 +19,9 @@ class Transaction extends AppModel {
|
||||
'conditions' => array('Charge.type' => 'CHARGE')
|
||||
),
|
||||
|
||||
'Payment' => array(
|
||||
'Disbursement' => array(
|
||||
'className' => 'StatementEntry',
|
||||
'conditions' => array('Payment.type' => 'PAYMENT')
|
||||
'conditions' => array('Disbursement.type' => 'DISBURSEMENT')
|
||||
),
|
||||
|
||||
'Debit' => array(
|
||||
@@ -93,9 +93,9 @@ class Transaction extends AppModel {
|
||||
'lease_id' => $lease_id,
|
||||
);
|
||||
|
||||
// Go through the statement entries and flag as payments
|
||||
// Go through the statement entries and flag as disbursements
|
||||
foreach ($data['Entry'] AS &$entry)
|
||||
$entry += array('type' => 'PAYMENT', // not used
|
||||
$entry += array('type' => 'DISBURSEMENT', // not used
|
||||
'crdr' => 'DEBIT',
|
||||
'account_id' =>
|
||||
(isset($entry['Tender']['tender_type_id'])
|
||||
@@ -125,9 +125,9 @@ class Transaction extends AppModel {
|
||||
if (count($data['Entry']) != 1)
|
||||
die("INTERNAL ERROR: Should be one Entry for addWaiver");
|
||||
|
||||
// Just make sure the payment(s) are marked as waivers
|
||||
// Just make sure the disbursement(s) are marked as waivers
|
||||
// and that they go to cover the specific charge.
|
||||
$data['Transaction']['payment_type'] = 'WAIVER';
|
||||
$data['Transaction']['disbursement_type'] = 'WAIVER';
|
||||
$data['Transaction']['charge_entry_id'] = $charge_id;
|
||||
|
||||
// In all other respects this is just a receipt.
|
||||
@@ -151,11 +151,13 @@ class Transaction extends AppModel {
|
||||
|
||||
// Establish the transaction as a deposit
|
||||
$deposit =& $data['Transaction'];
|
||||
$deposit['type'] = 'DEPOSIT';
|
||||
$deposit['crdr'] = 'DEBIT';
|
||||
$deposit['account_id'] = $account_id;
|
||||
$deposit['customer_id'] = null;
|
||||
$deposit['lease_id'] = null;
|
||||
$deposit +=
|
||||
array('type' => 'DEPOSIT',
|
||||
'crdr' => 'DEBIT',
|
||||
'account_id' => $account_id,
|
||||
'customer_id' => null,
|
||||
'lease_id' => null,
|
||||
);
|
||||
|
||||
// Save the list of IDs, so that we can mark their
|
||||
// deposit transaction after it has been created.
|
||||
@@ -201,10 +203,13 @@ class Transaction extends AppModel {
|
||||
|
||||
// Establish the transaction as a close
|
||||
$close =& $data['Transaction'];
|
||||
$close['type'] = 'CLOSE';
|
||||
$close['account_id'] = null;
|
||||
$close['customer_id'] = null;
|
||||
$close['lease_id'] = null;
|
||||
$close +=
|
||||
array('type' => 'CLOSE',
|
||||
'crdr' => null,
|
||||
'account_id' => null,
|
||||
'customer_id' => null,
|
||||
'lease_id' => null,
|
||||
);
|
||||
|
||||
$ledger_ids = array();
|
||||
$data['Entry'] = array();
|
||||
@@ -246,6 +251,44 @@ class Transaction extends AppModel {
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
**************************************************************************
|
||||
* function: addVoucher
|
||||
* - Adds a new voucher transaction, which is money outflow
|
||||
*/
|
||||
|
||||
function addVoucher($data) {
|
||||
$this->prEnter(compact('data', 'customer_id', 'lease_id'));
|
||||
|
||||
// REVISIT <AP>: 20090804
|
||||
// NOT IMPLEMENTED AT ALL. Just cut and paste so far
|
||||
return array('error' => true);
|
||||
|
||||
// Establish the transaction as an voucher
|
||||
$voucher =& $data['Transaction'];
|
||||
$voucher +=
|
||||
array('type' => 'VOUCHER',
|
||||
'crdr' => 'DEBIT',
|
||||
'account_id' => $this->Account->accountPayableAccountID(),
|
||||
'customer_id' => null,
|
||||
'lease_id' => null,
|
||||
);
|
||||
|
||||
// Go through the statement entries and flag as charges
|
||||
foreach ($data['Entry'] AS &$entry)
|
||||
$entry += array('type' => 'CHARGE',
|
||||
'crdr' => 'CREDIT',
|
||||
);
|
||||
|
||||
$ids = $this->addTransaction($data['Transaction'], $data['Entry']);
|
||||
if (isset($ids['transaction_id']))
|
||||
$ids['voucher_id'] = $ids['transaction_id'];
|
||||
|
||||
return $this->prReturn($ids);
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
**************************************************************************
|
||||
@@ -353,7 +396,7 @@ class Transaction extends AppModel {
|
||||
*
|
||||
* - Entry (array)
|
||||
* - [MANDATORY]
|
||||
* - type (CHARGE, PAYMENT)
|
||||
* - type (CHARGE, DISBURSEMENT)
|
||||
* - account_id
|
||||
* - crdr
|
||||
* - amount
|
||||
@@ -466,7 +509,7 @@ class Transaction extends AppModel {
|
||||
array_flip(array('customer_id', 'lease_id')));
|
||||
$se['comment'] = $entry['statement_entry_comment'];
|
||||
|
||||
// (PAYMENTS will have statement entries created below, when
|
||||
// (DISBURSEMENTS will have statement entries created below, when
|
||||
// assigning credits, and DEPOSITS don't have statement entries)
|
||||
if ($transaction['type'] != 'INVOICE' && $subtype !== 'NSF')
|
||||
$se = null;
|
||||
@@ -556,8 +599,8 @@ class Transaction extends AppModel {
|
||||
($transaction['type'] == 'RECEIPT' && !empty($transaction['charge_entry_id'])
|
||||
? $transaction['charge_entry_id']
|
||||
: null),
|
||||
(!empty($transaction['payment_type'])
|
||||
? $transaction['payment_type']
|
||||
(!empty($transaction['disbursement_type'])
|
||||
? $transaction['disbursement_type']
|
||||
: null),
|
||||
$transaction['customer_id'],
|
||||
$transaction['lease_id']
|
||||
@@ -587,7 +630,7 @@ class Transaction extends AppModel {
|
||||
// Enter the NSF
|
||||
// This is the transaction pulling money from the bank account
|
||||
// and recording it in the NSF account. It has nothing to do
|
||||
// with the customer statement (charges, payments, credits, etc).
|
||||
// with the customer statement (charges, disbursements, credits, etc).
|
||||
$bounce_result = $this->addDeposit
|
||||
(array('Transaction' => array(),
|
||||
'Entry' => array(array('tender_id' => null,
|
||||
@@ -637,20 +680,20 @@ class Transaction extends AppModel {
|
||||
$rollback['Transaction']['customer_id'] = $tender['Tender']['customer_id'];
|
||||
$rollback['Transaction']['amount'] = -1 * $tender['LedgerEntry']['amount'];
|
||||
|
||||
foreach ($nsf_ledger_entry['Transaction']['StatementEntry'] AS $payment) {
|
||||
if ($payment['type'] === 'SURPLUS') {
|
||||
$payment['type'] = 'VOID';
|
||||
$this->StatementEntry->id = $payment['id'];
|
||||
$this->StatementEntry->saveField('type', $payment['type']);
|
||||
foreach ($nsf_ledger_entry['Transaction']['StatementEntry'] AS $disbursement) {
|
||||
if ($disbursement['type'] === 'SURPLUS') {
|
||||
$disbursement['type'] = 'VOID';
|
||||
$this->StatementEntry->id = $disbursement['id'];
|
||||
$this->StatementEntry->saveField('type', $disbursement['type']);
|
||||
}
|
||||
else {
|
||||
$rollback['Entry'][] =
|
||||
array('type' => $payment['type'],
|
||||
'amount' => -1 * $payment['amount'],
|
||||
array('type' => $disbursement['type'],
|
||||
'amount' => -1 * $disbursement['amount'],
|
||||
'account_id' => $this->Account->nsfAccountID(),
|
||||
'customer_id' => $payment['customer_id'],
|
||||
'lease_id' => $payment['lease_id'],
|
||||
'charge_entry_id' => $payment['charge_entry_id'],
|
||||
'customer_id' => $disbursement['customer_id'],
|
||||
'lease_id' => $disbursement['lease_id'],
|
||||
'charge_entry_id' => $disbursement['charge_entry_id'],
|
||||
'effective_date' => $stamp,
|
||||
);
|
||||
}
|
||||
@@ -742,7 +785,7 @@ class Transaction extends AppModel {
|
||||
}
|
||||
elseif ($table == 'StatementEntry') {
|
||||
$squery['fields'] = array_merge($squery['fields'],
|
||||
$this->StatementEntry->chargePaymentFields(true));
|
||||
$this->StatementEntry->chargeDisbursementFields(true));
|
||||
}
|
||||
else {
|
||||
$squery['fields'][] = "SUM({$table}.amount) AS total";
|
||||
|
||||
Reference in New Issue
Block a user