property household added to entity

This commit is contained in:
Julie Lenaerts 2022-02-24 15:49:47 +01:00
parent ed33514aee
commit f8ec0f85e5

View File

@ -11,11 +11,13 @@ declare(strict_types=1);
namespace Chill\BudgetBundle\Entity; namespace Chill\BudgetBundle\Entity;
use Chill\PersonBundle\Entity\Household\Household;
use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person;
use DateTime; use DateTime;
use DateTimeImmutable; use DateTimeImmutable;
use DateTimeInterface; use DateTimeInterface;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Ramsey\Uuid\Type\Decimal;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
/** /**
@ -26,8 +28,6 @@ use Symfony\Component\Validator\Constraints as Assert;
abstract class AbstractElement abstract class AbstractElement
{ {
/** /**
* @var decimal
*
* @ORM\Column(name="amount", type="decimal", precision=10, scale=2) * @ORM\Column(name="amount", type="decimal", precision=10, scale=2)
* @Assert\GreaterThan( * @Assert\GreaterThan(
* value=0 * value=0
@ -36,17 +36,14 @@ abstract class AbstractElement
* message="The amount cannot be empty" * message="The amount cannot be empty"
* ) * )
*/ */
private $amount; private string $amount;
/** /**
* @var string|null
*
* @ORM\Column(name="comment", type="text", nullable=true) * @ORM\Column(name="comment", type="text", nullable=true)
*/ */
private $comment; private ?string $comment;
/** /**
* @var DateTimeImmutable|null
* *
* @ORM\Column(name="endDate", type="datetime_immutable", nullable=true) * @ORM\Column(name="endDate", type="datetime_immutable", nullable=true)
* @Assert\GreaterThan( * @Assert\GreaterThan(
@ -54,82 +51,68 @@ abstract class AbstractElement
* message="The budget element's end date must be after the start date" * message="The budget element's end date must be after the start date"
* ) * )
*/ */
private $endDate; private ?DateTimeImmutable $endDate;
/** /**
* @var Person
* @ORM\ManyToOne( * @ORM\ManyToOne(
* targetEntity="\Chill\PersonBundle\Entity\Person" * targetEntity="\Chill\PersonBundle\Entity\Person"
* ) * )
*/ */
private $person; private ?Person $person = null;
/**
* @ORM\ManyToOne(
* targetEntity="\Chill\PersonBundle\Entity\Household\Household"
* )
*/
private ?Household $household = null;
/** /**
* @var DateTimeImmutable
* *
* @ORM\Column(name="startDate", type="datetime_immutable") * @ORM\Column(name="startDate", type="datetime_immutable")
* @Assert\Date * @Assert\Date
*/ */
private $startDate; private DateTimeImmutable $startDate;
/** /**
* @var string
* *
* @ORM\Column(name="type", type="string", length=255) * @ORM\Column(name="type", type="string", length=255)
*/ */
private $type; private string $type;
/** /**Getters and Setters */
* Get amount.
* public function getAmount(): float
* @return float
*/
public function getAmount()
{ {
return (float) $this->amount; return (float) $this->amount;
} }
/** public function getComment(): ?string
* Get comment.
*
* @return string|null
*/
public function getComment()
{ {
return $this->comment; return $this->comment;
} }
/** public function getEndDate(): ?DateTimeImmutable
* Get endDate.
*
* @return DateTimeImmutable|null
*/
public function getEndDate()
{ {
return $this->endDate; return $this->endDate;
} }
public function getPerson(): Person public function getPerson(): ?Person
{ {
return $this->person; return $this->person;
} }
/** public function getHousehold(): ?Household
* Get startDate. {
* return $this->household;
* @return DateTimeImmutable }
*/
public function getStartDate() public function getStartDate(): DateTimeImmutable
{ {
return $this->startDate; return $this->startDate;
} }
/** public function getType(): string
* Get type.
*
* @return string
*/
public function getType()
{ {
return $this->type; return $this->type;
} }
@ -143,40 +126,21 @@ abstract class AbstractElement
abstract public function isResource(): bool; abstract public function isResource(): bool;
/** public function setAmount(string $amount): self
* Set amount.
*
* @param string $amount
*
* @return AbstractElement
*/
public function setAmount($amount)
{ {
$this->amount = $amount; $this->amount = $amount;
return $this; return $this;
} }
/** public function setComment(?string $comment = null): self
* Set comment.
*
* @param string|null $comment
*
* @return AbstractElement
*/
public function setComment($comment = null)
{ {
$this->comment = $comment; $this->comment = $comment;
return $this; return $this;
} }
/** public function setEndDate(?DateTimeInterface $endDate = null): self
* Set endDate.
*
* @return AbstractElement
*/
public function setEndDate(?DateTimeInterface $endDate = null)
{ {
if ($endDate instanceof DateTime) { if ($endDate instanceof DateTime) {
$this->endDate = DateTimeImmutable::createFromMutable($endDate); $this->endDate = DateTimeImmutable::createFromMutable($endDate);
@ -189,19 +153,21 @@ abstract class AbstractElement
return $this; return $this;
} }
public function setPerson(Person $person) public function setPerson(Person $person): self
{ {
$this->person = $person; $this->person = $person;
return $this; return $this;
} }
/** public function setHousehold(Household $household): self
* Set startDate. {
* $this->household = $household;
* @return AbstractElement
*/ return $this;
public function setStartDate(DateTimeInterface $startDate) }
public function setStartDate(DateTimeInterface $startDate): self
{ {
if ($startDate instanceof DateTime) { if ($startDate instanceof DateTime) {
$this->startDate = DateTimeImmutable::createFromMutable($startDate); $this->startDate = DateTimeImmutable::createFromMutable($startDate);
@ -214,14 +180,7 @@ abstract class AbstractElement
return $this; return $this;
} }
/** public function setType(string $type): self
* Set type.
*
* @param string $type
*
* @return AbstractElement
*/
public function setType($type)
{ {
$this->type = $type; $this->type = $type;