src/Invoice/EventSubscriber/SetInvoiceBankAccountByCurrencyForTCGSubscriber.php line 35

  1. <?php
  2. declare(strict_types=1);
  3. /**
  4.  * Copyright (c) 2022 TECLA Consulting Group oü.
  5.  * All rights reserved.
  6.  *
  7.  * This unpublished material is proprietary to TECLA Consulting Group oü.
  8.  * All rights reserved. The methods and
  9.  * techniques described herein are considered trade secrets
  10.  * and/or confidential. Reproduction or distribution, in whole
  11.  * or in part, is forbidden except by express written permission
  12.  * of TECLA Consulting Group oü.
  13.  *
  14.  * @author    Matúš Sýkorjak <matus@tecla.no>
  15.  * @copyright 2022 TECLA Consulting Group oü
  16.  */
  17. namespace App\Invoice\EventSubscriber;
  18. use App\Invoice\Event\InvoiceCreateEvent;
  19. use JetBrains\PhpStorm\ArrayShape;
  20. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  21. final class SetInvoiceBankAccountByCurrencyForTCGSubscriber implements EventSubscriberInterface
  22. {
  23.     #[ArrayShape([InvoiceCreateEvent::class => 'string'])]
  24.     public static function getSubscribedEvents(): array
  25.     {
  26.         return [
  27.             InvoiceCreateEvent::class => 'onInvoiceCreate',
  28.         ];
  29.     }
  30.     public function onInvoiceCreate(InvoiceCreateEvent $event): void
  31.     {
  32.         $invoice $event->getInvoice();
  33.         $supplier $invoice->getSupplier();
  34.         if (2860 !== $supplier->getOldId()) {
  35.             return;
  36.         }
  37.         if ('NOK' === $invoice->getCurrency()) {
  38.             $invoice->setSupplierBankAccountNumber(null);
  39.             $invoice->setSupplierBankIban('EE531700017001100361');
  40.             $invoice->setSupplierBankBic('RIKOEE22');
  41.             return;
  42.         }
  43.         if ('EUR' === $invoice->getCurrency()) {
  44.             $invoice->setSupplierBankAccountNumber(null);
  45.             $invoice->setSupplierBankIban('EE221700017000892272');
  46.             $invoice->setSupplierBankBic('RIKOEE22');
  47.         }
  48.     }
  49. }