Fix incorrect calculation of availability
This commit is contained in:
@@ -43,7 +43,7 @@ class ContingentRepository extends AbstractRepository implements ProviderInterfa
|
||||
* @return \CalendR\Event\EventInterface[]
|
||||
* @throws \Doctrine\DBAL\DBALException
|
||||
*/
|
||||
public function getEvents(\DateTime $dateFrom, \DateTime $dateTo, array $options = [])
|
||||
public function getEvents(\DateTime $dateFrom, \DateTime $dateTo = null, array $options = [])
|
||||
{
|
||||
$optionsResolver = new OptionsResolver();
|
||||
$optionsResolver->setDefined(['hotel']);
|
||||
@@ -71,11 +71,16 @@ class ContingentRepository extends AbstractRepository implements ProviderInterfa
|
||||
|
||||
$qb
|
||||
->andWhere('date >= :dateFrom')
|
||||
->andWhere('date <= :dateTo')
|
||||
->setParameter('dateFrom', $dateFrom->format('Y-m-d'))
|
||||
->setParameter('dateTo', $dateTo->format('Y-m-d'))
|
||||
;
|
||||
|
||||
if (null !== $dateTo) {
|
||||
$qb
|
||||
->andWhere('date <= :dateTo')
|
||||
->setParameter('dateTo', $dateTo->format('Y-m-d'))
|
||||
;
|
||||
}
|
||||
|
||||
$result = $qb->execute()->fetchAll();
|
||||
|
||||
$dates = [];
|
||||
|
||||
@@ -229,6 +229,7 @@ class ContingentImportService implements SingletonInterface, LoggerAwareInterfac
|
||||
$roomType = $roomTypes[$roomTypeBusProId];
|
||||
$roomCode = $roomType['code'];
|
||||
$availablePax = 0;
|
||||
$capacity = 0;
|
||||
if ($roomType['ctrl'] === true) {
|
||||
if ((string) $xmlRoom['status'] === 'A') {
|
||||
$status = Contingent::STATUS_ONREQUEST;
|
||||
|
||||
@@ -60,11 +60,11 @@ class IcalService implements SingletonInterface
|
||||
*/
|
||||
public function createContingentsFeed(Hotel $hotel): string
|
||||
{
|
||||
$range = Period::after(new \DateTime('now'), '1 year');
|
||||
$now = new \DateTime('now');
|
||||
try {
|
||||
$events = $this->contingentRepository->getEvents(
|
||||
\DateTime::createFromImmutable($range->getStartDate()),
|
||||
\DateTime::createFromImmutable($range->getEndDate()),
|
||||
$now,
|
||||
null,
|
||||
['hotel' => $hotel]
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user