120 lines
2.6 KiB
PHP
120 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace App\Model;
|
|
|
|
use App\Entity\Embeddable\BankAccount;
|
|
use App\Entity\Teamer;
|
|
use Symfony\Component\Validator\Constraints as Assert;
|
|
|
|
class FinancialDataDto
|
|
{
|
|
#[Assert\NotBlank(message: 'Bitte gib deine SteuerID an')]
|
|
private ?string $taxId = null;
|
|
|
|
#[Assert\NotBlank(message: 'Bitte gib die IBAN an')]
|
|
#[Assert\Iban(message: 'Bitte gib eine gültige IBAN an')]
|
|
private ?string $iban = null;
|
|
|
|
#[Assert\NotBlank(message: 'Bitte gib den BIC an')]
|
|
private ?string $bic = null;
|
|
|
|
#[Assert\NotBlank(message: 'Bitte gib den Namen deiner Bank an')]
|
|
private ?string $bank = null;
|
|
|
|
#[Assert\NotBlank(message: 'Bitte gib den Kontoinhaber an')]
|
|
private ?string $holder = null;
|
|
|
|
public static function fromTeamer(Teamer $teamer): self
|
|
{
|
|
$instance = (new self())->setTaxId($teamer->getTaxId());
|
|
|
|
if (null === $bankAccount = $teamer->getBankAccount()) {
|
|
return $instance;
|
|
}
|
|
|
|
return $instance
|
|
->setIban($bankAccount->getIban())
|
|
->setBic($bankAccount->getBic())
|
|
->setBank($bankAccount->getBank())
|
|
->setHolder($bankAccount->getHolder())
|
|
;
|
|
}
|
|
|
|
public function applyTo(Teamer $teamer): void
|
|
{
|
|
if (null === $bankAccount = $teamer->getBankAccount()) {
|
|
$bankAccount = new BankAccount();
|
|
$teamer->setBankAccount($bankAccount);
|
|
}
|
|
|
|
$bankAccount
|
|
->setIban($this->getIban())
|
|
->setBic($this->getBic())
|
|
->setBank($this->getBank())
|
|
->setHolder($this->getHolder())
|
|
;
|
|
|
|
$teamer->setTaxId($this->getTaxId());
|
|
}
|
|
|
|
public function getTaxId(): ?string
|
|
{
|
|
return $this->taxId;
|
|
}
|
|
|
|
public function setTaxId(?string $taxId): static
|
|
{
|
|
$this->taxId = $taxId;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getIban(): ?string
|
|
{
|
|
return $this->iban;
|
|
}
|
|
|
|
public function setIban(?string $iban): static
|
|
{
|
|
$this->iban = $iban;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getBic(): ?string
|
|
{
|
|
return $this->bic;
|
|
}
|
|
|
|
public function setBic(?string $bic): static
|
|
{
|
|
$this->bic = $bic;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getBank(): ?string
|
|
{
|
|
return $this->bank;
|
|
}
|
|
|
|
public function setBank(?string $bank): static
|
|
{
|
|
$this->bank = $bank;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getHolder(): ?string
|
|
{
|
|
return $this->holder;
|
|
}
|
|
|
|
public function setHolder(?string $holder): static
|
|
{
|
|
$this->holder = $holder;
|
|
|
|
return $this;
|
|
}
|
|
}
|