src/Entity/ContaBancaria.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Component\Serializer\Annotation\Groups;
  5. /**
  6.  * ContaBancaria
  7.  *
  8.  * @ORM\Table(name="conta_bancaria")
  9.  * @ORM\Entity(repositoryClass="App\Repository\ContaBancariaRepository")
  10.  */
  11. class ContaBancaria
  12. {
  13.     /**
  14.      * @var \Ramsey\Uuid\UuidInterface
  15.      *
  16.      * @ORM\Id
  17.      *  @ORM\Column(type="uuid", unique=true)
  18.      * @ORM\GeneratedValue(strategy="CUSTOM")
  19.      * @ORM\CustomIdGenerator(class="Ramsey\Uuid\Doctrine\UuidGenerator")
  20.      * @Groups("BankAccounts")
  21.      */
  22.     private $id;
  23.     /**
  24.      * @var string
  25.      *
  26.      * @ORM\Column(name="numero", type="string", length=255, nullable=true)
  27.      * @Groups("BankAccounts") 
  28.      */
  29.     private $numero;
  30.     /**
  31.      * @var string
  32.      *
  33.      * @ORM\Column(name="titulo", type="string", length=255, nullable=true)
  34.      * @Groups("BankAccounts")
  35.      */
  36.     private $titulo;
  37.     /**
  38.      * @var string
  39.      *
  40.      * @ORM\Column(name="swift_code", type="string", length=255, nullable=true)
  41.      * @Groups("BankAccounts")
  42.      */
  43.     private $swiftCode;
  44.     /**
  45.      * @var float
  46.      *
  47.      * @ORM\Column(name="valor", type="float", nullable=true)
  48.      * @Groups("BankAccounts")
  49.      */
  50.     private $valor;
  51.     /**
  52.      * @var string
  53.      *
  54.      * @ORM\Column(name="iban", type="string", length=255, nullable=true)
  55.      * @Groups("BankAccounts")
  56.      */
  57.     private $iban;
  58.     private $nib;
  59.     /**
  60.      * @var string
  61.      *
  62.      * @ORM\Column(name="balcao", type="string", length=255, nullable=true)
  63.      * @Groups("BankAccounts")
  64.      */
  65.     private $balcao;
  66.     /**
  67.      * @var string
  68.      *
  69.      * @ORM\Column(name="descricao", type="string", length=255, nullable=true)
  70.      * @Groups("BankAccounts")
  71.      */
  72.     private $descricao;
  73.     /**
  74.      * @ORM\ManyToOne(targetEntity="App\Entity\Banco", inversedBy="banco")
  75.      * @Groups("BankAccounts")
  76.      */
  77.     private $banco;
  78.     /**
  79.      * @ORM\ManyToOne(targetEntity="App\Entity\Moeda", inversedBy="moeda")
  80.      * @Groups("BankAccounts")
  81.      */
  82.     private $moeda;
  83.     /**
  84.      * @ORM\ManyToOne(targetEntity="App\Entity\Company", inversedBy="company")
  85.      */
  86.     private $company;
  87.     /**
  88.      * @ORM\OneToMany(targetEntity="App\Entity\Pagamento", mappedBy="contaDestino")
  89.      */
  90.     private $pagamentos;
  91.     /**
  92.      * @ORM\OneToMany(targetEntity="App\Entity\Recebimento", mappedBy="contaDestino")
  93.      */
  94.     private $recebimentos;
  95.     /**
  96.      * @ORM\ManyToOne(targetEntity="App\Entity\Account", inversedBy="account")
  97.      */
  98.     private $account;
  99.     private $saldoActual;
  100.     /**
  101.      * @ORM\ManyToMany(targetEntity="App\Entity\WareHouse", inversedBy="bankAccounts")
  102.      */
  103.     private $wareHouses;
  104.     /**
  105.      * Get id
  106.      *
  107.      * @return int
  108.      */
  109.     public function getId()
  110.     {
  111.         return $this->id;
  112.     }
  113.     /**
  114.      * Set numero
  115.      *
  116.      * @param string $numero
  117.      *
  118.      * @return ContaBancaria
  119.      */
  120.     public function setNumero($numero)
  121.     {
  122.         $this->numero $numero;
  123.         return $this;
  124.     }
  125.     /**
  126.      * Get numero
  127.      *
  128.      * @return string
  129.      */
  130.     public function getNumero()
  131.     {
  132.         return $this->numero;
  133.     }
  134.     /**
  135.      * Set banco
  136.      *
  137.      * @param Banco $banco
  138.      *
  139.      * @return ContaBancaria
  140.      */
  141.     public function setBanco($banco)
  142.     {
  143.         $this->banco $banco;
  144.         return $this;
  145.     }
  146.     /**
  147.      * Get banco
  148.      *
  149.      * @return Banco
  150.      */
  151.     public function getBanco()
  152.     {
  153.         return $this->banco;
  154.     }
  155.     /**
  156.      * Set valor
  157.      *
  158.      * @param string $valor
  159.      *
  160.      * @return ContaBancaria
  161.      */
  162.     public function setValor($valor)
  163.     {
  164.         $valor str_replace('.'''$valor);
  165.         $this->valor $valor;
  166.         return $this;
  167.     }
  168.     /**
  169.      * Get valor
  170.      *
  171.      * @return float
  172.      */
  173.     public function getValor()
  174.     {
  175.         return $this->valor;
  176.     }
  177.     /**
  178.      * Set iban
  179.      *
  180.      * @param string $iban
  181.      *
  182.      * @return ContaBancaria
  183.      */
  184.     public function setIban($iban)
  185.     {
  186.         $this->iban $iban;
  187.         return $this;
  188.     }
  189.     /**
  190.      * Get iban
  191.      *
  192.      * @return string
  193.      */
  194.     public function getIban()
  195.     {
  196.         return join('.',explode('-',$this->iban));
  197.     }
  198.     /**
  199.      * Set balcao
  200.      *
  201.      * @param string $balcao
  202.      *
  203.      * @return ContaBancaria
  204.      */
  205.     public function setBalcao($balcao)
  206.     {
  207.         $this->balcao $balcao;
  208.         return $this;
  209.     }
  210.     /**
  211.      * Get balcao
  212.      *
  213.      * @return string
  214.      */
  215.     public function getBalcao()
  216.     {
  217.         return $this->balcao;
  218.     }
  219.     /**
  220.      * Set descricao
  221.      *
  222.      * @param string $descricao
  223.      *
  224.      * @return ContaBancaria
  225.      */
  226.     public function setDescricao($descricao)
  227.     {
  228.         $this->descricao $descricao;
  229.         return $this;
  230.     }
  231.     /**
  232.      * Get descricao
  233.      *
  234.      * @return string
  235.      */
  236.     public function getDescricao()
  237.     {
  238.         return $this->descricao;
  239.     }
  240.     /**
  241.      * @return mixed
  242.      */
  243.     public function getMoeda()
  244.     {
  245.         return $this->moeda;
  246.     }
  247.     /**
  248.      * @param mixed $moeda
  249.      */
  250.     public function setMoeda($moeda)
  251.     {
  252.         $this->moeda $moeda;
  253.     }
  254.     /**
  255.      * @return string
  256.      */
  257.     public function getTitulo()
  258.     {
  259.         return $this->titulo;
  260.     }
  261.     /**
  262.      * @param string $titulo
  263.      */
  264.     public function setTitulo(string $titulo)
  265.     {
  266.         $this->titulo $titulo;
  267.     }
  268.     /**
  269.      * @return mixed
  270.      */
  271.     public function getCompany()
  272.     {
  273.         return $this->company;
  274.     }
  275.     /**
  276.      * @param mixed $company
  277.      */
  278.     public function setCompany($company)
  279.     {
  280.         $this->company $company;
  281.     }
  282.     /**
  283.      * @return string
  284.      */
  285.     public function getSwiftCode()
  286.     {
  287.         return $this->swiftCode;
  288.     }
  289.     /**
  290.      * @param string $swiftCode
  291.      */
  292.     public function setSwiftCode(string $swiftCode)
  293.     {
  294.         $this->swiftCode $swiftCode;
  295.     }
  296.     /**
  297.      * @return mixed
  298.      */
  299.     public function getPagamentos()
  300.     {
  301.         return $this->pagamentos;
  302.     }
  303.     /**
  304.      * @param mixed $pagamentos
  305.      */
  306.     public function setPagamentos($pagamentos)
  307.     {
  308.         $this->pagamentos $pagamentos;
  309.     }
  310.     /**
  311.      * @return mixed
  312.      */
  313.     public function getRecebimentos()
  314.     {
  315.         return $this->recebimentos;
  316.     }
  317.     /**
  318.      * @param mixed $recebimentos
  319.      */
  320.     public function setRecebimentos($recebimentos)
  321.     {
  322.         $this->recebimentos $recebimentos;
  323.     }
  324.     /**
  325.      * @return mixed
  326.      */
  327.     public function getSaldoActual()
  328.     {
  329.         $saldo 0;
  330.         if(is_null($this->getAccount()))
  331.             return $this->saldoActual;
  332.         foreach ($this->getAccount()->getMoviments() as $moviment)
  333.             if($moviment->getTransactionNature())
  334.             $saldo -= $moviment->getAmount();
  335.         else
  336.             $saldo += $moviment->getAmount();
  337.         $this->setSaldoActual($saldo);
  338.         return $this->saldoActual;
  339.     }
  340.     /**
  341.      * @param mixed $saldoActual
  342.      */
  343.     public function setSaldoActual($saldoActual)
  344.     {
  345.         $this->saldoActual $saldoActual;
  346.     }
  347.     /**
  348.      * @return mixed
  349.      */
  350.     public function getNib()
  351.     {
  352.         return str_replace('AO06','',$this->iban);
  353.     }
  354.     /**
  355.      * @param mixed $nib
  356.      */
  357.     public function setNib($nib)
  358.     {
  359.         $this->nib $nib;
  360.     }
  361.     /**
  362.      * @return Account
  363.      */
  364.     public function getAccount()
  365.     {
  366.         return $this->account;
  367.     }
  368.     /**
  369.      * @param Account $account
  370.      */
  371.     public function setAccount($account)
  372.     {
  373.         $this->account $account;
  374.     }
  375.     /**
  376.      * @return []WareHouse
  377.      */
  378.     public function getWareHouses()
  379.     {
  380.         return $this->wareHouses;
  381.     }
  382.     /**
  383.      * @param []$wareHouses
  384.      */
  385.     public function setWareHouses($wareHouses)
  386.     {
  387.         $this->wareHouses $wareHouses;
  388.     }
  389. }