mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-11 13:42:49 +01:00
77 lines
1.9 KiB
PHP
77 lines
1.9 KiB
PHP
<?php namespace App\Ninja\Presenters;
|
|
|
|
use URL;
|
|
use Utils;
|
|
|
|
class InvoicePresenter extends EntityPresenter {
|
|
|
|
public function client()
|
|
{
|
|
return $this->entity->client ? $this->entity->client->getDisplayName() : '';
|
|
}
|
|
|
|
public function user()
|
|
{
|
|
return $this->entity->user->getDisplayName();
|
|
}
|
|
|
|
public function balanceDueLabel()
|
|
{
|
|
if ($this->entity->partial > 0) {
|
|
return 'partial_due';
|
|
} elseif ($this->entity->isType(INVOICE_TYPE_QUOTE)) {
|
|
return 'total';
|
|
} else {
|
|
return 'balance_due';
|
|
}
|
|
}
|
|
|
|
// https://schema.org/PaymentStatusType
|
|
public function paymentStatus()
|
|
{
|
|
if ( ! $this->entity->balance) {
|
|
return 'PaymentComplete';
|
|
} elseif ($this->entity->isOverdue()) {
|
|
return 'PaymentPastDue';
|
|
} else {
|
|
return 'PaymentDue';
|
|
}
|
|
}
|
|
|
|
public function status()
|
|
{
|
|
if ($this->entity->is_deleted) {
|
|
return trans('texts.deleted');
|
|
} elseif ($this->entity->trashed()) {
|
|
return trans('texts.archived');
|
|
} elseif ($this->entity->is_recurring) {
|
|
return trans('texts.active');
|
|
} else {
|
|
$status = $this->entity->invoice_status ? $this->entity->invoice_status->name : 'draft';
|
|
$status = strtolower($status);
|
|
return trans("texts.status_{$status}");
|
|
}
|
|
}
|
|
|
|
public function invoice_date()
|
|
{
|
|
return Utils::fromSqlDate($this->entity->invoice_date);
|
|
}
|
|
|
|
public function due_date()
|
|
{
|
|
return Utils::fromSqlDate($this->entity->due_date);
|
|
}
|
|
|
|
public function frequency()
|
|
{
|
|
return $this->entity->frequency ? $this->entity->frequency->name : '';
|
|
}
|
|
|
|
public function email()
|
|
{
|
|
$client = $this->entity->client;
|
|
return count($client->contacts) ? $client->contacts[0]->email : '';
|
|
}
|
|
}
|