Skip to content

Commit

Permalink
[Adhesion] remove missing years contribution system
Browse files Browse the repository at this point in the history
  • Loading branch information
ottaviano committed Jan 2, 2025
1 parent 65c09f1 commit 619a4e3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 71 deletions.
4 changes: 1 addition & 3 deletions assets/pages/adhesion_funnel/components/FourthFormStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import CommonFormStep from './CommonFormStep';

/**
* First Step component for funnel
* @param {{missingYears: number}} props
* @return {AlpineComponent}
*/
const FourthForm = (props) => ({
Expand Down Expand Up @@ -34,8 +33,7 @@ const FourthForm = (props) => ({
calcCotisTotal() {
const cotis = 30 <= this.price ? 30 : 10;
const don = 10 === cotis ? 0 : this.price - cotis;
const totalCotis = props.missingYears ? props.missingYears * cotis : cotis;
const total = don + totalCotis;
const total = don + cotis;
if (7500 < total) {
return {
cotis,
Expand Down
14 changes: 8 additions & 6 deletions features/javascript/adhesion.feature
Original file line number Diff line number Diff line change
Expand Up @@ -422,15 +422,12 @@ Feature:
| membership_request[address][cityName] | Paris |
When I press "Suivant"
And I wait 3 seconds
And I should see "Cotisation pour l’année 2022"
And I should see "Cotisation pour l’année 2023"
And I should see "Cotisation pour l’année 2024"
And I should see "Cotisation pour l’année 2025"
When I press "Je cotise pour 150 €"
When I press "Je cotise pour 60 €"

# Step 5 : payment
Then I should be on "https://preprod-tpeweb.paybox.com/cgi/FramepagepaiementRWD.cgi" wait otherwise
And I wait until I see "150.00 EUR"
And I wait until I see "60.00 EUR"
When I fill in the following:
| CVVX | 123 |
| NUMERO_CARTE | 1111222233334444 |
Expand Down Expand Up @@ -529,7 +526,12 @@ Feature:
| membership_request[address][postalCode] | 75008 |
| membership_request[address][cityName] | Paris |
And I press "Suivant"
And I wait 3 seconds
And I wait 1 second
When I click the "membership_request_exclusiveMembership_0" element
And I click the "membership_request_isPhysicalPerson" element
And I click the "membership_request_allowNotifications" element
Then I click the "#step_3 .re-button" selector
And I wait 5 seconds
And I scroll element "#step_4 #amount_3_label" into view
And I click the "#step_4 #amount_4_label" selector
And I should see "Je confirme être étudiant, une personne bénéficiant des minima sociaux ou sans emploi"
Expand Down
45 changes: 0 additions & 45 deletions src/Entity/Adherent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2176,29 +2176,6 @@ public function hasActiveMembership(): bool
return $this->isRenaissanceAdherent() && $this->hasTag(TagEnum::getAdherentYearTag());
}

public function hasMembershipDonationCurrentYear(): bool
{
return $this->lastMembershipDonation && $this->lastMembershipDonation->format('Y') === date('Y');
}

public function getMissingMembershipYears(): array
{
if ($this->hasMembershipDonationCurrentYear()) {
return [];
}

$lastYear = $this->getLastMembershipYearFromTags();

if (!$lastYear) {
return [date('Y')];
}

return range(
((int) $lastYear) + 1,
(int) date('Y')
);
}

public function getLastMembershipDonation(): ?\DateTimeInterface
{
return $this->lastMembershipDonation;
Expand Down Expand Up @@ -2423,28 +2400,6 @@ public function hasTag(string $tag): bool
return TagEnum::includesTag($tag, $this->tags ?? []);
}

public function getLastMembershipYearFromTags(): ?string
{
$adherentTag = null;
foreach ($this->tags as $tag) {
if (preg_match('/^adherent:a_jour_[\d]{4}/', $tag)) {
$adherentTag = $tag;
break;
}
}

if (!$adherentTag) {
return null;
}

$matches = [];
if (preg_match('/^adherent:a_jour_([\d]{4})/', $adherentTag, $matches)) {
return $matches[1];
}

return null;
}

public function updateFromMembershipRequest(MembershipRequest $membershipRequest): void
{
if (!$this->isCertified()) {
Expand Down
24 changes: 7 additions & 17 deletions templates/renaissance/adhesion/form.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

{% form_theme form 'renaissance/forms/tailwind_form_theme.html.twig' %}

{% set isReContribution = (app.user and app.user.missingMembershipYears ? '1' : '0') %}
{% set isReContribution = app.user and app.user.isRenaissanceAdherent() %}
{% set stepsStepper = isReContribution ? ['Informations', 'Cotisation'] : ['Email', 'Informations', 'Autorisation', 'Cotisation'] %}

{% block content %}
<main class="bg-[#F4F4F7] re_new_ui">
<section x-data="xFunnelPage({initStep: {{ step }}, isReContribution: {{ isReContribution }} })" @stepper:adhesion-stepper:change.window="handleStepperChange($event.detail)">
<section x-data="xFunnelPage({initStep: {{ step }}, isReContribution: {{ isReContribution ? '1' : '0' }} })" @stepper:adhesion-stepper:change.window="handleStepperChange($event.detail)">
<header class="w-full flex flex-col p-4 bg-white sticky top-0 z-50 items-center h-auto xs:p-6 md:p-0 md:grid md:grid-cols-4 md:h-20 lg:grid-cols-3">
<div class="pb-6 md:pb-0 md:pl-8 md:px-12">
<a href="{{ path('renaissance_site') }}"><img src="{{ asset('/images/renaissance/logo-dark.svg') }}" class="h-4" alt="logo"/></a>
Expand Down Expand Up @@ -202,9 +202,7 @@
</p>
</twig:Atoms:ReCard>

{% set missing_membership_years = app.user ? app.user.missingMembershipYears : ['now'|date('Y')] %}

<twig:Atoms:ReCard class="max-w-[500px] re-step" id="step_4" x-data="FourthFormStep({missingYears: {{ missing_membership_years|length }}})">
<twig:Atoms:ReCard class="max-w-[500px] re-step" id="step_4" x-data="FourthFormStep">
<header>
<twig:Atoms:ReLabel class="mb-6">Cotisation adhérent</twig:Atoms:ReLabel>
<div class="text-ui_gray-80">
Expand Down Expand Up @@ -276,21 +274,13 @@
</twig:Molecules:ReCheckboxField>
</template>

{% if missing_membership_years|length > 1 %}
{% if isReContribution %}
<hr>
<twig:ReParagraphStatus status="info">
Quel plaisir de vous revoir ! <br>
<br>
Votre dernière cotisation a été enregistrée en {{ app.user.lastMembershipDonation|date('Y') }}.
Afin de régulariser votre situation pour {{ 'now'|date('Y') }}, nous vous remercions de procéder à son règlement.
</twig:ReParagraphStatus>

<ul class="font-medium leading-loose">
{% for year in missing_membership_years %}
<li class="flex justify-between items-center">
<span class="text-ui_gray-80">Cotisation pour l’année {{ year }}</span> <span class="text-ui_blue-50" x-text="`${calcCotisTotal().cotis} €`"></span>
</li>
{% endfor %}
<li class="flex justify-between items-center">
<span class="text-ui_gray-80">Cotisation pour l’année {{ 'now'|date('Y') }}</span> <span class="text-ui_blue-50" x-text="`${calcCotisTotal().cotis} €`"></span>
</li>
<li class="flex justify-between items-center">
<span class="text-ui_gray-80">Don</span> <span class="text-ui_green-50" x-text="`${calcCotisTotal().don} €`"></span>
</li>
Expand Down

0 comments on commit 619a4e3

Please sign in to comment.