Report stock usage and value, add material cost to profitability, document phase 5
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Inventory\Application\Contracts;
|
||||
|
||||
use App\Modules\Inventory\Application\DTOs\StockUsageEntry;
|
||||
use App\Modules\Inventory\Application\DTOs\StockValueEntry;
|
||||
|
||||
/**
|
||||
* Stock figures for management's reports (spec 19.8). Days are Y-m-d.
|
||||
*/
|
||||
interface StockReportQueries
|
||||
{
|
||||
/**
|
||||
* Use, write-offs and stock count corrections between the days.
|
||||
*
|
||||
* @return list<StockUsageEntry>
|
||||
*/
|
||||
public function usage(string $from, string $to): array;
|
||||
|
||||
/**
|
||||
* Every item with movements up to the day, or in use, in group order.
|
||||
*
|
||||
* @return list<StockValueEntry>
|
||||
*/
|
||||
public function valueOn(string $day): array;
|
||||
|
||||
/**
|
||||
* The value of the stock used and written off on jobs' tasks between
|
||||
* the days, by job id (spec 19.8: material cost in profitability).
|
||||
*
|
||||
* @return array<int, int>
|
||||
*/
|
||||
public function materialCostsByJob(string $from, string $to): array;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Inventory\Application\DTOs;
|
||||
|
||||
/**
|
||||
* Stock taken out in a period, summed by item, kind, machine and job: the
|
||||
* quantity (in thousandths) and value (in cents) as positive amounts
|
||||
* taken; a stock count correction that added stock is negative. Reversals
|
||||
* count with the movement they reverse. $kind is consumption, write_off
|
||||
* or adjustment.
|
||||
*/
|
||||
final readonly class StockUsageEntry
|
||||
{
|
||||
public function __construct(
|
||||
public int $itemId,
|
||||
public string $itemName,
|
||||
public string $groupName,
|
||||
public string $unit,
|
||||
public string $kind,
|
||||
public ?int $machineId,
|
||||
public ?int $jobId,
|
||||
public int $quantityMilli,
|
||||
public int $valueCents,
|
||||
) {}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Inventory\Application\DTOs;
|
||||
|
||||
/**
|
||||
* An item's balance (in thousandths) and book value (in cents) at the end
|
||||
* of a day: the sums of its movements up to the day, each at its own cost.
|
||||
*/
|
||||
final readonly class StockValueEntry
|
||||
{
|
||||
public function __construct(
|
||||
public int $itemId,
|
||||
public string $itemName,
|
||||
public string $groupName,
|
||||
public string $unit,
|
||||
public int $balanceMilli,
|
||||
public int $valueCents,
|
||||
public ?int $reorderLevelMilli,
|
||||
public bool $isActive,
|
||||
) {}
|
||||
|
||||
public function needsReorder(): bool
|
||||
{
|
||||
return $this->reorderLevelMilli !== null && $this->balanceMilli <= $this->reorderLevelMilli;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user