fix: revert pickup pricing to match current BusPro behavior
Reverts split pricing calculation to use outbound-only pricing, matching BusPro's current behavior where pickup is only charged when outbound transportation is BUS. - Use pickup->price directly instead of calculateEffectivePrice() - PKW+BUS scenario now correctly charges €0 (matches BusPro loophole) - priceOutbound/priceInbound remain populated for future activation - Updated documentation with current behavior and future plan
This commit is contained in:
1 parent
c1425f0562
commit
b68d5c9398
6 files changed
+262
-11
No files matched your search
@@ -39,6 +39,12 @@ class Pickup
|
||||
#[Groups(['api:single'])]
|
||||
public ?float $price = null;
|
||||
|
||||
#[Groups(['api:single'])]
|
||||
public ?float $priceOutbound = null;
|
||||
|
||||
#[Groups(['api:single'])]
|
||||
public ?float $priceInbound = null;
|
||||
|
||||
#[Groups(['api:booking'])]
|
||||
public array $mapping = [];
|
||||
|
||||
@@ -90,4 +96,75 @@ class Pickup
|
||||
|
||||
return sprintf('%s (€%s)', $label, number_format($this->price, 2, ',', '.'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the formatted label with context-aware pricing based on transportation directions.
|
||||
*
|
||||
* Calculates the effective price based on which directions use bus transportation:
|
||||
* - Both directions BUS: shows combined price (outbound + inbound)
|
||||
* - Only outbound BUS: shows outbound price only
|
||||
* - Only inbound BUS: shows inbound price only
|
||||
* - Falls back to legacy price property when split pricing data is unavailable
|
||||
*
|
||||
* @param bool $hasOutboundBus Whether outbound transportation is bus
|
||||
* @param bool $hasInboundBus Whether inbound transportation is bus
|
||||
*
|
||||
* @return string The formatted pickup label with contextual pricing
|
||||
*/
|
||||
public function getLabelWithContextualPrice(bool $hasOutboundBus, bool $hasInboundBus): string
|
||||
{
|
||||
$label = $this->getLabel();
|
||||
$effectivePrice = $this->calculateEffectivePrice($hasOutboundBus, $hasInboundBus);
|
||||
|
||||
if (null === $effectivePrice) {
|
||||
return $label;
|
||||
}
|
||||
|
||||
if (0.0 === $effectivePrice) {
|
||||
return sprintf('%s (inkl.)', $label);
|
||||
}
|
||||
|
||||
if ($effectivePrice < 0) {
|
||||
return sprintf('%s (-%s€ Rabatt)', $label, number_format(abs($effectivePrice), 2, ',', '.'));
|
||||
}
|
||||
|
||||
return sprintf('%s (€%s)', $label, number_format($effectivePrice, 2, ',', '.'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the effective pickup price based on transportation directions.
|
||||
*
|
||||
* Uses split pricing (priceOutbound/priceInbound) when available, falling back
|
||||
* to the legacy price property for backward compatibility with older data.
|
||||
*
|
||||
* @param bool $hasOutboundBus Whether outbound transportation is bus
|
||||
* @param bool $hasInboundBus Whether inbound transportation is bus
|
||||
*
|
||||
* @return float|null The calculated effective price or null if no applicable price
|
||||
*/
|
||||
public function calculateEffectivePrice(bool $hasOutboundBus, bool $hasInboundBus): ?float
|
||||
{
|
||||
// Neither direction is bus - no pickup price applies
|
||||
if (false === $hasOutboundBus && false === $hasInboundBus) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$effectivePrice = 0.0;
|
||||
$hasSplitPricing = null !== $this->priceOutbound || null !== $this->priceInbound;
|
||||
|
||||
if ($hasOutboundBus) {
|
||||
if ($hasSplitPricing) {
|
||||
$effectivePrice += $this->priceOutbound ?? 0.0;
|
||||
} else {
|
||||
// Fallback to legacy price for backward compatibility
|
||||
$effectivePrice += $this->price ?? 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
if ($hasInboundBus && null !== $this->priceInbound) {
|
||||
$effectivePrice += $this->priceInbound;
|
||||
}
|
||||
|
||||
return $effectivePrice;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user