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
45fbd986
Commit
45fbd986
authored
Mar 12, 2024
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: create new method to distribute TAV allowance, based on household
parent
265e0af4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
21 deletions
+58
-21
ProfilDeCotisation.php
src/Entity/ProfilDeCotisation.php
+1
-1
TAVCotisationUtils.php
src/Utils/TAVCotisationUtils.php
+57
-20
No files found.
src/Entity/ProfilDeCotisation.php
View file @
45fbd986
...
...
@@ -125,7 +125,7 @@ class ProfilDeCotisation
}
/**
* set
Contact
s.
* set
Beneficiaire
s.
*
* @param [type] $beneficiaires [description]
*/
...
...
src/Utils/TAVCotisationUtils.php
View file @
45fbd986
...
...
@@ -103,34 +103,71 @@ class TAVCotisationUtils
*
* Rules are as follow:
* - 150 emlc for the first person in user's household
* - 75 emlc for each other
* -
in case of shared custody for a dependent child, apply a percentage on the "75 emlc" amount for this child
:
* - 75 emlc for each other
adult
* -
75 emlc amount for each dependant child, with a percentage applied if the child is in shared custody
:
* 25%, 50% or 75% depending on the shared custody arrangement
*
* Once the full amount is calculated, cap user's balance.
* User account balance is capped at twice the amount previously calculated.
*/
public
function
applyAllowanceAccordingToHousehold
()
{
$profile
=
$flux
->
getDestinataire
()
->
getProfilDeCotisation
();
public
function
applyAllowanceAccordingToHousehold
(
Flux
$flux
)
{
$adherent
=
$flux
->
getDestinataire
();
$profile
=
$adherent
->
getProfilDeCotisation
();
$cotisationAmount
=
$profile
->
getMontant
();
// TODO amounts param
// base allowance, for one adult
$mlcAllowanceAmount
=
150
;
// $mlcAllowanceAmount += 75 * NombreDAdultesACharge;
// for each enfant à charge
// $childAllowanceAmount = 75;
// if (custody != null)
// $childAllowanceAmount = $childAllowanceAmount * custody
//
// $mlcAllowanceAmount += $childAllowanceAmount;
// // Apply cap
// $currentBalance = UserCurrentBalance;
// if ($currentBalance + $mlcAllowanceAmount >= 2 * $mlcAllowanceAmount)
// $capped = true
// $mlcAllowanceAmount = 2 * $mlcAllowanceAmount - $currentBalance // give difference to reach max balance
// create flux
$adultsCount
=
$adherent
->
getHouseholdAdultCount
();
if
(
$adultsCount
==
null
)
{
// error
}
// increment for each other adult in the household
$mlcAllowanceAmount
+=
75
*
(
$adultsCount
-
1
);
// increment allowance for each dependant child, depending on the shared custody arrangement
$dependentChildren
=
$adherent
->
getDependentChildren
();
foreach
(
$dependentChildren
as
$child
)
{
$childAllowanceAmount
=
75
;
if
(
$child
->
sharedCustodyPercentage
!=
null
)
{
$childAllowanceAmount
=
$childAllowanceAmount
*
$child
->
sharedCustodyPercentage
;
}
$mlcAllowanceAmount
+=
$childAllowanceAmount
;
}
// Apply cap
$currentBalance
=
$adherent
->
getEmlcAccount
()
->
getBalance
();
$capped
=
false
;
if
(
$currentBalance
+
$mlcAllowanceAmount
>=
2
*
$mlcAllowanceAmount
)
{
// Allow difference to reach max balance
$mlcAllowanceAmount
=
2
*
$mlcAllowanceAmount
-
$currentBalance
;
$capped
=
true
;
}
// Create Flux
if
(
$flux
->
getExpediteur
()
instanceof
Siege
)
{
$siege
=
$flux
->
getExpediteur
();
}
else
{
$siege
=
$flux
->
getExpediteur
()
->
getGroupe
()
->
getSiege
();
}
// TODO new flux entity ? use same entities ?
$fluxCotis
=
new
TauxCotisationReversement
();
$fluxCotis
->
setExpediteur
(
$siege
);
$fluxCotis
->
setDestinataire
(
$flux
->
getDestinataire
());
$fluxCotis
->
setMontant
(
$amountDiff
);
$fluxCotis
->
setReference
(
"Reversement allocation après paiement de "
.
$cotisationAmount
.
"€ et calcul en fonction du foyer."
);
$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