Improvements to invoice display and other misc items
This commit is contained in:
@@ -175,12 +175,13 @@ class Model_Service extends ORM_OSB {
|
||||
}
|
||||
|
||||
private function last_invoice_item() {
|
||||
return ORM::factory('Invoice_Item')->join('invoice')
|
||||
->on('invoice.id','=','invoice_item.invoice_id')
|
||||
->on('invoice.status','=',1)
|
||||
->on('invoice_item.service_id','=',$this)
|
||||
->on('invoice_item.item_type','=',0)
|
||||
->on('invoice_item.void','is','null')
|
||||
return ORM::factory('Invoice_Item')
|
||||
->where('item_type','IN',array(0,7))
|
||||
->where('service_id','=',$this)
|
||||
->where('invoice_item.void','IS',NULL)
|
||||
->join('invoice')
|
||||
->on('invoice.id','=','invoice_item.invoice_id')
|
||||
->on('invoice.status','=',1)
|
||||
->order_by('date_stop','DESC');
|
||||
}
|
||||
|
||||
@@ -195,15 +196,16 @@ class Model_Service extends ORM_OSB {
|
||||
* Returns the date that an item has been paid to
|
||||
*/
|
||||
public function paid_to($format=FALSE) {
|
||||
$x = NULL;
|
||||
$x = $metric = NULL;
|
||||
|
||||
foreach ($this->last_invoice_item()->order_by('date_orig','DESC')->find_all() as $iio)
|
||||
if ($iio->invoice->due() == 0) {
|
||||
$x = $iio;
|
||||
$metric = ($iio->total() < 0) ? $iio->date_start-86400 : $iio->date_stop;
|
||||
break;
|
||||
}
|
||||
|
||||
return $format ? ($x ? $x->display('date_stop') : ' ') : ($x ? $x->date_stop : NULL);
|
||||
return $format ? ($x ? Config::date($metric) : ' ') : ($x ? $metric : NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user