chore: initial commit of existing codebase
This commit is contained in:
commit
11e94889b2
292 files changed
+38586
No files matched your search
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class BillOfMaterial extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'bill_of_materials';
|
||||
|
||||
protected $fillable = ['product_id', 'raw_material_id', 'quantity_required', 'unit_of_measure', 'notes'];
|
||||
|
||||
protected $casts = ['quantity_required' => 'decimal:2'];
|
||||
|
||||
public function product()
|
||||
{
|
||||
return $this->belongsTo(Item::class, 'product_id');
|
||||
}
|
||||
|
||||
public function rawMaterial()
|
||||
{
|
||||
return $this->belongsTo(Item::class, 'raw_material_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Customer extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['name', 'contact_person', 'email', 'phone', 'address', 'tax_number', 'credit_limit', 'outstanding_balance', 'is_active'];
|
||||
|
||||
protected $casts = [
|
||||
'credit_limit' => 'decimal:2',
|
||||
'outstanding_balance' => 'decimal:2',
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
|
||||
public function salesOrders()
|
||||
{
|
||||
return $this->hasMany(SalesOrder::class);
|
||||
}
|
||||
|
||||
public function salesInvoices()
|
||||
{
|
||||
return $this->hasMany(SalesInvoice::class);
|
||||
}
|
||||
|
||||
public function paymentReceipts()
|
||||
{
|
||||
return $this->hasMany(PaymentReceipt::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class DeliveryNote extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['delivery_number', 'sales_order_id', 'customer_id', 'warehouse_id', 'delivery_date', 'status', 'notes', 'dispatched_by'];
|
||||
|
||||
protected $casts = ['delivery_date' => 'date'];
|
||||
|
||||
public function salesOrder()
|
||||
{
|
||||
return $this->belongsTo(SalesOrder::class);
|
||||
}
|
||||
|
||||
public function customer()
|
||||
{
|
||||
return $this->belongsTo(Customer::class);
|
||||
}
|
||||
|
||||
public function warehouse()
|
||||
{
|
||||
return $this->belongsTo(Warehouse::class);
|
||||
}
|
||||
|
||||
public function items()
|
||||
{
|
||||
return $this->hasMany(DeliveryNoteItem::class);
|
||||
}
|
||||
|
||||
public function dispatchedBy()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\User::class, 'dispatched_by');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class DeliveryNoteItem extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['delivery_note_id', 'sales_order_item_id', 'item_id', 'quantity_delivered'];
|
||||
|
||||
protected $casts = ['quantity_delivered' => 'decimal:2'];
|
||||
|
||||
public function deliveryNote()
|
||||
{
|
||||
return $this->belongsTo(DeliveryNote::class);
|
||||
}
|
||||
|
||||
public function salesOrderItem()
|
||||
{
|
||||
return $this->belongsTo(SalesOrderItem::class);
|
||||
}
|
||||
|
||||
public function item()
|
||||
{
|
||||
return $this->belongsTo(Item::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class GoodsReceiptNote extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['grn_number', 'purchase_order_id', 'supplier_id', 'warehouse_id', 'received_date', 'status', 'notes', 'received_by'];
|
||||
|
||||
protected $casts = ['received_date' => 'date'];
|
||||
|
||||
public function purchaseOrder()
|
||||
{
|
||||
return $this->belongsTo(PurchaseOrder::class);
|
||||
}
|
||||
|
||||
public function supplier()
|
||||
{
|
||||
return $this->belongsTo(Supplier::class);
|
||||
}
|
||||
|
||||
public function warehouse()
|
||||
{
|
||||
return $this->belongsTo(Warehouse::class);
|
||||
}
|
||||
|
||||
public function items()
|
||||
{
|
||||
return $this->hasMany(GrnItem::class);
|
||||
}
|
||||
|
||||
public function receivedBy()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\User::class, 'received_by');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class GrnItem extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['goods_receipt_note_id', 'purchase_order_item_id', 'item_id', 'quantity_received', 'unit_cost', 'type'];
|
||||
|
||||
protected $casts = [
|
||||
'quantity_received' => 'decimal:2',
|
||||
'unit_cost' => 'decimal:2',
|
||||
];
|
||||
|
||||
public function goodsReceiptNote()
|
||||
{
|
||||
return $this->belongsTo(GoodsReceiptNote::class);
|
||||
}
|
||||
|
||||
public function purchaseOrderItem()
|
||||
{
|
||||
return $this->belongsTo(PurchaseOrderItem::class);
|
||||
}
|
||||
|
||||
public function item()
|
||||
{
|
||||
return $this->belongsTo(Item::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Item extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['item_code', 'item_name', 'category', 'unit_of_measure', 'minimum_stock_level', 'cost_price', 'description', 'is_active'];
|
||||
|
||||
protected $casts = [
|
||||
'minimum_stock_level' => 'decimal:2',
|
||||
'cost_price' => 'decimal:2',
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
|
||||
public function stockLevels()
|
||||
{
|
||||
return $this->hasMany(StockLevel::class);
|
||||
}
|
||||
|
||||
public function stockMovements()
|
||||
{
|
||||
return $this->hasMany(StockMovement::class);
|
||||
}
|
||||
|
||||
public function billOfMaterials()
|
||||
{
|
||||
return $this->hasMany(BillOfMaterial::class, 'product_id');
|
||||
}
|
||||
|
||||
public function bomComponents()
|
||||
{
|
||||
return $this->hasMany(BillOfMaterial::class, 'raw_material_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class MaterialIssue extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['issue_number', 'production_order_id', 'item_id', 'warehouse_id', 'quantity', 'issue_date', 'notes', 'issued_by'];
|
||||
|
||||
protected $casts = [
|
||||
'issue_date' => 'date',
|
||||
'quantity' => 'decimal:2',
|
||||
];
|
||||
|
||||
public function productionOrder()
|
||||
{
|
||||
return $this->belongsTo(ProductionOrder::class);
|
||||
}
|
||||
|
||||
public function item()
|
||||
{
|
||||
return $this->belongsTo(Item::class);
|
||||
}
|
||||
|
||||
public function warehouse()
|
||||
{
|
||||
return $this->belongsTo(Warehouse::class);
|
||||
}
|
||||
|
||||
public function issuedBy()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\User::class, 'issued_by');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PaymentReceipt extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['sales_invoice_id', 'customer_id', 'receipt_date', 'amount', 'payment_method', 'reference_number', 'notes', 'created_by'];
|
||||
|
||||
protected $casts = [
|
||||
'receipt_date' => 'date',
|
||||
'amount' => 'decimal:2',
|
||||
];
|
||||
|
||||
public function salesInvoice()
|
||||
{
|
||||
return $this->belongsTo(SalesInvoice::class);
|
||||
}
|
||||
|
||||
public function customer()
|
||||
{
|
||||
return $this->belongsTo(Customer::class);
|
||||
}
|
||||
|
||||
public function createdBy()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\User::class, 'created_by');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ProductionCost extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['production_order_id', 'raw_material_cost', 'labor_cost', 'machine_cost', 'overhead_cost', 'total_cost', 'notes'];
|
||||
|
||||
protected $casts = [
|
||||
'raw_material_cost' => 'decimal:2',
|
||||
'labor_cost' => 'decimal:2',
|
||||
'machine_cost' => 'decimal:2',
|
||||
'overhead_cost' => 'decimal:2',
|
||||
'total_cost' => 'decimal:2',
|
||||
];
|
||||
|
||||
public function productionOrder()
|
||||
{
|
||||
return $this->belongsTo(ProductionOrder::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ProductionOrder extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['order_number', 'product_id', 'quantity_to_produce', 'quantity_produced', 'production_date', 'completion_date', 'status', 'notes', 'created_by'];
|
||||
|
||||
protected $casts = [
|
||||
'production_date' => 'date',
|
||||
'completion_date' => 'date',
|
||||
'quantity_to_produce' => 'decimal:2',
|
||||
'quantity_produced' => 'decimal:2',
|
||||
];
|
||||
|
||||
public function product()
|
||||
{
|
||||
return $this->belongsTo(Item::class, 'product_id');
|
||||
}
|
||||
|
||||
public function materialIssues()
|
||||
{
|
||||
return $this->hasMany(MaterialIssue::class);
|
||||
}
|
||||
|
||||
public function outputs()
|
||||
{
|
||||
return $this->hasMany(ProductionOutput::class);
|
||||
}
|
||||
|
||||
public function cost()
|
||||
{
|
||||
return $this->hasOne(ProductionCost::class);
|
||||
}
|
||||
|
||||
public function createdBy()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\User::class, 'created_by');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ProductionOutput extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['production_order_id', 'item_id', 'warehouse_id', 'quantity', 'output_date', 'notes', 'recorded_by'];
|
||||
|
||||
protected $casts = [
|
||||
'output_date' => 'date',
|
||||
'quantity' => 'decimal:2',
|
||||
];
|
||||
|
||||
public function productionOrder()
|
||||
{
|
||||
return $this->belongsTo(ProductionOrder::class);
|
||||
}
|
||||
|
||||
public function item()
|
||||
{
|
||||
return $this->belongsTo(Item::class);
|
||||
}
|
||||
|
||||
public function warehouse()
|
||||
{
|
||||
return $this->belongsTo(Warehouse::class);
|
||||
}
|
||||
|
||||
public function recordedBy()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\User::class, 'recorded_by');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PurchaseOrder extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['po_number', 'supplier_id', 'purchase_request_id', 'po_date', 'expected_delivery_date', 'total_amount', 'status', 'notes', 'created_by'];
|
||||
|
||||
protected $casts = [
|
||||
'po_date' => 'date',
|
||||
'expected_delivery_date' => 'date',
|
||||
'total_amount' => 'decimal:2',
|
||||
];
|
||||
|
||||
public function supplier()
|
||||
{
|
||||
return $this->belongsTo(Supplier::class);
|
||||
}
|
||||
|
||||
public function purchaseRequest()
|
||||
{
|
||||
return $this->belongsTo(PurchaseRequest::class);
|
||||
}
|
||||
|
||||
public function items()
|
||||
{
|
||||
return $this->hasMany(PurchaseOrderItem::class);
|
||||
}
|
||||
|
||||
public function goodsReceiptNotes()
|
||||
{
|
||||
return $this->hasMany(GoodsReceiptNote::class);
|
||||
}
|
||||
|
||||
public function supplierInvoices()
|
||||
{
|
||||
return $this->hasMany(SupplierInvoice::class);
|
||||
}
|
||||
|
||||
public function createdBy()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\User::class, 'created_by');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PurchaseOrderItem extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['purchase_order_id', 'item_id', 'quantity', 'rate', 'total_amount', 'quantity_received'];
|
||||
|
||||
protected $casts = [
|
||||
'quantity' => 'decimal:2',
|
||||
'rate' => 'decimal:2',
|
||||
'total_amount' => 'decimal:2',
|
||||
'quantity_received' => 'decimal:2',
|
||||
];
|
||||
|
||||
public function purchaseOrder()
|
||||
{
|
||||
return $this->belongsTo(PurchaseOrder::class);
|
||||
}
|
||||
|
||||
public function item()
|
||||
{
|
||||
return $this->belongsTo(Item::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PurchaseRequest extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'request_number', 'date', 'project_name', 'department',
|
||||
'requested_by_name', 'required_date_text', 'location',
|
||||
'remarks', 'status', 'stage', 'verified_by_name',
|
||||
'requested_by', 'approved_by', 'approved_at',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'date' => 'date',
|
||||
'approved_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function items()
|
||||
{
|
||||
return $this->hasMany(PurchaseRequestItem::class);
|
||||
}
|
||||
|
||||
public function requestedBy()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'requested_by');
|
||||
}
|
||||
|
||||
public function approvedBy()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'approved_by');
|
||||
}
|
||||
|
||||
public function purchaseOrders()
|
||||
{
|
||||
return $this->hasMany(PurchaseOrder::class);
|
||||
}
|
||||
|
||||
public function signature()
|
||||
{
|
||||
return $this->hasOne(PurchaseSignature::class);
|
||||
}
|
||||
|
||||
public function rfqInvitations()
|
||||
{
|
||||
return $this->hasMany(RfqInvitation::class);
|
||||
}
|
||||
|
||||
public function supplierQuotes()
|
||||
{
|
||||
return $this->hasMany(SupplierQuote::class);
|
||||
}
|
||||
|
||||
public function awardedQuote()
|
||||
{
|
||||
return $this->hasOne(SupplierQuote::class)->where('is_awarded', true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PurchaseRequestItem extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'purchase_request_id', 'description', 'unit',
|
||||
'quantity_required', 'purpose_use', 'required_date',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'required_date' => 'date',
|
||||
'quantity_required' => 'decimal:2',
|
||||
];
|
||||
|
||||
public function purchaseRequest()
|
||||
{
|
||||
return $this->belongsTo(PurchaseRequest::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PurchaseSignature extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'purchase_request_id', 'signed_by', 'signature_image', 'signed_at', 'ip_address',
|
||||
];
|
||||
|
||||
protected $casts = ['signed_at' => 'datetime'];
|
||||
|
||||
public function purchaseRequest()
|
||||
{
|
||||
return $this->belongsTo(PurchaseRequest::class);
|
||||
}
|
||||
|
||||
public function signedBy()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'signed_by');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class RfqInvitation extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'purchase_request_id', 'supplier_id', 'token', 'channel',
|
||||
'sent_at', 'opened_at', 'expires_at', 'status', 'item_ids',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'sent_at' => 'datetime',
|
||||
'opened_at' => 'datetime',
|
||||
'expires_at' => 'datetime',
|
||||
'item_ids' => 'array',
|
||||
];
|
||||
|
||||
public function purchaseRequest()
|
||||
{
|
||||
return $this->belongsTo(PurchaseRequest::class);
|
||||
}
|
||||
|
||||
public function supplier()
|
||||
{
|
||||
return $this->belongsTo(Supplier::class);
|
||||
}
|
||||
|
||||
public function quote()
|
||||
{
|
||||
return $this->hasOne(SupplierQuote::class);
|
||||
}
|
||||
|
||||
public function isExpired(): bool
|
||||
{
|
||||
return $this->expires_at && $this->expires_at->isPast();
|
||||
}
|
||||
|
||||
public function isSubmitted(): bool
|
||||
{
|
||||
return $this->status === 'submitted';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SalesInvoice extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['invoice_number', 'sales_order_id', 'customer_id', 'invoice_date', 'due_date', 'subtotal', 'vat_rate', 'vat_amount', 'total_amount', 'paid_amount', 'status', 'notes', 'created_by'];
|
||||
|
||||
protected $casts = [
|
||||
'invoice_date' => 'date',
|
||||
'due_date' => 'date',
|
||||
'subtotal' => 'decimal:2',
|
||||
'vat_rate' => 'decimal:2',
|
||||
'vat_amount' => 'decimal:2',
|
||||
'total_amount' => 'decimal:2',
|
||||
'paid_amount' => 'decimal:2',
|
||||
];
|
||||
|
||||
public function salesOrder()
|
||||
{
|
||||
return $this->belongsTo(SalesOrder::class);
|
||||
}
|
||||
|
||||
public function customer()
|
||||
{
|
||||
return $this->belongsTo(Customer::class);
|
||||
}
|
||||
|
||||
public function paymentReceipts()
|
||||
{
|
||||
return $this->hasMany(PaymentReceipt::class);
|
||||
}
|
||||
|
||||
public function createdBy()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\User::class, 'created_by');
|
||||
}
|
||||
|
||||
public function getOutstandingAttribute()
|
||||
{
|
||||
return $this->total_amount - $this->paid_amount;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SalesOrder extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['order_number', 'customer_id', 'order_date', 'delivery_date', 'total_amount', 'status', 'notes', 'created_by'];
|
||||
|
||||
protected $casts = [
|
||||
'order_date' => 'date',
|
||||
'delivery_date' => 'date',
|
||||
'total_amount' => 'decimal:2',
|
||||
];
|
||||
|
||||
public function customer()
|
||||
{
|
||||
return $this->belongsTo(Customer::class);
|
||||
}
|
||||
|
||||
public function items()
|
||||
{
|
||||
return $this->hasMany(SalesOrderItem::class);
|
||||
}
|
||||
|
||||
public function deliveryNotes()
|
||||
{
|
||||
return $this->hasMany(DeliveryNote::class);
|
||||
}
|
||||
|
||||
public function invoices()
|
||||
{
|
||||
return $this->hasMany(SalesInvoice::class);
|
||||
}
|
||||
|
||||
public function createdBy()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\User::class, 'created_by');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SalesOrderItem extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['sales_order_id', 'item_id', 'quantity', 'price', 'total_amount', 'quantity_delivered'];
|
||||
|
||||
protected $casts = [
|
||||
'quantity' => 'decimal:2',
|
||||
'price' => 'decimal:2',
|
||||
'total_amount' => 'decimal:2',
|
||||
'quantity_delivered' => 'decimal:2',
|
||||
];
|
||||
|
||||
public function salesOrder()
|
||||
{
|
||||
return $this->belongsTo(SalesOrder::class);
|
||||
}
|
||||
|
||||
public function item()
|
||||
{
|
||||
return $this->belongsTo(Item::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class StockLevel extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['item_id', 'warehouse_id', 'quantity'];
|
||||
|
||||
protected $casts = ['quantity' => 'decimal:2'];
|
||||
|
||||
public function item()
|
||||
{
|
||||
return $this->belongsTo(Item::class);
|
||||
}
|
||||
|
||||
public function warehouse()
|
||||
{
|
||||
return $this->belongsTo(Warehouse::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class StockMovement extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['item_id', 'warehouse_id', 'type', 'quantity', 'reference_type', 'reference_id', 'notes', 'created_by'];
|
||||
|
||||
protected $casts = ['quantity' => 'decimal:2'];
|
||||
|
||||
public function item()
|
||||
{
|
||||
return $this->belongsTo(Item::class);
|
||||
}
|
||||
|
||||
public function warehouse()
|
||||
{
|
||||
return $this->belongsTo(Warehouse::class);
|
||||
}
|
||||
|
||||
public function createdBy()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\User::class, 'created_by');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Supplier extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'supplier_code', 'name', 'category',
|
||||
'contact_person', 'email', 'secondary_email',
|
||||
'phone', 'phone2', 'whatsapp',
|
||||
'address', 'website',
|
||||
'tax_number', 'credit_terms', 'credit_days',
|
||||
'is_active', 'remarks',
|
||||
];
|
||||
|
||||
protected $casts = ['is_active' => 'boolean'];
|
||||
|
||||
public function purchaseOrders()
|
||||
{
|
||||
return $this->hasMany(PurchaseOrder::class);
|
||||
}
|
||||
|
||||
public function invoices()
|
||||
{
|
||||
return $this->hasMany(SupplierInvoice::class);
|
||||
}
|
||||
|
||||
public function payments()
|
||||
{
|
||||
return $this->hasMany(SupplierPayment::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SupplierInvoice extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['invoice_number', 'supplier_id', 'purchase_order_id', 'goods_receipt_note_id', 'invoice_date', 'due_date', 'subtotal', 'vat_amount', 'total_amount', 'paid_amount', 'status', 'notes'];
|
||||
|
||||
protected $casts = [
|
||||
'invoice_date' => 'date',
|
||||
'due_date' => 'date',
|
||||
'subtotal' => 'decimal:2',
|
||||
'vat_amount' => 'decimal:2',
|
||||
'total_amount' => 'decimal:2',
|
||||
'paid_amount' => 'decimal:2',
|
||||
];
|
||||
|
||||
public function supplier()
|
||||
{
|
||||
return $this->belongsTo(Supplier::class);
|
||||
}
|
||||
|
||||
public function purchaseOrder()
|
||||
{
|
||||
return $this->belongsTo(PurchaseOrder::class);
|
||||
}
|
||||
|
||||
public function goodsReceiptNote()
|
||||
{
|
||||
return $this->belongsTo(GoodsReceiptNote::class);
|
||||
}
|
||||
|
||||
public function payments()
|
||||
{
|
||||
return $this->hasMany(SupplierPayment::class);
|
||||
}
|
||||
|
||||
public function getOutstandingAttribute()
|
||||
{
|
||||
return $this->total_amount - $this->paid_amount;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SupplierPayment extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['supplier_invoice_id', 'supplier_id', 'payment_date', 'amount', 'payment_method', 'reference_number', 'notes', 'created_by'];
|
||||
|
||||
protected $casts = [
|
||||
'payment_date' => 'date',
|
||||
'amount' => 'decimal:2',
|
||||
];
|
||||
|
||||
public function supplierInvoice()
|
||||
{
|
||||
return $this->belongsTo(SupplierInvoice::class);
|
||||
}
|
||||
|
||||
public function supplier()
|
||||
{
|
||||
return $this->belongsTo(Supplier::class);
|
||||
}
|
||||
|
||||
public function createdBy()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\User::class, 'created_by');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SupplierQuote extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'rfq_invitation_id', 'purchase_request_id', 'supplier_id',
|
||||
'submitted_at', 'lead_time_days', 'payment_terms', 'notes',
|
||||
'total_amount', 'is_awarded', 'award_reason', 'awarded_at', 'awarded_by',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'submitted_at' => 'datetime',
|
||||
'awarded_at' => 'datetime',
|
||||
'is_awarded' => 'boolean',
|
||||
];
|
||||
|
||||
public function rfqInvitation()
|
||||
{
|
||||
return $this->belongsTo(RfqInvitation::class);
|
||||
}
|
||||
|
||||
public function purchaseRequest()
|
||||
{
|
||||
return $this->belongsTo(PurchaseRequest::class);
|
||||
}
|
||||
|
||||
public function supplier()
|
||||
{
|
||||
return $this->belongsTo(Supplier::class);
|
||||
}
|
||||
|
||||
public function items()
|
||||
{
|
||||
return $this->hasMany(SupplierQuoteItem::class);
|
||||
}
|
||||
|
||||
public function awardedBy()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'awarded_by');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SupplierQuoteItem extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'supplier_quote_id', 'description', 'unit', 'quantity', 'unit_price', 'total_price',
|
||||
];
|
||||
|
||||
public function quote()
|
||||
{
|
||||
return $this->belongsTo(SupplierQuote::class, 'supplier_quote_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Database\Factories\UserFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
/** @use HasFactory<UserFactory> */
|
||||
use HasFactory, Notifiable, HasRoles;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for serialization.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Warehouse extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['code', 'name', 'location', 'description', 'is_active'];
|
||||
|
||||
protected $casts = ['is_active' => 'boolean'];
|
||||
|
||||
public function stockLevels()
|
||||
{
|
||||
return $this->hasMany(StockLevel::class);
|
||||
}
|
||||
|
||||
public function stockMovements()
|
||||
{
|
||||
return $this->hasMany(StockMovement::class);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user