fix: correctly handle discounts applied by dpn api

This commit is contained in:
Björn Fromme
2026-01-14 17:46:15 +01:00
parent 398eb448cb
commit b18fccff9d
2 changed files with 76 additions and 4 deletions
+7 -4
View File
@@ -111,8 +111,12 @@ class BookingResponse
* - ERM/GRU: Gruppenrabatt (group discount for large bookings)
* - Other ERM subtypes: Various automatic discounts
*
* These discounts appear as negative price items and must be accounted for when
* comparing the API total price against the locally calculated price.
* These discounts appear as negative price items with type "ERM" and must be
* accounted for when comparing the API total price against the locally calculated price.
*
* Important: Only ERM type discounts are considered API-applied. Other negative price
* items (like BEF transportation discounts) are already handled by the local price
* calculator and should not be subtracted again.
*
* Note: Voucher discounts (AKTION, KULANZGUTSCHEIN) are handled separately via
* getVoucherDiscountFromPrices() as they are user-initiated, not automatic.
@@ -123,8 +127,7 @@ class BookingResponse
{
return array_filter(
$this->priceItems,
fn (PriceItem $item) => $item->totalPrice < 0
&& false === \in_array($item->type, ['AKTION', 'KULANZGUTSCHEIN'], true)
fn (PriceItem $item) => $item->totalPrice < 0 && 'ERM' === $item->type
);
}