Minor cleanup and fixes for Tasks
This commit is contained in:
@@ -657,11 +657,14 @@ class Model_Invoice extends ORM_OSB implements Cartable {
|
||||
return parent::list_autocomplete($term,$index,$value,$label,$limit,$options);
|
||||
}
|
||||
|
||||
private function _list_due() {
|
||||
private function _list_due($authorised) {
|
||||
static $result = array();
|
||||
|
||||
if ($authorised)
|
||||
$this->where_authorised();
|
||||
|
||||
if (! $result)
|
||||
foreach ($this->_where_active()->_where_unprocessed()->where_authorised()->find_all() as $io)
|
||||
foreach ($this->_where_active()->_where_unprocessed()->find_all() as $io)
|
||||
if ($io->due())
|
||||
array_push($result,$io);
|
||||
|
||||
@@ -679,13 +682,13 @@ class Model_Invoice extends ORM_OSB implements Cartable {
|
||||
/**
|
||||
* Identify all the invoices that are due
|
||||
*/
|
||||
public function list_overdue($time=NULL) {
|
||||
public function list_overdue($time=NULL,$authorised=TRUE) {
|
||||
$result = array();
|
||||
|
||||
if (is_null($time))
|
||||
$time = time();
|
||||
|
||||
foreach ($this->_list_due() as $io)
|
||||
foreach ($this->_list_due($authorised) as $io)
|
||||
if ($io->due_date <= $time)
|
||||
array_push($result,$io);
|
||||
|
||||
@@ -714,23 +717,23 @@ class Model_Invoice extends ORM_OSB implements Cartable {
|
||||
/**
|
||||
* Return a list of invoices that are due, excluding overdue.
|
||||
*/
|
||||
public function list_due($time=NULL) {
|
||||
public function list_due($time=NULL,$authorised=TRUE) {
|
||||
$result = array();
|
||||
|
||||
if (is_null($time))
|
||||
$time = time();
|
||||
|
||||
foreach ($this->_list_due() as $io)
|
||||
foreach ($this->_list_due($authorised) as $io)
|
||||
if ($io->due_date > $time)
|
||||
array_push($result,$io);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function list_due_total($format=FALSE,$time=NULL) {
|
||||
public function list_due_total($format=FALSE,$time=NULL,$authorised=TRUE) {
|
||||
$result = 0;
|
||||
|
||||
foreach ($this->list_due($time) as $io)
|
||||
foreach ($this->list_due($time,$authorised) as $io)
|
||||
$result += $io->due();
|
||||
|
||||
return $format ? Currency::display($result) : Currency::round($result);
|
||||
|
Reference in New Issue
Block a user