Fix 0,- prices in tables

This commit is contained in:
Björn Fromme
2020-03-09 10:35:03 +01:00
parent 14a887ef30
commit fb15a4e330
@@ -525,7 +525,8 @@ class DateImportService implements SingletonInterface, LoggerAwareInterface
*/
protected function parseRooms(\SimpleXMLElement $xmlHotel, $hotelUid, array &$date, array $services)
{
$minPrice = 0;
$minPriceOverall = 0;
$minPriceAvailable = 0;
$availableTotal = 0;
$boardCode = '';
$count = 0;
@@ -561,8 +562,14 @@ class DateImportService implements SingletonInterface, LoggerAwareInterface
$pax = (int) $roomXml->attributes()['MaxPax'];
$availableTotal += $available * $pax;
if ($code !== static::CODE_BABYROOM && $available > 0 && ($minPrice === 0 || $price < $minPrice)) {
$minPrice = $price;
// Determine lowest price of available rooms
if ($code !== static::CODE_BABYROOM && $available > 0 && ($minPriceAvailable === 0 || $price < $minPriceAvailable)) {
$minPriceAvailable = $price;
}
// Determine lowest overall price
if ($code !== static::CODE_BABYROOM && ($minPriceOverall === 0 || $price < $minPriceOverall)) {
$minPriceOverall = $price;
}
if ($roomXml->attributes()['status'] === static::STATUS_STOP && $price && !$available) {
@@ -600,7 +607,7 @@ class DateImportService implements SingletonInterface, LoggerAwareInterface
}
$date['board_code'] = $boardCode;
$date['min_price'] = $minPrice;
$date['min_price'] = $minPriceAvailable ?: $minPriceOverall;
$date['available'] = $availableTotal;
$date['rooms'] = $count;
}