Generate the models and migrations for incoming invoices.
This commit is contained in:
55
app/Models/Incoming.php
Normal file
55
app/Models/Incoming.php
Normal 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
36
app/Models/Incomingitem.php
Normal file
36
app/Models/Incomingitem.php
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
32
app/Models/Incomingtax.php
Normal file
32
app/Models/Incomingtax.php
Normal 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
38
app/Models/Supplier.php
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('suppliers', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
|
||||||
|
$table->string('name');
|
||||||
|
$table->string('registration_name')->nullable();
|
||||||
|
$table->string('email')->nullable();
|
||||||
|
$table->string('address')->nullable();
|
||||||
|
$table->string('city')->nullable();
|
||||||
|
$table->string('zip')->nullable();
|
||||||
|
$table->string('country_code')->default('DE')->nullable();
|
||||||
|
$table->string('tax_fc')->nullable();
|
||||||
|
$table->string('tax_vat')->nullable();
|
||||||
|
$table->string('contact_name')->nullable();
|
||||||
|
$table->string('contact_phone')->nullable();
|
||||||
|
$table->string('contact_email')->nullable();
|
||||||
|
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('suppliers');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('incomings', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
|
||||||
|
$table->foreignId('supplier_id')->constrained();
|
||||||
|
|
||||||
|
$table->string('invoice_number');
|
||||||
|
$table->date('issue_date');
|
||||||
|
$table->date('due_date')->nullable();
|
||||||
|
$table->string('invoice_type_code')->default('380');
|
||||||
|
$table->string('currency_code')->default('EUR');
|
||||||
|
$table->decimal('net');
|
||||||
|
$table->decimal('gross');
|
||||||
|
$table->decimal('tax');
|
||||||
|
$table->date('pay_date')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('incomings');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('incomingitems', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
|
||||||
|
$table->foreignId('incoming_id')->constrained();
|
||||||
|
|
||||||
|
$table->string('name');
|
||||||
|
$table->string('article_number')->nullable();
|
||||||
|
$table->text('description')->nullable();
|
||||||
|
$table->decimal('amount', 8, 2);
|
||||||
|
$table->decimal('discount', 8, 2)->nullable();
|
||||||
|
$table->decimal('tax', 8, 2);
|
||||||
|
$table->decimal('price', 8, 2);
|
||||||
|
$table->decimal('total', 8, 2);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('incomingitems');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('incomingtaxes', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
|
||||||
|
$table->foreignId('incoming_id')->constrained();
|
||||||
|
|
||||||
|
$table->decimal('taxable_amount', 8, 2)->default(0);
|
||||||
|
$table->decimal('amount', 8, 2)->default(0);
|
||||||
|
$table->decimal('percentage', 8, 2)->default(0);
|
||||||
|
$table->string('currency')->default('EUR');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('incomingtaxes');
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user