<?php

declare(strict_types=1);

namespace KupShop\POSBundle\Ordering\Triggers;

use KupShop\KupShopBundle\Query\JsonOperator;
use KupShop\OrderDiscountBundle\Triggers\AbstractTrigger;
use KupShop\OrderingBundle\Entity\Purchase\PurchaseState;
use Query\Operator;

class SourceTrigger extends AbstractTrigger
{
    protected static $type = 'source';
    protected $adminTemplate = 'triggers/source.tpl';

    public function getDiscountFilterSpec(PurchaseState $purchaseState)
    {
        return Operator::andX(
            Operator::equals(['odt.type' => static::getType()]),
            Operator::not(Operator::equals([JsonOperator::value('odt.data', 'source') => $purchaseState->getSource()]))
        );
    }
}
