Commit 5d8738cb by Yvon

WIP

parent 7ba7843f
......@@ -242,6 +242,38 @@ class UserController extends AbstractController
return $this->redirectToRoute('index');
}
/**
* @param Request $request
* @param TransactionAdherentPrestataire $transactionAdherentPrestataire
* @return void
* @Security("is_granted('ROLE_PRESTATAIRE') or is_granted('ROLE_CAISSIER')")
* @Route("/cancel-transaction-adherent-prestataire/{id}", name="cancel_transaction_adherent_prestataire")
*/
public function cancelTransactionAdherentPrestataireAction(Request $request, TransactionAdherentPrestataire $transactionAdherentPrestataire)
{
//Make sure current user is destinataire of transaction
if(!in_array($this->getUser(),$transactionAdherentPrestataire->getDestinataire()->getUsers())) {
$this->addFlash(
'error',
"Vous n'êtes pas autorisé à annuler cette transaction."
);
return $this->redirectToRoute('index');
}
// Check prestataire has enough funds
$balance = $transactionAdherentPrestataire->getDestinataire()->getEmlcAccount()->getBalance();
//I think this is unlikely in real situation but we need to make sure prestataire has enough founds
if ($balance < $transactionAdherentPrestataire->getMontant()) {
$this->addFlash(
'error',
'Fonds insuffisants pour annuler cette transaction.'
);
return $this->redirectToRoute('index');
}
//TODO: Save transaction
}
/**
* @Route("/encaissement", name="encaissement")
* @IsGranted({"ROLE_CAISSIER", "ROLE_PRESTATAIRE"})
......
......@@ -17,6 +17,11 @@
<th scope="col">Type</th>
<th scope="col">Operation</th>
<th scope="col">Montant</th>
{# Display column to store btn to cancel transaction adherent prestataire #}
{% if operation.flux.type = constant('App\\Entity\\Transaction::TYPE_TRANSACTION_ADHERENT_PRESTATAIRE')
and app.user in operation.flux.destinataire %}
<th scope="col"></th>
{% endif %}
</tr>
</thead>
<tbody>
......@@ -56,6 +61,15 @@
</div>
</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>
{# Display btn to cancel transaction adherent prestataire #}
{% if operation.flux.type = constant('App\\Entity\\Transaction::TYPE_TRANSACTION_ADHERENT_PRESTATAIRE')
and app.user in operation.flux.destinataire %}
<td>
<a href="{{ path('cancel_transactio_adherent_prestataire', {'id': operation.flux.id}) }}" type="button" class="button button-danger">
<i class="fa fa-remove" aria-hidden="true"></i>
</a>
</td>
{% endif %}
</tr>
{% endfor %}
</tbody>
......
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