Added transaction model writeOff function, and a new statement_entry WRITEOFF type. Not a big deal, but it makes presentation a bit more straightforward.

git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716/site@508 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-08-09 15:11:51 +00:00
parent bd26ec7218
commit bc95b31521
3 changed files with 33 additions and 11 deletions

View File

@@ -167,6 +167,33 @@ class Transaction extends AppModel {
}
/**************************************************************************
**************************************************************************
**************************************************************************
* function: addWriteOff
* - Adds a new write off of bad debt
*/
function addWriteOff($data, $customer_id, $lease_id = null) {
$this->prEnter(compact('data', 'charge_id', 'customer_id', 'lease_id'));
if (count($data['Entry']) != 1)
INTERNAL_ERROR("Should be one Entry for addWriteOff");
// Just make sure the disbursement(s) are marked as write offs,
// and that the write-off account is used.
$data['Transaction']['disbursement_type'] = 'WRITEOFF';
$data['Entry'][0]['account_id'] = $this->Account->badDebtAccountID();
// In all other respects this is just a receipt.
$ids = $this->addReceipt($data, $customer_id, $lease_id);
if (isset($ids['transaction_id']))
$ids['writeoff_id'] = $ids['transaction_id'];
return $this->prReturn($ids);
}
/**************************************************************************
**************************************************************************
**************************************************************************