Commit e26663ec by Damien Moulard

merge conflicts

parents c203aeb3 3a401fc8
...@@ -405,3 +405,27 @@ form[name="formEncaissement"] label { ...@@ -405,3 +405,27 @@ form[name="formEncaissement"] label {
text-align: right; text-align: right;
font-style: italic; font-style: italic;
} }
.presta-conventionnement-applied-text {
margin-top: -0.75rem !important;
margin-bottom: 1rem;
font-size: 100%;
}
.montant-panier-error {
margin-top: -0.75rem !important;
margin-bottom: 1rem;
font-size: 100%;
color: #ff4136;
}
.input-error {
border-color: #ff4136 !important;
}
.input-error:focus {
box-shadow: 0 0 0 0.2rem #ff403667 !important;
}
.text-error {
color: #ff4136;
}
\ No newline at end of file
...@@ -494,6 +494,88 @@ $(function() { ...@@ -494,6 +494,88 @@ $(function() {
// Set payment summary on validation page // Set payment summary on validation page
let recap = `${$("#formEncaissement_adherent option:selected").text()}, montant : ${$("#formEncaissement_montant").val()} ${KOH_MLC_NAME_SMALL}`; let recap = `${$("#formEncaissement_adherent option:selected").text()}, montant : ${$("#formEncaissement_montant").val()} ${KOH_MLC_NAME_SMALL}`;
$(".payment-recap").text(recap); $(".payment-recap").text(recap);
// If conventionnement mode is active
if ($(this).find("#formEncaissement_montantPanier").length > 0) {
$("#formEncaissement_montant").prop("disabled",true);
let maxAmount = 0;
function disableMontant() {
$("#formEncaissement_montant").val("");
$("#formEncaissement_montant").prop("disabled", true);
$(".presta-conventionnement-applied-text").hide();
}
/**
* If basket amount is set and valid, enable emlc amount field & hide errors if needed.
* Else display errors.
*/
function checkMontantPanier() {
let input = $("#formEncaissement_montantPanier");
let val = input.val();
if (val === '') {
// reset
$(".montant-panier-error").hide();
input.removeClass('input-error');
disableMontant();
} else {
let basketAmount = parseFloat(val);
if (isNaN(basketAmount)) {
// display error and reset the rest
$(".montant-panier-error").show();
input.addClass('input-error');
disableMontant();
return;
}
$(".montant-panier-error").hide();
input.removeClass('input-error');
// no error: enable amount field, set max emlc amount and display helper text
$("#formEncaissement_montant").prop("disabled", false);
$(".presta-conventionnement-applied-text").show();
maxAmount = parseFloat(formEncaissementConventionnement) * basketAmount;
$(".encaissment-emlc-max-amount").text(maxAmount);
}
checkMaxAmount();
}
checkMontantPanier();
$("#formEncaissement_montantPanier").on("input", checkMontantPanier);
/**
* Check that emlc amount is valid depending on basket amount
*/
function checkMaxAmount() {
function reset() {
$("#formEncaissement_montant").removeClass('input-error');
$(".encaissment-emlc-max-amount-container").removeClass("text-error");
}
let val = $("#formEncaissement_montant").val();
if (val === '') {
reset();
} else {
let amount = parseFloat(val);
if (!isNaN(amount) && amount > maxAmount) {
$(this).addClass('input-error');
$(".encaissment-emlc-max-amount-container").addClass("text-error");
} else if (!isNaN(amount) && amount <= maxAmount) {
reset();
}
}
}
checkMaxAmount();
$("#formEncaissement_montant").on("input", checkMaxAmount);
}
} }
/** /**
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
"app": { "app": {
"js": [ "js": [
"/build/runtime.6ad5c9da.js", "/build/runtime.6ad5c9da.js",
"/build/app.435420b4.js" "/build/app.27091a64.js"
], ],
"css": [ "css": [
"/build/app.7133af83.css" "/build/app.5cdc32e6.css"
] ]
}, },
"admin": { "admin": {
......
{ {
"build/app.css": "/build/app.7133af83.css", "build/app.css": "/build/app.5cdc32e6.css",
"build/app.js": "/build/app.435420b4.js", "build/app.js": "/build/app.27091a64.js",
"build/admin.css": "/build/admin.4de55830.css", "build/admin.css": "/build/admin.4de55830.css",
"build/admin.js": "/build/admin.86a2d986.js", "build/admin.js": "/build/admin.86a2d986.js",
"build/runtime.js": "/build/runtime.6ad5c9da.js", "build/runtime.js": "/build/runtime.6ad5c9da.js",
......
...@@ -29,6 +29,15 @@ class TransactionAdherentPrestataire extends Transaction ...@@ -29,6 +29,15 @@ class TransactionAdherentPrestataire extends Transaction
protected $destinataire; protected $destinataire;
/** /**
* If the transaction is cancelled, cancellerFlux is the
* opposite TransactionPrestataireAdherent flux.
*
* @ORM\ManyToOne(targetEntity="Flux")
* @ORM\JoinColumn(name="cancellerflux_id", referencedColumnName="id", nullable=true)
*/
protected $cancellerFlux;
/**
* @return string * @return string
*/ */
public function getType(): string public function getType(): string
...@@ -43,4 +52,7 @@ class TransactionAdherentPrestataire extends Transaction ...@@ -43,4 +52,7 @@ class TransactionAdherentPrestataire extends Transaction
'destinataires' => $this->getDestinataire()->getUsers()->toArray(), 'destinataires' => $this->getDestinataire()->getUsers()->toArray(),
]; ];
} }
public function setCancellerFlux($var) {$this->cancellerFlux = $var;}
public function getCancellerFlux() {return $this->cancellerFlux;}
} }
...@@ -10,23 +10,29 @@ use Symfony\Component\Form\Extension\Core\Type\HiddenType; ...@@ -10,23 +10,29 @@ use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\DependencyInjection\ContainerInterface;
use App\Entity\Adherent; use App\Entity\Adherent;
use App\Entity\GlobalParameter;
class EncaissementFormType extends AbstractType class EncaissementFormType extends AbstractType
{ {
protected $em; protected $em;
protected $security; protected $security;
protected $container;
public function __construct( public function __construct(
EntityManagerInterface $em, EntityManagerInterface $em,
Security $security Security $security,
ContainerInterface $container
) { ) {
$this->em = $em; $this->em = $em;
$this->security = $security; $this->security = $security;
$this->container = $container;
} }
public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options)
{ {
$mlcName = $this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::MLC_NAME_SMALL);
$builder $builder
->add('adherent', EntityType::class, [ ->add('adherent', EntityType::class, [
'class' => Adherent::class, 'class' => Adherent::class,
...@@ -40,7 +46,7 @@ class EncaissementFormType extends AbstractType ...@@ -40,7 +46,7 @@ class EncaissementFormType extends AbstractType
'choice_label' => 'name' 'choice_label' => 'name'
]) ])
->add('montant', NumberType::class, [ ->add('montant', NumberType::class, [
'label' => 'Montant : ', 'label' => "Montant à payer en {$mlcName} : ",
'required' => true, 'required' => true,
'attr' => ['autocomplete' => 'off'] 'attr' => ['autocomplete' => 'off']
]) ])
...@@ -51,6 +57,20 @@ class EncaissementFormType extends AbstractType ...@@ -51,6 +57,20 @@ class EncaissementFormType extends AbstractType
]) ])
->add('save', SubmitType::class, ['label' => 'Valider']) ->add('save', SubmitType::class, ['label' => 'Valider'])
; ;
if ($this->container->getParameter('presta_self_init_and_eval')) {
$builder
->add('montantPanier', NumberType::class, [
'label' => 'Montant total du panier : ',
'required' => true,
'attr' => ['autocomplete' => 'off'],
'mapped' => false,
'help' => ''
])
;
}
} }
public function getBlockPrefix() public function getBlockPrefix()
......
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240312135007 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}
public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE flux ADD cancellerflux_id CHAR(36) DEFAULT NULL COMMENT \'(DC2Type:uuid)\'');
$this->addSql('ALTER TABLE flux ADD CONSTRAINT FK_7252313ABB04641D FOREIGN KEY (cancellerflux_id) REFERENCES flux (id)');
$this->addSql('CREATE INDEX IDX_7252313ABB04641D ON flux (cancellerflux_id)');
$this->addSql('ALTER TABLE prestataire CHANGE iban iban LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:personal_data)\'');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE flux DROP FOREIGN KEY FK_7252313ABB04641D');
$this->addSql('DROP INDEX IDX_7252313ABB04641D ON flux');
$this->addSql('ALTER TABLE flux DROP cancellerflux_id');
$this->addSql('ALTER TABLE prestataire CHANGE iban iban LONGTEXT CHARACTER SET utf8 DEFAULT NULL COLLATE `utf8_general_ci` COMMENT \'(DC2Type:personal_data)\'');
}
}
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
{% include '@kohinos/presta/block/infos.html.twig' %} {% include '@kohinos/presta/block/infos.html.twig' %}
{% endif %} {% endif %}
{# {% include '@kohinos/block/transactions.html.twig' %} #} {# {% include '@kohinos/block/transactions.html.twig' %} #}
{% include '@kohinos/block/operations.html.twig' %} {% include '@kohinos/block/operations.html.twig' with {'display_cancel_transaction_btn' : tav_env} %}
{% if not tav_env %} {% if not tav_env %}
{% if getCurrentPrestataire().mlc == true %} {% if getCurrentPrestataire().mlc == true %}
{% include '@kohinos/block/operations.html.twig' with {'title' : 'Compte de fonctionnement €', 'operations': getLastOperations(app.request, app.user, constant('App\\Enum\\CurrencyEnum::CURRENCY_EURO'))} %} {% include '@kohinos/block/operations.html.twig' with {'title' : 'Compte de fonctionnement €', 'operations': getLastOperations(app.request, app.user, constant('App\\Enum\\CurrencyEnum::CURRENCY_EURO'))} %}
......
...@@ -17,6 +17,10 @@ ...@@ -17,6 +17,10 @@
<th scope="col">Type</th> <th scope="col">Type</th>
<th scope="col">Operation</th> <th scope="col">Operation</th>
<th scope="col">Montant</th> <th scope="col">Montant</th>
{# Display column to store btn to cancel transaction adherent prestataire #}
{% if display_cancel_transaction_btn is defined and display_cancel_transaction_btn %}
<th scope="col"></th>
{% endif %}
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
...@@ -55,7 +59,28 @@ ...@@ -55,7 +59,28 @@
Moyen : {{ operation.flux.moyen|trans }} Moyen : {{ operation.flux.moyen|trans }}
</div> </div>
</td> </td>
<td class='text-right'><span class='font-weight-bold {{ (operation.montant < 0)? '':'text-primary' }}'>{{ (operation.montant < 0)? '- ':'+ ' }} {{ operation.montant|abs|number_format(2) }} {{ getCurrencyName(operation.currency) }}</span></td> <td><span class='font-weight-bold {{ (operation.montant < 0)? '':'text-primary' }}'>{{ (operation.montant < 0)? '- ':'+ ' }} {{ operation.montant|abs|number_format(2) }} {{ getCurrencyName(operation.currency) }}</span></td>
{# Display btn to cancel transaction adherent prestataire #}
{% if display_cancel_transaction_btn is defined and display_cancel_transaction_btn
and operation.flux.type is same as(constant('App\\Entity\\Transaction::TYPE_TRANSACTION_ADHERENT_PRESTATAIRE'))
and app.user in operation.flux.destinataire.users %}
<td class='text-right'>
{# If transaction has been cancelled already #}
{% if operation.flux.cancellerFlux %}
<button class="btn btn-sm" title="Cette transaction a déjà été annulée." disabled>
<i class="fas fa-undo"></i>
</button>
{% else %}
<a href="{{ path('cancel_transaction_adherent_prestataire', {'id': operation.flux.id}) }}"
type="button"
class="btn btn-sm btn-primary"
title="Annuler cette transaction."
onclick="return confirm('Êtes-vous sûr de vouloir annuler cette transaction et rembourser le client ? L\'opération est irréversible.')">
<i class="fas fa-undo"></i>
</a>
{% endif %}
</td>
{% endif %}
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<b>{{ app.session.get('_prestagere') }}</b> <b>{{ app.session.get('_prestagere') }}</b>
</div> </div>
<h2 class='text-center w-100 mt-4 mb-4'>{{ "Paiement en MonA"|trans }}</h2> <h2 class='text-center w-100 mt-4 mb-4'>{{ "Paiement"|trans }}</h2>
{% else %} {% else %}
<div class="mt-3 payment-page-header"> <div class="mt-3 payment-page-header">
<a href='{{ path('encaissement') }}'> <a href='{{ path('encaissement') }}'>
...@@ -71,10 +71,27 @@ ...@@ -71,10 +71,27 @@
<div style="display:none;"> <div style="display:none;">
{{ form_row(form.adherent) }} {{ form_row(form.adherent) }}
{{ form_row(form.montant) }} {{ form_row(form.montant) }}
{% if form.montantPanier is defined %}
{{ form_row(form.montantPanier) }}
{% endif %}
</div> </div>
{% else %} {% else %}
{{ form_row(form.adherent) }} {{ form_row(form.adherent) }}
{% if form.montantPanier is defined %}
{{ form_row(form.montantPanier) }}
<div class="presta-conventionnement-applied-text form-text text-muted" style="display:none;">
Conventionnement du point de vente : {{ conventionnement * 100 }}% ;
<span class="encaissment-emlc-max-amount-container">
le montant maximum payable en MonA est de : <span class="encaissment-emlc-max-amount"></span> MonA
</span>
</div>
<div class="montant-panier-error form-text" style="display:none;">La valeur est invalide.</div>
{% endif %}
{{ form_row(form.montant) }} {{ form_row(form.montant) }}
<br/> <br/>
{% endif %} {% endif %}
<br/> <br/>
...@@ -86,6 +103,13 @@ ...@@ -86,6 +103,13 @@
var formEncaissementValidation = '{{ validation }}'; var formEncaissementValidation = '{{ validation }}';
var KOH_MLC_NAME_SMALL = "{{ KOH_MLC_NAME_SMALL|default('') }}"; var KOH_MLC_NAME_SMALL = "{{ KOH_MLC_NAME_SMALL|default('') }}";
</script> </script>
{% if conventionnement is defined %}
<script type="text/javascript">
var formEncaissementConventionnement = '{{ conventionnement }}';
</script>
{% endif %}
{% endblock %} {% endblock %}
{% block footer %}{% endblock footer %} {% block footer %}{% endblock footer %}
\ No newline at end of file
...@@ -5,7 +5,9 @@ ...@@ -5,7 +5,9 @@
{% block content %} {% block content %}
<div class='container' style='max-width: 800px;'> <div class='container' style='max-width: 800px;'>
<div class="payment-done-container"> <div class="payment-done-container">
<h1 class="text-center w-100 mt-4 payment-done-title">Paiement réussi !</h1> <h1 class="text-center w-100 mt-4 payment-done-title">
{{ 'Paiement réussi !'|trans }}
</h1>
<br/> <br/>
...@@ -20,6 +22,12 @@ ...@@ -20,6 +22,12 @@
<br/> <br/>
{% if remainingAmount is defined %}
<h5>{{ 'Reste à payer en euros :'|trans }} {{ remainingAmount }}</h5>
<br/>
{% endif %}
<a class='btn btn-xs btn-primary mt-4' href='{{ path('encaissement') }}'> <a class='btn btn-xs btn-primary mt-4' href='{{ path('encaissement') }}'>
{{ 'Nouvel encaissement'|trans }} {{ 'Nouvel encaissement'|trans }}
</a> </a>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment