src/AtechNet/CoreBundle/Entity/Company.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\AtechNet\CoreBundle\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\ORM\Mapping\Column;
  5. use Doctrine\ORM\Mapping\Entity;
  6. use Doctrine\ORM\Mapping\HasLifecycleCallbacks;
  7. use Doctrine\ORM\Mapping\JoinColumn;
  8. use Doctrine\ORM\Mapping\ManyToOne;
  9. use Doctrine\ORM\Mapping\OneToMany;
  10. use Doctrine\ORM\Mapping\OrderBy;
  11. use Doctrine\ORM\Mapping\Table as Table;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. /**
  14.  * Company
  15.  *
  16.  * @Table(name="company")
  17.  * @Entity(repositoryClass="App\AtechNet\CoreBundle\Repository\CompanyRepository")
  18.  * @HasLifecycleCallbacks
  19.  */
  20. class Company extends AbstractSortableEntity
  21. {
  22.     public const int COMPANY_ID_FURBIFY_SRO = 1;
  23.     public const int COMPANY_ID_FURBIFY_HUNGARY_KFT = 2;
  24.     public const int COMPANY_ID_NEXTIT_SRO = 3;
  25.     /**
  26.      * @var int
  27.      *
  28.      * @Assert\NotNull
  29.      *
  30.      * @Column(name="code", type="decimal", unique=true)
  31.      */
  32.     private $code;
  33.     /**
  34.      * @var Language
  35.      *
  36.      * @Assert\NotNull
  37.      *
  38.      * @ManyToOne(targetEntity="Language")
  39.      * @JoinColumn(name="language_id", referencedColumnName="id")
  40.      */
  41.     private $language;
  42.     /**
  43.      * @var string
  44.      *
  45.      * @Assert\NotNull
  46.      *
  47.      * @Column(name="name", type="text")
  48.      */
  49.     private $name;
  50.     /**
  51.      * @var string
  52.      *
  53.      * @Assert\NotNull
  54.      *
  55.      * @Column(name="currency", type="text")
  56.      */
  57.     private $currency;
  58.     /**
  59.      * @var float
  60.      *
  61.      * @Column(name="vat", type="decimal", precision=10, scale=2)
  62.      */
  63.     private $vat;
  64.     /**
  65.      * @var int
  66.      *
  67.      * @Assert\NotNull
  68.      *
  69.      * @Column(name="warranty", type="integer")
  70.      */
  71.     private $warranty;
  72.     /**
  73.      * @var string
  74.      *
  75.      * @Column(name="business_id", type="string", length=16, nullable=false)
  76.      */
  77.     private $businessId;
  78.     /**
  79.      * @var string
  80.      *
  81.      * @Column(name="tax_id", type="string", length=16, nullable=false)
  82.      */
  83.     private $taxId;
  84.     /**
  85.      * @var string
  86.      *
  87.      * @Column(name="vat_id", type="string", length=16, nullable=false)
  88.      */
  89.     private $vatId;
  90.     /**
  91.      * @var string
  92.      *
  93.      * @Column(name="street", type="string", length=32, nullable=false)
  94.      */
  95.     private $street;
  96.     /**
  97.      * @var string
  98.      *
  99.      * @Column(name="city", type="string", length=32, nullable=false)
  100.      */
  101.     private $city;
  102.     /**
  103.      * @var string
  104.      *
  105.      * @Column(name="zip", type="string", length=16, nullable=false)
  106.      */
  107.     private $zip;
  108.     /**
  109.      * @var string
  110.      *
  111.      * @Column(name="country", type="string", length=2, nullable=false)
  112.      */
  113.     private $country;
  114.     /**
  115.      * @var string
  116.      *
  117.      * @Column(name="ship_street", type="string", length=32, nullable=true)
  118.      */
  119.     private $shipStreet;
  120.     /**
  121.      * @var string
  122.      *
  123.      * @Column(name="ship_city", type="string", length=32, nullable=true)
  124.      */
  125.     private $shipCity;
  126.     /**
  127.      * @var string
  128.      *
  129.      * @Column(name="ship_zip", type="string", length=16, nullable=true)
  130.      */
  131.     private $shipZip;
  132.     /**
  133.      * @var string
  134.      *
  135.      * @Column(name="ship_country", type="string", length=2, nullable=true)
  136.      */
  137.     private $shipCountry;
  138.     /**
  139.      * @var string
  140.      *
  141.      * @Column(name="iban", type="string", length=34, nullable=true)
  142.      */
  143.     private $iban;
  144.     /**
  145.      * @var string
  146.      *
  147.      * @Column(name="swift", type="string", length=10, nullable=true)
  148.      */
  149.     private $swift;
  150.     /**
  151.      * @var ArrayCollection
  152.      *
  153.      * @OneToMany(targetEntity="Stock", mappedBy="company", orphanRemoval=true)
  154.      * @OrderBy({"title" = "DESC"})
  155.      **/
  156.     private $stocks;
  157.     /**
  158.      * @var ArrayCollection
  159.      *
  160.      * @OneToMany(targetEntity="DocumentYear", mappedBy="company", orphanRemoval=true)
  161.      * @OrderBy({"created" = "DESC"})
  162.      **/
  163.     private $documentYears;
  164.     public function __construct()
  165.     {
  166.         parent::__construct();
  167.         $this->stocks = new ArrayCollection();
  168.     }
  169.     /**
  170.      * @return Language
  171.      */
  172.     public function getLanguage()
  173.     {
  174.         return $this->language;
  175.     }
  176.     /**
  177.      * @param Language $language
  178.      */
  179.     public function setLanguage($language)
  180.     {
  181.         $this->language = $language;
  182.     }
  183.     /**
  184.      * @return string
  185.      */
  186.     public function getName()
  187.     {
  188.         return $this->name;
  189.     }
  190.     /**
  191.      * @param string $name
  192.      */
  193.     public function setName($name)
  194.     {
  195.         $this->name = $name;
  196.     }
  197.     /**
  198.      * @return string
  199.      */
  200.     public function getCurrency()
  201.     {
  202.         return $this->currency;
  203.     }
  204.     /**
  205.      * @param string $currency
  206.      */
  207.     public function setCurrency($currency)
  208.     {
  209.         $this->currency = $currency;
  210.     }
  211.     /**
  212.      * @return float
  213.      */
  214.     public function getVat()
  215.     {
  216.         return $this->vat;
  217.     }
  218.     /**
  219.      * @param float $vat
  220.      */
  221.     public function setVat($vat)
  222.     {
  223.         $this->vat = $vat;
  224.     }
  225.     /**
  226.      * @Assert\IsTrue
  227.      */
  228.     public function isVatValid()
  229.     {
  230.         return $this->vat >= 0;
  231.     }
  232.     /**
  233.      * @return int
  234.      */
  235.     public function getCode()
  236.     {
  237.         return $this->code;
  238.     }
  239.     /**
  240.      * @param int $code
  241.      */
  242.     public function setCode($code)
  243.     {
  244.         $this->code = $code;
  245.     }
  246.     /**
  247.      * @return int
  248.      */
  249.     public function getWarranty()
  250.     {
  251.         return $this->warranty;
  252.     }
  253.     /**
  254.      * @param int $warranty
  255.      */
  256.     public function setWarranty($warranty)
  257.     {
  258.         $this->warranty = $warranty;
  259.     }
  260.     /**
  261.      * @return string
  262.      */
  263.     public function getBusinessId()
  264.     {
  265.         return $this->businessId;
  266.     }
  267.     /**
  268.      * @param string $businessId
  269.      */
  270.     public function setBusinessId($businessId)
  271.     {
  272.         $this->businessId = $businessId;
  273.     }
  274.     /**
  275.      * @return string
  276.      */
  277.     public function getTaxId()
  278.     {
  279.         return $this->taxId;
  280.     }
  281.     /**
  282.      * @param string $taxId
  283.      */
  284.     public function setTaxId($taxId)
  285.     {
  286.         $this->taxId = $taxId;
  287.     }
  288.     /**
  289.      * @return string
  290.      */
  291.     public function getVatId()
  292.     {
  293.         return $this->vatId;
  294.     }
  295.     /**
  296.      * @param string $vatId
  297.      */
  298.     public function setVatId($vatId)
  299.     {
  300.         $this->vatId = $vatId;
  301.     }
  302.     /**
  303.      * @return string
  304.      */
  305.     public function getStreet()
  306.     {
  307.         return $this->street;
  308.     }
  309.     /**
  310.      * @param string $street
  311.      */
  312.     public function setStreet($street)
  313.     {
  314.         $this->street = $street;
  315.     }
  316.     /**
  317.      * @return string
  318.      */
  319.     public function getCity()
  320.     {
  321.         return $this->city;
  322.     }
  323.     /**
  324.      * @param string $city
  325.      */
  326.     public function setCity($city)
  327.     {
  328.         $this->city = $city;
  329.     }
  330.     /**
  331.      * @return string
  332.      */
  333.     public function getZip()
  334.     {
  335.         return $this->zip;
  336.     }
  337.     /**
  338.      * @param string $zip
  339.      */
  340.     public function setZip($zip)
  341.     {
  342.         $this->zip = $zip;
  343.     }
  344.     /**
  345.      * @return string
  346.      */
  347.     public function getCountry()
  348.     {
  349.         return $this->country;
  350.     }
  351.     /**
  352.      * @param string $country
  353.      */
  354.     public function setCountry($country)
  355.     {
  356.         $this->country = $country;
  357.     }
  358.     /**
  359.      * @return string
  360.      */
  361.     public function getShipStreet()
  362.     {
  363.         return $this->shipStreet;
  364.     }
  365.     /**
  366.      * @param string $shipStreet
  367.      */
  368.     public function setShipStreet($shipStreet)
  369.     {
  370.         $this->shipStreet = $shipStreet;
  371.     }
  372.     /**
  373.      * @return string
  374.      */
  375.     public function getShipCity()
  376.     {
  377.         return $this->shipCity;
  378.     }
  379.     /**
  380.      * @param string $shipCity
  381.      */
  382.     public function setShipCity($shipCity)
  383.     {
  384.         $this->shipCity = $shipCity;
  385.     }
  386.     /**
  387.      * @return string
  388.      */
  389.     public function getShipZip()
  390.     {
  391.         return $this->shipZip;
  392.     }
  393.     /**
  394.      * @param string $shipZip
  395.      */
  396.     public function setShipZip($shipZip)
  397.     {
  398.         $this->shipZip = $shipZip;
  399.     }
  400.     /**
  401.      * @return string
  402.      */
  403.     public function getShipCountry()
  404.     {
  405.         return $this->shipCountry;
  406.     }
  407.     /**
  408.      * @param string $shipCountry
  409.      */
  410.     public function setShipCountry($shipCountry)
  411.     {
  412.         $this->shipCountry = $shipCountry;
  413.     }
  414.     /**
  415.      * @return ArrayCollection
  416.      */
  417.     public function getStocks()
  418.     {
  419.         return $this->stocks;
  420.     }
  421.     /**
  422.      * @return string
  423.      */
  424.     public function getIban()
  425.     {
  426.         return $this->iban;
  427.     }
  428.     /**
  429.      * @param string $iban
  430.      */
  431.     public function setIban($iban)
  432.     {
  433.         $this->iban = $iban;
  434.         return $this;
  435.     }
  436.     /**
  437.      * @return string
  438.      */
  439.     public function getSwift()
  440.     {
  441.         return $this->swift;
  442.     }
  443.     /**
  444.      * @param string $swift
  445.      */
  446.     public function setSwift($swift)
  447.     {
  448.         $this->swift = $swift;
  449.         return $this;
  450.     }
  451.     /**
  452.      * @return ArrayCollection
  453.      */
  454.     public function getDocumentYears()
  455.     {
  456.         return $this->documentYears;
  457.     }
  458.     /**
  459.      * @param string $price
  460.      * @param int $vat
  461.      * @return string
  462.      */
  463.     public function createVatPrice($price, $vat)
  464.     {
  465.         return number_format($price * $this->getVatMultiplier($vat), 2, '.', '');
  466.     }
  467.     /**
  468.      * @param int $vat
  469.      * @return int
  470.      */
  471.     public function getVatMultiplier($vat)
  472.     {
  473.         return $vat != 0 ? 1 + ($vat / 100) : 1;
  474.     }
  475. }