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
3
Merge Requests
3
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
4bafcfee
Commit
4bafcfee
authored
Jan 24, 2023
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dont create second flux for tav cotis if rate is 1
parent
09be2c5b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
34 deletions
+38
-34
TAVCotisationUtils.php
src/Utils/TAVCotisationUtils.php
+38
-34
No files found.
src/Utils/TAVCotisationUtils.php
View file @
4bafcfee
...
...
@@ -46,48 +46,52 @@ class TAVCotisationUtils
/**
* 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.
*/
public
function
applyTauxCotisation
(
Flux
$flux
)
{
// get the mlc amount the user will receive
$profile
=
$flux
->
getDestinataire
()
->
getProfilDeCotisation
();
$cotisationAmount
=
$profile
->
getMontant
();
$cotisationTaux
=
$profile
->
getTauxCotisation
();
$mlcAmount
=
round
(
$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
();
// 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
);
// 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
(
$flux
->
getOperateur
());
$fluxCotis
->
setRole
(
$flux
->
getRole
());
$fluxCotis
->
setMoyen
(
MoyenEnum
::
MOYEN_EMLC
);
$this
->
em
->
persist
(
$fluxCotis
);
$this
->
operationUtils
->
executeOperations
(
$fluxCotis
);
}
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
(
$flux
->
getOperateur
());
$fluxCotis
->
setRole
(
$flux
->
getRole
());
$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