2018-10-15 23:40:34 +11:00
|
|
|
<?php
|
2019-05-11 13:32:07 +10:00
|
|
|
/**
|
2020-09-06 19:38:10 +10:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2019-05-11 13:32:07 +10:00
|
|
|
*
|
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
|
*
|
2022-04-27 13:20:41 +10:00
|
|
|
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
2019-05-11 13:32:07 +10:00
|
|
|
*
|
2021-06-16 16:58:16 +10:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2019-05-11 13:32:07 +10:00
|
|
|
*/
|
2018-10-15 23:40:34 +11:00
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
2020-01-20 12:31:58 +11:00
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
2018-10-15 23:40:34 +11:00
|
|
|
|
2018-11-02 21:54:46 +11:00
|
|
|
class Expense extends BaseModel
|
2018-10-15 23:40:34 +11:00
|
|
|
{
|
2020-01-20 12:31:58 +11:00
|
|
|
use SoftDeletes;
|
2020-01-20 15:53:40 +11:00
|
|
|
use Filterable;
|
2018-11-20 15:36:56 +11:00
|
|
|
|
2020-01-20 12:31:58 +11:00
|
|
|
protected $fillable = [
|
|
|
|
|
'client_id',
|
2020-10-22 17:46:02 +11:00
|
|
|
'assigned_user_id',
|
2020-01-20 12:31:58 +11:00
|
|
|
'vendor_id',
|
2020-10-22 17:46:02 +11:00
|
|
|
'invoice_id',
|
2020-10-30 20:17:29 +11:00
|
|
|
'currency_id',
|
2020-10-13 15:14:13 +11:00
|
|
|
'date',
|
2020-01-20 12:31:58 +11:00
|
|
|
'invoice_currency_id',
|
|
|
|
|
'amount',
|
|
|
|
|
'foreign_amount',
|
|
|
|
|
'exchange_rate',
|
|
|
|
|
'private_notes',
|
|
|
|
|
'public_notes',
|
|
|
|
|
'bank_id',
|
|
|
|
|
'transaction_id',
|
2020-10-22 17:46:02 +11:00
|
|
|
'category_id',
|
2020-01-20 12:31:58 +11:00
|
|
|
'tax_rate1',
|
|
|
|
|
'tax_name1',
|
|
|
|
|
'tax_rate2',
|
|
|
|
|
'tax_name2',
|
|
|
|
|
'tax_rate3',
|
|
|
|
|
'tax_name3',
|
|
|
|
|
'payment_date',
|
|
|
|
|
'payment_type_id',
|
2020-10-15 07:58:20 +11:00
|
|
|
'project_id',
|
2020-01-20 12:31:58 +11:00
|
|
|
'transaction_reference',
|
|
|
|
|
'invoice_documents',
|
|
|
|
|
'should_be_invoiced',
|
|
|
|
|
'custom_value1',
|
|
|
|
|
'custom_value2',
|
|
|
|
|
'custom_value3',
|
|
|
|
|
'custom_value4',
|
2020-10-29 20:40:13 +11:00
|
|
|
'number',
|
2021-01-08 21:27:49 +11:00
|
|
|
'tax_amount1',
|
|
|
|
|
'tax_amount2',
|
|
|
|
|
'tax_amount3',
|
|
|
|
|
'uses_inclusive_taxes',
|
2021-01-12 08:57:48 +11:00
|
|
|
'calculate_tax_by_amount',
|
2022-07-06 20:04:59 +10:00
|
|
|
'purchase_order_id',
|
2018-11-20 15:36:56 +11:00
|
|
|
];
|
|
|
|
|
|
2020-01-20 12:31:58 +11:00
|
|
|
protected $casts = [
|
|
|
|
|
'is_deleted' => 'boolean',
|
|
|
|
|
'updated_at' => 'timestamp',
|
|
|
|
|
'created_at' => 'timestamp',
|
|
|
|
|
'deleted_at' => 'timestamp',
|
|
|
|
|
];
|
2020-09-06 19:38:10 +10:00
|
|
|
|
2020-07-23 13:55:11 +10:00
|
|
|
protected $touches = [];
|
2018-11-20 15:36:56 +11:00
|
|
|
|
2020-05-06 21:49:42 +10:00
|
|
|
public function getEntityType()
|
|
|
|
|
{
|
2020-09-06 19:38:10 +10:00
|
|
|
return self::class;
|
2020-05-06 21:49:42 +10:00
|
|
|
}
|
2019-04-28 15:31:32 +10:00
|
|
|
|
|
|
|
|
public function documents()
|
|
|
|
|
{
|
|
|
|
|
return $this->morphMany(Document::class, 'documentable');
|
|
|
|
|
}
|
2019-11-05 21:16:38 +11:00
|
|
|
|
2021-01-04 22:22:48 +11:00
|
|
|
public function user()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(User::class)->withTrashed();
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-05 21:16:38 +11:00
|
|
|
public function assigned_user()
|
|
|
|
|
{
|
2021-09-08 09:29:20 +10:00
|
|
|
return $this->belongsTo(User::class, 'assigned_user_id', 'id')->withTrashed();
|
2019-11-05 21:16:38 +11:00
|
|
|
}
|
2020-07-17 07:50:02 +10:00
|
|
|
|
|
|
|
|
public function company()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(Company::class);
|
|
|
|
|
}
|
2020-12-07 21:43:21 +11:00
|
|
|
|
|
|
|
|
public function vendor()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(Vendor::class);
|
|
|
|
|
}
|
2021-05-15 12:19:36 +10:00
|
|
|
|
|
|
|
|
public function client()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(Client::class);
|
|
|
|
|
}
|
2022-04-06 10:38:01 +10:00
|
|
|
|
2022-07-06 19:25:22 +10:00
|
|
|
public function purchase_order()
|
|
|
|
|
{
|
2022-07-07 16:13:37 +10:00
|
|
|
return $this->hasOne(PurchaseOrder::class);
|
2022-07-06 19:25:22 +10:00
|
|
|
}
|
|
|
|
|
|
2022-04-06 10:38:01 +10:00
|
|
|
public function translate_entity()
|
|
|
|
|
{
|
|
|
|
|
return ctrans('texts.expense');
|
|
|
|
|
}
|
2022-04-08 17:03:03 +10:00
|
|
|
|
|
|
|
|
public function currency()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(Currency::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function category()
|
|
|
|
|
{
|
2022-05-12 10:57:58 +10:00
|
|
|
return $this->belongsTo(ExpenseCategory::class)->withTrashed();
|
2022-04-08 17:03:03 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function payment_type()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(PaymentType::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function project()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(Project::class);
|
2022-06-21 09:57:17 +00:00
|
|
|
}
|
2018-10-15 23:40:34 +11:00
|
|
|
}
|