Files
fewo-stommer/app/Pricing/CasePricing.php
T
LarsandClaude Opus 5.5 7e22e12cac U-A/U-B: Prozesskern mit Fachmodulen, versionierten Modellen, eingefrorenem Prozessplan, ProcessRunner (harte/weiche Abhängigkeiten), CasePricing, Loyalty nur im Tester
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>
2026-11-04 14:49:44 +01:00

44 lines
1.6 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?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;
}
}