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
4ac38f0c
Commit
4ac38f0c
authored
Jan 24, 2025
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add button in adherents admin to recalculate household allowance & move verifs
parent
0c6901dd
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
85 additions
and
7 deletions
+85
-7
AdherentAdmin.php
src/Admin/AdherentAdmin.php
+17
-2
AdherentAdminController.php
src/Controller/AdherentAdminController.php
+50
-0
UserComptoirController.php
src/Controller/UserComptoirController.php
+0
-5
TAVCotisationUtils.php
src/Utils/TAVCotisationUtils.php
+11
-0
admin_recalculate_allocations.html.twig
...kohinos/tav/block/admin_recalculate_allocations.html.twig
+7
-0
No files found.
src/Admin/AdherentAdmin.php
View file @
4ac38f0c
...
...
@@ -165,7 +165,7 @@ class AdherentAdmin extends AbstractAdmin
$tav_env
=
$this
->
getConfigurationPool
()
->
getContainer
()
->
getParameter
(
'tav_env'
);
$household_based_allowance
=
$this
->
getConfigurationPool
()
->
getContainer
()
->
getParameter
(
'household_based_allowance'
);
$simplified_household_based_allowance
=
$this
->
getConfigurationPool
()
->
getContainer
()
->
getParameter
(
'simplified_household_based_allowance'
);
// && !$simplified_household_based_allowance
$formMapper
->
tab
(
'General'
)
->
with
(
'Identité'
,
[
'class'
=>
'col-md-7'
])
...
...
@@ -893,7 +893,8 @@ class AdherentAdmin extends AbstractAdmin
parent
::
configureRoutes
(
$collection
);
$collection
->
remove
(
'delete'
)
->
add
(
'withdrawDownToTheCeiling'
,
$this
->
getRouterIdParameter
()
.
'/withdrawDownToTheCeiling'
);
->
add
(
'withdrawDownToTheCeiling'
,
$this
->
getRouterIdParameter
()
.
'/withdrawDownToTheCeiling'
)
->
add
(
'recalculateHouseholdAllocations'
,
'recalculateHouseholdAllocations'
);
}
public
function
getBatchActions
()
...
...
@@ -983,5 +984,19 @@ class AdherentAdmin extends AbstractAdmin
}
return
$res
;
}
public
function
configureActionButtons
(
$action
,
$object
=
null
)
{
$list
=
parent
::
configureActionButtons
(
$action
,
$object
);
$household_based_allowance
=
$this
->
getConfigurationPool
()
->
getContainer
()
->
getParameter
(
'household_based_allowance'
);
$simplified_household_based_allowance
=
$this
->
getConfigurationPool
()
->
getContainer
()
->
getParameter
(
'simplified_household_based_allowance'
);
if
(
$household_based_allowance
||
$simplified_household_based_allowance
)
{
$list
[
'test'
][
'template'
]
=
'@kohinos/tav/block/admin_recalculate_allocations.html.twig'
;
}
return
$list
;
}
}
src/Controller/AdherentAdminController.php
View file @
4ac38f0c
...
...
@@ -11,6 +11,8 @@ use Symfony\Component\HttpFoundation\Request;
use
Symfony\Component\HttpFoundation\Response
;
use
Symfony\Component\HttpKernel\Exception\NotFoundHttpException
;
use
Symfony\Component\Security\Core\Security
;
use
Symfony\Component\Routing\Annotation\Route
;
use
App\Entity\Adherent
;
class
AdherentAdminController
extends
CRUDController
{
...
...
@@ -54,4 +56,52 @@ class AdherentAdminController extends CRUDController
$this
->
admin
->
generateUrl
(
'list'
,
[
'filter'
=>
$this
->
admin
->
getFilterParameters
()])
);
}
/**
* Recalculate household allocation in case of switching between household allocation methods.
*
* @param Request $request
* @IsGranted({"ROLE_SUPER_ADMIN", "ROLE_ADMIN_SIEGE", "ROLE_TRESORIER"})
* @return Response
*/
public
function
recalculateHouseholdAllocationsAction
(
Request
$request
)
:
Response
{
$qb
=
$this
->
em
->
getRepository
(
Adherent
::
class
)
->
createQueryBuilder
(
'a'
);
if
(
$this
->
getParameter
(
'simplified_household_based_allowance'
))
{
$adherents
=
$qb
->
where
(
$qb
->
expr
()
->
isNotNull
(
"a.householdCount"
))
->
andWhere
(
$qb
->
expr
()
->
isNotNull
(
"a.cotisationAmount"
))
->
getQuery
()
->
getResult
();
;
foreach
(
$adherents
as
$adherent
)
{
$this
->
tavCotisationUtils
->
calculateAllowanceAccordingToHouseholdSimplified
(
$adherent
);
$this
->
em
->
persist
(
$adherent
);
}
}
else
if
(
$this
->
getParameter
(
'household_based_allowance'
))
{
$adherents
=
$qb
->
where
(
$qb
->
expr
()
->
isNotNull
(
"a.householdAdultCount"
))
->
andWhere
(
$qb
->
expr
()
->
isNotNull
(
"a.cotisationAmount"
))
->
getQuery
()
->
getResult
();
;
foreach
(
$adherents
as
$adherent
)
{
$this
->
tavCotisationUtils
->
calculateAllowanceAccordingToHousehold
(
$adherent
);
$this
->
em
->
persist
(
$adherent
);
}
}
$this
->
em
->
flush
();
$this
->
addFlash
(
'sonata_flash_success'
,
'Allocation recalculées avec succès'
);
return
new
RedirectResponse
(
$this
->
admin
->
generateUrl
(
'list'
,
[
'filter'
=>
$this
->
admin
->
getFilterParameters
()])
);
}
}
src/Controller/UserComptoirController.php
View file @
4ac38f0c
...
...
@@ -233,11 +233,6 @@ class UserComptoirController extends FluxController
return
$this
->
redirectToRoute
(
'index'
);
}
if
(
is_null
(
$destinataire
->
getAllocationAmount
()))
{
$this
->
tavCotisationUtils
->
calculateAllowanceAccordingToHouseholdSimplified
(
$destinataire
);
$this
->
em
->
persist
(
$destinataire
);
}
$flux
->
setMontant
(
$cotisationAmount
);
$this
->
em
->
persist
(
$flux
);
$this
->
operationUtils
->
executeOperations
(
$flux
);
...
...
src/Utils/TAVCotisationUtils.php
View file @
4ac38f0c
...
...
@@ -255,6 +255,17 @@ class TAVCotisationUtils
// get the mlc amount the user is supposed to receive
$mlcAllowanceAmount
=
$adherent
->
getAllocationAmount
();
// if allocation amount is null (as a security but should not occur), calculate here before applying & creating flux
if
(
is_null
(
$mlcAllowanceAmount
))
{
if
(
$this
->
container
->
getParameter
(
'simplified_household_based_allowance'
))
{
$this
->
calculateAllowanceAccordingToHouseholdSimplified
(
$adherent
);
}
else
{
$this
->
calculateAllowanceAccordingToHousehold
(
$adherent
);
}
$this
->
em
->
persist
(
$adherent
);
$mlcAllowanceAmount
=
$adherent
->
getAllocationAmount
();
}
// get the difference between what the user paid and what he•she's supposed to receive
$amountDiff
=
$mlcAllowanceAmount
-
$cotisationAmount
;
...
...
templates/themes/kohinos/tav/block/admin_recalculate_allocations.html.twig
0 → 100644
View file @
4ac38f0c
<li>
<a
class=
"sonata-action-element"
href=
"
{{
admin.generateUrl
(
'recalculateHouseholdAllocations'
)
}}
"
>
<i
class=
"fa fa-calculator"
></i>
{{
'Recalculer les allocations en fonction du foyer'
|
trans
()
}}
</a>
</li>
\ No newline at end of file
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