Forgot to check in the model as part of the last change set. Guess that's what happens when you're tired.
git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629/site@310 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -234,6 +234,63 @@ class LedgerEntry extends AppModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
**************************************************************************
|
||||||
|
**************************************************************************
|
||||||
|
* function: reverse
|
||||||
|
* - Reverses the ledger entry
|
||||||
|
*/
|
||||||
|
|
||||||
|
function reverse($id) {
|
||||||
|
// Get the LedgerEntry and related fields
|
||||||
|
$entry = $this->find
|
||||||
|
('first',
|
||||||
|
array('contain' => array('MonetarySource.id',
|
||||||
|
'Transaction.id',
|
||||||
|
'DebitLedger.id',
|
||||||
|
'DebitLedger.account_id',
|
||||||
|
'CreditLedger.id',
|
||||||
|
'CreditLedger.account_id',
|
||||||
|
'Customer.id',
|
||||||
|
'Lease.id',
|
||||||
|
),
|
||||||
|
|
||||||
|
'fields' => array('LedgerEntry.*'),
|
||||||
|
|
||||||
|
'conditions' => array('LedgerEntry.id' => $id),
|
||||||
|
));
|
||||||
|
//pr($entry);
|
||||||
|
|
||||||
|
$A = new Account();
|
||||||
|
|
||||||
|
$ids = $this->Ledger->Account->postLedgerEntry
|
||||||
|
(//array('transaction_id' => $entry['Transaction']['id']),
|
||||||
|
null,
|
||||||
|
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' => $entry['LedgerEntry']['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' => $entry['LedgerEntry']['amount'],
|
||||||
|
))),
|
||||||
|
'credit' => array(array('LedgerEntry' => array('id' => $entry['LedgerEntry']['id'],
|
||||||
|
'amount' => $entry['LedgerEntry']['amount'],
|
||||||
|
))),
|
||||||
|
));
|
||||||
|
|
||||||
|
if ($ids['error'])
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return $ids['id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
|
|||||||
Reference in New Issue
Block a user