From 3acbd2038e3afd15272a9bb8470207a090596627 Mon Sep 17 00:00:00 2001 From: engel <> Date: Fri, 18 Feb 2022 11:51:13 +0000 Subject: [PATCH] =?UTF-8?q?gestion=20compl=C3=A8te=20taux=20r=C3=A9duction?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FossilOrigin-Name: 65f4c90bd70dda1733695d52ff242e58fe10220efee4077c813f49961d2686bc --- lib/Personne.php | 6 ++++-- lib/RecusPDF.php | 4 ++-- lib/Utils.php | 19 +++++++++++++++++- lib/Versement.php | 7 +++++-- www/admin/config.php | 4 +--- www/admin/generer_activites.php | 32 ++++++++++++++++++++---------- www/admin/generer_personnes.php | 8 ++------ www/admin/index.php | 3 +++ www/admin/versements_activites.php | 4 +++- www/admin/versements_personnes.php | 2 ++ 10 files changed, 61 insertions(+), 28 deletions(-) diff --git a/lib/Personne.php b/lib/Personne.php index 02c73ec..ab34dbf 100644 --- a/lib/Personne.php +++ b/lib/Personne.php @@ -58,13 +58,15 @@ class Personne public function ajouterVersement( $idActivite, $idTarif, - $montant + $montant, + $tauxReduction ) { $this->versements[] = new Versement( $idActivite, $idTarif, - $montant + $montant, + $tauxReduction ); } } diff --git a/lib/RecusPDF.php b/lib/RecusPDF.php index 87d1f41..9891cc2 100644 --- a/lib/RecusPDF.php +++ b/lib/RecusPDF.php @@ -164,9 +164,9 @@ class RecusPDF extends tFPDF "Le bénéficiaire reconnaît avoir reçu au titre des dons et versements ouvrant droit à réduction d'impôt :", 'LTR', 1); - foreach ($lesMontants as $montant) + foreach ($lesMontants as $taux => $montant) { - $this->imprimer_montant(" - la somme de ", $montant, "aide aux personnes en difficulté"); + $this->imprimer_montant(" - la somme de ", $montant, Utils::getLigneReduction($taux)); } $this->Cell(0, 3, "", 'LR', 1); $this->imprimer_description('Date des versements : ', diff --git a/lib/Utils.php b/lib/Utils.php index a0798f9..0d0bfb2 100644 --- a/lib/Utils.php +++ b/lib/Utils.php @@ -139,6 +139,23 @@ class Utils return DB::getInstance()->get($sql, $annee); } + public static function getLignesReduction($lesTaux) + { + foreach ($lesTaux as $elem) + { + $ligne = "taux " . $elem->taux . ", ligne " . $elem->ligne; + if ($elem->remarque != "") { + $ligne .= ", " . $elem->remarque; + } + $lignes[$elem->taux] = $ligne; + } + return $lignes; + } + public static function getLigneReduction($taux) + { + return $_SESSION['ligneReduction'][$taux]; + } + // ------------------------------------------------------------ /** @@ -373,7 +390,7 @@ class Utils * @param tableau des versements par personne */ static function genererRecus() { - + } /** diff --git a/lib/Versement.php b/lib/Versement.php index 0a4a5bf..3ac3f07 100644 --- a/lib/Versement.php +++ b/lib/Versement.php @@ -12,10 +12,13 @@ class Versement public function __construct( $idActivite, $idTarif, - $montant - ) { + $montant, + $tauxReduction + ) + { $this->idActivite = $idActivite; $this->idTarif = $idTarif; $this->montant = $montant; + $this->tauxReduction = $tauxReduction; } } diff --git a/www/admin/config.php b/www/admin/config.php index e773b51..5fdd667 100644 --- a/www/admin/config.php +++ b/www/admin/config.php @@ -4,7 +4,7 @@ namespace Garradin; $session->requireAccess($session::SECTION_CONFIG, $session::ACCESS_ADMIN); $art_sel=f('articlesCGI') ? : []; -error_log("art sel=" . print_r($art_sel, true) . "\n"); + if (f('save') && $form->check('recusfiscaux_config')) { try { @@ -18,9 +18,7 @@ if (f('save') && $form->check('recusfiscaux_config')) foreach ($art_sel as $article) { $confArticles[$article]->valeur = 1; } - error_log("confArticles=" . print_r($confArticles, true) . "\n"); $plugin->setConfig("articlesCGI", $confArticles); - error_log("plugin->config=" . print_r($plugin->getConfig("articlesCGI"), true) . "\n"); \Garradin\Utils::redirect(PLUGIN_URL . 'config.php?ok'); } catch (UserException $e) diff --git a/www/admin/generer_activites.php b/www/admin/generer_activites.php index c9a24e9..26f7d95 100644 --- a/www/admin/generer_activites.php +++ b/www/admin/generer_activites.php @@ -41,8 +41,14 @@ foreach ($totalPersonnes as $idPersonne => $personne) { ); // extraire les montants des versements $lesMontants = array(); - foreach ($personne->versements as $versement) { - $lesMontants[] = $versement->montant; + foreach ($personne->versements as $versement) + { + if (array_key_exists($versement->tauxReduction, $lesMontants)) { + $lesMontants[$versement->tauxReduction] += $versement->montant; + } + else { + $lesMontants[$versement->tauxReduction] = $versement->montant; + } } $pdf->imprimer_recu( $_SESSION['annee_recu'], @@ -82,16 +88,19 @@ function cumulerVersements($versements) $idTarif_courant = -1; $idPersonne_courant = -1; $totalVersements = 0; - foreach ($versements as $ligne) { + foreach ($versements as $ligne) + { if ( $ligne->idTarif != $idTarif_courant || $ligne->idUser != $idPersonne_courant - ) { + ) + { if ($idTarif_courant != -1) { - $totalPersonnes["$idPersonne_courant"]->ajouterVersement( + $totalPersonnes[$idPersonne_courant]->ajouterVersement( $_SESSION['lesTarifs'][$idTarif_courant]->idActivite, $idTarif_courant, - $totalVersements/100 + $totalVersements/100, + $_SESSION['tauxSelectionnes'][$idTarif_courant] ); } $idTarif_courant = $ligne->idTarif; @@ -108,11 +117,12 @@ function cumulerVersements($versements) } } // et le dernier - $totalPersonnes["$idPersonne_courant"]->ajouterVersement( - $_SESSION['lesTarifs'][$idTarif_courant]->idActivite, - $idTarif_courant, - $totalVersements/100 - ); + $totalPersonnes[$idPersonne_courant]->ajouterVersement( + $_SESSION['lesTarifs'][$idTarif_courant]->idActivite, + $idTarif_courant, + $totalVersements/100, + $_SESSION['tauxSelectionnes'][$idTarif_courant] + ); return $totalPersonnes; } diff --git a/www/admin/generer_personnes.php b/www/admin/generer_personnes.php index a676037..696410d 100644 --- a/www/admin/generer_personnes.php +++ b/www/admin/generer_personnes.php @@ -15,15 +15,10 @@ foreach ($lesLignes as $ligne) { $versementsSelectionnes[] = $_SESSION['lesVersementsTotaux'][$ligne]; } -error_log("versements sélectionnés " . print_r($versementsSelectionnes, true)); - // générer les reçus $nomAsso = Utils::getNomAsso(); $adresseAsso = Utils::getAdresseAsso(); -// TODO -// - associer le taux de réduction à chaque montant total - $logoCERFA = PLUGIN_ROOT . "/data/logoCerfa.png"; $signature = PLUGIN_ROOT . "/data/default_signature.png"; $listeFichiers = []; @@ -39,11 +34,12 @@ foreach ($versementsSelectionnes as $ligne) { $signature ); // extraire les montants des versements + $lesMontants[$_SESSION['taux_reduction']] = $ligne->versement/100; $pdf->imprimer_recu( $_SESSION['annee_recu'], $ligne->idUser, $_SESSION['membresDonateurs'][$ligne->idUser]->nomPrenom, - array($ligne->versement/100), + $lesMontants, $_SESSION['membresDonateurs'][$ligne->idUser]->adresse, $_SESSION['membresDonateurs'][$ligne->idUser]->codePostal, $_SESSION['membresDonateurs'][$ligne->idUser]->ville diff --git a/www/admin/index.php b/www/admin/index.php index 521bdea..e4d20dd 100644 --- a/www/admin/index.php +++ b/www/admin/index.php @@ -11,6 +11,9 @@ if ($anneesFiscales[0] < $anneeCourante) { array_unshift($anneesFiscales, $anneeCourante); } +// libellés pour les taux de réduction +$_SESSION['ligneReduction'] = Utils::getLignesReduction($plugin->getConfig('reduction')); + // liste des activités, cotisations et comptes associés $activitesTarifsComptes = Utils::getActivitesTarifsEtComptes(); diff --git a/www/admin/versements_activites.php b/www/admin/versements_activites.php index 92643dd..4f263c1 100644 --- a/www/admin/versements_activites.php +++ b/www/admin/versements_activites.php @@ -20,8 +20,10 @@ $tauxSelectionnes = array(); foreach ($tarifsSelectionnes as $idTarif) { $nomRadio = "taux_reduction_" . $idTarif; $valRadio = f("$nomRadio"); - $tauxSelectionnes[] = $valRadio ? $valRadio: $plugin->getConfig('reduction')[0]->taux; + $tauxSelectionnes[$idTarif] = $valRadio; } +$_SESSION['tauxSelectionnes'] = $tauxSelectionnes; + // obtenir les instances de tarifs correspondant à la sélection $lesTarifs = array(); foreach (Utils::getTarifs($tarifsSelectionnes) as $ot) { diff --git a/www/admin/versements_personnes.php b/www/admin/versements_personnes.php index 23a6761..209c7fc 100644 --- a/www/admin/versements_personnes.php +++ b/www/admin/versements_personnes.php @@ -5,6 +5,8 @@ namespace Garradin; use Garradin\Plugin\RecusFiscaux\Personne; use Garradin\Plugin\RecusFiscaux\Utils; +$_SESSION['taux_reduction'] = $_POST['taux_reduction']; + // vérifier si l'année a bien été sélectionnée au préalable $_SESSION['annee_recu'] = f('annee_recu'); if (! isset($_SESSION['annee_recu']) || $_SESSION['annee_recu'] == "") {