Skip to content

Commit

Permalink
Revert "[Tags] update year tag pattern (#11354)"
Browse files Browse the repository at this point in the history
This reverts commit 0c3998f.
  • Loading branch information
ottaviano authored Jan 24, 2025
1 parent 28a1d9b commit dc2c3e0
Show file tree
Hide file tree
Showing 19 changed files with 117 additions and 132 deletions.
9 changes: 4 additions & 5 deletions features/api/adherent_messages.feature
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,10 @@ Feature:
"adherent:a_jour_2025": "Adhérent - À jour 2025",
"adherent:a_jour_2025:primo": "Adhérent - À jour 2025 - Primo-adhérent",
"adherent:a_jour_2025:recotisation": "Adhérent - À jour 2025 - Recotisation",
"adherent:a_jour_2025:elu_a_jour": "Adhérent - À jour 2025 - Élu à jour",
"adherent:plus_a_jour": "Adhérent - Plus à jour",
"adherent:plus_a_jour:annee_2024": "Adhérent - Plus à jour - À jour 2024",
"adherent:plus_a_jour:annee_2023": "Adhérent - Plus à jour - À jour 2023",
"adherent:plus_a_jour:annee_2022": "Adhérent - Plus à jour - À jour 2022",
"adherent:a_jour_2025:elu_a_jour": "Adhérent - À jour 2025 - Car à jour de cotisation élu",
"adherent:a_jour_2024": "Adhérent - À jour 2024",
"adherent:a_jour_2023": "Adhérent - À jour 2023",
"adherent:a_jour_2022": "Adhérent - À jour 2022",
"sympathisant": "Sympathisant",
"sympathisant:adhesion_incomplete": "Sympathisant - Adhésion incomplète",
"sympathisant:compte_em": "Sympathisant - Ancien compte En Marche",
Expand Down
52 changes: 28 additions & 24 deletions features/api/adherents.feature
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,15 @@ Feature:
"nationality": "FR",
"tags": [
{
"code": "adherent:a_jour_2025:recotisation",
"label": "Adhérent à jour 2025",
"code": "adherent:a_jour_2025",
"label": "À jour 2025",
"type": "adherent"
},
{
"code": "elu:cotisation_ok:exempte",
"label": "Exempté de cotisation",
"type": "elu"
},
{
"type": "role",
"label": "Délégué de circonscription",
Expand Down Expand Up @@ -466,10 +471,15 @@ Feature:
"nationality": "FR",
"tags": [
{
"code": "adherent:a_jour_2025:recotisation",
"label": "Adhérent à jour 2025",
"code": "adherent:a_jour_2025",
"label": "À jour 2025",
"type": "adherent"
},
{
"code": "elu:cotisation_ok:exempte",
"label": "Exempté de cotisation",
"type": "elu"
},
{
"type": "role",
"label": "Délégué de circonscription",
Expand Down Expand Up @@ -649,10 +659,15 @@ Feature:
"nationality": "FR",
"tags": [
{
"code": "adherent:a_jour_2025:recotisation",
"label": "Adhérent à jour 2025",
"code": "adherent:a_jour_2025",
"label": "À jour 2025",
"type": "adherent"
},
{
"code": "elu:cotisation_ok:exempte",
"label": "Exempté de cotisation",
"type": "elu"
},
{
"type": "role",
"label": "Délégué de circonscription",
Expand Down Expand Up @@ -916,11 +931,10 @@ Feature:
"adherent:a_jour_2025": "Adhérent - À jour 2025",
"adherent:a_jour_2025:primo": "Adhérent - À jour 2025 - Primo-adhérent",
"adherent:a_jour_2025:recotisation": "Adhérent - À jour 2025 - Recotisation",
"adherent:a_jour_2025:elu_a_jour": "Adhérent - À jour 2025 - Élu à jour",
"adherent:plus_a_jour": "Adhérent - Plus à jour",
"adherent:plus_a_jour:annee_2024": "Adhérent - Plus à jour - À jour 2024",
"adherent:plus_a_jour:annee_2023": "Adhérent - Plus à jour - À jour 2023",
"adherent:plus_a_jour:annee_2022": "Adhérent - Plus à jour - À jour 2022",
"adherent:a_jour_2025:elu_a_jour": "Adhérent - À jour 2025 - Car à jour de cotisation élu",
"adherent:a_jour_2024": "Adhérent - À jour 2024",
"adherent:a_jour_2023": "Adhérent - À jour 2023",
"adherent:a_jour_2022": "Adhérent - À jour 2022",
"sympathisant": "Sympathisant",
"sympathisant:adhesion_incomplete": "Sympathisant - Adhésion incomplète",
"sympathisant:compte_em": "Sympathisant - Ancien compte En Marche",
Expand Down Expand Up @@ -1160,11 +1174,6 @@ Feature:
"phone": "+33 1 87 26 42 36",
"nationality": "FR",
"tags": [
{
"code": "adherent:a_jour_2025:recotisation",
"label": "Adhérent à jour 2025",
"type": "adherent"
},
{
"type": "role",
"label": "Président assemblée départementale",
Expand Down Expand Up @@ -1235,11 +1244,6 @@ Feature:
"phone": "+33 1 87 26 42 36",
"nationality": "FR",
"tags": [
{
"code": "adherent:a_jour_2025:recotisation",
"label": "Adhérent à jour 2025",
"type": "adherent"
},
{
"type": "role",
"label": "Président assemblée départementale",
Expand Down Expand Up @@ -1303,7 +1307,7 @@ Feature:
"""
{
"adherent": 6,
"sympathizer": 3
"sympathizer": 2
}
"""
When I send a "GET" request to "/api/v3/adherents/count?scope=president_departmental_assembly&since=2022"
Expand All @@ -1313,7 +1317,7 @@ Feature:
{
"adherent": 6,
"adherent_since": 5,
"sympathizer": 3
"sympathizer": 2
}
"""
When I send a "POST" request to "/api/v3/adherents/count?scope=president_departmental_assembly" with body:
Expand All @@ -1324,7 +1328,7 @@ Feature:
And the JSON should be equal to:
"""
{
"adherent": 3,
"adherent": 2,
"sympathizer": 1
}
"""
10 changes: 5 additions & 5 deletions features/api/committees.feature
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Feature:
"created_at": "@[email protected]()",
"updated_at": "@[email protected]()",
"name": "Second Comité des 3 communes",
"members_count": 3,
"members_count": 2,
"members_em_count": 0,
"sympathizers_count": 0
}
Expand All @@ -61,7 +61,7 @@ Feature:
And the JSON should be equal to:
"""
{
"members_count": 3,
"members_count": 2,
"members_em_count": 0,
"sympathizers_count": 0,
"description": "Un petit comité avec seulement 3 communes",
Expand Down Expand Up @@ -115,7 +115,7 @@ Feature:
And the JSON should be equal to:
"""
{
"members_count": 3,
"members_count": 2,
"members_em_count": 0,
"sympathizers_count": 0,
"description": "Un petit comité avec seulement 3 communes",
Expand Down Expand Up @@ -172,7 +172,7 @@ Feature:
And the JSON should be equal to:
"""
{
"members_count": 3,
"members_count": 2,
"members_em_count": 0,
"sympathizers_count": 0,
"description": "my desc",
Expand Down Expand Up @@ -228,7 +228,7 @@ Feature:
And the JSON should be equal to:
"""
{
"members_count": 3,
"members_count": 2,
"members_em_count": 0,
"sympathizers_count": 0,
"description": "my desc",
Expand Down
9 changes: 4 additions & 5 deletions features/api/elected_representatives.feature
Original file line number Diff line number Diff line change
Expand Up @@ -362,11 +362,10 @@ Feature:
"adherent:a_jour_2025": "Adhérent - À jour 2025",
"adherent:a_jour_2025:primo": "Adhérent - À jour 2025 - Primo-adhérent",
"adherent:a_jour_2025:recotisation": "Adhérent - À jour 2025 - Recotisation",
"adherent:a_jour_2025:elu_a_jour": "Adhérent - À jour 2025 - Élu à jour",
"adherent:plus_a_jour": "Adhérent - Plus à jour",
"adherent:plus_a_jour:annee_2024": "Adhérent - Plus à jour - À jour 2024",
"adherent:plus_a_jour:annee_2023": "Adhérent - Plus à jour - À jour 2023",
"adherent:plus_a_jour:annee_2022": "Adhérent - Plus à jour - À jour 2022",
"adherent:a_jour_2025:elu_a_jour": "Adhérent - À jour 2025 - Car à jour de cotisation élu",
"adherent:a_jour_2024": "Adhérent - À jour 2024",
"adherent:a_jour_2023": "Adhérent - À jour 2023",
"adherent:a_jour_2022": "Adhérent - À jour 2022",
"sympathisant": "Sympathisant",
"sympathisant:adhesion_incomplete": "Sympathisant - Adhésion incomplète",
"sympathisant:compte_em": "Sympathisant - Ancien compte En Marche",
Expand Down
2 changes: 1 addition & 1 deletion features/api/events.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2172,7 +2172,7 @@ Feature:
| gisele-berthoux@caramail.com | delegated_b24fea43-ecd8-4bf4-b500-6f97886ab77c | DELETE | /0e5f9f02-fa33-4c2c-a700-4235d752315b/image |

Scenario: As connected user I can subscribe to an event
Given I am logged with "[email protected]" via OAuth client "JeMengage Mobile" with scope "jemarche_app"
Given I am logged with "[email protected]" via OAuth client "JeMengage Mobile" with scope "jemarche_app"
When I send a "POST" request to "/api/v3/events/2b7238f9-10ca-4a39-b8a4-ad7f438aa95f/subscribe"
Then the response status code should be 400
And the JSON should be equal to:
Expand Down
6 changes: 3 additions & 3 deletions features/api/profile.feature
Original file line number Diff line number Diff line change
Expand Up @@ -1362,7 +1362,7 @@ Feature:
"name": "Comité des 3 communes"
},
{
"members_count": 3,
"members_count": 2,
"sympathizers_count": 0,
"members_em_count": 0,
"description": "Un petit comité avec seulement 3 communes",
Expand Down Expand Up @@ -1655,7 +1655,7 @@ Feature:
"""

Scenario: As a logged-in user I can unregister
Given I am logged with "[email protected]" via OAuth client "JeMengage Mobile"
Given I am logged with "[email protected]" via OAuth client "JeMengage Mobile"
When I send a "POST" request to "/api/v3/profile/unregister" with body:
"""
{
Expand Down Expand Up @@ -1728,7 +1728,7 @@ Feature:
"type": "committee",
"uuid": "@uuid@",
"name": "Second Comité des 3 communes",
"members_count": 3,
"members_count": 2,
"assembly_committees_count": 2,
"can_change_committee": true,
"message": null
Expand Down
2 changes: 1 addition & 1 deletion features/api/statutory_message.feature
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ Feature:
"label": "Message statutaire de test",
"subject": "Voici un message statutaire",
"status": "draft",
"recipient_count": 3,
"recipient_count": 2,
"preview_link": null,
"source": "api",
"author": {
Expand Down
8 changes: 1 addition & 7 deletions features/api/user.feature
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,7 @@ Feature:
"total": 7,
"last_month": 7
},
"tags": [
{
"code": "adherent:a_jour_2025:recotisation",
"label": "Adhérent à jour 2025",
"type": "adherent"
}
],
"tags": [],
"cadre_access": true,
"cadre_auth_path": "/oauth/v2/auth?scope=jemengage_admin&response_type=code&client_id=4498e44f-f214-110d-8b76-98a83f9d2b0c&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fauth",
"instances": {
Expand Down
18 changes: 2 additions & 16 deletions src/Adherent/Tag/TagEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ class TagEnum extends Enum
public const ADHERENT_YEAR_RECOTISATION_TAG_PATTERN = self::ADHERENT_YEAR_TAG_PATTERN.':recotisation';
public const ADHERENT_YEAR_ELU_TAG_PATTERN = self::ADHERENT_YEAR_TAG_PATTERN.':elu_a_jour';

public const ADHERENT_NOT_UP_TO_DATE = self::ADHERENT.':plus_a_jour';
public const ADHERENT_NOT_UP_TO_DATE_TAG_PATTERN = self::ADHERENT_NOT_UP_TO_DATE.':annee_%s';

public const SYMPATHISANT = 'sympathisant';
public const SYMPATHISANT_COMPTE_EM = 'sympathisant:compte_em';
public const SYMPATHISANT_COMPTE_AVECVOUS_JEMENGAGE = 'sympathisant:compte_avecvous_jemengage';
Expand Down Expand Up @@ -53,7 +50,6 @@ public static function getAdherentTags(bool $adherentOnly = false): array
\sprintf(self::ADHERENT_YEAR_PRIMO_TAG_PATTERN, $currentYear),
\sprintf(self::ADHERENT_YEAR_RECOTISATION_TAG_PATTERN, $currentYear),
\sprintf(self::ADHERENT_YEAR_ELU_TAG_PATTERN, $currentYear),
self::ADHERENT_NOT_UP_TO_DATE,
],
array_map(
fn (int $year) => self::getAdherentYearTag($year),
Expand Down Expand Up @@ -94,19 +90,9 @@ public static function getStaticTags(): array
];
}

public static function getAdherentYearTag(?int $year = null, ?string $tag = null): string
public static function getAdherentYearTag(?int $year = null, string $tag = self::ADHERENT_YEAR_TAG_PATTERN): string
{
$currentYear = date('Y');

if (!$tag) {
if (!$year || $currentYear == $year) {
$tag = self::ADHERENT_YEAR_TAG_PATTERN;
} else {
$tag = self::ADHERENT_NOT_UP_TO_DATE_TAG_PATTERN;
}
}

return \sprintf($tag, $year ?? $currentYear);
return \sprintf($tag, $year ?? date('Y'));
}

public static function includesTag(string $searchTag, array $previousTags): bool
Expand Down
25 changes: 16 additions & 9 deletions src/Adherent/Tag/TagGenerator/AdherentStatusTagGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ public function generate(Adherent $adherent, array $previousTags): array
return [\sprintf(TagEnum::ADHERENT_YEAR_RECOTISATION_TAG_PATTERN, $currentYear)];
}

if (\count($adherent->getConfirmedPayments()) || $adherent->hasRecentContribution()) {
if (
\count($adherent->getConfirmedPayments())
|| $adherent->hasRecentContribution()
) {
return [\sprintf(TagEnum::ADHERENT_YEAR_ELU_TAG_PATTERN, $currentYear)];
}

Expand All @@ -54,8 +57,10 @@ public function generate(Adherent $adherent, array $previousTags): array
&& $totalContributionPaymentsByYear[$currentYear] >= 30
&& (
!$adherent->findElectedRepresentativeMandates(true)
|| $adherent->exemptFromCotisation
|| ContributionStatusEnum::NOT_ELIGIBLE === $adherent->getContributionStatus()
|| (
$adherent->exemptFromCotisation
|| ContributionStatusEnum::NOT_ELIGIBLE === $adherent->getContributionStatus()
)
)
) {
return [\sprintf(TagEnum::ADHERENT_YEAR_ELU_TAG_PATTERN, $currentYear)];
Expand All @@ -66,25 +71,27 @@ public function generate(Adherent $adherent, array $previousTags): array
array_keys($countCotisationByYear),
array_keys($totalContributionPaymentsByYear)
));

unset($allYears[$currentYear]);
rsort($allYears);
sort($allYears);
$allYears = array_reverse($allYears);

foreach ($allYears as $year) {
if (\array_key_exists($year, $countCotisationByYear)) {
return [TagEnum::getAdherentYearTag($year)];
return [\sprintf(TagEnum::ADHERENT_YEAR_TAG_PATTERN, $year)];
}

if (
\array_key_exists($year, $totalContributionPaymentsByYear)
&& $totalContributionPaymentsByYear[$year] >= 30
&& (
!$adherent->findElectedRepresentativeMandates(true)
|| $adherent->exemptFromCotisation
|| ContributionStatusEnum::NOT_ELIGIBLE === $adherent->getContributionStatus()
|| (
$adherent->exemptFromCotisation
|| ContributionStatusEnum::NOT_ELIGIBLE === $adherent->getContributionStatus()
)
)
) {
return [TagEnum::getAdherentYearTag($year)];
return [\sprintf(TagEnum::ADHERENT_YEAR_TAG_PATTERN, $year)];
}
}
}
Expand Down
Loading

0 comments on commit dc2c3e0

Please sign in to comment.