1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 15:13:29 +01:00
invoiceninja/app/Models/PaymentTerm.php

52 lines
942 B
PHP
Raw Normal View History

2017-01-30 20:40:43 +01:00
<?php
namespace App\Models;
2015-03-16 22:45:25 +01:00
use Cache;
2016-01-07 20:39:51 +01:00
use Illuminate\Database\Eloquent\SoftDeletes;
2015-03-25 20:56:31 +01:00
/**
2017-01-30 20:40:43 +01:00
* Class PaymentTerm.
*/
2016-01-07 20:39:51 +01:00
class PaymentTerm extends EntityModel
2015-03-16 22:45:25 +01:00
{
use SoftDeletes;
/**
* @var bool
*/
2016-01-07 20:39:51 +01:00
public $timestamps = true;
/**
* @var array
*/
2016-01-07 20:39:51 +01:00
protected $dates = ['deleted_at'];
/**
* @return mixed
*/
2016-01-07 20:39:51 +01:00
public function getEntityType()
{
return ENTITY_PAYMENT_TERM;
}
2017-04-18 09:22:46 +02:00
public function getNumDays()
{
return $this->num_days == -1 ? 0 : $this->num_days;
}
public static function getSelectOptions()
{
2017-06-13 10:14:32 +02:00
$terms = PaymentTerm::whereAccountId(0)->get();
foreach (PaymentTerm::scope()->get() as $term) {
$terms->push($term);
}
2017-04-18 09:22:46 +02:00
foreach ($terms as $term) {
$term->name = trans('texts.payment_terms_net') . ' ' . $term->getNumDays();
}
return $terms->sortBy('num_days');
}
2015-03-16 22:45:25 +01:00
}