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:
@@ -49,6 +49,7 @@ class ProfitabilityCsv implements ReportCsv
|
||||
$profit->workCents,
|
||||
$profit->expenseRevenueCents,
|
||||
$profit->expenseCostCents,
|
||||
$profit->materialCostCents,
|
||||
$profit->hourCostCents ?? '',
|
||||
$profit->marginCents() ?? '',
|
||||
];
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Reports\Presentation\Csv;
|
||||
|
||||
use App\Modules\Inventory\Domain\ValueObjects\StockQuantity;
|
||||
use App\Modules\Reports\Application\UseCases\StockUsageReport;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
* Stock usage as CSV: a row per item, quantities with a decimal comma and
|
||||
* values in cents (VAT 0).
|
||||
*/
|
||||
class StockUsageCsv implements ReportCsv
|
||||
{
|
||||
public function __construct(private StockUsageReport $report) {}
|
||||
|
||||
public function fileName(Request $request): string
|
||||
{
|
||||
$period = CsvFilters::period($request);
|
||||
|
||||
return __('reports.stock_usage.file').'-'.$period->from.'-'.$period->to;
|
||||
}
|
||||
|
||||
public function headers(): array
|
||||
{
|
||||
return array_values(__('reports.stock_usage.csv'));
|
||||
}
|
||||
|
||||
public function rows(Request $request): iterable
|
||||
{
|
||||
foreach ($this->report->execute(CsvFilters::period($request))->items as $row) {
|
||||
yield [
|
||||
$row->label,
|
||||
(string) $row->group,
|
||||
__('inventory.units.'.$row->unit),
|
||||
StockQuantity::inputValue($row->usedMilli),
|
||||
$row->usedCents,
|
||||
StockQuantity::inputValue($row->writtenOffMilli),
|
||||
$row->writtenOffCents,
|
||||
StockQuantity::inputValue($row->adjustedMilli),
|
||||
$row->adjustedCents,
|
||||
$row->totalCents(),
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Reports\Presentation\Csv;
|
||||
|
||||
use App\Modules\Inventory\Domain\ValueObjects\StockQuantity;
|
||||
use App\Modules\Reports\Application\UseCases\StockValueReport;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
* Stock value of a day as CSV: a row per item, the balance with a decimal
|
||||
* comma and the value in cents (VAT 0).
|
||||
*/
|
||||
class StockValueCsv implements ReportCsv
|
||||
{
|
||||
public function __construct(private StockValueReport $report) {}
|
||||
|
||||
public function fileName(Request $request): string
|
||||
{
|
||||
return __('reports.stock_value.file').'-'.CsvFilters::day($request, 'paiva');
|
||||
}
|
||||
|
||||
public function headers(): array
|
||||
{
|
||||
return array_values(__('reports.stock_value.csv'));
|
||||
}
|
||||
|
||||
public function rows(Request $request): iterable
|
||||
{
|
||||
foreach ($this->report->execute(CsvFilters::day($request, 'paiva'))->items as $item) {
|
||||
yield [
|
||||
$item->itemName,
|
||||
$item->groupName,
|
||||
__('inventory.units.'.$item->unit),
|
||||
StockQuantity::inputValue($item->balanceMilli),
|
||||
$item->valueCents,
|
||||
$item->needsReorder() ? __('inventory.status.reorder') : '',
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user