diff --git a/site/controllers/units_controller.php b/site/controllers/units_controller.php index 59515db..9fcb630 100644 --- a/site/controllers/units_controller.php +++ b/site/controllers/units_controller.php @@ -169,14 +169,18 @@ class UnitsController extends AppController { $lease['balance'] = $stats['Account']['Ledger']['balance']; } - // Figure out the outstanding balance of the current lease. - $stats = $this->Unit->stats($id); - $outstanding_balance = - $stats['CurrentLease']['Account']['Ledger']['balance']; + $outstanding_balance = 0; + $outstanding_deposit = 0; + if (isset($unit['CurrentLease']['id'])) { + // Figure out the outstanding balance of the current lease. + $stats = $this->Unit->stats($id); + $outstanding_balance = + $stats['CurrentLease']['Account']['Ledger']['balance']; - // Figure out the total security deposit for the current lease. - $deposits = $this->Unit->Lease->findSecurityDeposits($unit['CurrentLease']['id']); - $outstanding_deposit = $deposits['summary']['balance']; + // Figure out the total security deposit for the current lease. + $deposits = $this->Unit->Lease->findSecurityDeposits($unit['CurrentLease']['id']); + $outstanding_deposit = $deposits['summary']['balance']; + } $this->sidemenu_links[] = array('name' => 'Operations', 'header' => true);