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
261e7f4f
Commit
261e7f4f
authored
Mar 19, 2024
by
Yvon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
in adherent admin, add column showing balance vs ceiling and withdraw btn for super admin and siege
parent
b9d2a992
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
139 additions
and
3 deletions
+139
-3
services.yaml
config/services.yaml
+1
-1
AdherentAdmin.php
src/Admin/AdherentAdmin.php
+20
-2
AdherentAdminController.php
src/Controller/AdherentAdminController.php
+57
-0
Adherent.php
src/Entity/Adherent.php
+6
-0
CotisationTavPrelevement.php
src/Entity/CotisationTavPrelevement.php
+2
-0
TAVCotisationUtils.php
src/Utils/TAVCotisationUtils.php
+31
-0
adherent_action_withdraw_down_to_the_ceiling.html.twig
...av/adherent_action_withdraw_down_to_the_ceiling.html.twig
+7
-0
list_user_ssa_ceiling.html.twig
templates/themes/kohinos/tav/list_user_ssa_ceiling.html.twig
+15
-0
No files found.
config/services.yaml
View file @
261e7f4f
...
@@ -253,7 +253,7 @@ services:
...
@@ -253,7 +253,7 @@ services:
admin.adherent.gerer
:
admin.adherent.gerer
:
class
:
App\Admin\AdherentAdmin
class
:
App\Admin\AdherentAdmin
# arguments: [~, App\Entity\OBJECT, 'PixSortableBehaviorBundle:SortableAdmin']
# arguments: [~, App\Entity\OBJECT, 'PixSortableBehaviorBundle:SortableAdmin']
arguments
:
[
~
,
App\Entity\Adherent
,
'
App\Controller\
CRUD\CRUD
Controller'
]
arguments
:
[
~
,
App\Entity\Adherent
,
'
App\Controller\
AdherentAdmin
Controller'
]
tags
:
tags
:
-
name
:
sonata.admin
-
name
:
sonata.admin
manager_type
:
orm
manager_type
:
orm
...
...
src/Admin/AdherentAdmin.php
View file @
261e7f4f
...
@@ -583,6 +583,7 @@ class AdherentAdmin extends AbstractAdmin
...
@@ -583,6 +583,7 @@ class AdherentAdmin extends AbstractAdmin
->
addIdentifier
(
'user.email'
,
null
,
[
'label'
=>
'Email'
])
->
addIdentifier
(
'user.email'
,
null
,
[
'label'
=>
'Email'
])
;
;
$actions
=
[
'edit'
=>
[]];
if
(
!
$this
->
getConfigurationPool
()
->
getContainer
()
->
getParameter
(
'tav_env'
))
{
if
(
!
$this
->
getConfigurationPool
()
->
getContainer
()
->
getParameter
(
'tav_env'
))
{
$listMapper
$listMapper
->
add
(
->
add
(
...
@@ -603,6 +604,21 @@ class AdherentAdmin extends AbstractAdmin
...
@@ -603,6 +604,21 @@ class AdherentAdmin extends AbstractAdmin
'template'
=>
'@kohinos/tav/list_user_tav_cotisation.html.twig'
,
'template'
=>
'@kohinos/tav/list_user_tav_cotisation.html.twig'
,
]
]
);
);
if
(
$this
->
getConfigurationPool
()
->
getContainer
()
->
getParameter
(
'household_based_allowance'
)
&&
$this
->
security
->
isGranted
(
'ROLE_SUPER_ADMIN'
)
||
$this
->
security
->
isGranted
(
'ROLE_ADMIN_SIEGE'
))
{
$listMapper
->
add
(
'ceiling'
,
null
,
[
'label'
=>
'Solde & plafond'
,
'template'
=>
'@kohinos/tav/list_user_ssa_ceiling.html.twig'
,
]
);
$actions
[
'withdrawDownToTheCeiling'
]
=
[
'template'
=>
'@kohinos/tav/adherent_action_withdraw_down_to_the_ceiling.html.twig'
];
}
}
}
$listMapper
$listMapper
...
@@ -625,7 +641,7 @@ class AdherentAdmin extends AbstractAdmin
...
@@ -625,7 +641,7 @@ class AdherentAdmin extends AbstractAdmin
'label'
=>
'Mis à jour le'
,
'label'
=>
'Mis à jour le'
,
])
])
->
add
(
'_action'
,
null
,
[
->
add
(
'_action'
,
null
,
[
'actions'
=>
[
'edit'
=>
[]]
,
'actions'
=>
$actions
,
])
])
;
;
}
}
...
@@ -633,7 +649,9 @@ class AdherentAdmin extends AbstractAdmin
...
@@ -633,7 +649,9 @@ class AdherentAdmin extends AbstractAdmin
protected
function
configureRoutes
(
RouteCollection
$collection
)
protected
function
configureRoutes
(
RouteCollection
$collection
)
{
{
parent
::
configureRoutes
(
$collection
);
parent
::
configureRoutes
(
$collection
);
$collection
->
remove
(
'delete'
);
$collection
->
remove
(
'delete'
)
->
add
(
'withdrawDownToTheCeiling'
,
$this
->
getRouterIdParameter
()
.
'/withdrawDownToTheCeiling'
);
}
}
public
function
getBatchActions
()
public
function
getBatchActions
()
...
...
src/Controller/AdherentAdminController.php
0 → 100644
View file @
261e7f4f
<?php
namespace
App\Controller
;
use
App\Utils\CustomEntityManager
;
use
App\Utils\TAVCotisationUtils
;
use
Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted
;
use
Sonata\AdminBundle\Controller\CRUDController
;
use
Symfony\Component\HttpFoundation\RedirectResponse
;
use
Symfony\Component\HttpFoundation\Request
;
use
Symfony\Component\HttpFoundation\Response
;
use
Symfony\Component\HttpKernel\Exception\NotFoundHttpException
;
use
Symfony\Component\Security\Core\Security
;
class
AdherentAdminController
extends
CRUDController
{
protected
$em
;
protected
$security
;
protected
$tavCotisationUtils
;
public
function
__construct
(
CustomEntityManager
$em
,
Security
$security
,
TAVCotisationUtils
$tavCotisationUtils
)
{
$this
->
em
=
$em
;
$this
->
security
=
$security
;
$this
->
tavCotisationUtils
=
$tavCotisationUtils
;
}
/**
* Prélèvement d'un adhérent pour ramener son solde sous son plafond.
*
* @param Request $request
* @param Uuid $id Id du prestataire
* @IsGranted({"ROLE_SUPER_ADMIN", "ROLE_ADMIN_SIEGE"})
* @return Response
*/
public
function
withdrawDownToTheCeilingAction
(
Request
$request
,
$id
)
:
Response
{
$adherent
=
$this
->
admin
->
getSubject
();
if
(
!
$adherent
)
{
throw
new
NotFoundHttpException
(
sprintf
(
'Impossible de trouver l\'adhérent avec l\'id: %s'
,
$id
));
}
$amountDiff
=
$this
->
tavCotisationUtils
->
withdrawDownToTheCeiling
(
$adherent
);
$this
->
em
->
flush
();
$this
->
addFlash
(
'sonata_flash_success'
,
'Prélèvement de '
.
$amountDiff
.
' MonA'
.
' effectué.'
);
return
new
RedirectResponse
(
$this
->
admin
->
generateUrl
(
'list'
,
[
'filter'
=>
$this
->
admin
->
getFilterParameters
()])
);
}
}
src/Entity/Adherent.php
View file @
261e7f4f
...
@@ -446,4 +446,10 @@ class Adherent extends AccountableObject implements AccountableInterface
...
@@ -446,4 +446,10 @@ class Adherent extends AccountableObject implements AccountableInterface
return
$this
;
return
$this
;
}
}
public
function
getCeiling
()
{
//This formula has been configured for ssa gironde project
return
2
*
$this
->
allocationAmount
;
}
}
}
src/Entity/CotisationTavPrelevement.php
View file @
261e7f4f
...
@@ -10,6 +10,8 @@ use Doctrine\ORM\Mapping as ORM;
...
@@ -10,6 +10,8 @@ use Doctrine\ORM\Mapping as ORM;
* Dans les cas suivants :
* Dans les cas suivants :
* - [Profil de Cotisation] La taux est inférieur à 1
* - [Profil de Cotisation] La taux est inférieur à 1
* - [Allocation selon foyer] Le montant reçu calculé est inférieur au montant payé
* - [Allocation selon foyer] Le montant reçu calculé est inférieur au montant payé
* - [Allocation selon foyer] Un administrateur effectue une opération manuelle de prélèvement de l'adhérent
* pour ramener son solde au niveau de son plafond.
*
*
* L'adhérent•e reçoit moins d'emlc que ce qu'elle•il paye en €,
* L'adhérent•e reçoit moins d'emlc que ce qu'elle•il paye en €,
* un second flux est créé pour prélever le complément de la cotisation.
* un second flux est créé pour prélever le complément de la cotisation.
...
...
src/Utils/TAVCotisationUtils.php
View file @
261e7f4f
...
@@ -184,6 +184,37 @@ class TAVCotisationUtils
...
@@ -184,6 +184,37 @@ class TAVCotisationUtils
$this
->
em
->
persist
(
$fluxCotis
);
$this
->
em
->
persist
(
$fluxCotis
);
$this
->
operationUtils
->
executeOperations
(
$fluxCotis
);
$this
->
operationUtils
->
executeOperations
(
$fluxCotis
);
}
}
/**
* Method called to create Flux based on allowance amount (for household based allowance).
*/
public
function
withdrawDownToTheCeiling
(
Adherent
$adherent
)
{
$balance
=
$adherent
->
getEmlcAccount
()
->
getBalance
();
$ceiling
=
$adherent
->
getCeiling
();
$siege
=
$this
->
em
->
getRepository
(
Siege
::
class
)
->
getTheOne
();
// get the amount we want to withdraw
$amountDiff
=
$ceiling
-
$balance
;
if
(
$amountDiff
>=
0
)
{
throw
new
\Exception
(
"Impossible de prélèver : le solde de l'adhérent est inférieur ou égal au plafond."
);
}
$flux
=
new
CotisationTavPrelevement
();
$flux
->
setExpediteur
(
$adherent
);
$flux
->
setDestinataire
(
$siege
);
$flux
->
setMontant
(
-
$amountDiff
);
$flux
->
setReference
(
"Prélèvement pour ramener le solde de "
.
$balance
.
"MonA sous le plafond de "
.
$ceiling
.
" MonA."
);
$flux
->
setOperateur
(
$this
->
security
->
getUser
());
$flux
->
setRole
(
$this
->
security
->
getUser
()
->
getGroups
()[
0
]
->
__toString
());
$flux
->
setMoyen
(
MoyenEnum
::
MOYEN_EMLC
);
$this
->
em
->
persist
(
$flux
);
$this
->
operationUtils
->
executeOperations
(
$flux
);
return
$amountDiff
;
}
/**
/**
* Get the last cotisation of an adhérent
* Get the last cotisation of an adhérent
*
*
...
...
templates/themes/kohinos/tav/adherent_action_withdraw_down_to_the_ceiling.html.twig
0 → 100644
View file @
261e7f4f
{%
set
balance
=
object.user.adherent.emlcAccount.balance
%}
{%
set
ceiling
=
object.user.adherent.ceiling
%}
{%
if
balance
and
ceiling
and
balance
>
ceiling
%}
<a
class=
"btn btn-sm btn-default"
href=
"
{{
admin.generateObjectUrl
(
'withdrawDownToTheCeiling'
,
object
)
}}
"
>
Prélever
</a>
{%
endif
%}
templates/themes/kohinos/tav/list_user_ssa_ceiling.html.twig
0 → 100644
View file @
261e7f4f
{%
extends
admin.getTemplate
(
'base_list_field'
)
%}
{%
block
field
%}
{%
-
spaceless
%}
{%
set
balance
=
object.user.adherent.emlcAccount.balance
%}
{%
set
ceiling
=
object.user.adherent.ceiling
%}
{%
if
balance
and
ceiling
and
balance
>
ceiling
%}
{%
set
class
=
'label label-danger'
%}
{%
set
text
=
balance
~
' > '
~
ceiling
%}
{%
else
%}
{%
set
class
=
'label label-success'
%}
{%
set
text
=
balance
~
" ≤ "
~
ceiling
%}
{%
endif
%}
<span
class=
"
{{
class
}}
"
>
{{
text
|
raw
}}
</span>
{%
endspaceless
-
%}
{%
endblock
%}
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