Loading front/Paiement/DemandeMiseEnPaiementStructure.vue +52 −104 Original line number Diff line number Diff line Loading @@ -14,61 +14,44 @@ <div :id="'dmep-collapse-' + datas.code" :aria-labelledby="'dmep-heading-' + datas.code" class="accordion-collapse collapse show"> <div class="accordion-body"> <div v-if="this.dotationPaieEtat + dotationRessourcesPropres > 0"> <div v-if="this.datas.budget.dotation.total > 0"> <!--Budget--> <div class="cartridge gray bordered" style="padding-bottom: 5px;margin-bottom:20px;"> <span>Budget</span> </div> <div class="container"> <table class="table table-bordered caption-top"> <table class="table table-bordered caption-top" style="table-layout: fixed;width:100%"> <thead class="table-light"> <tr> <th class="fw-bold" scope="col">Paie état</th> <th class="fw-bold" scope="col">Ressources propres</th> <th v-for="(value, index) in datasBudget" :key="index" class="fw-bold" scope="col">{{ value.libelle }} </th> </tr> </thead> <tbody> <tr> <td style="width:50%;"> <div v-if="this.dotationPaieEtat > 0" <td v-for="(value, index) in datasBudget"> <div v-if="value.dotation > 0" class="text-center progress position-relative bg-secondary" style="height: 30px;"> <span class="position-absolute top-50 start-50 translate-middle" style="color:white;">{{ this.consommationPaieEtat + ' sur ' + this.dotationPaieEtat value.consommation + ' sur ' + value.dotation }} HETD</span> <div :aria-valuemax="this.dotationPaieEtat" :aria-valuenow="this.consommationPaieEtat" :class="'progress-bar progress-bar-striped '+ this.bgPaieEtat" :style="'width:' + this.pourcentagePaieEtat + '%;'" :title="this.pourcentagePaieEtat + '%'" <div :aria-valuemax="value.dotation" :aria-valuenow="value.consommation" :class="'progress-bar progress-bar-striped '+ bgBudget(value)" :style="'width:' + pourcentageBudget(value) + '%;'" :title="this.pourcentageBudget(value) + '%'" aria-valuemin="0" role="progressbar"> </div> </div> <div v-if="this.dotationPaieEtat == 0" class="text-center"> Aucune dotation paie état </div> </td> <td style="width:50%;"> <div v-if="this.dotationRessourcesPropres > 0" class="progress position-relative bg-secondary" style="height: 30px;"> <span class="position-absolute top-50 start-50 translate-middle" style="color:white;">{{ this.consommationRessourcesPropres + ' sur ' + this.dotationRessourcesPropres }} HETD</span> <div :aria-valuemax="this.dotationRessourcesPropres" :aria-valuenow="this.consommationRessourcesPropres" :class="'progress-bar progress-bar-striped '+ this.bgRessourcesPropres" :style="'width:' + this.pourcentageRessourcePropre + '%;'" :title="this.pourcentageRessourcePropre + '%'" aria-valuemin="0" role="progressbar"> </div> </div> <div v-if="this.dotationRessourcesPropres == 0" class="text-center"> Aucune dotation ressources propres <div v-if="value.dotation == 0" class="text-center"> Aucune dotation {{ value.libelle }} </div> </td> </tr> Loading Loading @@ -159,8 +142,6 @@ <option v-for="item in group.child" :key="item.value" :data-paie-etat="item.paieEtat" :data-ressources-propres="item.ressourcesPropres" :selected="item.centreCoutId==value.centreCout.centreCoutId" :value="item.centreCoutId"> {{ Loading Loading @@ -303,8 +284,6 @@ :label="group.group"> <option v-for="item in group.child" :key="item.value" :data-paie-etat="item.paieEtat" :data-ressources-propres="item.ressourcesPropres" :selected="item.centreCoutId == value.centreCout.centreCoutId" :value="item.centreCoutId"> {{ Loading Loading @@ -463,8 +442,6 @@ :label="group.group"> <option v-for="item in group.child" :key="item.value" :data-paie-etat="item.paieEtat" :data-ressources-propres="item.ressourcesPropres" :selected="item.centreCoutId == value.centreCout.centreCoutId" :value="item.centreCoutId" > Loading Loading @@ -570,59 +547,39 @@ export default { name: "DemandeMiseEnPaiementStructure", props: { datas: {required: true}, intervenant: {required: true}, }, data() { return { dotationPaieEtat: this.datas.budget.dotation.paieEtat, dotationRessourcesPropres: this.datas.budget.dotation.ressourcePropre, consommationPaieEtat: this.datas.budget.liquidation.paieEtat, consommationRessourcesPropres: this.datas.budget.liquidation.ressourcePropre, } }, watch: { datas: function () { this.dotationPaieEtat = this.datas.budget.dotation.paieEtat; this.dotationRessourcesPropres = this.datas.budget.dotation.ressourcePropre; this.consommationPaieEtat = this.datas.budget.liquidation.paieEtat; this.consommationRessourcesPropres = this.datas.budget.liquidation.ressourcePropre; }, }, computed: { pourcentagePaieEtat() { return Math.round((this.consommationPaieEtat / this.dotationPaieEtat) * 100); }, pourcentageRessourcePropre() { return Math.round((this.consommationRessourcesPropres / this.dotationRessourcesPropres) * 100); }, bgPaieEtat() datasBudget() { if (Math.round((this.consommationPaieEtat / this.dotationPaieEtat) * 100) > 100) { return 'bg-warning'; } else { return 'bg-success'; let datasBudget = {}; Object.entries(this.datas.budget.dotation).forEach(([key, value]) => { if (key != 'total') { datasBudget[key] = {}; datasBudget[key]['libelle'] = value.libelle; datasBudget[key]['dotation'] = value.heures; datasBudget[key]['consommation'] = 1001; } }, bgRessourcesPropres() { if (Math.round((this.consommationRessourcesPropres / this.dotationRessourcesPropres) * 100) > 100) { return 'bg-warning'; } else { return 'bg-success'; }); Object.entries(this.datas.budget.consommation).forEach(([key, value]) => { if (key != 'total') { if (key in datasBudget) { datasBudget[key]['consommation'] = value.heures; } } }); return datasBudget; } }, methods: { heuresStatutToString(value) { Loading Loading @@ -707,8 +664,6 @@ export default { let missionId = (inputHeure.hasAttribute('data-mission-id') ? inputHeure.getAttribute('data-mission-id') : ''); let centreCoutId = inputCentreCout.value; let ressourcesPropres = inputCentreCout.options[inputCentreCout.selectedIndex].getAttribute('data-ressources-propres'); let paieEtat = inputCentreCout.options[inputCentreCout.selectedIndex].getAttribute('data-paie-etat'); //Si centre de cout non sélectionné if (centreCoutId == '') { unicaenVue.flashMessenger.toast("Vous devez sélectionner un centre de coût pour demander la mise en paiement de ces heures", 'error', options) Loading @@ -721,25 +676,6 @@ export default { this.$emit('refresh-btn-state');; return false; } //Si je suis sur une demande de mise en paiement avec des fonds paie etat if (paieEtat == 1 && this.dotationPaieEtat > 0) { let solde = this.dotationPaieEtat - (this.consommationPaieEtat + heureADemander); if (solde <= 0) { unicaenVue.flashMessenger.toast("Demande de mise en paiement impossible manque de dotation 'paie etat' pour ces heures", 'error', options) this.$emit('refresh-btn-state'); return false; } } //Si je suis sur une demande de mise en paiement avec des fonds ressources propres if (ressourcesPropres == 1 && this.dotationRessourcesPropres > 0) { let solde = this.dotationRessourcesPropres - (this.consommationRessourcesPropres + heureADemander); if (solde <= 0) { unicaenVue.flashMessenger.toast("Demande de mise en paiement impossible manque de dotation 'ressources propres' pour ces heures", 'error', options) this.$emit('refresh-btn-state'); return false; } } var datas = []; let demande = { Loading Loading @@ -893,6 +829,18 @@ export default { { return Util.dateToString(val); }, pourcentageBudget(value) { return Math.round((value.consommation / value.dotation) * 100); }, bgBudget(value) { if (Math.round((value.consommation / value.dotation) * 100) > 100) { return 'bg-danger'; } else { return 'bg-success'; } } Loading module/Paiement/src/Controller/DemandesController.php +2 −1 Original line number Diff line number Diff line Loading @@ -64,7 +64,8 @@ class DemandesController extends AbstractController $demandes = $this->axios()->fromPost(); $demandesApprouveesBudgetairement = $this->getServiceDemandes()->verifierBudgetDemandeMiseEnPaiement($demandes); $error = 0; $errorBudget = count($demandes) - count($demandesApprouveesBudgetairement); $errorBudget = round(count($demandes) - count($demandesApprouveesBudgetairement)); $success = 0; foreach ($demandesApprouveesBudgetairement as $demande) { try { Loading module/Paiement/src/Service/BudgetService.php +20 −14 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ use Lieu\Entity\Db\Structure; class BudgetService extends AbstractService { use DotationServiceAwareTrait; use TypeRessourceServiceAwareTrait; /** Loading Loading @@ -102,32 +103,37 @@ class BudgetService extends AbstractService { $budget = [ 'dotation' => [ 'paieEtat' => 0, 'ressourcePropre' => 0, 'total' => 0, ], 'liquidation' => [ 'paieEtat' => 0, 'ressourcePropre' => 0, 'consommation' => [ 'total' => 0, ], ]; if ($structure instanceof Structure) { $dotation = $this->getServiceDotation()->getTableauBord([$structure->getId()]); $liquidation = $this->getTblLiquidation($structure); foreach ($dotation as $key => $value) { if (!empty($dotation)) { $dotation = $this->getServiceDotation()->getTableauBord([$structure->getId()]); $liquidation = $this->getTblLiquidation($structure); foreach ($dotation as $key => $values) { if ($key == $structure->getId()) { $budget['dotation']['paieEtat'] = (key_exists(1, $value)) ? $value['1'] : 0; $budget['dotation']['ressourcePropre'] = (key_exists(2, $value)) ? $value['2'] : 0; $budget['dotation']['total'] = $value['total']; foreach ($values as $k => $v) { if ($k != 'total') { $typeRessources = $this->getServiceTypeRessource()->get($k); $budget['dotation'][$typeRessources->getCode()]['heures'] = $v; $budget['dotation'][$typeRessources->getCode()]['libelle'] = $typeRessources->getLibelle(); $budget['consommation'][$typeRessources->getCode()]['heures'] = (key_exists($k, $liquidation)) ? $liquidation[$k] : 0; $budget['consommation'][$typeRessources->getCode()]['libelle'] = $typeRessources->getLibelle(); } else { $budget['dotation']['total'] = $values['total']; } } break; } } //liquidation $budget['liquidation']['paieEtat'] = (key_exists('1', $liquidation)) ? $liquidation['1'] : 0; $budget['liquidation']['ressourcePropre'] = (key_exists('2', $liquidation)) ? $liquidation['2'] : 0; $budget['liquidation']['total'] = $liquidation['total']; $budget['consommation']['total'] = $liquidation['total']; } return $budget; Loading module/Paiement/src/Service/DemandesService.php +25 −30 Original line number Diff line number Diff line Loading @@ -56,8 +56,7 @@ class DemandesService extends AbstractService //On récupère les données nécessaires à la demande de mis en paiement $data = []; $data['heures'] = $heures->getHeuresAPayerAA() + $heures->getHeuresAPayerAC(); $data['centre-cout-id'] = ($heures->getCentreCout()) ? $heures->getCentreCout()->getId() : ''; ; $data['centre-cout-id'] = ($heures->getCentreCout()) ? $heures->getCentreCout()->getId() : '';; $data['domaine-fonctionnel-id'] = ($heures->getDomaineFonctionnel()) ? $heures->getDomaineFonctionnel()->getId() : ''; $data['service-id'] = ($heures->getService()) ? $heures->getService()->getId() : ''; $data['service-referentiel-id'] = ($heures->getServiceReferentiel()) ? $heures->getServiceReferentiel()->getId() : ''; Loading Loading @@ -177,9 +176,12 @@ class DemandesService extends AbstractService $parametreCentreCout = 'enseignement'; } if ($intervenantStructure instanceof Structure && $structure instanceof Structure) { if ($parametreCentreCout == 'affectation') { //Cas ou c'est la composante d'affectation qui fait les demandes de mises en paiement if ($intervenantStructure->getId() == $structure->getId()) { if ($intervenantStructure instanceof Structure && $structure instanceof Structure) { if($parametreCentreCout == 'affectation') { //Cas ou c'est la composante d'affectation qui fait les demandes de mises en paiement if ($intervenantStructure->getId() == $structure->getId()) { /*Si j'ai un role avec un périmètre composante et que ma structure d'affectation est la même que celle de l'intervenant j'accède à toutes les demandes de mise en paiement peu importe la structure de l'enseignement réalisé de l'intervenant on ne filtre pas les dmep*/ Loading Loading @@ -593,8 +595,7 @@ class DemandesService extends AbstractService public function verifierBudgetDemandeMiseEnPaiement(array $demandes): array { $demandesApprouvees = []; $totalHeuresDemandees['ressourcePropre'] = 0; $totalHeuresDemandees['paieEtat'] = 0; $totalHeuresDemandees = []; //1 - On récupère le budget de la structure pour laquelle on a des heures à demander foreach ($demandes as $demande) { Loading @@ -603,36 +604,30 @@ class DemandesService extends AbstractService if ($structure instanceof Structure) { $budget = $this->getServiceBudget()->getBudgetPaiement($structure); //2 - On récupère le centre de cout que nous souhaitons utiliser pour la demande de mise en paiement $centreCout = $this->getEntityManager()->getRepository(CentreCout::class)->find($demande['centreCoutId']); $centreCout = $this->getServiceCentreCout()->get($demande['centreCoutId']); if ($centreCout instanceof CentreCout) { //3 - on vérifier si il y a du budget dans le type de ressource auquel est rattaché ce centre de cout if ($centreCout->getTypeRessource()->getCode() == 'ressources-propres') { if ($budget['dotation']['ressourcePropre'] > 0) { if (array_key_exists($centreCout->getTypeRessource()->getCode(), $budget['dotation'])) { if (!array_key_exists($centreCout->getTypeRessource()->getCode(), $totalHeuresDemandees)) { $totalHeuresDemandees[$centreCout->getTypeRessource()->getCode()] = 0; } if ($budget['dotation'][$centreCout->getTypeRessource()->getCode()]['heures'] > 0) { //4 - on regarde si il y a encore assez de budget pour demander les heures en paiement $total = round($budget['liquidation']['ressourcePropre'] + $demande['heures'] + $totalHeuresDemandees['ressourcePropre'], 2); if ($total <= $budget['dotation']['ressourcePropre']) { $totalHeuresDemandees['ressourcePropre'] += $demande['heures']; $total = round($budget['consommation'][$centreCout->getTypeRessource()->getCode()]['heures'] + $demande['heures'] + $totalHeuresDemandees[$centreCout->getTypeRessource()->getCode()], 2); if ($total <= $budget['dotation'][$centreCout->getTypeRessource()->getCode()]['heures']) { $totalHeuresDemandees[$centreCout->getTypeRessource()->getCode()] += $demande['heures']; } else { continue; } } $demandesApprouvees[] = $demande; } if ($centreCout->getTypeRessource()->getCode() == 'paie-etat') { //Si la dotation est supérieur à 0, alors on vérifie s'il reste du budget disponible if ($budget['dotation']['paieEtat'] > 0) { //4bis - on regarde s'il y a encore assez de budget pour demander les heures en paiement $total = round($budget['liquidation']['paieEtat'] + $demande['heures'] + $totalHeuresDemandees['paieEtat'], 2); if ($total <= $budget['dotation']['paieEtat']) { $totalHeuresDemandees['paieEtat'] += $demande['heures']; } else { continue; } } //Si pas de dotation dans ce type de ressources alors on autorise obligatoirement la demande $demandesApprouvees[] = $demande; } } else { Loading module/Paiement/src/Service/DotationService.php +5 −1 Original line number Diff line number Diff line Loading @@ -49,7 +49,7 @@ class DotationService extends AbstractEntityService /** * Retourne, dans un tableau, le nombre d'heures abondées budgétairement par structure et par type de ressource */ public function getTableauBord( array $structures = [] ) public function getTableauBord(array $structures = []): array { $sql = " SELECT Loading Loading @@ -80,6 +80,10 @@ class DotationService extends AbstractEntityService $res['total'] += $heures; } if ($res['total'] == 0) { return []; } return $res; } Loading Loading
front/Paiement/DemandeMiseEnPaiementStructure.vue +52 −104 Original line number Diff line number Diff line Loading @@ -14,61 +14,44 @@ <div :id="'dmep-collapse-' + datas.code" :aria-labelledby="'dmep-heading-' + datas.code" class="accordion-collapse collapse show"> <div class="accordion-body"> <div v-if="this.dotationPaieEtat + dotationRessourcesPropres > 0"> <div v-if="this.datas.budget.dotation.total > 0"> <!--Budget--> <div class="cartridge gray bordered" style="padding-bottom: 5px;margin-bottom:20px;"> <span>Budget</span> </div> <div class="container"> <table class="table table-bordered caption-top"> <table class="table table-bordered caption-top" style="table-layout: fixed;width:100%"> <thead class="table-light"> <tr> <th class="fw-bold" scope="col">Paie état</th> <th class="fw-bold" scope="col">Ressources propres</th> <th v-for="(value, index) in datasBudget" :key="index" class="fw-bold" scope="col">{{ value.libelle }} </th> </tr> </thead> <tbody> <tr> <td style="width:50%;"> <div v-if="this.dotationPaieEtat > 0" <td v-for="(value, index) in datasBudget"> <div v-if="value.dotation > 0" class="text-center progress position-relative bg-secondary" style="height: 30px;"> <span class="position-absolute top-50 start-50 translate-middle" style="color:white;">{{ this.consommationPaieEtat + ' sur ' + this.dotationPaieEtat value.consommation + ' sur ' + value.dotation }} HETD</span> <div :aria-valuemax="this.dotationPaieEtat" :aria-valuenow="this.consommationPaieEtat" :class="'progress-bar progress-bar-striped '+ this.bgPaieEtat" :style="'width:' + this.pourcentagePaieEtat + '%;'" :title="this.pourcentagePaieEtat + '%'" <div :aria-valuemax="value.dotation" :aria-valuenow="value.consommation" :class="'progress-bar progress-bar-striped '+ bgBudget(value)" :style="'width:' + pourcentageBudget(value) + '%;'" :title="this.pourcentageBudget(value) + '%'" aria-valuemin="0" role="progressbar"> </div> </div> <div v-if="this.dotationPaieEtat == 0" class="text-center"> Aucune dotation paie état </div> </td> <td style="width:50%;"> <div v-if="this.dotationRessourcesPropres > 0" class="progress position-relative bg-secondary" style="height: 30px;"> <span class="position-absolute top-50 start-50 translate-middle" style="color:white;">{{ this.consommationRessourcesPropres + ' sur ' + this.dotationRessourcesPropres }} HETD</span> <div :aria-valuemax="this.dotationRessourcesPropres" :aria-valuenow="this.consommationRessourcesPropres" :class="'progress-bar progress-bar-striped '+ this.bgRessourcesPropres" :style="'width:' + this.pourcentageRessourcePropre + '%;'" :title="this.pourcentageRessourcePropre + '%'" aria-valuemin="0" role="progressbar"> </div> </div> <div v-if="this.dotationRessourcesPropres == 0" class="text-center"> Aucune dotation ressources propres <div v-if="value.dotation == 0" class="text-center"> Aucune dotation {{ value.libelle }} </div> </td> </tr> Loading Loading @@ -159,8 +142,6 @@ <option v-for="item in group.child" :key="item.value" :data-paie-etat="item.paieEtat" :data-ressources-propres="item.ressourcesPropres" :selected="item.centreCoutId==value.centreCout.centreCoutId" :value="item.centreCoutId"> {{ Loading Loading @@ -303,8 +284,6 @@ :label="group.group"> <option v-for="item in group.child" :key="item.value" :data-paie-etat="item.paieEtat" :data-ressources-propres="item.ressourcesPropres" :selected="item.centreCoutId == value.centreCout.centreCoutId" :value="item.centreCoutId"> {{ Loading Loading @@ -463,8 +442,6 @@ :label="group.group"> <option v-for="item in group.child" :key="item.value" :data-paie-etat="item.paieEtat" :data-ressources-propres="item.ressourcesPropres" :selected="item.centreCoutId == value.centreCout.centreCoutId" :value="item.centreCoutId" > Loading Loading @@ -570,59 +547,39 @@ export default { name: "DemandeMiseEnPaiementStructure", props: { datas: {required: true}, intervenant: {required: true}, }, data() { return { dotationPaieEtat: this.datas.budget.dotation.paieEtat, dotationRessourcesPropres: this.datas.budget.dotation.ressourcePropre, consommationPaieEtat: this.datas.budget.liquidation.paieEtat, consommationRessourcesPropres: this.datas.budget.liquidation.ressourcePropre, } }, watch: { datas: function () { this.dotationPaieEtat = this.datas.budget.dotation.paieEtat; this.dotationRessourcesPropres = this.datas.budget.dotation.ressourcePropre; this.consommationPaieEtat = this.datas.budget.liquidation.paieEtat; this.consommationRessourcesPropres = this.datas.budget.liquidation.ressourcePropre; }, }, computed: { pourcentagePaieEtat() { return Math.round((this.consommationPaieEtat / this.dotationPaieEtat) * 100); }, pourcentageRessourcePropre() { return Math.round((this.consommationRessourcesPropres / this.dotationRessourcesPropres) * 100); }, bgPaieEtat() datasBudget() { if (Math.round((this.consommationPaieEtat / this.dotationPaieEtat) * 100) > 100) { return 'bg-warning'; } else { return 'bg-success'; let datasBudget = {}; Object.entries(this.datas.budget.dotation).forEach(([key, value]) => { if (key != 'total') { datasBudget[key] = {}; datasBudget[key]['libelle'] = value.libelle; datasBudget[key]['dotation'] = value.heures; datasBudget[key]['consommation'] = 1001; } }, bgRessourcesPropres() { if (Math.round((this.consommationRessourcesPropres / this.dotationRessourcesPropres) * 100) > 100) { return 'bg-warning'; } else { return 'bg-success'; }); Object.entries(this.datas.budget.consommation).forEach(([key, value]) => { if (key != 'total') { if (key in datasBudget) { datasBudget[key]['consommation'] = value.heures; } } }); return datasBudget; } }, methods: { heuresStatutToString(value) { Loading Loading @@ -707,8 +664,6 @@ export default { let missionId = (inputHeure.hasAttribute('data-mission-id') ? inputHeure.getAttribute('data-mission-id') : ''); let centreCoutId = inputCentreCout.value; let ressourcesPropres = inputCentreCout.options[inputCentreCout.selectedIndex].getAttribute('data-ressources-propres'); let paieEtat = inputCentreCout.options[inputCentreCout.selectedIndex].getAttribute('data-paie-etat'); //Si centre de cout non sélectionné if (centreCoutId == '') { unicaenVue.flashMessenger.toast("Vous devez sélectionner un centre de coût pour demander la mise en paiement de ces heures", 'error', options) Loading @@ -721,25 +676,6 @@ export default { this.$emit('refresh-btn-state');; return false; } //Si je suis sur une demande de mise en paiement avec des fonds paie etat if (paieEtat == 1 && this.dotationPaieEtat > 0) { let solde = this.dotationPaieEtat - (this.consommationPaieEtat + heureADemander); if (solde <= 0) { unicaenVue.flashMessenger.toast("Demande de mise en paiement impossible manque de dotation 'paie etat' pour ces heures", 'error', options) this.$emit('refresh-btn-state'); return false; } } //Si je suis sur une demande de mise en paiement avec des fonds ressources propres if (ressourcesPropres == 1 && this.dotationRessourcesPropres > 0) { let solde = this.dotationRessourcesPropres - (this.consommationRessourcesPropres + heureADemander); if (solde <= 0) { unicaenVue.flashMessenger.toast("Demande de mise en paiement impossible manque de dotation 'ressources propres' pour ces heures", 'error', options) this.$emit('refresh-btn-state'); return false; } } var datas = []; let demande = { Loading Loading @@ -893,6 +829,18 @@ export default { { return Util.dateToString(val); }, pourcentageBudget(value) { return Math.round((value.consommation / value.dotation) * 100); }, bgBudget(value) { if (Math.round((value.consommation / value.dotation) * 100) > 100) { return 'bg-danger'; } else { return 'bg-success'; } } Loading
module/Paiement/src/Controller/DemandesController.php +2 −1 Original line number Diff line number Diff line Loading @@ -64,7 +64,8 @@ class DemandesController extends AbstractController $demandes = $this->axios()->fromPost(); $demandesApprouveesBudgetairement = $this->getServiceDemandes()->verifierBudgetDemandeMiseEnPaiement($demandes); $error = 0; $errorBudget = count($demandes) - count($demandesApprouveesBudgetairement); $errorBudget = round(count($demandes) - count($demandesApprouveesBudgetairement)); $success = 0; foreach ($demandesApprouveesBudgetairement as $demande) { try { Loading
module/Paiement/src/Service/BudgetService.php +20 −14 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ use Lieu\Entity\Db\Structure; class BudgetService extends AbstractService { use DotationServiceAwareTrait; use TypeRessourceServiceAwareTrait; /** Loading Loading @@ -102,32 +103,37 @@ class BudgetService extends AbstractService { $budget = [ 'dotation' => [ 'paieEtat' => 0, 'ressourcePropre' => 0, 'total' => 0, ], 'liquidation' => [ 'paieEtat' => 0, 'ressourcePropre' => 0, 'consommation' => [ 'total' => 0, ], ]; if ($structure instanceof Structure) { $dotation = $this->getServiceDotation()->getTableauBord([$structure->getId()]); $liquidation = $this->getTblLiquidation($structure); foreach ($dotation as $key => $value) { if (!empty($dotation)) { $dotation = $this->getServiceDotation()->getTableauBord([$structure->getId()]); $liquidation = $this->getTblLiquidation($structure); foreach ($dotation as $key => $values) { if ($key == $structure->getId()) { $budget['dotation']['paieEtat'] = (key_exists(1, $value)) ? $value['1'] : 0; $budget['dotation']['ressourcePropre'] = (key_exists(2, $value)) ? $value['2'] : 0; $budget['dotation']['total'] = $value['total']; foreach ($values as $k => $v) { if ($k != 'total') { $typeRessources = $this->getServiceTypeRessource()->get($k); $budget['dotation'][$typeRessources->getCode()]['heures'] = $v; $budget['dotation'][$typeRessources->getCode()]['libelle'] = $typeRessources->getLibelle(); $budget['consommation'][$typeRessources->getCode()]['heures'] = (key_exists($k, $liquidation)) ? $liquidation[$k] : 0; $budget['consommation'][$typeRessources->getCode()]['libelle'] = $typeRessources->getLibelle(); } else { $budget['dotation']['total'] = $values['total']; } } break; } } //liquidation $budget['liquidation']['paieEtat'] = (key_exists('1', $liquidation)) ? $liquidation['1'] : 0; $budget['liquidation']['ressourcePropre'] = (key_exists('2', $liquidation)) ? $liquidation['2'] : 0; $budget['liquidation']['total'] = $liquidation['total']; $budget['consommation']['total'] = $liquidation['total']; } return $budget; Loading
module/Paiement/src/Service/DemandesService.php +25 −30 Original line number Diff line number Diff line Loading @@ -56,8 +56,7 @@ class DemandesService extends AbstractService //On récupère les données nécessaires à la demande de mis en paiement $data = []; $data['heures'] = $heures->getHeuresAPayerAA() + $heures->getHeuresAPayerAC(); $data['centre-cout-id'] = ($heures->getCentreCout()) ? $heures->getCentreCout()->getId() : ''; ; $data['centre-cout-id'] = ($heures->getCentreCout()) ? $heures->getCentreCout()->getId() : '';; $data['domaine-fonctionnel-id'] = ($heures->getDomaineFonctionnel()) ? $heures->getDomaineFonctionnel()->getId() : ''; $data['service-id'] = ($heures->getService()) ? $heures->getService()->getId() : ''; $data['service-referentiel-id'] = ($heures->getServiceReferentiel()) ? $heures->getServiceReferentiel()->getId() : ''; Loading Loading @@ -177,9 +176,12 @@ class DemandesService extends AbstractService $parametreCentreCout = 'enseignement'; } if ($intervenantStructure instanceof Structure && $structure instanceof Structure) { if ($parametreCentreCout == 'affectation') { //Cas ou c'est la composante d'affectation qui fait les demandes de mises en paiement if ($intervenantStructure->getId() == $structure->getId()) { if ($intervenantStructure instanceof Structure && $structure instanceof Structure) { if($parametreCentreCout == 'affectation') { //Cas ou c'est la composante d'affectation qui fait les demandes de mises en paiement if ($intervenantStructure->getId() == $structure->getId()) { /*Si j'ai un role avec un périmètre composante et que ma structure d'affectation est la même que celle de l'intervenant j'accède à toutes les demandes de mise en paiement peu importe la structure de l'enseignement réalisé de l'intervenant on ne filtre pas les dmep*/ Loading Loading @@ -593,8 +595,7 @@ class DemandesService extends AbstractService public function verifierBudgetDemandeMiseEnPaiement(array $demandes): array { $demandesApprouvees = []; $totalHeuresDemandees['ressourcePropre'] = 0; $totalHeuresDemandees['paieEtat'] = 0; $totalHeuresDemandees = []; //1 - On récupère le budget de la structure pour laquelle on a des heures à demander foreach ($demandes as $demande) { Loading @@ -603,36 +604,30 @@ class DemandesService extends AbstractService if ($structure instanceof Structure) { $budget = $this->getServiceBudget()->getBudgetPaiement($structure); //2 - On récupère le centre de cout que nous souhaitons utiliser pour la demande de mise en paiement $centreCout = $this->getEntityManager()->getRepository(CentreCout::class)->find($demande['centreCoutId']); $centreCout = $this->getServiceCentreCout()->get($demande['centreCoutId']); if ($centreCout instanceof CentreCout) { //3 - on vérifier si il y a du budget dans le type de ressource auquel est rattaché ce centre de cout if ($centreCout->getTypeRessource()->getCode() == 'ressources-propres') { if ($budget['dotation']['ressourcePropre'] > 0) { if (array_key_exists($centreCout->getTypeRessource()->getCode(), $budget['dotation'])) { if (!array_key_exists($centreCout->getTypeRessource()->getCode(), $totalHeuresDemandees)) { $totalHeuresDemandees[$centreCout->getTypeRessource()->getCode()] = 0; } if ($budget['dotation'][$centreCout->getTypeRessource()->getCode()]['heures'] > 0) { //4 - on regarde si il y a encore assez de budget pour demander les heures en paiement $total = round($budget['liquidation']['ressourcePropre'] + $demande['heures'] + $totalHeuresDemandees['ressourcePropre'], 2); if ($total <= $budget['dotation']['ressourcePropre']) { $totalHeuresDemandees['ressourcePropre'] += $demande['heures']; $total = round($budget['consommation'][$centreCout->getTypeRessource()->getCode()]['heures'] + $demande['heures'] + $totalHeuresDemandees[$centreCout->getTypeRessource()->getCode()], 2); if ($total <= $budget['dotation'][$centreCout->getTypeRessource()->getCode()]['heures']) { $totalHeuresDemandees[$centreCout->getTypeRessource()->getCode()] += $demande['heures']; } else { continue; } } $demandesApprouvees[] = $demande; } if ($centreCout->getTypeRessource()->getCode() == 'paie-etat') { //Si la dotation est supérieur à 0, alors on vérifie s'il reste du budget disponible if ($budget['dotation']['paieEtat'] > 0) { //4bis - on regarde s'il y a encore assez de budget pour demander les heures en paiement $total = round($budget['liquidation']['paieEtat'] + $demande['heures'] + $totalHeuresDemandees['paieEtat'], 2); if ($total <= $budget['dotation']['paieEtat']) { $totalHeuresDemandees['paieEtat'] += $demande['heures']; } else { continue; } } //Si pas de dotation dans ce type de ressources alors on autorise obligatoirement la demande $demandesApprouvees[] = $demande; } } else { Loading
module/Paiement/src/Service/DotationService.php +5 −1 Original line number Diff line number Diff line Loading @@ -49,7 +49,7 @@ class DotationService extends AbstractEntityService /** * Retourne, dans un tableau, le nombre d'heures abondées budgétairement par structure et par type de ressource */ public function getTableauBord( array $structures = [] ) public function getTableauBord(array $structures = []): array { $sql = " SELECT Loading Loading @@ -80,6 +80,10 @@ class DotationService extends AbstractEntityService $res['total'] += $heures; } if ($res['total'] == 0) { return []; } return $res; } Loading