Generate the models and migrations for incoming invoices.

This commit is contained in:
2025-01-18 11:05:58 +01:00
parent f246f80b6b
commit d25a67a109
8 changed files with 310 additions and 0 deletions

55
app/Models/Incoming.php Normal file
View File

@@ -0,0 +1,55 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Incoming extends Model
{
public $timestamps = false;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'supplier_id',
'invoice_number',
'issue_date',
'due_date',
'invoice_type_code',
'currency_code',
'net',
'gross',
'tax',
'pay_date',
];
/**
* Get the supplier of the incoming invoice.
*/
public function supplier(): BelongsTo
{
return $this->belongsTo(Supplier::class);
}
/**
* Get the items (invoice positions) of this incoming invoice.
*/
public function items(): HasMany
{
return $this->hasMany(Incomingitem::class);
}
/**
* Get the tax subtotals for the incoming invoice.
*/
public function taxes(): HasMany
{
return $this->hasMany(Incomingtax::class);
}
}

View File

@@ -0,0 +1,36 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Incomingitem extends Model
{
public $timestamps = false;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'incoming_id',
'name',
'article_number',
'description',
'amount',
'discount',
'tax',
'price',
'total',
];
/**
* Get the invoice the item belongs to.
*/
public function incoming(): BelongsTo
{
return $this->belongsTo(Incoming::class);
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Incomingtax extends Model
{
public $timestamps = false;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'incoming_id',
'taxable_amount',
'amount',
'percentage',
'currency',
];
/**
* Get the incoming invoice this tax belongs to.
*/
public function incoming(): BelongsTo
{
return $this->belongsTo(Incoming::class);
}
}

38
app/Models/Supplier.php Normal file
View File

@@ -0,0 +1,38 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
class Supplier extends Model
{
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'name',
'registration_name',
'email',
'address',
'city',
'zip',
'country_code',
'tax_fc',
'tax_vat',
'contact_name',
'contact_phone',
'contact_email',
];
/**
* Get the supplier's incoming invoices.
*/
public function invoices(): HasMany
{
return $this->hasMany(Incoming::class);
}
}