<?php
declare(strict_types=1);
namespace Iwv\IwvDatevV6\Subscriber;
use Iwv\IwvDatevV6\Events\IwvDatevCustomDocumentLinesEvent;
use Iwv\IwvDatevV6\Service\CustomDocuments\PickwareErpProInvoiceCorrection;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class CustomDocumentLinesSubscriber implements EventSubscriberInterface
{
/** @var PickwareErpProInvoiceCorrection */
protected $documentErpProRefund;
public function __construct(PickwareErpProInvoiceCorrection $documentErpProRefund)
{
$this->documentErpProRefund = $documentErpProRefund;
}
public static function getSubscribedEvents(): array
{
return [
IwvDatevCustomDocumentLinesEvent::class => 'onCustomDocumentLines',
];
}
/**
* @param IwvDatevCustomDocumentLinesEvent $customDocumentLineEvent
* @return void
*/
public function onCustomDocumentLines(IwvDatevCustomDocumentLinesEvent $customDocumentLineEvent): void
{
# Disable ERP Pro (missing discounts from export)
$documentLines = $this->documentErpProRefund->getDocumentLines($customDocumentLineEvent->getDocumentDB(), $customDocumentLineEvent->getContext());
$customDocumentLineEvent->setDocumentLines($documentLines);
}
}