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