Replace status with active in tables
This commit is contained in:
@@ -33,7 +33,7 @@ class Invoice {
|
||||
|
||||
// Set our invoice as valid
|
||||
if (is_null($io))
|
||||
$this->_io->status = 1;
|
||||
$this->_io->active = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,8 +73,8 @@ class Invoice {
|
||||
|
||||
// Check if there are any charges
|
||||
$c = ORM::factory('Charge')
|
||||
->where_active()
|
||||
->where('service_id','=',$so->id)
|
||||
->where('void','is',NULL)
|
||||
->where('processed','is',NULL);
|
||||
|
||||
foreach ($c->find_all() as $co) {
|
||||
@@ -172,7 +172,7 @@ class Invoice {
|
||||
case 'html':
|
||||
switch ($section) {
|
||||
case 'body':
|
||||
if (! $this->_io->status)
|
||||
if (! $this->_io->active)
|
||||
Style::factory()
|
||||
->type('file')
|
||||
->data('media/css/pages/invoice.css');
|
||||
|
@@ -27,18 +27,15 @@ class Model_Invoice extends ORM implements Cartable {
|
||||
);
|
||||
|
||||
protected $_display_filters = array(
|
||||
'active'=>array(
|
||||
array('StaticList_YesNo::get',array(':value',TRUE)),
|
||||
),
|
||||
'date_orig'=>array(
|
||||
array('Site::Date',array(':value')),
|
||||
),
|
||||
'due_date'=>array(
|
||||
array('Site::Date',array(':value')),
|
||||
),
|
||||
'status'=>array(
|
||||
array('StaticList_YesNo::get',array(':value',TRUE)),
|
||||
),
|
||||
'void'=>array(
|
||||
array('StaticList_YesNo::get',array(':value',TRUE)),
|
||||
),
|
||||
);
|
||||
|
||||
// Items belonging to an invoice
|
||||
@@ -98,7 +95,7 @@ class Model_Invoice extends ORM implements Cartable {
|
||||
*/
|
||||
public function due($format=FALSE) {
|
||||
// If the invoice is active calculate the due amount
|
||||
$result = $this->status ? Currency::round($this->total()-$this->payments_total(),1) : 0;
|
||||
$result = $this->active ? Currency::round($this->total()-$this->payments_total(),1) : 0;
|
||||
|
||||
return $format ? Currency::display($result) : $result;
|
||||
}
|
||||
@@ -136,7 +133,7 @@ class Model_Invoice extends ORM implements Cartable {
|
||||
// Ensure we dont process this item again
|
||||
array_push($track,$iio->id);
|
||||
|
||||
if (! $iio->void)
|
||||
if ($iio->active)
|
||||
array_push($result['s'],$iio);
|
||||
}
|
||||
|
||||
@@ -149,14 +146,14 @@ class Model_Invoice extends ORM implements Cartable {
|
||||
// Ensure we dont process this item again
|
||||
array_push($track,$iio->id);
|
||||
|
||||
if (! $iio->void)
|
||||
if ($iio->active)
|
||||
array_push($result['s'],$iio);
|
||||
}
|
||||
}
|
||||
|
||||
// Get service items that dont have a recurring schedule
|
||||
foreach ($this->_sub_items as $iio)
|
||||
if (! $iio->void AND ! in_array($iio->id,$track) AND $iio->service_id) {
|
||||
if ($iio->active AND ! in_array($iio->id,$track) AND $iio->service_id) {
|
||||
// Ensure we dont process this item again
|
||||
array_push($track,$iio->id);
|
||||
|
||||
@@ -166,7 +163,7 @@ class Model_Invoice extends ORM implements Cartable {
|
||||
// Next get the items we havent already got
|
||||
$result['other'] = array();
|
||||
foreach ($this->_sub_items as $iio)
|
||||
if (! $iio->void AND ! in_array($iio->id,$track))
|
||||
if ($iio->active AND ! in_array($iio->id,$track))
|
||||
array_push($result['other'],$iio);
|
||||
|
||||
// Debug
|
||||
@@ -324,7 +321,7 @@ class Model_Invoice extends ORM implements Cartable {
|
||||
$iio->save();
|
||||
|
||||
if (! $iio->saved()) {
|
||||
$this->void = 1;
|
||||
$this->active = 0;
|
||||
$this->save();
|
||||
|
||||
break;
|
||||
@@ -416,7 +413,7 @@ class Model_Invoice extends ORM implements Cartable {
|
||||
|
||||
foreach ($this->_sub_items as $iio) {
|
||||
// Ignore voided items
|
||||
if ($iio->void)
|
||||
if (! $iio->active)
|
||||
continue;
|
||||
|
||||
$return = FALSE;
|
||||
@@ -529,12 +526,8 @@ class Model_Invoice extends ORM implements Cartable {
|
||||
return $format ? Currency::display($result) : $result;
|
||||
}
|
||||
|
||||
private function _where_unprocessed() {
|
||||
return $this->where_open()->where('process_status','!=',1)->or_where('process_status','is',NULL)->where_close();
|
||||
}
|
||||
|
||||
public function where_unprocessed() {
|
||||
return $this->_where_unprocessed();
|
||||
return $this->where_open()->where('process_status','!=',1)->or_where('process_status','is',NULL)->where_close();
|
||||
}
|
||||
|
||||
// Our list function
|
||||
@@ -570,7 +563,7 @@ class Model_Invoice extends ORM implements Cartable {
|
||||
$this->where_authorised();
|
||||
|
||||
if (! $result)
|
||||
foreach ($this->_where_active()->_where_unprocessed()->find_all() as $io)
|
||||
foreach ($this->where_active()->where_unprocessed()->find_all() as $io)
|
||||
if ($io->due())
|
||||
array_push($result,$io);
|
||||
|
||||
|
@@ -238,7 +238,7 @@ class Model_Invoice_Item extends ORM {
|
||||
$iito->save();
|
||||
|
||||
if (! $iito->saved()) {
|
||||
$this->void = 1;
|
||||
$this->active = 0;
|
||||
$this->save();
|
||||
|
||||
break;
|
||||
@@ -301,7 +301,7 @@ class Model_Invoice_Item extends ORM {
|
||||
}
|
||||
|
||||
public function total($format=FALSE) {
|
||||
$result = $this->void ? 0 : $this->subtotal()+$this->tax()-$this->discount();
|
||||
$result = ! $this->active ? 0 : $this->subtotal()+$this->tax()-$this->discount();
|
||||
|
||||
return $format ? Currency::display($result) : Currency::round($result);
|
||||
}
|
||||
|
Reference in New Issue
Block a user