| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287 |
- <?php
- namespace AppBundle\Entity\Billing;
- use AppBundle\Entity\Core\Tagg;
- use AppBundle\Entity\Organization\Organization;
- use AppBundle\Entity\Product\Intangible;
- use AppBundle\Entity\Traits\ActivityPeriodTrait;
- use AppBundle\Entity\Traits\BillingRuleTrait;
- use AppBundle\Entity\Traits\LockableTrait;
- use AppBundle\Enum\Billing\PeriodicityTypeEnum;
- use Doctrine\ORM\Mapping as ORM;
- use Dunglas\ApiBundle\Annotation\Iri;
- use Symfony\Component\Validator\Constraints as Assert;
- use Doctrine\Common\Collections\ArrayCollection;
- use Symfony\Component\Serializer\Annotation\Groups;
- use AppBundle\Annotation\DefaultField;
- use AppBundle\Entity\Traits\TimestampableEntity;
- use AppBundle\Entity\Traits\CreatorUpdaterEntity;
- /**
- * Enregistrement d'un produit à facturer par une Organization, un Access ou un EducationalProject
- * Classe de base de @see AccessIntangible, EducationalProjectIntangible
- *
- *
- */
- #[ORM\Entity]
- #[ORM\Table(name: 'BillingIntangible')]
- #[ORM\InheritanceType('SINGLE_TABLE')]
- #[ORM\DiscriminatorColumn(name: 'discr', type: 'string')]
- #[ORM\DiscriminatorMap(['access' => 'AccessIntangible', 'educationalproject' => 'EducationalProjectIntangible'])]
- abstract class AbstractBillingIntangible
- {
- use TimestampableEntity;
- use CreatorUpdaterEntity;
- use ActivityPeriodTrait;
- use BillingRuleTrait;
- /**
- * @var int
- */
- #[ORM\Column(type: 'integer')]
- #[ORM\Id]
- #[ORM\GeneratedValue(strategy: 'AUTO')]
- #[Groups(['accessintangible', 'educationalprojectintangible', 'access_details', 'student_registration', 'educationalproject_details', 'accessbilling_edit'])]
- private $id;
- /**
- * @var Intangible
- */
- #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Product\Intangible', inversedBy: 'accessIntangibles')]
- #[ORM\JoinColumn(nullable: false)]
- #[Assert\NotNull]
- #[Groups(['accessintangible', 'accessintangible_intangible', 'educationalprojectintangible', 'access_details_accessintangibles', 'student_registration_accessintangibles', 'educationalproject_details_educationalprojectintangibles', 'accessbilling_edit_accessintangibles', 'access_intangible_list'])]
- private $intangible;
- /**
- * @var string
- *
- * @Iri("https://schema.org/description")
- */
- #[ORM\Column(type: 'text', nullable: true)]
- #[Assert\Type(type: 'string')]
- #[Groups(['accessintangible', 'educationalprojectintangible', 'student_registration_accessintangibles', 'accessbilling_edit_accessintangibles', 'access_intangible_list'])]
- private $customDescription;
- /**
- * @var int
- */
- #[ORM\Column(type: 'integer', nullable: true)]
- #[Assert\Type(type: 'integer', message: 'invalid-integer')]
- #[Groups(['accessintangible', 'educationalprojectintangible', 'student_registration_accessintangibles', 'accessbilling_edit_accessintangibles'])]
- private $quantity;
- /**
- * @var float
- */
- #[ORM\Column(type: 'float', nullable: true)]
- #[Assert\Type(type: 'float')]
- #[Groups(['accessintangible', 'educationalprojectintangible', 'student_registration_accessintangibles', 'accessbilling_edit_accessintangibles'])]
- private $forcedAmount;
- /**
- * @var bool
- */
- #[ORM\Column(type: 'boolean', options: ['default' => false])]
- #[Assert\Type(type: 'boolean')]
- #[Assert\NotNull]
- #[Groups(['accessintangible', 'educationalprojectintangible', 'student_registration_accessintangibles', 'accessbilling_edit_accessintangibles'])]
- private $isForcedAmount = false;
- /**
- * @var ArrayCollection<Tagg>
- */
- #[ORM\ManyToMany(targetEntity: 'AppBundle\Entity\Core\Tagg', cascade: ['persist'], inversedBy: 'billingIntangibles')]
- #[Assert\Valid]
- #[ORM\JoinTable(name: 'tag_billingIntangible', joinColumns: [], inverseJoinColumns: [])]
- #[ORM\JoinColumn(name: 'billingIntangible_id', referencedColumnName: 'id')]
- #[ORM\JoinColumn(name: 'tag_id', referencedColumnName: 'id')]
- #[Groups(['billingintangible_tags', 'manage_tags', 'access_intangible_list'])]
- private $tags;
- /**
- * The constructor
- */
- public function __construct() {
- $this->tags= new ArrayCollection();
- }
- /**
- * Sets id.
- *
- * @param int $id
- *
- * @return $this
- */
- public function setId($id)
- {
- $this->id = $id;
- return $this;
- }
- /**
- * Gets id.
- *
- * @return int
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * Set customDescription
- *
- * @param string $customDescription
- *
- * @return AbstractBillingIntangible
- */
- public function setCustomDescription($customDescription)
- {
- $this->customDescription = $customDescription;
- return $this;
- }
- /**
- * Get customDescription
- *
- * @return string
- */
- public function getCustomDescription()
- {
- return $this->customDescription;
- }
- /**
- * Set quantity
- *
- * @param integer $quantity
- *
- * @return AbstractBillingIntangible
- */
- public function setQuantity($quantity)
- {
- $this->quantity = $quantity;
- return $this;
- }
- /**
- * Get quantity
- *
- * @return integer
- */
- public function getQuantity()
- {
- return $this->quantity;
- }
- /**
- * Set forcedAmount
- *
- * @param float $forcedAmount
- *
- * @return AbstractBillingIntangible
- */
- public function setForcedAmount($forcedAmount)
- {
- $this->forcedAmount = floatval($forcedAmount);
- return $this;
- }
- /**
- * Get forcedAmount
- *
- * @return float
- */
- public function getForcedAmount()
- {
- return $this->forcedAmount;
- }
- /**
- * Set isForcedAmount
- *
- * @param boolean $isForcedAmount
- *
- * @return AbstractBillingIntangible
- */
- public function setIsForcedAmount($isForcedAmount)
- {
- $this->isForcedAmount = $isForcedAmount;
- return $this;
- }
- /**
- * Get isForcedAmount
- *
- * @return boolean
- */
- public function getIsForcedAmount()
- {
- return $this->isForcedAmount;
- }
- /**
- * Set intangible
- *
- * @param \AppBundle\Entity\Product\Intangible $intangible
- *
- * @return AbstractBillingIntangible
- */
- public function setIntangible(\AppBundle\Entity\Product\Intangible $intangible)
- {
- $this->intangible = $intangible;
- return $this;
- }
- /**
- * Get intangible
- *
- * @return \AppBundle\Entity\Product\Intangible
- */
- public function getIntangible()
- {
- return $this->intangible;
- }
- /**
- * Add tag
- *
- * @param \AppBundle\Entity\Core\Tagg $tag
- *
- * @return AbstractBillingIntangible
- */
- public function addTag(\AppBundle\Entity\Core\Tagg $tag)
- {
- $this->tags[] = $tag;
- return $this;
- }
- /**
- * Remove tag
- *
- * @param \AppBundle\Entity\Core\Tagg $tag
- */
- public function removeTag(\AppBundle\Entity\Core\Tagg $tag)
- {
- $this->tags->removeElement($tag);
- }
- /**
- * Get tags
- *
- * @return \Doctrine\Common\Collections\Collection
- */
- public function getTags()
- {
- return $this->tags;
- }
- /**
- * Sets start date
- *
- * @param \DateTime $startDate
- * @return $this
- */
- public function setStartDate(\DateTime $startDate = null) {
- if($startDate == null) $startDate = new \DateTime();
- $this->startDate = $startDate;
- if(!empty($this->getIntangible()) && $this->getIntangible()->getBillingPeriodicityType() === PeriodicityTypeEnum::PUNCTUAL){
- $this->setEndDate($startDate);
- }
- return $this;
- }
- public function setEndDate(\DateTime $endDate = null) {
- if(empty($endDate) && !empty($this->getIntangible()) && $this->getIntangible()->getBillingPeriodicityType() === PeriodicityTypeEnum::PUNCTUAL){
- return $this;
- }
- $this->endDate = $endDate;
- return $this;
- }
- }
|