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:
@@ -275,9 +275,6 @@ class TransactionsController extends AppController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$data = $this->data;
|
$data = $this->data;
|
||||||
$data['Entry'][0]['account_id'] =
|
|
||||||
$this->Transaction->Account->badDebtAccountID();
|
|
||||||
|
|
||||||
if (empty($data['Customer']['id']))
|
if (empty($data['Customer']['id']))
|
||||||
$data['Customer']['id'] = null;
|
$data['Customer']['id'] = null;
|
||||||
if (empty($data['Lease']['id']))
|
if (empty($data['Lease']['id']))
|
||||||
@@ -285,9 +282,9 @@ class TransactionsController extends AppController {
|
|||||||
|
|
||||||
pr(compact('data'));
|
pr(compact('data'));
|
||||||
|
|
||||||
if (!$this->Transaction->addReceipt($data,
|
if (!$this->Transaction->addWriteOff($data,
|
||||||
$data['Customer']['id'],
|
$data['Customer']['id'],
|
||||||
$data['Lease']['id'])) {
|
$data['Lease']['id'])) {
|
||||||
$this->Session->setFlash("WRITE OFF FAILED", true);
|
$this->Session->setFlash("WRITE OFF FAILED", true);
|
||||||
// REVISIT <AP> 20090706:
|
// REVISIT <AP> 20090706:
|
||||||
// Until we can work out the session problems,
|
// Until we can work out the session problems,
|
||||||
@@ -295,8 +292,6 @@ class TransactionsController extends AppController {
|
|||||||
die("<H1>WRITE-OFF FAILED</H1>");
|
die("<H1>WRITE-OFF FAILED</H1>");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->render('/fake');
|
|
||||||
|
|
||||||
// Return to viewing the lease/customer
|
// Return to viewing the lease/customer
|
||||||
if (empty($data['Lease']['id']))
|
if (empty($data['Lease']['id']))
|
||||||
$this->redirect(array('controller' => 'customers',
|
$this->redirect(array('controller' => 'customers',
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class StatementEntry extends AppModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function creditTypes() {
|
function creditTypes() {
|
||||||
return array('DISBURSEMENT', 'WAIVER', 'REVERSAL', 'SURPLUS');
|
return array('DISBURSEMENT', 'WAIVER', 'REVERSAL', 'WRITEOFF', 'SURPLUS');
|
||||||
}
|
}
|
||||||
|
|
||||||
function voidTypes() {
|
function voidTypes() {
|
||||||
@@ -125,14 +125,14 @@ class StatementEntry extends AppModel {
|
|||||||
|
|
||||||
$ret = array();
|
$ret = array();
|
||||||
if (!$this->verifyStatementEntry($entry))
|
if (!$this->verifyStatementEntry($entry))
|
||||||
return array('error' => true, 'verify_data' => $entry) + $ret;
|
return $this->prReturn(array('error' => true, 'verify_data' => $entry) + $ret);
|
||||||
|
|
||||||
$this->pr(20, array('checkpoint' => 'Pre-Save')
|
$this->pr(20, array('checkpoint' => 'Pre-Save')
|
||||||
+ compact('entry'));
|
+ compact('entry'));
|
||||||
|
|
||||||
$this->create();
|
$this->create();
|
||||||
if (!$this->save($entry))
|
if (!$this->save($entry))
|
||||||
return array('error' => true, 'save_data' => $entry) + $ret;
|
return $this->prReturn(array('error' => true, 'save_data' => $entry) + $ret);
|
||||||
|
|
||||||
$ret['statement_entry_id'] = $this->id;
|
$ret['statement_entry_id'] = $this->id;
|
||||||
return $this->prReturn($ret + array('error' => false));
|
return $this->prReturn($ret + array('error' => false));
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
|
|||||||
Reference in New Issue
Block a user