Commit 45fbd986 by Damien Moulard

WIP: create new method to distribute TAV allowance, based on household

parent 265e0af4
...@@ -125,7 +125,7 @@ class ProfilDeCotisation ...@@ -125,7 +125,7 @@ class ProfilDeCotisation
} }
/** /**
* setContacts. * setBeneficiaires.
* *
* @param [type] $beneficiaires [description] * @param [type] $beneficiaires [description]
*/ */
......
...@@ -103,34 +103,71 @@ class TAVCotisationUtils ...@@ -103,34 +103,71 @@ class TAVCotisationUtils
* *
* Rules are as follow: * Rules are as follow:
* - 150 emlc for the first person in user's household * - 150 emlc for the first person in user's household
* - 75 emlc for each other * - 75 emlc for each other adult
* - in case of shared custody for a dependent child, apply a percentage on the "75 emlc" amount for this child: * - 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 * 25%, 50% or 75% depending on the shared custody arrangement
* *
* Once the full amount is calculated, cap user's balance. * Once the full amount is calculated, cap user's balance.
* User account balance is capped at twice the amount previously calculated. * User account balance is capped at twice the amount previously calculated.
*/ */
public function applyAllowanceAccordingToHousehold() { public function applyAllowanceAccordingToHousehold(Flux $flux) {
$profile = $flux->getDestinataire()->getProfilDeCotisation(); $adherent = $flux->getDestinataire();
$profile = $adherent->getProfilDeCotisation();
$cotisationAmount = $profile->getMontant(); $cotisationAmount = $profile->getMontant();
// TODO amounts param
// base allowance, for one adult
$mlcAllowanceAmount = 150; $mlcAllowanceAmount = 150;
// $mlcAllowanceAmount += 75 * NombreDAdultesACharge;
// for each enfant à charge $adultsCount = $adherent->getHouseholdAdultCount();
// $childAllowanceAmount = 75; if ($adultsCount == null) {
// if (custody != null) // error
// $childAllowanceAmount = $childAllowanceAmount * custody }
//
// $mlcAllowanceAmount += $childAllowanceAmount; // increment for each other adult in the household
$mlcAllowanceAmount += 75 * ($adultsCount - 1);
// // Apply cap
// $currentBalance = UserCurrentBalance; // increment allowance for each dependant child, depending on the shared custody arrangement
$dependentChildren = $adherent->getDependentChildren();
// if ($currentBalance + $mlcAllowanceAmount >= 2 * $mlcAllowanceAmount) foreach ($dependentChildren as $child) {
// $capped = true $childAllowanceAmount = 75;
// $mlcAllowanceAmount = 2 * $mlcAllowanceAmount - $currentBalance // give difference to reach max balance
if ($child->sharedCustodyPercentage != null) {
// create flux $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);
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment