networkOrganizationRepository->isLastParent($organization) && $this->networkUtils->isCMF($organization); } /** * Test si l'organisation est une structure (non manager) ET appartient à la CMF * @param Organization $organization * @return bool * @see UtilsTest::testIsStructureAndCMF() */ public function isStructureAndCMF(Organization $organization): bool { return $this->organizationUtils->isStructure($organization) && $this->networkUtils->isCMF($organization); } /** * Test si la structure est un manager ET qu'elle appartient à la CMF * @param Organization $organization * @return bool * @see UtilsTest::testIsManagerAndCMF() */ public function isManagerAndCMF(Organization $organization): bool { return $this->organizationUtils->isManager($organization) && $this->networkUtils->isCMF($organization); } /** * Test si l'organisation est un manager ET un dernier parent ET appartient à la CMF * @param Organization $organization * @return bool * @see UtilsTest::testIsManagerAndLastParentAndCMF() */ public function isManagerAndLastParentAndCMF(Organization $organization): bool { return $this->organizationUtils->isManager($organization) && $this->isLastParentAndCMF($organization); } /** * Test si l'organisation est un manager ET n'est pas un dernier parent ET appartient à la CMF * @param Organization $organization * @return bool * @see UtilsTest::testIsManagerAndNotLastParentAndCMF() */ public function isManagerAndNotLastParentAndCMF(Organization $organization): bool { return $this->organizationUtils->isManager($organization) && !$this->isLastParentAndCMF($organization); } /** * Retourne le niveau d'alerte de l'appel de cotisation pour une année. * @param Organization $organization * @param int $year * @return string|null * @see UtilsTest::testGetAlertStateAffiliation() */ public function getAlertState(Organization $organization, int $year) { $state = $this->cotisationApiResourcesRepository->getAffiliationState($organization->getId(), $year); $alertState = null; if ($state == self::MEMBERSHIP_WAITING || $state == self::SUBMIT_IN_PROGRESS) { $alertState = AlertStateEnum::AFFILIATION()->getValue(); } else if ($state == self::MEMBERSHIP_NOPAYMENT) { $alertState = AlertStateEnum::INVOICE()->getValue(); } else if ($this->cotisationApiResourcesRepository->isInsuranceNotDone($organization->getId(), $year)) { $alertState = AlertStateEnum::INSURANCE()->getValue(); } else if ($this->cotisationApiResourcesRepository->isNotDGVCustomer($organization->getId())) { $alertState = AlertStateEnum::ADVERTISINGINSURANCE()->getValue(); } return $alertState; } /** * Retourne dans quelle année de cotisation on est aujourd'hui * @return int * @throws \Exception * @see UtilsTest::testGetCurrentCotisationYear() */ public function getCurrentCotisationYear(): int { $today = new \DateTime('now'); $year = intval($today->format('Y')); $base_date = new \DateTime($year . '-09-01'); $dateStart = new \DateTime($year . '-01-01'); if ($today >= $dateStart && $today <= $base_date) { $cotisationYear = $year; } else { $cotisationYear = $year + 1; } return $cotisationYear; } }