Add refund capability to the customer, and in fact only the customer, as we've revoked refund capability from the lease. This is to help work through various issues surrounding use of security deposits and general refund functionality. For example, a customer who has overpayed (customer surplus, with zero balance on lease), and then moves out. Where that security deposit surplus goes has been a bit of a thorn. Hopefully, this resolves the issue, although there may still be some bugs to flush out.
git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716@504 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -395,18 +395,35 @@ class CustomersController extends AppController {
|
||||
* - Refunds customer charges
|
||||
*/
|
||||
|
||||
function refund() {
|
||||
$entries = $this->Customer->StatementEntry->find
|
||||
('all', array
|
||||
function refund($id) {
|
||||
$customer = $this->Customer->find
|
||||
('first', array
|
||||
('contain' => false,
|
||||
'conditions' => array('StatementEntry.id' =>
|
||||
//array(199,200,201)
|
||||
61
|
||||
'conditions' => array(array('Customer.id' => $id),
|
||||
),
|
||||
));
|
||||
pr(compact('entries'));
|
||||
if (empty($customer)) {
|
||||
$this->redirect(array('action'=>'view', $id));
|
||||
}
|
||||
|
||||
$this->Customer->refund($entries);
|
||||
// Determine the customer balance, bailing if the customer owes money
|
||||
$balance = $this->Customer->balance($id);
|
||||
if ($balance >= 0) {
|
||||
$this->redirect(array('action'=>'view', $id));
|
||||
}
|
||||
|
||||
// The refund will be for a positive amount
|
||||
$balance *= -1;
|
||||
|
||||
// Get the accounts capable of paying the refund
|
||||
$refundAccounts = $this->Customer->StatementEntry->Account->refundAccounts();
|
||||
$defaultAccount = current($refundAccounts);
|
||||
$this->set(compact('refundAccounts', 'defaultAccount'));
|
||||
|
||||
// Prepare to render
|
||||
$title = ($customer['Customer']['name'] . ': Refund');
|
||||
$this->set(compact('title', 'customer', 'balance'));
|
||||
$this->render('/transactions/refund');
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user