Eliminated the LedgerEntry::nsf code, which was replaced with MonetarySource::nsf.

git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629/site@346 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-15 18:32:14 +00:00
parent fcb23d12a5
commit ae04aafaca

View File

@@ -375,151 +375,6 @@ class LedgerEntry extends AppModel {
}
/**************************************************************************
**************************************************************************
**************************************************************************
* function: nsf
* - Flags the ledger entry as having insufficient funds
* - NOTE: nsf only works if given transaction t2b, below
*
* FEE RENT A/R RECEIPT CHECK NSF BANK
* ------- ------- ------- ------- ------- ------- -------
* | |50 50| | | | | t1
* | | | | | | |
* | | |50 50| | | | t2a
* | | | |50 50| | | t2b
* | | | | | | |
* | | | | |50 | 50| t3
* | | | | | | |
* | | | | | 50| |50 t4a
* | | 50| | | |50 | t4b
* |35 | 35| | | | | t4b
*
*/
function nsf($id, $amount = null, $transaction_id = null, $rec_id = null) {
pr(array('LedgerEntry::nsf',
compact('id', 'amount', 'transaction_id', 'rec_id')));
// Get the LedgerEntry and related fields
$entry = $this->find
('first',
array('contain' => array(/* t2b */
'Transaction.id',
'MonetarySource.id',
'Customer.id',
'Lease.id',
/* e.g. CHECK */
/* 'DebitLedger.account_id', */
'DebitLedger' =>
array('fields' => array(),
'Account' =>
array('fields' => array('id', 'name'),
'conditions' =>
array(array('Account.payable' => 1),
array('Account.type' => 'ASSET')),
),
),
/* e.g. RECEIPT */
/* 'CreditLedger.account_id', */
array('fields' => array(),
'Account' =>
array('fields' => array('id', 'name'),
'conditions' =>
array('Account.depositable' => 1),
),
),
/* t3 */
'DebitReconciliationLedgerEntry' =>
array(/* e.g. BANK */
'DebitLedger.account_id',
),
),
/* 'fields' => array('LedgerEntry.*'), */
'conditions' => array(array('LedgerEntry.id' => $id),
),
));
pr($entry);
if (!isset($amount))
$amount = $entry['LedgerEntry']['amount'];
$A = new Account();
$ids = $this->Ledger->Account->postLedgerEntry
(array('transaction_id' => $transaction_id),
null,
array('debit_ledger_id' => $A->currentLedgerID($entry['CreditLedger']['account_id']),
'credit_ledger_id' => $A->currentLedgerID($entry['DebitLedger']['account_id']),
'effective_date' => $entry['LedgerEntry']['effective_date'],
//'effective_date' => $entry['LedgerEntry']['effective_date'],
'amount' => $amount,
'lease_id' => $entry['Lease']['id'],
'customer_id' => $entry['Customer']['id'],
'comment' => "Reversal of Ledger Entry #{$id}",
),
array('debit' => array(array('LedgerEntry' => array('id' => $entry['LedgerEntry']['id'],
'amount' => $amount,
))),
'credit' => array(array('LedgerEntry' => array('id' => $entry['LedgerEntry']['id'],
'amount' => $amount,
))),
));
if ($ids['error'])
return null;
$tid = $ids['transaction_id'];
/* pr(compact('entry')); */
foreach (array('Debit', 'Credit') AS $dc_type) {
foreach ($entry[$dc_type . 'ReconciliationLedgerEntry'] AS $RLE) {
/* pr(array('checkpoint' => "Reverse $dc_type LE", */
/* compact('id', 'RLE'))); */
if ($RLE['id'] == $rec_id)
continue;
if (!$this->reverse($RLE['id'], $RLE['Reconciliation']['amount'], $tid, $id))
$ids['error'] = true;
/* $rids = $this->Ledger->Account->postLedgerEntry */
/* (array('transaction_id' => $tid), */
/* null, */
/* array('debit_ledger_id' => $A->currentLedgerID($RLE['CreditLedger']['account_id']), */
/* 'credit_ledger_id' => $A->currentLedgerID($RLE['DebitLedger']['account_id']), */
/* 'effective_date' => $RLE['effective_date'], */
/* //'effective_date' => $RLE['effective_date'], */
/* 'amount' => $RLE['Reconciliation']['amount'], */
/* 'lease_id' => $entry['Lease']['id'], */
/* 'customer_id' => $entry['Customer']['id'], */
/* 'comment' => "Reversal of Ledger Entry #{$RLE['id']}", */
/* ), */
/* array('debit' => array(array('LedgerEntry' => array('id' => $RLE['id'], */
/* 'amount' => $RLE['Reconciliation']['amount'], */
/* ))), */
/* 'credit' => array(array('LedgerEntry' => array('id' => $RLE['id'], */
/* 'amount' => $RLE['Reconciliation']['amount'], */
/* ))), */
/* )); */
/* if ($rids['error']) */
/* $ids['error'] = true; */
}
}
if ($ids['error'])
return null;
return $ids['id'];
}
/**************************************************************************
**************************************************************************
**************************************************************************