1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00
invoiceninja/app/Ninja/Presenters/ExpensePresenter.php

74 lines
1.6 KiB
PHP
Raw Normal View History

2017-01-30 20:40:43 +01:00
<?php
namespace App\Ninja\Presenters;
2016-01-06 20:52:09 +01:00
2017-01-22 11:09:29 +01:00
use Carbon;
2017-01-30 20:40:43 +01:00
use Utils;
2016-01-06 20:52:09 +01:00
/**
2017-01-30 20:40:43 +01:00
* Class ExpensePresenter.
*/
class ExpensePresenter extends EntityPresenter
{
/**
* @return string
*/
2016-01-06 20:52:09 +01:00
public function vendor()
{
return $this->entity->vendor ? $this->entity->vendor->getDisplayName() : '';
}
/**
* @return \DateTime|string
*/
2016-01-06 20:52:09 +01:00
public function expense_date()
{
return Utils::fromSqlDate($this->entity->expense_date);
}
2016-01-21 21:36:49 +01:00
2017-04-19 16:18:24 +02:00
/**
* @return \DateTime|string
*/
public function payment_date()
{
return Utils::fromSqlDate($this->entity->payment_date);
}
2017-01-22 11:09:29 +01:00
public function month()
{
return Carbon::parse($this->entity->payment_date)->format('Y m');
}
2016-12-05 19:35:01 +01:00
public function amount()
{
return Utils::formatMoney($this->entity->amount, $this->entity->expense_currency_id);
}
public function category()
{
return $this->entity->expense_category ? $this->entity->expense_category->name : '';
}
2017-09-12 12:43:59 +02:00
public function calendarEvent()
{
$data = parent::calendarEvent();
$expense = $this->entity;
$data->title = trans('texts.expense') . ' ' . $this->amount() . ' | ' . $this->category();
$data->title = trans('texts.expense') . ' ' . $this->amount();
if ($category = $this->category()) {
$data->title .= ' | ' . $category;
}
if ($this->public_notes) {
$data->title .= ' | ' . $this->public_notes;
}
$data->start = $expense->expense_date;
2017-09-12 16:16:18 +02:00
$data->borderColor = $data->backgroundColor = '#F45D01';
2017-09-12 12:43:59 +02:00
return $data;
}
2016-05-23 11:26:08 +02:00
}