mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
Historique ménage pour une personne
This commit is contained in:
@@ -117,6 +117,41 @@ class Household
|
||||
return $this->members;
|
||||
}
|
||||
|
||||
public function getMembersOnRange(\DateTimeImmutable $from, ?\DateTimeImmutable $to): Collection
|
||||
{
|
||||
$criteria = new Criteria();
|
||||
$expr = Criteria::expr();
|
||||
|
||||
$criteria->where(
|
||||
$expr->gte('startDate', $from)
|
||||
);
|
||||
|
||||
if (NULL !== $to) {
|
||||
$criteria->andWhere(
|
||||
$expr->orX(
|
||||
$expr->lte('endDate', $to),
|
||||
$expr->eq('endDate', NULL)
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return $this->getMembers()
|
||||
->matching($criteria)
|
||||
;
|
||||
}
|
||||
|
||||
public function getMembersDuringMembership(HouseholdMember $membership)
|
||||
{
|
||||
return $this->getMembersOnRange(
|
||||
$membership->getStartDate(),
|
||||
$membership->getEndDate()
|
||||
)->filter(
|
||||
function(HouseholdMember $m) use ($membership) {
|
||||
return $m !== $membership;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public function getMembersHolder(): Collection
|
||||
{
|
||||
$criteria = new Criteria();
|
||||
|
@@ -206,4 +206,13 @@ class HouseholdMember
|
||||
{
|
||||
return $this->holder;
|
||||
}
|
||||
|
||||
public function isCurrent(\DateTimeImmutable $at = null): bool
|
||||
{
|
||||
$at = NULL === $at ? new \DateTimeImmutable('now'): $at;
|
||||
|
||||
return $this->getStartDate() < $at && (
|
||||
NULL === $this->getEndDate() || $at < $this->getEndDate()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -1209,14 +1209,44 @@ class Person implements HasCenterInterface
|
||||
return $this->householdParticipations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get participation where the person does share the household.
|
||||
*
|
||||
* Order by startDate, desc
|
||||
*/
|
||||
public function getHouseholdParticipationsShareHousehold(): Collection
|
||||
{
|
||||
$criteria = new Criteria();
|
||||
$expr = Criteria::expr();
|
||||
|
||||
$criteria->where(
|
||||
$expr->eq('shareHousehold', true)
|
||||
);
|
||||
$criteria
|
||||
->where(
|
||||
$expr->eq('shareHousehold', true)
|
||||
)
|
||||
->orderBy(['startDate' => Criteria::DESC])
|
||||
;
|
||||
|
||||
return $this->getHouseholdParticipations()
|
||||
->matching($criteria)
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get participation where the person does not share the household.
|
||||
*
|
||||
* Order by startDate, desc
|
||||
*/
|
||||
public function getHouseholdParticipationsNotShareHousehold(): Collection
|
||||
{
|
||||
$criteria = new Criteria();
|
||||
$expr = Criteria::expr();
|
||||
|
||||
$criteria
|
||||
->where(
|
||||
$expr->eq('shareHousehold', false)
|
||||
)
|
||||
->orderBy(['startDate' => Criteria::DESC])
|
||||
;
|
||||
|
||||
return $this->getHouseholdParticipations()
|
||||
->matching($criteria)
|
||||
|
Reference in New Issue
Block a user