This is probably what we really want for NSF... two transactions. One for backing out the bank deposit, and the other for adjusting A/R and all the associated statement entries. This is working reasonably well, even seemingly fine for the collected rents report. I do see that there is another bug though, that is causing statement entries to have the opposite account_id than intended (A/R instead of Cash) when entering new receipts. Not sure when I broke that, but it must have been when working on deposits.

git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716/site@427 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-30 07:30:50 +00:00
parent 7450d2a98e
commit 94c0efa881
2 changed files with 24 additions and 26 deletions

View File

@@ -128,17 +128,22 @@ class Tender extends AppModel {
if (empty($tender['DepositTransaction']['id']))
die("Item has not been deposited yet");
/* $payments = $this->LedgerEntry->Transaction->StatementEntry->find */
/* ('all', array */
/* ('contain' => array('Transaction' => */
/* array('fields' => array(), */
/* 'LedgerEntry */
/* 'conditions' => array('StatementEntry.transaction_id' => xx, */
// Enter the NSF
$result = $this->DepositTransaction->addDeposit
(array('Transaction' => array(),
'Entry' => array(array('tender_id' => null,
'account_id' => $this->LedgerEntry->Account->nsfAccountID(),
'amount' => -1 * $tender['LedgerEntry']['amount'],
))),
$tender['DepositTransaction']['account_id']);
pr(compact('result'));
if ($result['error'])
die("Unable to save NSF transaction");
$this->id = $id;
$this->saveField('nsf_transaction_id', $result['transaction_id']);
/* array('LedgerEntry', */
/* 'DepositTransaction', */
/* 'NsfTransaction'), */
/* )); */
$nsf_ledger_entry = $this->LedgerEntry->find
('first', array
@@ -157,18 +162,18 @@ class Tender extends AppModel {
$bounce = array('Transaction' => array(),
'Entry' => array());
$bounce['Transaction']['account_id'] = $tender['DepositTransaction']['account_id'];
$bounce['Transaction']['account_id'] = $this->LedgerEntry->Account->nsfAccountID();
$bounce['Transaction']['customer_id'] = $tender['Tender']['customer_id'];
$bounce['Transaction']['amount'] = -1 * $tender['LedgerEntry']['amount'];
foreach ($nsf_ledger_entry['Transaction']['StatementEntry'] AS $payment) {
$bounce['Entry'][] =
array('type' => 'PAYMENT',
'amount' => -1 * $payment['amount'],
'account_id' => $payment['account_id'],
'customer_id' => $payment['customer_id'],
'lease_id' => $payment['lease_id'],
'charge_entry_id' => $payment['charge_entry_id'],
array('type' => 'PAYMENT',
'amount' => -1 * $payment['amount'],
'account_id' => $this->LedgerEntry->Account->nsfAccountID(),
'customer_id' => $payment['customer_id'],
'lease_id' => $payment['lease_id'],
'charge_entry_id' => $payment['charge_entry_id'],
//'effective_date' => $tender[ stamp ],
);
}
@@ -177,10 +182,7 @@ class Tender extends AppModel {
$result = $this->NsfTransaction->addNsf($bounce);
if ($result['error'])
die("Unable to save NSF transaction");
$this->id = $id;
$this->saveField('nsf_transaction_id', $result['transaction_id']);
die("Unable to save Bounce transaction");
die();

View File

@@ -549,8 +549,6 @@ class Transaction extends AppModel {
array('checkpoint' => 'Pre Transaction Save')
+ compact('transaction')));
pr(compact('data'));
// Save transaction to the database
$this->create();
if (!$this->save($transaction))
@@ -567,7 +565,6 @@ class Transaction extends AppModel {
$le1_tender = null;
$le2 = null;
$se = null;
pr(compact('entry'));
extract($entry);
if (!empty($le1) && !empty($le2)) {
@@ -591,7 +588,6 @@ class Transaction extends AppModel {
continue;
}
}
pr(compact('ret'));
}
/* if (($transaction['type'] == 'INVOICE' || */