Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kohinos-tav
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
6
Merge Requests
6
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
agplv3
kohinos-tav
Commits
33b04f78
Commit
33b04f78
authored
Dec 12, 2022
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apply taux cotisation at payment by adherent
parent
965b172b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
85 additions
and
33 deletions
+85
-33
FluxController.php
src/Controller/FluxController.php
+3
-0
UserAdherentController.php
src/Controller/UserAdherentController.php
+6
-2
UserComptoirController.php
src/Controller/UserComptoirController.php
+2
-31
TAVCotisationUtils.php
src/Utils/TAVCotisationUtils.php
+74
-0
No files found.
src/Controller/FluxController.php
View file @
33b04f78
...
...
@@ -22,6 +22,7 @@ use App\Flux\FluxInterface;
use
App\Security\LoginAuthenticator
;
use
App\Utils\CustomEntityManager
;
use
App\Utils\OperationUtils
;
use
App\Utils\TAVCotisationUtils
;
use
FOS\UserBundle\Model\UserManagerInterface
;
use
FOS\UserBundle\Util\TokenGeneratorInterface
;
use
Gamez\Symfony\Component\Serializer\Normalizer\UuidNormalizer
;
...
...
@@ -107,6 +108,7 @@ class FluxController extends AbstractController
Payum
$payum
,
Environment
$templating
,
OperationUtils
$operationUtils
,
TAVCotisationUtils
$tavCotisationsUtils
,
TokenGeneratorInterface
$tokenGenerator
,
ValidatorInterface
$validator
,
CsrfTokenManagerInterface
$tokenManager
,
...
...
@@ -127,6 +129,7 @@ class FluxController extends AbstractController
$this
->
validator
=
$validator
;
$this
->
tokenManager
=
$tokenManager
;
$this
->
router
=
$router
;
$this
->
tavCotisationsUtils
=
$tavCotisationsUtils
;
}
protected
function
manageFluxForm
(
Request
$request
,
Form
$form
,
$template
=
'@kohinos/flux/transaction.html.twig'
,
$params
=
[])
...
...
src/Controller/UserAdherentController.php
View file @
33b04f78
...
...
@@ -136,7 +136,7 @@ class UserAdherentController extends FluxController
$form
->
handleRequest
(
$request
);
if
(
$form
->
isSubmitted
()
&&
$form
->
isValid
())
{
// TODO: set CB payment when
functionality
validated
// TODO: set CB payment when
the functionality is
validated
$flux
=
$form
->
getData
();
if
(
null
==
$flux
->
getDon
()
||
0
==
$flux
->
getDon
()
->
getMontant
())
{
...
...
@@ -145,10 +145,14 @@ class UserAdherentController extends FluxController
$this
->
em
->
persist
(
$flux
);
$this
->
operationUtils
->
executeOperations
(
$flux
);
// Apply cotisation rate, create new flux
$this
->
tavCotisationsUtils
->
applyTauxCotisation
(
$flux
);
$this
->
em
->
flush
();
$this
->
addFlash
(
'success'
,
$this
->
translator
->
trans
(
'Cotisation payée ! [Payzen désactivé en attent du compte ;
bonification et mensualité pas encore implémentés
]'
)
$this
->
translator
->
trans
(
'Cotisation payée ! [Payzen désactivé en attent du compte ;
mensualité pas encore implémentée
]'
)
);
return
$this
->
redirectToRoute
(
'index'
);
...
...
src/Controller/UserComptoirController.php
View file @
33b04f78
...
...
@@ -12,8 +12,6 @@ use App\Entity\VenteComptoirAdherent;
use
App\Entity\VenteComptoirPrestataire
;
use
App\Entity\VenteEmlcComptoirAdherent
;
use
App\Entity\VenteEmlcComptoirPrestataire
;
use
App\Entity\TauxCotisationReversement
;
use
App\Entity\TauxCotisationPrelevement
;
use
App\Form\Type\ChangeAdherentComptoirFormType
;
use
App\Form\Type\ChangePrestataireComptoirFormType
;
use
App\Form\Type\ComptoirInfosFormType
;
...
...
@@ -24,7 +22,6 @@ use App\Form\Type\VenteComptoirPrestataireFormType;
use
App\Form\Type\VenteEmlcAdherentFormType
;
use
App\Form\Type\VenteEmlcPrestataireFormType
;
use
App\Form\Type\EncaisserCotisationAdherentFormType
;
use
App\Enum\MoyenEnum
;
use
Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted
;
use
Symfony\Component\HttpFoundation\Request
;
use
Symfony\Component\HttpFoundation\Response
;
...
...
@@ -223,34 +220,8 @@ class UserComptoirController extends FluxController
$this
->
em
->
persist
(
$flux
);
$this
->
operationUtils
->
executeOperations
(
$flux
);
// get the mlc amount the user will receive
$cotisationTaux
=
$profile
->
getTauxCotisation
();
$mlcAmount
=
$cotisationAmount
*
$cotisationTaux
;
// get the difference between what the user paid and what he•she's supposed to receive
$amountDiff
=
$mlcAmount
-
$cotisationAmount
;
if
(
$amountDiff
>
0
)
{
// User should receive more than he•she paid: send a new flux to the user to complete its cotisation
$fluxCotis
=
new
TauxCotisationReversement
();
$fluxCotis
->
setExpediteur
(
$flux
->
getExpediteur
()
->
getGroupe
()
->
getSiege
());
$fluxCotis
->
setDestinataire
(
$flux
->
getDestinataire
());
$fluxCotis
->
setMontant
(
$amountDiff
);
$fluxCotis
->
setReference
(
"Reversement cotisation après paiement de "
.
$cotisationAmount
.
"€ et application du taux "
.
$cotisationTaux
);
}
else
{
// User should receive less than he•she paid: fetch the difference from his account
$fluxCotis
=
new
TauxCotisationPrelevement
();
$fluxCotis
->
setExpediteur
(
$flux
->
getDestinataire
());
$fluxCotis
->
setDestinataire
(
$flux
->
getExpediteur
()
->
getGroupe
()
->
getSiege
());
$fluxCotis
->
setMontant
(
-
$amountDiff
);
$fluxCotis
->
setReference
(
"Prélèvement cotisation après paiement de "
.
$cotisationAmount
.
"€ et application du taux "
.
$cotisationTaux
);
}
$fluxCotis
->
setOperateur
(
$this
->
getUser
());
$fluxCotis
->
setRole
(
$this
->
getUser
()
->
getGroups
()[
0
]
->
__toString
());
$fluxCotis
->
setMoyen
(
MoyenEnum
::
MOYEN_EMLC
);
$this
->
em
->
persist
(
$fluxCotis
);
$this
->
operationUtils
->
executeOperations
(
$fluxCotis
);
// Apply cotisation rate, create new flux
$this
->
tavCotisationsUtils
->
applyTauxCotisation
(
$flux
);
$this
->
em
->
flush
();
...
...
src/Utils/TAVCotisationUtils.php
0 → 100644
View file @
33b04f78
<?php
namespace
App\Utils
;
use
App\Entity\Siege
;
use
App\Entity\Flux
;
use
App\Entity\TauxCotisationReversement
;
use
App\Entity\TauxCotisationPrelevement
;
use
App\Enum\MoyenEnum
;
use
App\Utils\CustomEntityManager
;
use
Symfony\Component\Security\Core\Security
;
class
TAVCotisationUtils
{
private
$em
;
private
$security
;
private
$operationUtils
;
public
function
__construct
(
CustomEntityManager
$em
,
Security
$security
,
OperationUtils
$operationUtils
)
{
$this
->
em
=
$em
;
$this
->
security
=
$security
;
$this
->
operationUtils
=
$operationUtils
;
}
/**
* Apply the cotisation profile rate to the amount paid
* and register the complement as a new flux
*
* Warning: EntityManager not flushed here.
*/
public
function
applyTauxCotisation
(
Flux
$flux
)
{
// get the mlc amount the user will receive
$profile
=
$flux
->
getDestinataire
()
->
getProfilDeCotisation
();
$cotisationAmount
=
$profile
->
getMontant
();
$cotisationTaux
=
$profile
->
getTauxCotisation
();
$mlcAmount
=
$cotisationAmount
*
$cotisationTaux
;
// get the difference between what the user paid and what he•she's supposed to receive
$amountDiff
=
$mlcAmount
-
$cotisationAmount
;
if
(
$flux
->
getExpediteur
()
instanceof
Siege
)
{
$siege
=
$flux
->
getExpediteur
();
}
else
{
$siege
=
$flux
->
getExpediteur
()
->
getGroupe
()
->
getSiege
();
}
if
(
$amountDiff
>
0
)
{
// User should receive more than he•she paid: send a new flux to the user to complete its cotisation
$fluxCotis
=
new
TauxCotisationReversement
();
$fluxCotis
->
setExpediteur
(
$siege
);
$fluxCotis
->
setDestinataire
(
$flux
->
getDestinataire
());
$fluxCotis
->
setMontant
(
$amountDiff
);
$fluxCotis
->
setReference
(
"Reversement cotisation après paiement de "
.
$cotisationAmount
.
"€ et application du taux "
.
$cotisationTaux
);
}
else
{
// User should receive less than he•she paid: fetch the difference from his account
$fluxCotis
=
new
TauxCotisationPrelevement
();
$fluxCotis
->
setExpediteur
(
$flux
->
getDestinataire
());
$fluxCotis
->
setDestinataire
(
$siege
);
$fluxCotis
->
setMontant
(
-
$amountDiff
);
$fluxCotis
->
setReference
(
"Prélèvement cotisation après paiement de "
.
$cotisationAmount
.
"€ et application du taux "
.
$cotisationTaux
);
}
$fluxCotis
->
setOperateur
(
$this
->
security
->
getUser
());
$fluxCotis
->
setRole
(
$this
->
security
->
getUser
()
->
getGroups
()[
0
]
->
__toString
());
$fluxCotis
->
setMoyen
(
MoyenEnum
::
MOYEN_EMLC
);
$this
->
em
->
persist
(
$fluxCotis
);
$this
->
operationUtils
->
executeOperations
(
$fluxCotis
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment