mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-03 14:24:34 -04:00
INA-4 | Purchase Order model
This commit is contained in:
parent
6ffad400db
commit
19c286c37e
169
app/Models/PurchaseOrder.php
Normal file
169
app/Models/PurchaseOrder.php
Normal file
@ -0,0 +1,169 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://www.elastic.co/licensing/elastic-license
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
|
||||
use App\Services\PurchaseOrder\PurchaseOrderService;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class PurchaseOrder extends BaseModel
|
||||
{
|
||||
use Filterable;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'number',
|
||||
'discount',
|
||||
'company_id',
|
||||
'status_id',
|
||||
'user_id',
|
||||
'last_sent_date',
|
||||
'is_deleted',
|
||||
'po_number',
|
||||
'date',
|
||||
'due_date',
|
||||
'terms',
|
||||
'public_notes',
|
||||
'private_notes',
|
||||
'tax_name1',
|
||||
'tax_rate1',
|
||||
'tax_name2',
|
||||
'tax_rate2',
|
||||
'tax_name3',
|
||||
'tax_rate3',
|
||||
'total_taxes',
|
||||
'uses_inclusive_taxes',
|
||||
'is_amount_discount',
|
||||
'partial',
|
||||
'recurring_id',
|
||||
'next_send_date',
|
||||
'reminder1_sent',
|
||||
'reminder2_sent',
|
||||
'reminder3_sent',
|
||||
'reminder_last_sent',
|
||||
'partial_due_date',
|
||||
'project_id',
|
||||
'custom_value1',
|
||||
'custom_value2',
|
||||
'custom_value3',
|
||||
'custom_value4',
|
||||
'backup',
|
||||
'footer',
|
||||
'line_items',
|
||||
'client_id',
|
||||
'custom_surcharge1',
|
||||
'custom_surcharge2',
|
||||
'custom_surcharge3',
|
||||
'custom_surcharge4',
|
||||
// 'custom_surcharge_tax1',
|
||||
// 'custom_surcharge_tax2',
|
||||
// 'custom_surcharge_tax3',
|
||||
// 'custom_surcharge_tax4',
|
||||
'design_id',
|
||||
'invoice_id',
|
||||
'assigned_user_id',
|
||||
'exchange_rate',
|
||||
'balance',
|
||||
'partial',
|
||||
'paid_to_date',
|
||||
'subscription_id',
|
||||
'vendor_id',
|
||||
'last_viewed'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'line_items' => 'object',
|
||||
'backup' => 'object',
|
||||
'updated_at' => 'timestamp',
|
||||
'created_at' => 'timestamp',
|
||||
'deleted_at' => 'timestamp',
|
||||
'is_amount_discount' => 'bool',
|
||||
|
||||
];
|
||||
|
||||
const STATUS_DRAFT = 1;
|
||||
const STATUS_SENT = 2;
|
||||
const STATUS_PARTIAL = 3;
|
||||
const STATUS_APPLIED = 4;
|
||||
|
||||
public function assigned_user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'assigned_user_id', 'id')->withTrashed();
|
||||
}
|
||||
|
||||
public function vendor()
|
||||
{
|
||||
return $this->belongsTo(Vendor::class);
|
||||
}
|
||||
|
||||
public function history()
|
||||
{
|
||||
return $this->hasManyThrough(Backup::class, Activity::class);
|
||||
}
|
||||
|
||||
public function activities()
|
||||
{
|
||||
return $this->hasMany(Activity::class)->orderBy('id', 'DESC')->take(50);
|
||||
}
|
||||
|
||||
public function company()
|
||||
{
|
||||
return $this->belongsTo(Company::class);
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class)->withTrashed();
|
||||
}
|
||||
|
||||
public function client()
|
||||
{
|
||||
return $this->belongsTo(Client::class)->withTrashed();
|
||||
}
|
||||
|
||||
|
||||
public function invitations()
|
||||
{
|
||||
return $this->hasMany(CreditInvitation::class);
|
||||
}
|
||||
|
||||
public function project()
|
||||
{
|
||||
return $this->belongsTo(Project::class)->withTrashed();
|
||||
}
|
||||
|
||||
public function invoice()
|
||||
{
|
||||
return $this->belongsTo(Invoice::class);
|
||||
}
|
||||
|
||||
public function service()
|
||||
{
|
||||
return new PurchaseOrderService($this);
|
||||
}
|
||||
|
||||
public function invoices()
|
||||
{
|
||||
return $this->belongsToMany(Invoice::class)->using(Paymentable::class);
|
||||
}
|
||||
|
||||
public function payments()
|
||||
{
|
||||
return $this->morphToMany(Payment::class, 'paymentable');
|
||||
}
|
||||
|
||||
public function documents()
|
||||
{
|
||||
return $this->morphMany(Document::class, 'documentable');
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user