1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-24 02:11:34 +02:00
invoiceninja/app/models/Invoice.php

60 lines
971 B
PHP
Raw Normal View History

2013-11-26 13:45:07 +01:00
<?php
2013-12-04 17:20:14 +01:00
class Invoice extends EntityModel
2013-11-26 13:45:07 +01:00
{
2013-12-05 16:23:24 +01:00
protected $hidden = array('id', 'account_id', 'client_id', 'created_at', 'updated_at', 'deleted_at', 'viewed_date');
2013-12-03 18:32:33 +01:00
2013-12-01 21:58:25 +01:00
public function account()
{
return $this->belongsTo('Account');
}
2013-11-26 13:45:07 +01:00
public function client()
{
return $this->belongsTo('Client');
}
public function invoice_items()
{
return $this->hasMany('InvoiceItem');
}
2013-12-01 08:33:17 +01:00
public function invoice_status()
{
return $this->belongsTo('InvoiceStatus');
}
2013-12-01 21:58:25 +01:00
public function getName()
{
return $this->invoice_number;
}
public function getEntityType()
{
return ENTITY_INVOICE;
}
2013-12-09 10:38:49 +01:00
public function isRecurring()
{
return $this->how_often || $this->start_date || $this->end_date;
}
2013-12-05 16:23:24 +01:00
/*
2013-11-26 13:45:07 +01:00
public function getTotal()
{
$total = 0;
foreach ($this->invoice_items as $invoiceItem)
{
$total += $invoiceItem->qty * $invoiceItem->cost;
}
return $total;
}
2013-12-05 16:23:24 +01:00
*/
2013-11-26 22:45:10 +01:00
}
Invoice::created(function($invoice)
{
Activity::createInvoice($invoice);
});