diff --git a/src/Controller/ContributionController.php b/src/Controller/ContributionController.php
index 41d727a..86a36f2 100644
--- a/src/Controller/ContributionController.php
+++ b/src/Controller/ContributionController.php
@@ -151,6 +151,27 @@ public function payContribution(Request $request, MollieApiClient $mollieApiClie
return $this->redirect($molliePayment->getCheckoutUrl(), 303);
}
+ /**
+ * @Route("/contributie-aanpassen", name="member_contribution_change_amount")
+ */
+ public function changeContributionAmount(Request $request, MollieApiClient $mollieApiClient, bool $automaticCollection = false): Response
+ {
+ $member = $this->getUser();
+
+ $mollieCustomerId = $member->getMollieCustomerId();
+ $contributionAmount = $member->getContributionPerPeriodInEuros();
+ $subscriptionId = $member->getMollieSubscriptionId();
+ // update subscription amount
+ $updatedSubscription = $mollieApiClient->subscriptions->update($mollieCustomerId, $subscriptionId, [
+ 'amount' => [
+ 'currency' => 'EUR',
+ 'value' => number_format($contributionAmount, 2, '.', '')
+ ]
+ ]);
+
+ return $this->redirectToRoute('member_details');
+ }
+
/**
* @Route("/api/webhook/mollie-contribution", name="member_contribution_mollie_webhook")
*/
@@ -229,6 +250,38 @@ public function automaticCollection(Request $request, LoggerInterface $logger):
]);
}
+ /**
+ * @Route("/automatische-incasso-aanpassen", name="member_contribution_automatic_collection_change_amount")
+ */
+ public function automaticCollectionChangeAmount(Request $request, LoggerInterface $logger): Response
+ {
+ $projectRoot = $this->getParameter('kernel.project_dir');
+ $org_config = Yaml::parseFile($projectRoot . '/config/instances/' . $this->getParameter('app.organizationID') . '.yaml');
+
+ $form = $this->createForm(ContributionIncomeType::class, null, [
+ 'contribution' => $org_config['contribution']
+ ]);
+
+ $form->handleRequest($request);
+ if ($form->isSubmitted() && $form->isValid()) {
+ $em = $this->getDoctrine()->getManager();
+ $member = $this->getUser();
+ $member->setContributionPerPeriodInCents($form->getData());
+ $member->setContributionPeriod(Member::PERIOD_QUARTERLY);
+ $em->flush();
+
+ return $this->redirectToRoute('member_contribution_change_amount');
+ }
+
+ return $this->render('user/contribution/automatic-collection-change.html.twig', [
+ 'success' => false,
+ 'form' => $form->createView(),
+ 'contribution' => $org_config['contribution'],
+ // The user is currently setting up contribution, so setting this false disables the contribution nagbar
+ 'contributionEnabled' => false,
+ ]);
+ }
+
/**
* @Route("/automatische-incasso/inschakelen", name="member_contribution_automatic_collection_enable")
*/
diff --git a/templates/user/contribution/automatic-collection-change.html.twig b/templates/user/contribution/automatic-collection-change.html.twig
new file mode 100644
index 0000000..497490a
--- /dev/null
+++ b/templates/user/contribution/automatic-collection-change.html.twig
@@ -0,0 +1,91 @@
+{% extends 'user/layout/members.html.twig' %}
+
+{% block scripts %}
+ {{ parent() }}
+
+{% endblock %}
+
+{% block content %}
+
+
Automatische incasso
+
+ Contributie zal elk kwartaal automatisch van je rekening afgeschreven worden via automatisch incasso.
+ Hoeveel je hierbij betaalt hangt af van je inkomen.
+
+
+ {% if contribution.tiers|length > 2 %}
+
+
+
+ Maandinkomen
+ Contributie
+
+
+
+ {% for tier in contribution.tiers %}
+ {% if tier.amount is not same as(null) %}
+
+ {{ tier.description }}
+ €{{ (tier.amount / 100)|number_format(2, ',') }} per kwartaal (€{{ (tier.amount / 100 / 3)|number_format(2, ',') }} per maand)
+
+ {% endif %}
+ {% endfor %}
+
+
+ {% endif %}
+
+ {% if form.vars.submitted and not form.vars.valid %}
+
+ {{ form_errors(form) }}
+
+ {% endif %}
+
+
+ Selecteer wat er voor jou van toepassing is:
+
+ {{ form_start(form, { attr: { class: 'incomes' }}) }}
+ {{ form_row(form._token) }}
+
+
+ {% for option in form.contributionAmount %}
+
+ {{ form_widget(option) }}
+
+ {{ form_label(option, null, { required: false }) }}
+ {% if option.vars.value == 0 %}
+
+ {{ form_widget(form.otherAmount, { attr: { class: 'other-amount' } }) }} per kwartaal
+ {% endif %}
+
+
+ {% endfor %}
+
+
+
Incasso bedrag aanpassen
+ {{ form_end(form, {render_rest: false}) }}
+
+
+{% endblock %}
diff --git a/templates/user/contribution/automatic-collection.html.twig b/templates/user/contribution/automatic-collection.html.twig
index 2bc83a6..7f33d27 100644
--- a/templates/user/contribution/automatic-collection.html.twig
+++ b/templates/user/contribution/automatic-collection.html.twig
@@ -42,6 +42,7 @@
Automatische incasso stopzetten
Instellen met andere bankrekening
+ Incasso bedrag aanpassen
{% else %}
Contributie zal elk kwartaal automatisch van je rekening afgeschreven worden via automatisch incasso.
diff --git a/templates/user/details.html.twig b/templates/user/details.html.twig
index e6d207e..ece9c9f 100644
--- a/templates/user/details.html.twig
+++ b/templates/user/details.html.twig
@@ -112,6 +112,7 @@
Automatische incasso stopzetten
Instellen met andere bankrekening
+ Incasso bedrag aanpassen
{% else %}
{% if app.user.contributionCompleted(date()) %}