vendor/crosiersource/crosierlib-radx/src/Entity/Financeiro/Modo.php line 58

Open in your IDE?
  1. <?php
  2. namespace CrosierSource\CrosierLibRadxBundle\Entity\Financeiro;
  3. use ApiPlatform\Core\Annotation\ApiFilter;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\NumericFilter;
  6. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
  7. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  8. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\BooleanFilter;
  9. use ApiPlatform\Core\Serializer\Filter\PropertyFilter;
  10. use CrosierSource\CrosierLibBaseBundle\Doctrine\Annotations\EntityHandler;
  11. use CrosierSource\CrosierLibBaseBundle\Entity\EntityId;
  12. use CrosierSource\CrosierLibBaseBundle\Entity\EntityIdTrait;
  13. use Doctrine\ORM\Mapping as ORM;
  14. use Symfony\Component\Serializer\Annotation\Groups;
  15. use Symfony\Component\Validator\Constraints as Assert;
  16. /**
  17.  * Entidade Modo de Movimentação.
  18.  *
  19.  * Informa se a movimentação foi em 'espécie', 'cheque', 'boleto', etc.
  20.  *
  21.  * @ApiResource(
  22.  *     normalizationContext={"groups"={"modo","entityId"},"enable_max_depth"=true},
  23.  *     denormalizationContext={"groups"={"modo"},"enable_max_depth"=true},
  24.  *
  25.  *     itemOperations={
  26.  *          "get"={"path"="/fin/modo/{id}", "security"="is_granted('ROLE_FINAN')"},
  27.  *          "put"={"path"="/fin/modo/{id}", "security"="is_granted('ROLE_FINAN_MASTER')"},
  28.  *          "delete"={"path"="/fin/modo/{id}", "security"="is_granted('ROLE_FINAN_MASTER')"}
  29.  *     },
  30.  *     collectionOperations={
  31.  *          "get"={"path"="/fin/modo", "security"="is_granted('ROLE_FINAN')"},
  32.  *          "post"={"path"="/fin/modo", "security"="is_granted('ROLE_FINAN_MASTER')"}
  33.  *     },
  34.  *
  35.  *     attributes={
  36.  *          "pagination_items_per_page"=10,
  37.  *          "formats"={"jsonld", "csv"={"text/csv"}}
  38.  *     }
  39.  *
  40.  * )
  41.  * @ApiFilter(PropertyFilter::class)
  42.  *
  43.  * @ApiFilter(SearchFilter::class, properties={"descricao": "partial"})
  44.  * @ApiFilter(NumericFilter::class, properties={"id","codigo"})
  45.  * @ApiFilter(BooleanFilter::class, properties={"modoDeTransfPropria", "modoDeMovimentAgrup", "modoDeCartao", "modoDeCheque", "modoDeTransfCaixa", "modoComBancoOrigem"})
  46.  * @ApiFilter(OrderFilter::class, properties={"id", "codigo", "descricao", "updated"}, arguments={"orderParameterName"="order"})
  47.  *
  48.  * @EntityHandler(entityHandlerClass="CrosierSource\CrosierLibRadxBundle\EntityHandler\Financeiro\ModoEntityHandler")
  49.  *
  50.  * @ORM\Entity(repositoryClass="CrosierSource\CrosierLibRadxBundle\Repository\Financeiro\ModoRepository")
  51.  * @ORM\Table(name="fin_modo")
  52.  *
  53.  * @author Carlos Eduardo Pauluk
  54.  */
  55. class Modo implements EntityId
  56. {
  57.     use EntityIdTrait;
  58.     
  59.     const EM_ESPECIE 1;
  60.     const DEBITO_AUTOMATICO 2;
  61.     const CHEQUE_PROPRIO 3;
  62.     const CHEQUE_TERCEIROS 4;
  63.     const DEPOSITO_BANCARIO 5;
  64.     const BOLETO_GUIA_DDA 6;
  65.     const PIX_TRANSF_BANCARIA 7;
  66.     const RECEB_CARTAO_CREDITO 9;
  67.     const RECEB_CARTAO_DEBITO 10;
  68.     const TRANSF_ENTRE_CONTAS 11;
  69.     const MOVIMENTACAO_AGRUPADA 50;
  70.     const VIRTUAL 60;
  71.     const INDEFINIDO 99;
  72.     
  73.     /**
  74.      * @ORM\Column(name="codigo", type="integer")
  75.      * @Groups("modo")
  76.      */
  77.     public ?int $codigo null;
  78.     /**
  79.      * @ORM\Column(name="descricao", type="string")
  80.      * @Groups("modo")
  81.      */
  82.     public ?string $descricao null;
  83.     /**
  84.      * Informa se este modo é aceito para transferências próprias (entre
  85.      * carteiras).
  86.      *
  87.      * @ORM\Column(name="transf_propria", type="boolean", nullable=false)
  88.      * @Assert\NotNull()
  89.      * @Groups("modo")
  90.      */
  91.     public ?bool $modoDeTransfPropria false;
  92.     /**
  93.      *
  94.      * @ORM\Column(name="moviment_agrup", type="boolean")
  95.      * @Assert\NotNull()
  96.      * @Groups("modo")
  97.      */
  98.     public ?bool $modoDeMovimentAgrup false;
  99.     /**
  100.      *
  101.      * @ORM\Column(name="modo_cartao", type="boolean")
  102.      * @Assert\NotNull()
  103.      * @Groups("modo")
  104.      */
  105.     public ?bool $modoDeCartao false;
  106.     /**
  107.      *
  108.      * @ORM\Column(name="modo_cheque", type="boolean")
  109.      * @Groups("modo")
  110.      */
  111.     public ?bool $modoDeCheque false;
  112.     /**
  113.      * Informa se este modo é aceito para transferência/recolhimento de caixas.
  114.      *
  115.      * @ORM\Column(name="transf_caixa", type="boolean")
  116.      * @Assert\NotNull()
  117.      * @Groups("modo")
  118.      */
  119.     public ?bool $modoDeTransfCaixa false;
  120.     /**
  121.      *
  122.      * @ORM\Column(name="com_banco_origem", type="boolean", nullable=false)
  123.      * @Assert\NotNull()
  124.      * @Groups("modo")
  125.      *
  126.      * @var bool|null
  127.      */
  128.     public ?bool $modoComBancoOrigem false;
  129.     /**
  130.      * @param bool $format
  131.      * @return int|null|string
  132.      */
  133.     public function getCodigo(bool $format false)
  134.     {
  135.         if ($format) {
  136.             return str_pad($this->codigo2"0"STR_PAD_LEFT);
  137.         }
  138.         return $this->codigo;
  139.     }
  140.     /**
  141.      * @Groups("modo")
  142.      * @return string
  143.      */
  144.     public function getDescricaoMontada(): string
  145.     {
  146.         return $this->getCodigo(true) . ' - ' $this->descricao;
  147.     }
  148. }