Count stock and correct the differences on confirmation

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
2026-11-26 16:34:08 +02:00
co-authored by Claude Sonnet 5.5
parent bca1eed166
commit 0de0e332b2
27 changed files with 1568 additions and 0 deletions
@@ -0,0 +1,41 @@
<?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\Support\Carbon;
/**
* Persistence model, used only inside the Inventory Infrastructure layer.
*
* @property int $id
* @property int $inventory_count_id
* @property int $stock_item_id
* @property int $book_quantity_milli
* @property int $counted_quantity_milli
* @property int|null $unit_cost_hundredths
* @property int $counted_by
* @property Carbon $counted_at
*/
#[Table('inventory_count_lines')]
#[Fillable(['inventory_count_id', 'stock_item_id', 'book_quantity_milli', 'counted_quantity_milli', 'unit_cost_hundredths', 'counted_by', 'counted_at'])]
class InventoryCountLineModel extends Model
{
/**
* @return array<string, string>
*/
protected function casts(): array
{
return [
'inventory_count_id' => 'integer',
'stock_item_id' => 'integer',
'book_quantity_milli' => 'integer',
'counted_quantity_milli' => 'integer',
'unit_cost_hundredths' => 'integer',
'counted_by' => 'integer',
'counted_at' => 'immutable_datetime',
];
}
}
@@ -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',
];
}
}