Commit 4bafcfee by Damien Moulard

dont create second flux for tav cotis if rate is 1

parent 09be2c5b
...@@ -46,16 +46,19 @@ class TAVCotisationUtils ...@@ -46,16 +46,19 @@ class TAVCotisationUtils
/** /**
* Apply the cotisation profile rate to the amount paid * Apply the cotisation profile rate to the amount paid
* and register the complement as a new flux * and register the complement as a new flux (only if rate != 1)
* *
* Warning: EntityManager not flushed here. * Warning: EntityManager not flushed here.
*/ */
public function applyTauxCotisation(Flux $flux) public function applyTauxCotisation(Flux $flux)
{ {
// get the mlc amount the user will receive
$profile = $flux->getDestinataire()->getProfilDeCotisation(); $profile = $flux->getDestinataire()->getProfilDeCotisation();
$cotisationAmount = $profile->getMontant();
$cotisationTaux = $profile->getTauxCotisation(); $cotisationTaux = $profile->getTauxCotisation();
// don't need to create an other Flux if the rate is 1
if ($cotisationTaux != 1) {
// calculate the mlc amount the user will receive
$cotisationAmount = $profile->getMontant();
$mlcAmount = round($cotisationAmount * $cotisationTaux); $mlcAmount = round($cotisationAmount * $cotisationTaux);
// get the difference between what the user paid and what he•she's supposed to receive // get the difference between what the user paid and what he•she's supposed to receive
...@@ -89,6 +92,7 @@ class TAVCotisationUtils ...@@ -89,6 +92,7 @@ class TAVCotisationUtils
$this->em->persist($fluxCotis); $this->em->persist($fluxCotis);
$this->operationUtils->executeOperations($fluxCotis); $this->operationUtils->executeOperations($fluxCotis);
} }
}
/** /**
* Get the last cotisation of an adhérent * Get the last cotisation of an adhérent
......
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