Hoan thien core finance v2 - Calculation Pipeline, Form Templates

This commit is contained in:
2026-04-28 03:57:18 +00:00
parent 002c9a8b99
commit 49aa20a634
24 changed files with 1043 additions and 875 deletions

View File

@@ -0,0 +1,51 @@
<?php
namespace App\Services\Calculation;
class CalculationResult
{
protected array $steps = [];
protected array $values = [];
public function addStep(array $stepResult): void
{
$this->steps[] = $stepResult;
$this->values[$stepResult['output_key']] = $stepResult['rounded_value'];
}
public function get(string $key): ?int
{
return $this->values[$key] ?? null;
}
public function getSteps(): array
{
return $this->steps;
}
public function getValues(): array
{
return $this->values;
}
public function toArray(): array
{
return [
'steps' => $this->steps,
'final_values' => $this->values,
];
}
public function toPriceSheet(): array
{
$sheet = [];
foreach ($this->steps as $step) {
$sheet[] = [
'description' => $step['name'],
'value' => $step['rounded_value'],
'is_overridden' => $step['is_overridden'],
];
}
return $sheet;
}
}