<?php

declare(strict_types=1);

namespace External\HannahBundle\Overrides\View;

use KupShop\OrderingBundle\Util\Order\OrderInfo;
use Query\Operator;
use Query\QueryBuilder;

class CreateReturnView extends \KupShop\ReturnsBundle\View\CreateReturnView
{
    protected function modifyBoughtItemsQueryBuilder(QueryBuilder $qb): void
    {
        // chceme umoznit vracet pouze objednavky se zdrojem SHOP
        $qb->andWhere(Operator::equals(['o.source' => OrderInfo::ORDER_SOURCE_SHOP]));
        // objednavka musi mit prirazenou fakturu
        $qb->andWhere('JSON_EXTRACT(o.note_admin, "$.sapInvoiceNumber")');
    }
}
