Count stock and correct the differences on confirmation
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Inventory\Infrastructure\Persistence\Eloquent;
|
||||
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Table;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
/**
|
||||
* Persistence model, used only inside the Inventory Infrastructure layer.
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon $counted_on
|
||||
* @property string $status
|
||||
* @property list<int>|null $group_ids
|
||||
* @property int $started_by
|
||||
* @property int|null $confirmed_by
|
||||
* @property Carbon|null $confirmed_at
|
||||
* @property int|null $value_before_cents
|
||||
* @property int|null $value_after_cents
|
||||
*/
|
||||
#[Table('inventory_counts')]
|
||||
#[Fillable(['counted_on', 'status', 'group_ids', 'started_by', 'confirmed_by', 'confirmed_at', 'value_before_cents', 'value_after_cents'])]
|
||||
class InventoryCountModel extends Model
|
||||
{
|
||||
public const string OPEN = 'open';
|
||||
|
||||
public const string CONFIRMED = 'confirmed';
|
||||
|
||||
/**
|
||||
* @return HasMany<InventoryCountLineModel, $this>
|
||||
*/
|
||||
public function lines(): HasMany
|
||||
{
|
||||
return $this->hasMany(InventoryCountLineModel::class, 'inventory_count_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'counted_on' => 'immutable_date',
|
||||
'group_ids' => 'array',
|
||||
'started_by' => 'integer',
|
||||
'confirmed_by' => 'integer',
|
||||
'confirmed_at' => 'immutable_datetime',
|
||||
'value_before_cents' => 'integer',
|
||||
'value_after_cents' => 'integer',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user