Minor cleanup and fixes for Tasks

This commit is contained in:
Deon George 2013-10-11 11:00:16 +11:00
parent ac4ad76886
commit 91980b891e
3 changed files with 15 additions and 10 deletions

View File

@ -10,6 +10,10 @@
* @license http://dev.osbill.net/license.html * @license http://dev.osbill.net/license.html
*/ */
class Task_Adsl_Trafficget extends Minion_Task { class Task_Adsl_Trafficget extends Minion_Task {
protected $_options = array(
'verbose'=>FALSE,
);
protected function _traffic_suppliers($active=FALSE) { protected function _traffic_suppliers($active=FALSE) {
$suppliers = ORM::factory('ADSL_Supplier'); $suppliers = ORM::factory('ADSL_Supplier');

View File

@ -657,11 +657,14 @@ class Model_Invoice extends ORM_OSB implements Cartable {
return parent::list_autocomplete($term,$index,$value,$label,$limit,$options); return parent::list_autocomplete($term,$index,$value,$label,$limit,$options);
} }
private function _list_due() { private function _list_due($authorised) {
static $result = array(); static $result = array();
if ($authorised)
$this->where_authorised();
if (! $result) 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()) if ($io->due())
array_push($result,$io); array_push($result,$io);
@ -679,13 +682,13 @@ class Model_Invoice extends ORM_OSB implements Cartable {
/** /**
* Identify all the invoices that are due * Identify all the invoices that are due
*/ */
public function list_overdue($time=NULL) { public function list_overdue($time=NULL,$authorised=TRUE) {
$result = array(); $result = array();
if (is_null($time)) if (is_null($time))
$time = time(); $time = time();
foreach ($this->_list_due() as $io) foreach ($this->_list_due($authorised) as $io)
if ($io->due_date <= $time) if ($io->due_date <= $time)
array_push($result,$io); 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. * 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(); $result = array();
if (is_null($time)) if (is_null($time))
$time = time(); $time = time();
foreach ($this->_list_due() as $io) foreach ($this->_list_due($authorised) as $io)
if ($io->due_date > $time) if ($io->due_date > $time)
array_push($result,$io); array_push($result,$io);
return $result; return $result;
} }
public function list_due_total($format=FALSE,$time=NULL) { public function list_due_total($format=FALSE,$time=NULL,$authorised=TRUE) {
$result = 0; $result = 0;
foreach ($this->list_due($time) as $io) foreach ($this->list_due($time,$authorised) as $io)
$result += $io->due(); $result += $io->due();
return $format ? Currency::display($result) : Currency::round($result); return $format ? Currency::display($result) : Currency::round($result);

View File

@ -68,8 +68,6 @@ class Task_Task_Clean extends Minion_Task {
$to->delete(); $to->delete();
continue; continue;
} }
continue;
print_r(array($to->object(),$to->display('date_orig')));die();
} }
} }
} }