add methods to get budgetResources and budgetCharges in person entity

This commit is contained in:
Julie Lenaerts 2022-02-25 16:18:21 +01:00
parent fc5a893b00
commit f8d5f13a88

View File

@ -29,6 +29,8 @@ use Chill\PersonBundle\Entity\Person\PersonCurrentAddress;
use Chill\PersonBundle\Validator\Constraints\Household\HouseholdMembershipSequential; use Chill\PersonBundle\Validator\Constraints\Household\HouseholdMembershipSequential;
use Chill\PersonBundle\Validator\Constraints\Person\Birthdate; use Chill\PersonBundle\Validator\Constraints\Person\Birthdate;
use Chill\PersonBundle\Validator\Constraints\Person\PersonHasCenter; use Chill\PersonBundle\Validator\Constraints\Person\PersonHasCenter;
use Chill\BudgetBundle\Entity\Charge;
use Chill\BudgetBundle\Entity\Resource;
use DateTime; use DateTime;
use DateTimeImmutable; use DateTimeImmutable;
use DateTimeInterface; use DateTimeInterface;
@ -36,6 +38,7 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\PersistentCollection;
use Exception; use Exception;
use Symfony\Component\Serializer\Annotation\DiscriminatorMap; use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
@ -483,6 +486,26 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
*/ */
private $updatedBy; private $updatedBy;
/**
* Read-only field, computed by the database.
*
* @ORM\OneToMany(
* targetEntity=Resource::class,
* mappedBy="person"
* )
*/
private Collection $budgetResources;
/**
* Read-only field, computed by the database.
*
* @ORM\OneToMany(
* targetEntity=Charge::class,
* mappedBy="person"
* )
*/
private Collection $budgetCharges;
/** /**
* Person constructor. * Person constructor.
*/ */
@ -499,6 +522,8 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
$this->maritalStatusComment = new CommentEmbeddable(); $this->maritalStatusComment = new CommentEmbeddable();
$this->periodLocatedOn = new ArrayCollection(); $this->periodLocatedOn = new ArrayCollection();
$this->accompanyingPeriodRequested = new ArrayCollection(); $this->accompanyingPeriodRequested = new ArrayCollection();
$this->budgetResources = new ArrayCollection();
$this->budgetCharges = new ArrayCollection();
} }
/** /**
@ -522,20 +547,14 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this; return $this;
} }
/** public function addAddress(Address $address): self
* @return $this
*/
public function addAddress(Address $address)
{ {
$this->addresses[] = $address; $this->addresses[] = $address;
return $this; return $this;
} }
/** public function addAltName(PersonAltName $altName): self
* @return $this
*/
public function addAltName(PersonAltName $altName)
{ {
if (false === $this->altNames->contains($altName)) { if (false === $this->altNames->contains($altName)) {
$this->altNames->add($altName); $this->altNames->add($altName);
@ -545,6 +564,20 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this; return $this;
} }
public function addBudgetResource(Resource $budgetResource): self
{
$this->budgetResources[] = $budgetResource;
return $this;
}
public function addBudgetCharge(Charge $budgetCharge): self
{
$this->budgetCharges[] = $budgetCharge;
return $this;
}
public function addHouseholdParticipation(HouseholdMember $member): self public function addHouseholdParticipation(HouseholdMember $member): self
{ {
$this->householdParticipations[] = $member; $this->householdParticipations[] = $member;
@ -637,7 +670,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
* Used in template, to find the participation when iterating on a list * Used in template, to find the participation when iterating on a list
* of period. * of period.
* *
* @return AccompanyingPeriodParticipation
*/ */
public function findParticipationForPeriod(AccompanyingPeriod $period): ?AccompanyingPeriodParticipation public function findParticipationForPeriod(AccompanyingPeriod $period): ?AccompanyingPeriodParticipation
{ {
@ -819,6 +851,22 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this->addresses; return $this->addresses;
} }
/**
* @return Collection|BudgetResources[]
*/
public function getBudgetResources(): Collection
{
return $this->budgetResources;
}
/**
* @return Collection|BudgetCharges[]
*/
public function getBudgetCharges(): Collection
{
return $this->budgetCharges;
}
/** /**
* Return the age of a person, calculated at the date 'now'. * Return the age of a person, calculated at the date 'now'.
* *
@ -844,32 +892,17 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this->altNames; return $this->altNames;
} }
/** public function getBirthdate(): ?DateTime
* Get birthdate.
*
* @return DateTime
*/
public function getBirthdate()
{ {
return $this->birthdate; return $this->birthdate;
} }
/** public function getCenter(): ?Center
* Get center.
*
* @return Center
*/
public function getCenter()
{ {
return $this->center; return $this->center;
} }
/** public function getCFData(): ?array
* Get cFData.
*
* @return array
*/
public function getCFData()
{ {
if (null === $this->cFData) { if (null === $this->cFData) {
$this->cFData = []; $this->cFData = [];
@ -878,32 +911,17 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this->cFData; return $this->cFData;
} }
/** public function getCivility(): ?Civility
* Get civility.
*
* @return Civility
*/
public function getCivility()
{ {
return $this->civility; return $this->civility;
} }
/** public function getcontactInfo(): ?string
* Get contactInfo.
*
* @return string
*/
public function getcontactInfo()
{ {
return $this->contactInfo; return $this->contactInfo;
} }
/** public function getCountryOfBirth(): ?Country
* Get countryOfBirth.
*
* @return Chill\MainBundle\Entity\Country
*/
public function getCountryOfBirth()
{ {
return $this->countryOfBirth; return $this->countryOfBirth;
} }
@ -1047,22 +1065,12 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this->deathdate; return $this->deathdate;
} }
/** public function getEmail(): ?string
* Get email.
*
* @return string
*/
public function getEmail()
{ {
return $this->email; return $this->email;
} }
/** public function getFirstName(): string
* Get firstName.
*
* @return string
*/
public function getFirstName()
{ {
return $this->firstName; return $this->firstName;
} }
@ -1072,17 +1080,12 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this->fullnameCanonical; return $this->fullnameCanonical;
} }
/** public function getGender(): ?string
* Get gender.
*
* @return string
*/
public function getGender()
{ {
return $this->gender; return $this->gender;
} }
public function getGenderComment(): CommentEmbeddable public function getGenderComment(): ?CommentEmbeddable
{ {
return $this->genderComment; return $this->genderComment;
} }
@ -1187,22 +1190,12 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this->getCurrentPersonAddress(); return $this->getCurrentPersonAddress();
} }
/** public function getLastName(): string
* Get lastName.
*
* @return string
*/
public function getLastName()
{ {
return $this->lastName; return $this->lastName;
} }
/** public function getMaritalStatus(): ?MaritalStatus
* Get maritalStatus.
*
* @return MaritalStatus
*/
public function getMaritalStatus()
{ {
return $this->maritalStatus; return $this->maritalStatus;
} }
@ -1217,29 +1210,16 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this->maritalStatusDate; return $this->maritalStatusDate;
} }
/** public function getMemo(): ?string
* Get memo.
*
* @return string
*/
public function getMemo()
{ {
return $this->memo; return $this->memo;
} }
/**
* Get mobilenumber.
*/
public function getMobilenumber(): string public function getMobilenumber(): string
{ {
return $this->mobilenumber; return $this->mobilenumber;
} }
/**
* Get nationality.
*
* @return Country
*/
public function getNationality(): ?Country public function getNationality(): ?Country
{ {
return $this->nationality; return $this->nationality;
@ -1295,30 +1275,17 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this->otherPhoneNumbers; return $this->otherPhoneNumbers;
} }
/**
* Get phonenumber.
*/
public function getPhonenumber(): string public function getPhonenumber(): string
{ {
return $this->phonenumber; return $this->phonenumber;
} }
/** public function getPlaceOfBirth(): ?string
* Get placeOfBirth.
*
* @return string
*/
public function getPlaceOfBirth()
{ {
return $this->placeOfBirth; return $this->placeOfBirth;
} }
/** public function getSpokenLanguages(): ?Collection
* Get spokenLanguages.
*
* @return ArrayCollection
*/
public function getSpokenLanguages()
{ {
return $this->spokenLanguages; return $this->spokenLanguages;
} }
@ -1459,10 +1426,21 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
$this->addresses->removeElement($address); $this->addresses->removeElement($address);
} }
/** public function removeBudgetResource(Resource $budgetResource): self
* @return $this {
*/ $this->budgetResources->removeElement($budgetResource);
public function removeAltName(PersonAltName $altName)
return $this;
}
public function removeBudgetCharge(Charge $budgetCharge): self
{
$this->budgetCharges->removeElement($budgetCharge);
return $this;
}
public function removeAltName(PersonAltName $altName): self
{ {
if ($this->altNames->contains($altName)) { if ($this->altNames->contains($altName)) {
$altName->setPerson(null); $altName->setPerson(null);
@ -1472,10 +1450,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this; return $this;
} }
/** public function removeOtherPhoneNumber(PersonPhone $otherPhoneNumber): self
* @return $this
*/
public function removeOtherPhoneNumber(PersonPhone $otherPhoneNumber)
{ {
if ($this->otherPhoneNumbers->contains($otherPhoneNumber)) { if ($this->otherPhoneNumbers->contains($otherPhoneNumber)) {
$this->otherPhoneNumbers->removeElement($otherPhoneNumber); $this->otherPhoneNumbers->removeElement($otherPhoneNumber);
@ -1498,10 +1473,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this; return $this;
} }
/** public function setAltNames(Collection $altNames): self
* @return $this
*/
public function setAltNames(Collection $altNames)
{ {
$this->altNames = $altNames; $this->altNames = $altNames;
@ -1509,25 +1481,16 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
} }
/** /**
* Set birthdate.
*
* @param DateTime $birthdate * @param DateTime $birthdate
*
* @return Person
*/ */
public function setBirthdate($birthdate) public function setBirthdate($birthdate): self
{ {
$this->birthdate = $birthdate; $this->birthdate = $birthdate;
return $this; return $this;
} }
/** public function setCenter(Center $center): self
* Set the center.
*
* @return \Chill\PersonBundle\Entity\Person
*/
public function setCenter(Center $center)
{ {
$this->center = $center; $this->center = $center;
@ -1535,41 +1498,23 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
} }
/** /**
* Set cFData.
*
* @param array $cFData
*
* @return Report * @return Report
*/ */
public function setCFData($cFData) public function setCFData(?array $cFData)
{ {
$this->cFData = $cFData; $this->cFData = $cFData;
return $this; return $this;
} }
/** public function setCivility(?Civility $civility = null): self
* Set civility.
*
* @param Civility $civility
*
* @return Person
*/
public function setCivility(?Civility $civility = null)
{ {
$this->civility = $civility; $this->civility = $civility;
return $this; return $this;
} }
/** public function setcontactInfo($contactInfo): self
* Set contactInfo.
*
* @param string $contactInfo
*
* @return Person
*/
public function setcontactInfo($contactInfo)
{ {
if (null === $contactInfo) { if (null === $contactInfo) {
$contactInfo = ''; $contactInfo = '';
@ -1580,14 +1525,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this; return $this;
} }
/** public function setCountryOfBirth(?Country $countryOfBirth = null): self
* Set countryOfBirth.
*
* @param Chill\MainBundle\Entity\Country $countryOfBirth
*
* @return Person
*/
public function setCountryOfBirth(?Country $countryOfBirth = null)
{ {
$this->countryOfBirth = $countryOfBirth; $this->countryOfBirth = $countryOfBirth;
@ -1615,14 +1553,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this; return $this;
} }
/** public function setEmail(?string $email): self
* Set email.
*
* @param string $email
*
* @return Person
*/
public function setEmail($email)
{ {
if (null === $email) { if (null === $email) {
$email = ''; $email = '';
@ -1633,35 +1564,21 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this; return $this;
} }
/** public function setFirstName(string $firstName): self
* Set firstName.
*
* @param string $firstName
*
* @return Person
*/
public function setFirstName($firstName)
{ {
$this->firstName = $firstName; $this->firstName = $firstName;
return $this; return $this;
} }
public function setFullnameCanonical($fullnameCanonical): Person public function setFullnameCanonical($fullnameCanonical): self
{ {
$this->fullnameCanonical = $fullnameCanonical; $this->fullnameCanonical = $fullnameCanonical;
return $this; return $this;
} }
/** public function setGender(?string $gender): self
* Set gender.
*
* @param string $gender
*
* @return Person
*/
public function setGender($gender)
{ {
$this->gender = $gender; $this->gender = $gender;
@ -1675,28 +1592,14 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this; return $this;
} }
/** public function setLastName(string $lastName): self
* Set lastName.
*
* @param string $lastName
*
* @return Person
*/
public function setLastName($lastName)
{ {
$this->lastName = $lastName; $this->lastName = $lastName;
return $this; return $this;
} }
/** public function setMaritalStatus(?MaritalStatus $maritalStatus = null): self
* Set maritalStatus.
*
* @param MaritalStatus $maritalStatus
*
* @return Person
*/
public function setMaritalStatus(?MaritalStatus $maritalStatus = null)
{ {
$this->maritalStatus = $maritalStatus; $this->maritalStatus = $maritalStatus;
@ -1717,14 +1620,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this; return $this;
} }
/** public function setMemo(?string $memo): self
* Set memo.
*
* @param string $memo
*
* @return Person
*/
public function setMemo($memo)
{ {
if (null === $memo) { if (null === $memo) {
$memo = ''; $memo = '';
@ -1737,28 +1633,14 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this; return $this;
} }
/** public function setMobilenumber(?string $mobilenumber = ''): self
* Set mobilenumber.
*
* @param string $mobilenumber
*
* @return Person
*/
public function setMobilenumber(?string $mobilenumber = '')
{ {
$this->mobilenumber = (string) $mobilenumber; $this->mobilenumber = (string) $mobilenumber;
return $this; return $this;
} }
/** public function setNationality(?Country $nationality = null): self
* Set nationality.
*
* @param Chill\MainBundle\Entity\Country $nationality
*
* @return Person
*/
public function setNationality(?Country $nationality = null)
{ {
$this->nationality = $nationality; $this->nationality = $nationality;
@ -1772,38 +1654,21 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this; return $this;
} }
/** public function setOtherPhoneNumbers(Collection $otherPhoneNumbers): self
* @return $this
*/
public function setOtherPhoneNumbers(Collection $otherPhoneNumbers)
{ {
$this->otherPhoneNumbers = $otherPhoneNumbers; $this->otherPhoneNumbers = $otherPhoneNumbers;
return $this; return $this;
} }
/** public function setPhonenumber(?string $phonenumber = ''): self
* Set phonenumber.
*
* @param string $phonenumber
*
* @return Person
*/
public function setPhonenumber(?string $phonenumber = '')
{ {
$this->phonenumber = (string) $phonenumber; $this->phonenumber = (string) $phonenumber;
return $this; return $this;
} }
/** public function setPlaceOfBirth(?string $placeOfBirth): self
* Set placeOfBirth.
*
* @param string $placeOfBirth
*
* @return Person
*/
public function setPlaceOfBirth($placeOfBirth)
{ {
if (null === $placeOfBirth) { if (null === $placeOfBirth) {
$placeOfBirth = ''; $placeOfBirth = '';
@ -1815,13 +1680,9 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
} }
/** /**
* Set spokenLanguages.
*
* @param type $spokenLanguages * @param type $spokenLanguages
*
* @return Person
*/ */
public function setSpokenLanguages($spokenLanguages) public function setSpokenLanguages($spokenLanguages): self
{ {
$this->spokenLanguages = $spokenLanguages; $this->spokenLanguages = $spokenLanguages;