chore: update document approval workflow and bug fixes
This commit is contained in:
45
Modules/MaterialLogistics/app/Models/PurchaseOrderItem.php
Normal file
45
Modules/MaterialLogistics/app/Models/PurchaseOrderItem.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\MaterialLogistics\Models;
|
||||
use Modules\MasterData\Models\Material;
|
||||
use Modules\MasterData\Models\MaterialGroup;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class PurchaseOrderItem extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'purchase_order_id', 'material_id', 'material_requisition_item_id',
|
||||
'quantity', 'unit_cost',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'quantity' => 'decimal:2',
|
||||
'unit_cost' => 'decimal:2',
|
||||
];
|
||||
}
|
||||
|
||||
public function purchaseOrder(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(PurchaseOrder::class);
|
||||
}
|
||||
|
||||
public function material(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Material::class);
|
||||
}
|
||||
|
||||
public function requisitionItem(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(MaterialRequisitionItem::class, 'material_requisition_item_id');
|
||||
}
|
||||
|
||||
public function getLineTotalAttribute(): float
|
||||
{
|
||||
return (float) $this->quantity * (float) $this->unit_cost;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user