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
bf498140
Commit
bf498140
authored
Apr 17, 2024
by
Yvon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add fields to fix balance in fiche adherent form for super admin only
parent
924cdf01
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
90 additions
and
1 deletions
+90
-1
AdherentAdmin.php
src/Admin/AdherentAdmin.php
+55
-1
TAVCotisationUtils.php
src/Utils/TAVCotisationUtils.php
+35
-0
No files found.
src/Admin/AdherentAdmin.php
View file @
bf498140
...
...
@@ -40,6 +40,7 @@ use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use
Symfony\Component\Form\Extension\Core\Type\ChoiceType
;
use
Symfony\Component\Form\Extension\Core\Type\CollectionType
;
use
Symfony\Component\Form\Extension\Core\Type\IntegerType
;
use
Symfony\Component\Form\Extension\Core\Type\PasswordType
;
use
Symfony\Component\Form\Extension\Core\Type\TextType
;
use
Symfony\Component\Form\Extension\Core\Type\NumberType
;
use
Symfony\Component\Form\FormError
;
...
...
@@ -359,6 +360,39 @@ class AdherentAdmin extends AbstractAdmin
])
->
end
()
->
end
();
//Add form part allowing super admin to fix balance
if
(
$this
->
getConfigurationPool
()
->
getContainer
()
->
getParameter
(
'household_based_allowance'
)
&&
$this
->
security
->
isGranted
(
'ROLE_SUPER_ADMIN'
))
{
$formMapper
->
tab
(
'General'
)
->
with
(
'Informations de cotisation'
)
->
add
(
'fixedBalance'
,
TextType
::
class
,
[
'label'
=>
"Corriger le solde suite à une erreur de cotisation"
,
'mapped'
=>
false
,
'required'
=>
false
,
'attr'
=>
[
'autocomplete'
=>
'off'
]
])
->
add
(
'justification'
,
TextType
::
class
,
[
'mapped'
=>
false
,
'required'
=>
false
,
'attr'
=>
[
'autocomplete'
=>
'off'
]
])
->
add
(
'password'
,
PasswordType
::
class
,
[
'label'
=>
'Mot de passe pour corriger le solde'
,
'mapped'
=>
false
,
'required'
=>
false
,
'data'
=>
""
,
'attr'
=>
[
'autocomplete'
=>
'off'
]
])
->
end
()
->
end
();
}
}
}
...
...
@@ -378,8 +412,8 @@ class AdherentAdmin extends AbstractAdmin
}
}
// check cotisation amount
if
(
$this
->
getConfigurationPool
()
->
getContainer
()
->
getParameter
(
'household_based_allowance'
))
{
// check cotisation amount
$adultsCount
=
$adherent
->
getHouseholdAdultCount
();
$dependentChildrenCount
=
count
(
$adherent
->
getDependentChildren
());
$minCotisationAmount
=
10
+
5
*
(
$adultsCount
-
1
)
+
5
*
$dependentChildrenCount
;
...
...
@@ -387,6 +421,26 @@ class AdherentAdmin extends AbstractAdmin
if
(
$adherent
->
getCotisationAmount
()
<
$minCotisationAmount
)
{
$event
->
getForm
()
->
get
(
'cotisationAmount'
)
->
addError
(
new
FormError
(
'Le montant minimum est de '
.
$minCotisationAmount
.
'€ (selon les données du foyer indiquées)'
));
}
// try to fix balance if required
if
(
$this
->
security
->
isGranted
(
'ROLE_SUPER_ADMIN'
)
&&
$event
->
getForm
()
->
has
(
'fixedBalance'
)
&&
$event
->
getForm
()
->
get
(
'fixedBalance'
)
->
getData
()
&&
$event
->
getForm
()
->
get
(
'fixedBalance'
)
->
getData
()
>=
0
)
{
$password
=
"cestl@fete"
;
//this password purpose is to be an additional warning for super admin and
//is not intended to be securely stored as only super admin can use this feature
if
(
$event
->
getForm
()
->
get
(
'password'
)
->
getData
()
!==
$password
)
{
$event
->
getForm
()
->
get
(
'password'
)
->
addError
(
new
FormError
(
'Mot de passe incorrect.'
));
}
elseif
(
!
$event
->
getForm
()
->
get
(
'justification'
)
->
getData
())
{
$event
->
getForm
()
->
get
(
'justification'
)
->
addError
(
new
FormError
(
'Merci de justifier cette opération sensible.'
));
}
else
{
$this
->
tavCotisationUtils
->
fixBalance
(
$adherent
,
$event
->
getForm
()
->
get
(
'fixedBalance'
)
->
getData
(),
$event
->
getForm
()
->
get
(
'justification'
)
->
getData
()
);
$em
->
flush
();
}
}
}
});
parent
::
configureFormFields
(
$formMapper
);
...
...
src/Utils/TAVCotisationUtils.php
View file @
bf498140
...
...
@@ -238,6 +238,41 @@ class TAVCotisationUtils
}
/**
* Method called to create Flux to fix balance (for household based allowance).
*/
public
function
fixBalance
(
Adherent
$adherent
,
$fixedBalance
,
$justification
)
{
$balance
=
$adherent
->
getEmlcAccount
()
->
getBalance
();
$siege
=
$this
->
em
->
getRepository
(
Siege
::
class
)
->
getTheOne
();
$amountDiff
=
$fixedBalance
-
$balance
;
if
(
$amountDiff
>=
0
)
{
//Accroissement du solde
$flux
=
new
CotisationTavReversement
();
$flux
->
setExpediteur
(
$siege
);
$flux
->
setDestinataire
(
$adherent
);
$flux
->
setReference
(
"Reversement pour corriger le solde de "
.
$balance
.
" MonA à "
.
$fixedBalance
.
" MonA : "
.
$justification
);
}
else
{
//Réduction du solde
$flux
=
new
CotisationTavPrelevement
();
$flux
->
setExpediteur
(
$adherent
);
$flux
->
setDestinataire
(
$siege
);
$flux
->
setReference
(
"Prélèvement pour corriger le solde de "
.
$balance
.
" MonA à "
.
$fixedBalance
.
" MonA : "
.
$justification
);
}
$flux
->
setMontant
(
abs
(
$amountDiff
));
$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
);
}
/**
* Get the last cotisation of an adhérent
*
* @param Adherent $adherent
...
...
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