Loading module/Oscar/src/Oscar/Controller/DepenseController.php +17 −3 Original line number Diff line number Diff line Loading @@ -214,12 +214,13 @@ class DepenseController extends AbstractOscarController implements UseServiceCon // Récupération des affectations $postedAffectations = $this->params()->fromPost('affectation'); if( !$postedAffectations ){ return $this->getResponseBadRequest("Erreur de transmission : " . print_r($_POST, true)); } try { $this->getSpentService()->updateAffectation($postedAffectations); $this->getSpentService()->updateAffectation(json_decode($postedAffectations, true)); } catch (\Exception $e) { return $this->getResponseInternalError($e->getMessage()); Loading @@ -246,6 +247,8 @@ class DepenseController extends AbstractOscarController implements UseServiceCon $this->getOscarUserContextService()->check(Privileges::DEPENSE_DETAILS, $activity); $format = $this->params()->fromQuery('format', 'json'); try { if( !$activity->getCodeEOTP() ){ throw new OscarException(sprintf(_("Cette activité n'a pas de Numéro financier"))); Loading @@ -253,8 +256,19 @@ class DepenseController extends AbstractOscarController implements UseServiceCon //$spents = $this->getSpentService()->getGroupedSpentsDatas($activity->getCodeEOTP()); $spents = $this->getSpentService()->getSpentsDatas($activity->getCodeEOTP(),SpentService::SPENT_BOTH); $spents['informations'] = $activity->toArray(); if( $this->getOscarUserContextService()->hasPrivileges(Privileges::ACTIVITY_SHOW, $activity) ){ $spents['url_activity'] = $this->url()->fromRoute('contract/show', ['id' => $activity->getId()]); } if( $this->getOscarUserContextService()->hasPrivileges(Privileges::DEPENSE_SYNC, $activity) ){ $spents['url_sync'] = $this->url()->fromRoute('contract/list-spent', ['id' => $activity->getId()]); } if( $this->getOscarUserContextService()->hasPrivileges(Privileges::DEPENSE_DOWNLOAD, $activity) ){ $spents['url_download'] = $this->url()->fromRoute('spent/activity-api', ['id' => $activity->getId()]) . '?format=excel&mode=details'; } if( $this->getOscarUserContextService()->hasPrivileges(Privileges::MAINTENANCE_SPENDTYPEGROUP_MANAGE) ){ $spents['url_spentaffectation'] = $this->url()->fromRoute('spent/compte-affectation'); } $format = $this->params()->fromQuery('format', 'json'); switch($format){ case 'json' : $datas = $this->baseJsonResponse(); Loading module/Oscar/src/Oscar/Controller/ProjectGrantController.php +2 −13 Original line number Diff line number Diff line Loading @@ -2003,18 +2003,6 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif $out['error'] = null; // Affiche les erreurs survenue lors de la récupération/synchronisation des données $out['warning'] = null; // Affiche les avertissements // if ($this->getOscarConfigurationService()->getAutoUpdateSpent()) { // if (!$this->getOscarUserContextService()->hasPrivileges(Privileges::DEPENSE_SYNC, $entity)) { // $out['warning'] = "Vous n'êtes pas autorisé à mettre à jour les dépenses, les données peuvent ne pas être à jour"; // } else { // try { // $this->spentService->syncSpentsByEOTP($pfi); // } catch (\Exception $e) { // $out['error'] = $e->getMessage(); // } // } // } // Construction des données de dépense $out['masses'] = $masses; $out['dateUpdated'] = $entity->getDateTotalSpent(); Loading @@ -2022,7 +2010,8 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif $pfis, $this->getOscarUserContextService()->hasPrivileges( Privileges::MAINTENANCE_SPENDTYPEGROUP_MANAGE ) ), 'basic' ); } catch (\Exception $e) { return $this->getResponseInternalError("Impossible de charger les dépenses pour la/les activité(s)"); Loading module/Oscar/src/Oscar/Service/SpentService.php +138 −195 Original line number Diff line number Diff line Loading @@ -847,204 +847,90 @@ class SpentService implements UseLoggerService, UseOscarConfigurationService, Us * @param false $curationNB * @return array */ public function getSynthesisDatasPFI($pfi, $curationNB = false) :array public function getSynthesisDatasPFI($pfis, $curationNB = false, string $mode = 'advanced' ) :array { $clauseEffective = $this->getOscarConfigurationService()->getSpentEffectiveClauseValue(); $clausePredicted = $this->getOscarConfigurationService()->getSpentPredictedClauseValue(); // Récupération des dépenses $effectives = $spents = $this->getSpentsByPFIs($pfi, self::SPENT_EFFECTIVE); $predicted = $this->getSpentsByPFIs($pfi, self::SPENT_PREVISIONNAL); $spents = []; foreach ($pfis as $pfi) { $spents = array_merge($spents, $this->getSpentsByPFI($pfi, self::SPENT_BOTH)); } // Récupération des Masses comptable configurées dans config $masses = $this->getOscarConfigurationService()->getMasses(); // Structuration du tableau de retour $out = []; $out['N.B'] = 0.0; $out['entries'] = count($spents); $out['total'] = 0.0; $predicted_aggregator = []; // Dépenses "prévues" $out['predicted'] = [ 'N.B' => [] ]; $out['predicted_count'] = count($predicted); $out['predicted_total'] = 0.0; $out['details'] = []; $out['predicted_totals'] = [ 'N.B' => 0.0 ]; // Dépenses "effectives" $out['effective'] = [ 'N.B' => [] ]; $out['effective_count'] = count($effectives); $out['effective_total'] = 0.0; $out['effective_totals'] = [ 'N.B' => 0.0 ]; $out['details'] = [ 'N.B' => [] ]; $out['totals'] = [ 'N.B' => 0.0 ]; $out['recettes'] = [ 'total' => 0.0, 'details' => [] ]; if( $curationNB ){ $out['curations'] = []; } foreach ($masses as $key => $label) { $out[$key] = 0.0; $out['totals'][$key] = 0.0; $out['details'][$key] = []; $out['predicted'][$key] = []; $out['predicted_totals'][$key] = 0.0; $out['effective'][$key] = []; $out['effective_totals'][$key] = 0.0; } // On commence par traiter les données effectives $idsEffectiveDone = []; // Aggrégation des données /** @var SpentLine $spent */ foreach ($effectives as $spent) { $compte = $spent->getCompteGeneral(); $compteInfos = $this->getCompte($compte); $annexe = $compteInfos['annexe']; $montant = floatval($spent->getMontant()); $out['details'][] = $spent->toArray(); $idSifac = $spent->getNumSifac(); $idsEffectiveDone[] = $idSifac; if( $annexe == '' || $annexe == null ){ $annexe = $compteInfos['masse_inherit']; } if( $annexe == '0' ){ continue; } if( $annexe == '1' ){ $out['recettes']['total'] += $montant; $out['recettes']['details'][] = $spent->toArray(); continue; } if ($annexe == '') { if( $curationNB ){ $exist = $compte == $compteInfos['code']; if( !array_key_exists($compte, $out['curations']) ){ $out['curations'][$compte] = [ 'compte' => $compte, 'compteInfos' => $compteInfos, 'label' => $compteInfos['label'], 'montant' => 0.0, 'totalEntries' => 0, 'exist' => $exist ? 'true' : 'false' ]; } $out['curations'][$compte]['montant'] += $montant; $out['curations'][$compte]['totalEntries']++; } $annexe = 'N.B'; if (!in_array($compte, $out['details'][$annexe])) $out['details'][$annexe][] = $compte . ' (' . $compteInfos['label'] . ')'; } $out[$annexe] += $montant; $out['total'] += $montant; $out['totals'][$annexe] += $montant; $out['effective_total'] += $montant; $out['effective_totals'][$annexe] += $montant; } // Puis les données prévues en évacuant les lignes déjà présentes dans les données effectives // /** @var SpentLine $spent */ foreach ($predicted as $spent) { $idSifac = $spent->getNumSifac(); if( in_array($idSifac, $idsEffectiveDone) ){ continue; } $compte = $spent->getCompteGeneral(); $compteInfos = $this->getCompte($compte); $annexe = $compteInfos['annexe']; $montant = floatval($spent->getMontant()); $out['details'][] = $spent->toArray(); if( $annexe == '' || $annexe == null ){ $annexe = $compteInfos['masse_inherit']; } if( $annexe == '0' ){ continue; } if( $annexe == '1' ){ $out['recettes']['total'] += $montant; $out['recettes']['details'][] = $spent->toArray(); continue; } if ($annexe == '') { if( $curationNB ){ $exist = $compte == $compteInfos['code']; if( !array_key_exists($compte, $out['curations']) ){ $out['curations'][$compte] = [ 'compte' => $compte, 'compteInfos' => $compteInfos, 'label' => $compteInfos['label'], 'montant' => 0.0, 'totalEntries' => 0, 'exist' => $exist ? 'true' : 'false' return [ 'pfi' => $pfi, 'masses' => $masses, 'synthesis' => $this->getSpentDatasSynthesisBySpents($spents) ]; } $out['curations'][$compte]['montant'] += $montant; $out['curations'][$compte]['totalEntries']++; } $annexe = 'N.B'; if (!in_array($compte, $out['details'][$annexe])) $out['details'][$annexe][] = $compte . ' (' . $compteInfos['label'] . ')'; } $out[$annexe] += $montant; $out['total'] += $montant; $out['totals'][$annexe] += $montant; $out['predicted_total'] += $montant; $out['predicted_totals'][$annexe] += $montant; } // // // // Structuration du tableau de retour // $out = []; // // $out['N.B'] = 0.0; // $out['entries'] = count($spents); // $out['total'] = 0.0; // // $predicted_aggregator = []; // // // // Dépenses "prévues" // $out['predicted'] = [ // 'N.B' => [] // ]; // $out['predicted_count'] = count($predicted); // $out['predicted_total'] = 0.0; // $out['predicted_totals'] = [ // 'N.B' => 0.0 // ]; // // // Dépenses "effectives" // $out['effective'] = [ // 'N.B' => [] // ]; // $out['effective_count'] = count($effectives); // $out['effective_total'] = 0.0; // $out['effective_totals'] = [ // 'N.B' => 0.0 // ]; // // $out['totals'] = [ // 'N.B' => 0.0 // ]; // $out['recettes'] = [ // 'total' => 0.0, // ]; // // if( $curationNB ){ // $out['curations'] = []; // } // // foreach ($masses as $key => $label) { // $out[$key] = 0.0; // $out['totals'][$key] = 0.0; // // $out['predicted'][$key] = []; // $out['predicted_totals'][$key] = 0.0; // // $out['effective'][$key] = []; // $out['effective_totals'][$key] = 0.0; // } // // // On commence par traiter les données effectives // $idsEffectiveDone = []; // // Aggrégation des données // /** @var SpentLine $spent */ // foreach (array_merge($effectives, $predicted) as $spent) { // foreach ($effectives as $spent) { // // $compte = $spent->getCompteGeneral(); // $compteInfos = $this->getCompte($compte); // $annexe = $compteInfos['annexe']; // $montant = floatval($spent->getMontant()); // $out['details'][] = $spent->toArray(); // //$out['details'][] = $spent->toArray(); // $idSifac = $spent->getNumSifac(); // $idsEffectiveDone[] = $idSifac; // // if( $annexe == '' || $annexe == null ){ // $annexe = $compteInfos['masse_inherit']; Loading @@ -1056,7 +942,7 @@ class SpentService implements UseLoggerService, UseOscarConfigurationService, Us // // if( $annexe == '1' ){ // $out['recettes']['total'] += $montant; // $out['recettes']['details'][] = $spent->toArray(); // //$out['recettes']['details'][] = $spent->toArray(); // continue; // } // Loading @@ -1077,8 +963,8 @@ class SpentService implements UseLoggerService, UseOscarConfigurationService, Us // $out['curations'][$compte]['totalEntries']++; // } // $annexe = 'N.B'; // if (!in_array($compte, $out['details'][$annexe])) // $out['details'][$annexe][] = $compte . ' (' . $compteInfos['label'] . ')'; //// if (!in_array($compte, $out['details'][$annexe])) //// $out['details'][$annexe][] = $compte . ' (' . $compteInfos['label'] . ')'; // } // // Loading @@ -1087,18 +973,69 @@ class SpentService implements UseLoggerService, UseOscarConfigurationService, Us // $out['total'] += $montant; // $out['totals'][$annexe] += $montant; // // if( $spent->getRldnr() == $clauseEffective ){ // $out['effective_total'] += $montant; // $out['effective_totals'][$annexe] += $montant; // } // elseif ($spent->getRldnr() == $clausePredicted) { // $out['predicted_total'] += $montant; // $out['predicted_totals'][$annexe] += $montant; // // // Puis les données prévues en évacuant les lignes déjà présentes dans les données effectives // // /** @var SpentLine $spent */ // foreach ($predicted as $spent) { // // $idSifac = $spent->getNumSifac(); // if( in_array($idSifac, $idsEffectiveDone) ){ // continue; // } // $compte = $spent->getCompteGeneral(); // $compteInfos = $this->getCompte($compte); // $annexe = $compteInfos['annexe']; // $montant = floatval($spent->getMontant()); // //$out['details'][] = $spent->toArray(); // // if( $annexe == '' || $annexe == null ){ // $annexe = $compteInfos['masse_inherit']; // } // // if( $annexe == '0' ){ // continue; // } // // if( $annexe == '1' ){ // $out['recettes']['total'] += $montant; // //$out['recettes']['details'][] = $spent->toArray(); // continue; // } // // if ($annexe == '') { // if( $curationNB ){ // $exist = $compte == $compteInfos['code']; // if( !array_key_exists($compte, $out['curations']) ){ // $out['curations'][$compte] = [ // 'compte' => $compte, // 'compteInfos' => $compteInfos, // 'label' => $compteInfos['label'], // 'montant' => 0.0, // 'totalEntries' => 0, // 'exist' => $exist ? 'true' : 'false' // ]; // } // else { // $this->getLoggerService()->error("Une valeur de dépenses pour $spent est incohérente pour le champ RLDNR"); // $out['curations'][$compte]['montant'] += $montant; // $out['curations'][$compte]['totalEntries']++; // } // $annexe = 'N.B'; // if (!in_array($compte, $out['details'][$annexe])) // $out['details'][$annexe][] = $compte . ' (' . $compteInfos['label'] . ')'; // } // // // // $out[$annexe] += $montant; // $out['total'] += $montant; // $out['totals'][$annexe] += $montant; // // $out['predicted_total'] += $montant; // $out['predicted_totals'][$annexe] += $montant; // } return $out; } Loading Loading @@ -1269,7 +1206,9 @@ class SpentService implements UseLoggerService, UseOscarConfigurationService, Us * @return array[] */ public function getSpentDatasSynthesisBySpents($spents){ $pfis = []; $synthesis = [ 'lines' => count($spents), '1' => [ 'label' => "Recettes", 'total' => 0.0, Loading Loading @@ -1321,6 +1260,9 @@ class SpentService implements UseLoggerService, UseOscarConfigurationService, Us $numSifacDone = []; /** @var SpentLine $spent */ foreach ($spents as $spent) { if( !in_array($spent->getPfi(), $pfis) ){ $pfis[] = $spent->getPfi(); } if($spent->getBtart() == SpentLine::BTART_EFFECTUE && !in_array($spent->getNumSifac(), $numSifacDone)){ $numSifacDone[] = $spent->getNumSifac(); } Loading Loading @@ -1360,6 +1302,7 @@ class SpentService implements UseLoggerService, UseOscarConfigurationService, Us $synthesis[$masse]['nbr']++; } $synthesis['pfis'] = $pfis; return $synthesis; Loading module/Oscar/view/oscar/project-grant/spent-list.phtml +0 −3 Original line number Diff line number Diff line Loading @@ -16,11 +16,8 @@ </style> <section class="container-fluid"> <h1>TEST</h1> <div id="depensesdetails" data-informations="<?= json_encode($activity->toArray()) ?>" data-url="<?= $this->url('spent/activity-api', ['id' => $activity->getId()]) ?>" > </div> <?= $this->Vite()->addJs('src/ActivitySpentDetails.js'); ?> Loading public/js/oscar/src/ActivitySpentSynthesis.vue +9 −4 Original line number Diff line number Diff line Loading @@ -52,6 +52,8 @@ </div> </transition> {{ synthesis }} <table class="table table-condensed" v-if="!pendingMsg"> <tr v-for="m,k in masses"> <th>{{ m }}</th> Loading Loading @@ -91,9 +93,6 @@ </section> </template> <script> // nodejs node_modules/.bin/poi watch --format umd --moduleName ActivitySpentSynthesis --filename.js ActivitySpentSynthesis.js --dist public/js/oscar/dist public/js/oscar/src/ActivitySpentSynthesis.vue export default { props: ['url', 'manageDepense'], Loading @@ -106,7 +105,13 @@ masses: {}, dateUpdated: null, showCuration: false, affectations: {} affectations: {}, // URL url_activity: null, url_sync: null, url_download: null, url_spentaffectation: null, } }, Loading Loading
module/Oscar/src/Oscar/Controller/DepenseController.php +17 −3 Original line number Diff line number Diff line Loading @@ -214,12 +214,13 @@ class DepenseController extends AbstractOscarController implements UseServiceCon // Récupération des affectations $postedAffectations = $this->params()->fromPost('affectation'); if( !$postedAffectations ){ return $this->getResponseBadRequest("Erreur de transmission : " . print_r($_POST, true)); } try { $this->getSpentService()->updateAffectation($postedAffectations); $this->getSpentService()->updateAffectation(json_decode($postedAffectations, true)); } catch (\Exception $e) { return $this->getResponseInternalError($e->getMessage()); Loading @@ -246,6 +247,8 @@ class DepenseController extends AbstractOscarController implements UseServiceCon $this->getOscarUserContextService()->check(Privileges::DEPENSE_DETAILS, $activity); $format = $this->params()->fromQuery('format', 'json'); try { if( !$activity->getCodeEOTP() ){ throw new OscarException(sprintf(_("Cette activité n'a pas de Numéro financier"))); Loading @@ -253,8 +256,19 @@ class DepenseController extends AbstractOscarController implements UseServiceCon //$spents = $this->getSpentService()->getGroupedSpentsDatas($activity->getCodeEOTP()); $spents = $this->getSpentService()->getSpentsDatas($activity->getCodeEOTP(),SpentService::SPENT_BOTH); $spents['informations'] = $activity->toArray(); if( $this->getOscarUserContextService()->hasPrivileges(Privileges::ACTIVITY_SHOW, $activity) ){ $spents['url_activity'] = $this->url()->fromRoute('contract/show', ['id' => $activity->getId()]); } if( $this->getOscarUserContextService()->hasPrivileges(Privileges::DEPENSE_SYNC, $activity) ){ $spents['url_sync'] = $this->url()->fromRoute('contract/list-spent', ['id' => $activity->getId()]); } if( $this->getOscarUserContextService()->hasPrivileges(Privileges::DEPENSE_DOWNLOAD, $activity) ){ $spents['url_download'] = $this->url()->fromRoute('spent/activity-api', ['id' => $activity->getId()]) . '?format=excel&mode=details'; } if( $this->getOscarUserContextService()->hasPrivileges(Privileges::MAINTENANCE_SPENDTYPEGROUP_MANAGE) ){ $spents['url_spentaffectation'] = $this->url()->fromRoute('spent/compte-affectation'); } $format = $this->params()->fromQuery('format', 'json'); switch($format){ case 'json' : $datas = $this->baseJsonResponse(); Loading
module/Oscar/src/Oscar/Controller/ProjectGrantController.php +2 −13 Original line number Diff line number Diff line Loading @@ -2003,18 +2003,6 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif $out['error'] = null; // Affiche les erreurs survenue lors de la récupération/synchronisation des données $out['warning'] = null; // Affiche les avertissements // if ($this->getOscarConfigurationService()->getAutoUpdateSpent()) { // if (!$this->getOscarUserContextService()->hasPrivileges(Privileges::DEPENSE_SYNC, $entity)) { // $out['warning'] = "Vous n'êtes pas autorisé à mettre à jour les dépenses, les données peuvent ne pas être à jour"; // } else { // try { // $this->spentService->syncSpentsByEOTP($pfi); // } catch (\Exception $e) { // $out['error'] = $e->getMessage(); // } // } // } // Construction des données de dépense $out['masses'] = $masses; $out['dateUpdated'] = $entity->getDateTotalSpent(); Loading @@ -2022,7 +2010,8 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif $pfis, $this->getOscarUserContextService()->hasPrivileges( Privileges::MAINTENANCE_SPENDTYPEGROUP_MANAGE ) ), 'basic' ); } catch (\Exception $e) { return $this->getResponseInternalError("Impossible de charger les dépenses pour la/les activité(s)"); Loading
module/Oscar/src/Oscar/Service/SpentService.php +138 −195 Original line number Diff line number Diff line Loading @@ -847,204 +847,90 @@ class SpentService implements UseLoggerService, UseOscarConfigurationService, Us * @param false $curationNB * @return array */ public function getSynthesisDatasPFI($pfi, $curationNB = false) :array public function getSynthesisDatasPFI($pfis, $curationNB = false, string $mode = 'advanced' ) :array { $clauseEffective = $this->getOscarConfigurationService()->getSpentEffectiveClauseValue(); $clausePredicted = $this->getOscarConfigurationService()->getSpentPredictedClauseValue(); // Récupération des dépenses $effectives = $spents = $this->getSpentsByPFIs($pfi, self::SPENT_EFFECTIVE); $predicted = $this->getSpentsByPFIs($pfi, self::SPENT_PREVISIONNAL); $spents = []; foreach ($pfis as $pfi) { $spents = array_merge($spents, $this->getSpentsByPFI($pfi, self::SPENT_BOTH)); } // Récupération des Masses comptable configurées dans config $masses = $this->getOscarConfigurationService()->getMasses(); // Structuration du tableau de retour $out = []; $out['N.B'] = 0.0; $out['entries'] = count($spents); $out['total'] = 0.0; $predicted_aggregator = []; // Dépenses "prévues" $out['predicted'] = [ 'N.B' => [] ]; $out['predicted_count'] = count($predicted); $out['predicted_total'] = 0.0; $out['details'] = []; $out['predicted_totals'] = [ 'N.B' => 0.0 ]; // Dépenses "effectives" $out['effective'] = [ 'N.B' => [] ]; $out['effective_count'] = count($effectives); $out['effective_total'] = 0.0; $out['effective_totals'] = [ 'N.B' => 0.0 ]; $out['details'] = [ 'N.B' => [] ]; $out['totals'] = [ 'N.B' => 0.0 ]; $out['recettes'] = [ 'total' => 0.0, 'details' => [] ]; if( $curationNB ){ $out['curations'] = []; } foreach ($masses as $key => $label) { $out[$key] = 0.0; $out['totals'][$key] = 0.0; $out['details'][$key] = []; $out['predicted'][$key] = []; $out['predicted_totals'][$key] = 0.0; $out['effective'][$key] = []; $out['effective_totals'][$key] = 0.0; } // On commence par traiter les données effectives $idsEffectiveDone = []; // Aggrégation des données /** @var SpentLine $spent */ foreach ($effectives as $spent) { $compte = $spent->getCompteGeneral(); $compteInfos = $this->getCompte($compte); $annexe = $compteInfos['annexe']; $montant = floatval($spent->getMontant()); $out['details'][] = $spent->toArray(); $idSifac = $spent->getNumSifac(); $idsEffectiveDone[] = $idSifac; if( $annexe == '' || $annexe == null ){ $annexe = $compteInfos['masse_inherit']; } if( $annexe == '0' ){ continue; } if( $annexe == '1' ){ $out['recettes']['total'] += $montant; $out['recettes']['details'][] = $spent->toArray(); continue; } if ($annexe == '') { if( $curationNB ){ $exist = $compte == $compteInfos['code']; if( !array_key_exists($compte, $out['curations']) ){ $out['curations'][$compte] = [ 'compte' => $compte, 'compteInfos' => $compteInfos, 'label' => $compteInfos['label'], 'montant' => 0.0, 'totalEntries' => 0, 'exist' => $exist ? 'true' : 'false' ]; } $out['curations'][$compte]['montant'] += $montant; $out['curations'][$compte]['totalEntries']++; } $annexe = 'N.B'; if (!in_array($compte, $out['details'][$annexe])) $out['details'][$annexe][] = $compte . ' (' . $compteInfos['label'] . ')'; } $out[$annexe] += $montant; $out['total'] += $montant; $out['totals'][$annexe] += $montant; $out['effective_total'] += $montant; $out['effective_totals'][$annexe] += $montant; } // Puis les données prévues en évacuant les lignes déjà présentes dans les données effectives // /** @var SpentLine $spent */ foreach ($predicted as $spent) { $idSifac = $spent->getNumSifac(); if( in_array($idSifac, $idsEffectiveDone) ){ continue; } $compte = $spent->getCompteGeneral(); $compteInfos = $this->getCompte($compte); $annexe = $compteInfos['annexe']; $montant = floatval($spent->getMontant()); $out['details'][] = $spent->toArray(); if( $annexe == '' || $annexe == null ){ $annexe = $compteInfos['masse_inherit']; } if( $annexe == '0' ){ continue; } if( $annexe == '1' ){ $out['recettes']['total'] += $montant; $out['recettes']['details'][] = $spent->toArray(); continue; } if ($annexe == '') { if( $curationNB ){ $exist = $compte == $compteInfos['code']; if( !array_key_exists($compte, $out['curations']) ){ $out['curations'][$compte] = [ 'compte' => $compte, 'compteInfos' => $compteInfos, 'label' => $compteInfos['label'], 'montant' => 0.0, 'totalEntries' => 0, 'exist' => $exist ? 'true' : 'false' return [ 'pfi' => $pfi, 'masses' => $masses, 'synthesis' => $this->getSpentDatasSynthesisBySpents($spents) ]; } $out['curations'][$compte]['montant'] += $montant; $out['curations'][$compte]['totalEntries']++; } $annexe = 'N.B'; if (!in_array($compte, $out['details'][$annexe])) $out['details'][$annexe][] = $compte . ' (' . $compteInfos['label'] . ')'; } $out[$annexe] += $montant; $out['total'] += $montant; $out['totals'][$annexe] += $montant; $out['predicted_total'] += $montant; $out['predicted_totals'][$annexe] += $montant; } // // // // Structuration du tableau de retour // $out = []; // // $out['N.B'] = 0.0; // $out['entries'] = count($spents); // $out['total'] = 0.0; // // $predicted_aggregator = []; // // // // Dépenses "prévues" // $out['predicted'] = [ // 'N.B' => [] // ]; // $out['predicted_count'] = count($predicted); // $out['predicted_total'] = 0.0; // $out['predicted_totals'] = [ // 'N.B' => 0.0 // ]; // // // Dépenses "effectives" // $out['effective'] = [ // 'N.B' => [] // ]; // $out['effective_count'] = count($effectives); // $out['effective_total'] = 0.0; // $out['effective_totals'] = [ // 'N.B' => 0.0 // ]; // // $out['totals'] = [ // 'N.B' => 0.0 // ]; // $out['recettes'] = [ // 'total' => 0.0, // ]; // // if( $curationNB ){ // $out['curations'] = []; // } // // foreach ($masses as $key => $label) { // $out[$key] = 0.0; // $out['totals'][$key] = 0.0; // // $out['predicted'][$key] = []; // $out['predicted_totals'][$key] = 0.0; // // $out['effective'][$key] = []; // $out['effective_totals'][$key] = 0.0; // } // // // On commence par traiter les données effectives // $idsEffectiveDone = []; // // Aggrégation des données // /** @var SpentLine $spent */ // foreach (array_merge($effectives, $predicted) as $spent) { // foreach ($effectives as $spent) { // // $compte = $spent->getCompteGeneral(); // $compteInfos = $this->getCompte($compte); // $annexe = $compteInfos['annexe']; // $montant = floatval($spent->getMontant()); // $out['details'][] = $spent->toArray(); // //$out['details'][] = $spent->toArray(); // $idSifac = $spent->getNumSifac(); // $idsEffectiveDone[] = $idSifac; // // if( $annexe == '' || $annexe == null ){ // $annexe = $compteInfos['masse_inherit']; Loading @@ -1056,7 +942,7 @@ class SpentService implements UseLoggerService, UseOscarConfigurationService, Us // // if( $annexe == '1' ){ // $out['recettes']['total'] += $montant; // $out['recettes']['details'][] = $spent->toArray(); // //$out['recettes']['details'][] = $spent->toArray(); // continue; // } // Loading @@ -1077,8 +963,8 @@ class SpentService implements UseLoggerService, UseOscarConfigurationService, Us // $out['curations'][$compte]['totalEntries']++; // } // $annexe = 'N.B'; // if (!in_array($compte, $out['details'][$annexe])) // $out['details'][$annexe][] = $compte . ' (' . $compteInfos['label'] . ')'; //// if (!in_array($compte, $out['details'][$annexe])) //// $out['details'][$annexe][] = $compte . ' (' . $compteInfos['label'] . ')'; // } // // Loading @@ -1087,18 +973,69 @@ class SpentService implements UseLoggerService, UseOscarConfigurationService, Us // $out['total'] += $montant; // $out['totals'][$annexe] += $montant; // // if( $spent->getRldnr() == $clauseEffective ){ // $out['effective_total'] += $montant; // $out['effective_totals'][$annexe] += $montant; // } // elseif ($spent->getRldnr() == $clausePredicted) { // $out['predicted_total'] += $montant; // $out['predicted_totals'][$annexe] += $montant; // // // Puis les données prévues en évacuant les lignes déjà présentes dans les données effectives // // /** @var SpentLine $spent */ // foreach ($predicted as $spent) { // // $idSifac = $spent->getNumSifac(); // if( in_array($idSifac, $idsEffectiveDone) ){ // continue; // } // $compte = $spent->getCompteGeneral(); // $compteInfos = $this->getCompte($compte); // $annexe = $compteInfos['annexe']; // $montant = floatval($spent->getMontant()); // //$out['details'][] = $spent->toArray(); // // if( $annexe == '' || $annexe == null ){ // $annexe = $compteInfos['masse_inherit']; // } // // if( $annexe == '0' ){ // continue; // } // // if( $annexe == '1' ){ // $out['recettes']['total'] += $montant; // //$out['recettes']['details'][] = $spent->toArray(); // continue; // } // // if ($annexe == '') { // if( $curationNB ){ // $exist = $compte == $compteInfos['code']; // if( !array_key_exists($compte, $out['curations']) ){ // $out['curations'][$compte] = [ // 'compte' => $compte, // 'compteInfos' => $compteInfos, // 'label' => $compteInfos['label'], // 'montant' => 0.0, // 'totalEntries' => 0, // 'exist' => $exist ? 'true' : 'false' // ]; // } // else { // $this->getLoggerService()->error("Une valeur de dépenses pour $spent est incohérente pour le champ RLDNR"); // $out['curations'][$compte]['montant'] += $montant; // $out['curations'][$compte]['totalEntries']++; // } // $annexe = 'N.B'; // if (!in_array($compte, $out['details'][$annexe])) // $out['details'][$annexe][] = $compte . ' (' . $compteInfos['label'] . ')'; // } // // // // $out[$annexe] += $montant; // $out['total'] += $montant; // $out['totals'][$annexe] += $montant; // // $out['predicted_total'] += $montant; // $out['predicted_totals'][$annexe] += $montant; // } return $out; } Loading Loading @@ -1269,7 +1206,9 @@ class SpentService implements UseLoggerService, UseOscarConfigurationService, Us * @return array[] */ public function getSpentDatasSynthesisBySpents($spents){ $pfis = []; $synthesis = [ 'lines' => count($spents), '1' => [ 'label' => "Recettes", 'total' => 0.0, Loading Loading @@ -1321,6 +1260,9 @@ class SpentService implements UseLoggerService, UseOscarConfigurationService, Us $numSifacDone = []; /** @var SpentLine $spent */ foreach ($spents as $spent) { if( !in_array($spent->getPfi(), $pfis) ){ $pfis[] = $spent->getPfi(); } if($spent->getBtart() == SpentLine::BTART_EFFECTUE && !in_array($spent->getNumSifac(), $numSifacDone)){ $numSifacDone[] = $spent->getNumSifac(); } Loading Loading @@ -1360,6 +1302,7 @@ class SpentService implements UseLoggerService, UseOscarConfigurationService, Us $synthesis[$masse]['nbr']++; } $synthesis['pfis'] = $pfis; return $synthesis; Loading
module/Oscar/view/oscar/project-grant/spent-list.phtml +0 −3 Original line number Diff line number Diff line Loading @@ -16,11 +16,8 @@ </style> <section class="container-fluid"> <h1>TEST</h1> <div id="depensesdetails" data-informations="<?= json_encode($activity->toArray()) ?>" data-url="<?= $this->url('spent/activity-api', ['id' => $activity->getId()]) ?>" > </div> <?= $this->Vite()->addJs('src/ActivitySpentDetails.js'); ?> Loading
public/js/oscar/src/ActivitySpentSynthesis.vue +9 −4 Original line number Diff line number Diff line Loading @@ -52,6 +52,8 @@ </div> </transition> {{ synthesis }} <table class="table table-condensed" v-if="!pendingMsg"> <tr v-for="m,k in masses"> <th>{{ m }}</th> Loading Loading @@ -91,9 +93,6 @@ </section> </template> <script> // nodejs node_modules/.bin/poi watch --format umd --moduleName ActivitySpentSynthesis --filename.js ActivitySpentSynthesis.js --dist public/js/oscar/dist public/js/oscar/src/ActivitySpentSynthesis.vue export default { props: ['url', 'manageDepense'], Loading @@ -106,7 +105,13 @@ masses: {}, dateUpdated: null, showCuration: false, affectations: {} affectations: {}, // URL url_activity: null, url_sync: null, url_download: null, url_spentaffectation: null, } }, Loading