CaseActivities/CaseAutomation sind Fassaden über ProcessRunner. Verhaltensvergleich v0.11: 11 Abläufe und 198 Konstellationen gleich, beabsichtigte Abweichungen I-004/I-005 (F-001/F-002). Volle Suite vor U-B: 785/785. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
44 lines
1.6 KiB
PHP
44 lines
1.6 KiB
PHP
<?php
|
||
|
||
namespace App\Pricing;
|
||
|
||
use App\Models\Booking;
|
||
use App\Process\CaseContext;
|
||
use App\Process\Modules\ContributesToPrice;
|
||
use App\Process\ProcessCatalogue;
|
||
|
||
/**
|
||
* The price of a case before it is fixed (extension point BeforePriceFixing, docs/Prozessarchitektur/Architektur/02
|
||
* §6.4): PriceCalculator unchanged, plus the lines of the modules of the case's plan that contribute to the price.
|
||
* Without contributing modules the result is exactly PriceCalculator's. Never adds anything to a binding case – its
|
||
* price is fixed (rule R5). Pure: reads, never writes (also used for previews).
|
||
*/
|
||
final class CasePricing
|
||
{
|
||
public function __construct(private PriceCalculator $calculator, private ProcessCatalogue $catalogue) {}
|
||
|
||
public function quote(Booking $booking, StayRequest $stay): PriceQuote
|
||
{
|
||
$quote = $this->calculator->calculate($booking->property, $stay);
|
||
if ($booking->isBinding() || ! $booking->exists) {
|
||
return $quote;
|
||
}
|
||
|
||
$context = CaseContext::of($booking);
|
||
foreach ($context->plan->moduleKeys() as $key) {
|
||
if (! $this->catalogue->hasModule($key) || ! $context->plan->enabled($key)) {
|
||
continue;
|
||
}
|
||
$module = $this->catalogue->module($key);
|
||
if (! $module instanceof ContributesToPrice || ! $module->applies($context)) {
|
||
continue;
|
||
}
|
||
foreach ($module->priceLines($context, $quote) as $line) {
|
||
$quote = $quote->withLine($line);
|
||
}
|
||
}
|
||
|
||
return $quote;
|
||
}
|
||
}
|