Improvements to invoice display and other misc items

This commit is contained in:
Deon George
2013-12-20 10:00:32 +11:00
parent 778eada7f0
commit e19518c505
43 changed files with 1122 additions and 887 deletions

View File

@@ -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') : '&nbsp;') : ($x ? $x->date_stop : NULL);
return $format ? ($x ? Config::date($metric) : '&nbsp;') : ($x ? $metric : NULL);
}
/**