simplification cumul versements

FossilOrigin-Name: e4a942b3cc6913da11da2dfd480b2f71703c1781911e8d7c5e0a57c1b170bfd8
This commit is contained in:
engel 2022-03-25 15:09:55 +00:00
parent 83cc830fb1
commit b1645828fc
6 changed files with 44 additions and 84 deletions

View file

@ -13,7 +13,7 @@ class Personne
public $codePostal;
public $ville;
public $courriel;
public $versements; // tableau des versements totaux par activité/tarif
public $versements; // versements par taux de réduction
public function __construct(
$id,
@ -30,7 +30,7 @@ class Personne
$this->codePostal = $codePostal;
$this->ville = $ville;
$this->courriel = $courriel;
$this->versements = array();
$this->versements = array(); // clé = tarif, valeur = montant
}
/**
@ -49,24 +49,21 @@ class Personne
/**
* ajouter un versement
* @param $idActivite
* @param $idTarif
* @param $montant
* @param $tauxReduction
* @param $montant
*/
public function ajouterVersement(
$idActivite,
$idTarif,
$montant,
$tauxReduction
$tauxReduction,
$montant
)
{
$this->versements[] =
new Versement(
$idActivite,
$idTarif,
$montant,
$tauxReduction
);
if (array_key_exists($tauxReduction, $this->versements))
{
$this->versements[$tauxReduction] += $montant;
}
else
{
$this->versements[$tauxReduction] = $montant;
}
}
}

View file

@ -72,6 +72,7 @@ class Utils
/**
* @return versements correspondants à l'année et aux tarifs donnés
* triés par tarif, nom, date
* @param $annee
* @param array $tarifs
* @param array $champsNom : liste non vide des champs de nom/prénom
@ -209,7 +210,7 @@ class Utils
* @param $annee
* @param array $champsNom : champs qui définissent le nom et le prénom d'une personne
*/
public static function getDonateurs($annee, $champsNom)
public static function getDonateurs($annee, $champsNom) : array
{
// concaténer les champs nom/prénoms pour la sélection
$nom = 'trim(' . Utils::combinerChamps($champsNom) . ') as nom,';
@ -241,7 +242,16 @@ class Utils
GROUP by membres.id
ORDER by " . $tri . " COLLATE U_NOCASE
";
return DB::getInstance()->get($sql, $annee);
$donateurs = array();
foreach (DB::getInstance()->iterate($sql, $annee) as $personne)
{
$donateurs[$personne->idUser] = new Personne($personne->idUser,
$personne->nom,
$personne->adresse,
$personne->codePostal,
$personne->ville);
}
return $donateurs;
}
public static function getLignesReduction($lesTaux)