Procházet zdrojové kódy

v1.0.3 Corrección de bugs en MESMPR y MESMRE

JeanBenitez před 3 roky
rodič
revize
5385a50b99

+ 0 - 1
vacaciones/src/app/auth/user.guard.ts

@@ -69,7 +69,6 @@ export class UserGuard implements CanActivate {
 
       const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
       await sleep(200);
-      console.log(usuario);
       
       if (usuario != null) {
         switch (this._encService.desencriptar(usuario.PERFIL)) {

+ 10 - 2
vacaciones/src/app/components/mes/mesmpr/mesmpr.component.css

@@ -2,7 +2,6 @@
   transition: box-shadow 280ms cubic-bezier(0.4, 0, 0.2, 1);
   display: block;
   position: relative;
-  padding: 10px 10px 30px 10px;
   border-radius: 4px;
 }
 
@@ -11,7 +10,7 @@
 }
 
 .expansion-panel {
-  width: 45%;
+  width: 60%;
   margin: auto;
   margin-bottom: 2%;
 }
@@ -45,6 +44,15 @@
   align-items: center;
 }
 
+.position-left {
+  position: absolute;
+  right: 0;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+}
+
+
 .mat-card-title {
   display: block;
   margin-bottom: 0%;

+ 147 - 106
vacaciones/src/app/components/mes/mesmpr/mesmpr.component.html

@@ -9,153 +9,194 @@
   </mat-grid-tile>
 </mat-grid-list>
 
-<mat-card class="card-normal-text mat-card-text mat-elevation-z8 animated fadeIn fast"
-  *ngIf="periodo_actual != null && !loading && !caso3">
+<!-- EASYG -->
+<mat-card class="card-normal-text mat-card-text mat-elevation-z8 animated fadeIn fast" *ngIf="!loading && casoEAYG">
   <mat-grid-list cols="12" rowHeight="100px">
+    <!-- Fila 1 | Periodo | Días disponibles (título) -->
     <mat-grid-tile colspan="12">
+      <!-- Periodo Actual -->
       <div class="ml-5" style="position: absolute; left: 0">
-        <!-- <mat-card-title style="margin-left: 5%"
-          ><b>{{
-            periodo_actual_anios != "" ? periodo_actual_anios : ""
-          }}</b></mat-card-title
-        > -->
-        <mat-card-title style="margin-left: 5%">
-          <b>
-            {{ anios_actuales }}
-          </b>
+        <mat-card-title style="margin-left: auto">
+          <b>{{ periodoEAYG }}</b>
         </mat-card-title>
-        <span class="display-text">Periodo actual</span>
-        <!-- 
-        <span class="display-text" *ngIf="caso2">Periodo actual Earn As You Go</span> -->
+        <span class="display-text">Periodo EAYG</span><br>
+        <span style="margin-top: 5px;"><b>Vencimiento:</b> {{ fechaVencimientoEAYG }}</span>
       </div>
       <div>
         <span class="display-0">Días disponibles</span>
       </div>
-      <div class="mr-5" class="position-right" style="margin-right: 2%; margin-top: 2.5%; width: 210px">
+      <div class="mr-5" class="position-right" style="width: 210px">
         <mat-card-title class="display-text">Días por periodo</mat-card-title>
-        <span class="display-text-small text-secondary"><b>{{ dias_por_periodo_actual }}</b></span>
+        <span class="display-text-small text-secondary"><b>{{ diasPeriodoEAYG }}</b></span>
       </div>
     </mat-grid-tile>
+    <!-- Fila 2 | Días Tomados | Días disponibles (Dato) -->
     <mat-grid-tile colspan="12">
       <h1 class="display-4 text-secondary">
-        {{
-        periodo_actual_2.ESEAYG == "Si"
-        ? 0
-        : periodo_actual_2.VACACIONESDISPONIBLES
-        }}
+        {{ diasDisponiblesEAYG }}
       </h1>
-      <!-- <h1 class="display-4 text-secondary">
-        {{ periodo_actual.VACACIONESDISPONIBLES }}
-      </h1> -->
-      <div class="mr-5" class="position-right" style="margin-right: 3%; width: 180px">
+      <div class="mr-5" class="position-right" style="margin-right: 1%; width: 180px">
         <mat-card-title class="display-text">Días tomados</mat-card-title>
-        <span class="display-text-small text-secondary"><b>{{ dias_tomados }}</b></span>
+        <span class="display-text-small text-secondary"><b> {{ diasTomadosEAYG }} </b></span>
       </div>
     </mat-grid-tile>
   </mat-grid-list>
-  <div class="mr-5" class="position-right" style="margin-right: 3.5%">
-    <mat-card-title class="display-text">Días disponibles EAYG</mat-card-title>
-    <span class="display-text-small text-secondary"><b>
-        {{ periodo_eayg !== null ? periodo_eayg.VACACIONESDISPONIBLES : 0 }}
-      </b></span>
+  <div align="right" style="right: 0; display: flex; align-items: center">
+    
+    <div  style="width: 100%; margin-left: 150px;">  
+      <mat-accordion class="headers-align" style="width: 100%; margin-top: 1%;" *ngIf="!casoActual && !casoAnterior">
+        <mat-expansion-panel class="expansion-panel" [disabled]="detalles.length === 0">
+          <mat-expansion-panel-header style="margin: auto;">
+            <mat-panel-title>
+              <mat-icon>calendar_month</mat-icon>
+            </mat-panel-title>
+            <mat-panel-description><b>Vacaciones tomadas</b></mat-panel-description>
+          </mat-expansion-panel-header>
+          <div class="vacaciones-panel" *ngFor="let periodos of periodos">
+            <div class="periodo-flex">
+              <span>Periodo {{ formatoPeriodo(periodos.PERIODO) }}</span>
+            </div>
+    
+            <div>
+              <div *ngFor="let detallePeriodo of formatoDetalles(periodos.DETALLES)">
+                 <mat-divider></mat-divider>
+                <div class="panel-flex">
+                  <span><b> Fecha inicio: </b>{{ formatoFecha(detallePeriodo.fecha_inicio) }}</span>
+                  <span><b> Fecha fin: </b>{{ formatoFecha(detallePeriodo.fecha_fin) }}</span>
+                  <span><b> Días tomados: </b>{{ detallePeriodo.dias_tomados }}</span>
+                </div>
+              </div>
+            </div>
+          </div>
+        </mat-expansion-panel>
+      </mat-accordion>
+    </div>
+
+    <div style="width: 180px; text-align: center; margin-right: 30px;">
+      <mat-card-title class="display-text">Días solicitados</mat-card-title>
+      <span class="display-text-small text-secondary"><b> {{ diasSolicitadosEAYG }} </b></span>
+    </div>
   </div>
+  
+</mat-card>
 
-  <br />
-  <mat-accordion class="headers-align">
-    <mat-expansion-panel class="expansion-panel" [disabled]="arr_detalles.length === 0">
-      <mat-expansion-panel-header>
-        <mat-panel-title>
-          <mat-icon>calendar_month</mat-icon>
-        </mat-panel-title>
-        <mat-panel-description><b>Vacaciones tomadas</b></mat-panel-description>
-      </mat-expansion-panel-header>
-      <div class="vacaciones-panel" *ngFor="let detalle of this.arr_detalles">
-        <div class="periodo-flex" *ngIf="detalle.DIASTOMADOS > 0">
-          <span>{{ obtenerAnios(detalle.PERIODO) }}</span>
-        </div>
+<!-- Periodo Actual -->
+<mat-card class="card-normal-text mat-card-text mat-elevation-z8 animated fadeIn fast" [style.margin-bottom]="!casoAnterior ? '100px' : ''"
+  *ngIf="!loading && casoActual">
+  <mat-grid-list cols="12" rowHeight="100px">
+    <!-- Fila 1 | Periodo | Días disponibles (título) -->
+    <mat-grid-tile colspan="12">
+      <!-- Periodo Actual -->
+      <div class="ml-5" style="position: absolute; left: 0">
+        <mat-card-title style="margin-left: auto">
+          <b>{{ periodoActual }}</b>
+        </mat-card-title>
+        <span class="display-text">Periodo actual</span><br>
+        <span style="margin-top: 5px;"><b>Vencimiento:</b> {{ fechaVencimientoActual }}</span>
+      </div>
+      <div>
+        <span class="display-0">Días disponibles</span>
+      </div>
+      <div class="mr-5" class="position-right" style="width: 210px">
+        <mat-card-title class="display-text">Días por periodo</mat-card-title>
+        <span class="display-text-small text-secondary"><b>{{ diasPeriodoActual }}</b></span>
+      </div>
+    </mat-grid-tile>
+    <!-- Fila 2 | Días Tomados | Días disponibles (Dato) -->
+    <mat-grid-tile colspan="12">
+      <h1 class="display-4 text-secondary">
+        {{ diasDisponiblesActual }}
+      </h1>
+      <div class="mr-5" class="position-right" style="margin-right: 1%; width: 180px">
+        <mat-card-title class="display-text">Días tomados</mat-card-title>
+        <span class="display-text-small text-secondary"><b> {{ diasTomadosActual }} </b></span>
+      </div>
+    </mat-grid-tile>    
+  </mat-grid-list>
 
-        <div>
-          <div *ngIf="detalle.DIASTOMADOS > 0">
-            <mat-divider></mat-divider>
-            <div class="panel-flex">
-              <span><b> Fecha inicio: </b>{{
-                formatoFecha(detalle.FECHASVACACIONES.split("|")[0])
-                }}</span>
-              <span><b> Fecha fin: </b>{{
-                formatoFecha(detalle.FECHASVACACIONES.split("|")[1])
-                }}</span>
-              <span><b> Días tomados: </b>{{ detalle.DIASTOMADOS }}</span>
+  <div align="right" style="right: 0; display: flex; align-items: center">
+    <div  style="width: 100%; margin-left: 150px;">  
+      <mat-accordion class="headers-align" style="width: 100%; margin-top: 1%;">
+        <mat-expansion-panel class="expansion-panel" [disabled]="detalles.length === 0">
+          <mat-expansion-panel-header style="margin: auto;">
+            <mat-panel-title>
+              <mat-icon>calendar_month</mat-icon>
+            </mat-panel-title>
+            <mat-panel-description><b>Vacaciones tomadas</b></mat-panel-description>
+          </mat-expansion-panel-header>
+          <div class="vacaciones-panel" *ngFor="let periodos of periodos">
+            <div class="periodo-flex">
+              <span>Periodo {{ formatoPeriodo(periodos.PERIODO) }}</span>
+            </div>
+    
+            <div>
+              <div *ngFor="let detallePeriodo of formatoDetalles(periodos.DETALLES)">
+                 <mat-divider></mat-divider>
+                <div class="panel-flex">
+                  <span><b> Fecha inicio: </b>{{ formatoFecha(detallePeriodo.fecha_inicio) }}</span>
+                  <span><b> Fecha fin: </b>{{ formatoFecha(detallePeriodo.fecha_fin) }}</span>
+                  <span><b> Días tomados: </b>{{ detallePeriodo.dias_tomados }}</span>
+                </div>
+              </div>
             </div>
           </div>
-        </div>
-      </div>
-    </mat-expansion-panel>
-  </mat-accordion>
+        </mat-expansion-panel>
+      </mat-accordion>
+    </div>
+
+    <div style="width: 180px; text-align: center; margin-right: 30px;">
+      <mat-card-title class="display-text">Días solicitados</mat-card-title>
+      <span class="display-text-small text-secondary"><b> {{ diasSolicitadosActual }} </b></span>
+    </div>
+  </div>
 </mat-card>
 
-<mat-card class="card-normal-text mat-elevation-z8 animated fadeIn fast" *ngIf="
-    periodo_anterior != null &&
-    !loading &&
-    !caso3 &&
-    periodo_anterior_2.CADUCADO == 'No'
-  ">
-  <mat-grid-list cols="12" rowHeight="95px" class="mb-5">
+<!-- Periodo Anterior -->
+<mat-card class="card-normal-text mat-card-text mat-elevation-z8 animated fadeIn fast" style="margin-bottom: 100px;"
+  *ngIf="!loading && casoAnterior">
+  <mat-grid-list cols="12">
+    <!-- Fila 1 | Periodo | Días disponibles (título) -->
     <mat-grid-tile colspan="12">
       <div class="ml-5" style="position: absolute; left: 0">
-        <mat-card-title style="margin-left: 10%">
-          <b>{{ anios_anteriores }}</b>
+        <mat-card-title style="margin-left: auto">
+          <b>{{ periodoAnterior }}</b>
         </mat-card-title>
-        <span class="display-text">Periodo anterior</span>
+        <span class="display-text">Periodo anterior</span><br>
+        <span style="margin-top: 5px;"><b>Vencimiento:</b> {{ fechaVencimientoAnterior }}</span>
       </div>
       <div>
-        <span class="display-0">Vacaciones disponibles</span>
-      </div>
-
-      <div *ngIf="false" class="mr-5" class="position-right" style="margin-right: 2%; margin-top: 2.5%">
-        <mat-card-title class="display-text">Días tomados EAYG</mat-card-title>
-        <span class="display-text-small text-secondary"><b>{{ dias_periodo }}</b></span>
+        <span class="display-0">Días disponibles</span>
       </div>
-      <div class="mr-5" class="position-right" style="margin-right: 2%; margin-top: 2.5%; width: 210px">
+      <div class="mr-5" class="position-right" style="width: 210px">
         <mat-card-title class="display-text">Días por periodo</mat-card-title>
-        <span class="display-text-small text-secondary"><b>{{ dias_por_periodo_anterior }}</b></span>
+        <span class="display-text-small text-secondary"><b>{{ diasPeriodoAnterior }}</b></span>
       </div>
     </mat-grid-tile>
+
+    <!-- Fila 2 | Días Tomados | Días disponibles (Dato) -->
     <mat-grid-tile colspan="12">
       <h1 class="display-4 text-secondary">
-        {{ periodo_anterior.VACACIONESDISPONIBLES }}
+        {{ diasDisponiblesAnterior }}
       </h1>
+      <div class="mr-5" class="position-right" style="margin-right: 1%; width: 180px; ">
+        <mat-card-title class="display-text">Días tomados</mat-card-title>
+        <span class="display-text-small text-secondary"><b>{{ diasTomadosAnterior }}</b></span>
+      </div>
     </mat-grid-tile>
   </mat-grid-list>
-  <br />
-</mat-card>
 
-<mat-card class="card-normal-text mat-card-text mat-elevation-z8 animated fadeIn fast" *ngIf="!loading && caso2">
-  <mat-card-content>
-    <mat-grid-list cols="12" rowHeight="100px">
-      <mat-grid-tile colspan="12">
-        <div class="ml-5" style="position: absolute; left: 0">
-          <mat-card-title style="margin-left: 5%"><b>{{ construirPeriodo(periodos[0].PERIODO) }}</b></mat-card-title>
-          <span class="display-text">Periodo actual cd</span>
-          <!-- 
-          <span class="display-text" *ngIf="caso2">Periodo actual Earn As You Go</span> -->
-        </div>
-        <div>
-          <span class="display-0">Días disponibles Earn As You Go</span>
-        </div>
-      </mat-grid-tile>
-      <mat-grid-tile colspan="12">
-        <h1 class="display-4 text-secondary">
-          <!--  -->
-        </h1>
-      </mat-grid-tile>
-      <div class="mr-5 pt-5 position-right" style="margin-right: 3%; width: 160px; top: 24px">
-        <mat-card-title class="display-text">Días tomados</mat-card-title>
-        <span class="display-text-small text-secondary"><b>0</b></span>
-      </div>
-    </mat-grid-list>
-  </mat-card-content>
+  <div align="right" style="right: 0; display: flex; align-items: center">
+    <div style="width: 100%; margin-left: 150px;">  
+     
+    </div>
+
+    <div style="width: 180px; text-align: center; margin-right: 30px;">
+      <mat-card-title class="display-text">Días solicitados</mat-card-title>
+        <span class="display-text-small text-secondary"><b> {{ diasSolicitadosAnterior }} </b></span>
+    </div>
+  </div>
 </mat-card>
 
-<div *ngIf="caso3 && !loading" class="centre">
+<div *ngIf="caso0 && !loading" class="centre">
   <h2>Aún no existen periodos vacaciones para este usuario</h2>
 </div>

+ 155 - 168
vacaciones/src/app/components/mes/mesmpr/mesmpr.component.ts

@@ -5,6 +5,10 @@ import { USERInterface } from 'src/app/interfaces/user-interface';
 import { IAMService } from 'src/app/services/iam/iam.service';
 import { MESMPRService } from 'src/app/services/mes/mesmpr/mesmpr.service';
 import { MESMPRDetallesInterface } from 'src/app/interfaces/mes/mesmpr/mesmpr-detalles-interface';
+import { ENCService } from 'src/app/services/enc/enc.service';
+import { MesmprVacacionesInterface } from 'src/app/interfaces/mes/mesmpr/mesmpr-vacaciones-interface';
+import { TileStyler } from '@angular/material/grid-list/tile-styler';
+import { ResponseData } from 'src/app/interfaces/response-data';
 @Component({
   selector: 'app-mesmpr',
   templateUrl: './mesmpr.component.html',
@@ -12,32 +16,40 @@ import { MESMPRDetallesInterface } from 'src/app/interfaces/mes/mesmpr/mesmpr-de
 })
 export class MESMPRComponent implements OnInit {
   loading: Boolean = true;
-  periodo: number;
-  periodos: MesmprInterface[] = [];
   
-  detalles: MESMPRDetallesInterface[] = [];
+  public detalles: Array<any> = [];
 
-  anios_actuales: string = `${ new Date().getFullYear()-1 }-${ new Date().getFullYear() }`
-  anios_anteriores: string = `${ new Date().getFullYear()-2 }-${ new Date().getFullYear()-1 }`
-  periodo_actual_2: MesmprInterface = {} as MesmprInterface;
-  periodo_anterior_2: MesmprInterface = {} as MesmprInterface;
-  periodo_eayg: MesmprInterface = null!;
-  dias_por_periodo_actual: number = 0;
-  dias_por_periodo_anterior: number = 0;
-  dias_tomados: number = 0;
-  arr_detalles: any[] = [];
+  public periodos: Array<MesmprInterface> = [] as Array<MesmprInterface>;
 
-  periodo_actual: any = null;
-  periodo_actual_anios: String = '';
 
-  periodo_anterior: any = null;
-  periodo_anterior_anios: String = '';
+  public caso0: boolean = false;
+  public casoEAYG: boolean = false;
+  public casoActual: boolean = false;
+  public casoAnterior: boolean = false;
 
-  dias_periodo = 0;
+  public periodoEAYG: string = "2020-2021";
+  public periodoActual: string = "2020-2021";
+  public periodoAnterior: string = "2020-2021";
 
-  caso1: boolean = false;
-  caso2: boolean = false;
-  caso3: boolean = false;
+  public fechaVencimientoEAYG: string = "2020-2021";
+  public fechaVencimientoActual: string = "2020-2021";
+  public fechaVencimientoAnterior: string = "2020-2021";
+
+  public diasDisponiblesEAYG: number = 10;
+  public diasDisponiblesActual: number = 10;
+  public diasDisponiblesAnterior: number = 10;
+
+  public diasPeriodoEAYG: number = 5;
+  public diasPeriodoActual: number = 5;
+  public diasPeriodoAnterior: number = 5;
+
+  public diasTomadosEAYG: number = 5;
+  public diasTomadosActual: number = 5;
+  public diasTomadosAnterior: number = 5;
+
+  public diasSolicitadosEAYG: number = 0;
+  public diasSolicitadosActual: number = 0;
+  public diasSolicitadosAnterior: number = 0;
 
   usuario: string = '';
   usuario_session: USERInterface = JSON.parse(
@@ -47,103 +59,32 @@ export class MESMPRComponent implements OnInit {
   constructor(
     private _mesmprService: MESMPRService,
     private _iamService: IAMService,
-    private _snackBar: MatSnackBar
+    private _snackBar: MatSnackBar,
+    private _encService: ENCService
   ) {
-    this.periodo = new Date().getFullYear();
     this.usuario = this.usuario_session.NOMBRE;
-
-    
   }
 
   ngOnInit(): void {
     this.obtener();
   }
 
-  obtenerDetalles(periodos: MesmprInterface[]){    
-    periodos.forEach( element0 => {
-      if (element0.DETALLES.length !== 0 ) {
-        element0.DETALLES.forEach( element1 => {
-
-          if (element1.DIASTOMADOS !== 0) {
-            this.arr_detalles.push({
-              DIASTOMADOS: element1.DIASTOMADOS,
-              FECHASVACACIONES: element1.FECHASVACACIONES,
-              PERIODO: element0.PERIODO
-            });
-          }
-        });
-      }
-    });
-
-    
-  }
-
-  obtenerPeriodoActual(periodos: MesmprInterface[]){
-
-    let ultimo_periodo = periodos[periodos.length-  1];
-    
-    if (ultimo_periodo.ESEAYG != "Si") {
-      this.periodo_actual_2 = ultimo_periodo;
-      this.periodo_anterior_2 = periodos[periodos.length - 2];
-    }else{
-      if (periodos.length > 1 ) {
-        this.periodo_actual_2 =  periodos[periodos.length - 2];
-        this.periodo_anterior_2 = periodos[periodos.length - 3];
-      }else{
-        this.periodo_actual_2 =  periodos[periodos.length - 1];
-        this.periodo_anterior_2 = periodos[periodos.length - 2];
-      }
-      
-      this.periodo_eayg = ultimo_periodo;
-    }
-
-    this.dias_por_periodo_actual = this.periodo_actual_2.VACACIONESDISPONIBLES;
-    this.dias_por_periodo_anterior = this.periodo_anterior_2.VACACIONESDISPONIBLES;
-
-    this.periodo_actual_2.DETALLES.forEach(element => {
-      this.dias_tomados += element.DIASTOMADOS;
-      this.dias_por_periodo_actual += element.DIASTOMADOS;
-    });
-    
-    this.periodo_anterior_2.DETALLES.forEach(element => {
-      this.dias_por_periodo_anterior += element.DIASTOMADOS;
-    });
-  }
-
-  construirPeriodo(periodo:String){
-    let arr_periodo = periodo.split("|");
-    let anio_inicio = arr_periodo[0].split("-")[0];
-    let anio_final = arr_periodo[1].split("-")[0];
-    return `${anio_inicio}-${anio_final}`
-  }
-
-  obtener() {
+  private async obtener() {
     this._mesmprService.obtener().subscribe(
-      (res: any) => {0
-
+      (res: ResponseData) => {        
         if (res.status == 'Token is Expired') {
           this._iamService.logout();
           this.snackAlert('Sesión expirada. Vuelva a iniciar sesión');
-        }
-        if (res.response.length == 0) {
-          this.caso3 = true;
-        }else if(res.response.length == 1 && res.response[0].DIASEAYGDISPONIBLES > 0){
-          this.caso2 = true;
-          this.caso3 = false;
-          
-          this.obtenerPeriodoActual( res.response);
         }else{
-          this.obtenerDetalles(res.response);
-          this.obtenerPeriodoActual( res.response);
-          this.caso1 = true;
+          let verPeriodos:MesmprInterface[] = res.response.filter((element:any) => element.CADUCADO === "No"  && element.DETALLES.length > 0);
+
+          this.periodos = verPeriodos;                 
+          this.obtenerCasos(res.response);
+          this.loading = false;
         }
-        
-        this.periodos = res.response;
-        
-        this.loading = false;
-        this.filtroPeriodos();
       },
       (error) => {
+        console.log(error);
         
         if (!error.ok) {
           this.snackAlert('Ocurrió un error inesperado');
@@ -158,82 +99,128 @@ export class MESMPRComponent implements OnInit {
     );
   }
 
-  filtroPeriodos() {
-    if (this.periodos.length > 0) {
-      //"2018-01-24|2019-01-24"
-      //Split para separar las fechas, split para obtener el año
-      let filtro_periodos: MesmprInterface[] = this.periodos.filter(
-        (p:any) =>
-          parseInt(p.PERIODO.split('|')[1].split('-')[0]) <= this.periodo &&
-          p.VACACIONESDISPONIBLES > 0
-      );
-
-      if (filtro_periodos.length == 1) {
-        this.periodo_actual = filtro_periodos[0];
-      } else if (filtro_periodos.length > 1) {
-        filtro_periodos.sort(function (a, b) {
-          if (
-            parseInt(a.PERIODO.split('|')[1].split('-')[0]) >
-            parseInt(b.PERIODO.split('|')[1].split('-')[0])
-          ) {
-            return -1;
-          }
-          if (
-            parseInt(a.PERIODO.split('|')[1].split('-')[0]) <
-            parseInt(b.PERIODO.split('|')[1].split('-')[0])
-          ) {
-            return 1;
-          }
-          return 0;
-        });
-
-        //Obtener periodo actual
-        this.periodo_actual = filtro_periodos[0];
-        
-        //Obtener periodo anterior
-        this.periodo_anterior = filtro_periodos[1];
-
-        //Asignar dias del periodo, tomados
-        filtro_periodos[0].DETALLES.forEach((detalle) => {
-          this.dias_periodo += detalle.DIASTOMADOS;
-        });
-        //Asignar dias disponibles
-        this.dias_periodo += filtro_periodos[0].VACACIONESDISPONIBLES;
-
-        //Formato años 2021-2022
-        this.periodo_actual_anios = this.obtenerAnios(
-          filtro_periodos[0].PERIODO
-        );
-
-        //Formato años periodo anterior
-        this.periodo_anterior_anios = this.obtenerAnios(
-          filtro_periodos[1].PERIODO
-        );
+  private obtenerCasos(response: Array<MesmprInterface>){
+    let verPeriodos:MesmprInterface[] = response.filter(element => element.CADUCADO === "No");
+    if(verPeriodos.length == 0){
+      this.caso0 = true;
+    }else{
+      let periodoAux = verPeriodos;
+      periodoAux.map(element => {
+        if (element.DETALLES.length > 0) {
+          this.detalles = [...element.DETALLES];
+        }
+        return element;
+      });
+      
+      if (verPeriodos.some(element => element.ESEAYG === "Si")) {
+        let eayg:MesmprInterface = verPeriodos.pop()!;
+
+        this.periodoEAYG = this.formatoPeriodo(eayg.PERIODO) // Periodo en años 'Periodo EAYG'
+        this.fechaVencimientoEAYG = this.formatoFecha(eayg.PERIODO.split('|')[1]); // Fecha de vencimiento del periodo
+        this.diasPeriodoEAYG = this.obtenerDiasPeriodos(eayg.DETALLES) + eayg.VACACIONESDISPONIBLES; // Cantidad de días disponibles por periodo 'Días por periodo' EAYG
+        this.diasDisponiblesEAYG = eayg.VACACIONESDISPONIBLES; // Cantidad de 'Días disponibles' EAYG
+        this.diasTomadosEAYG = this.obtenerDiasTomados(eayg.DETALLES) // Cantidad de días tomados 'Días tomados' EAYG
+        this.diasSolicitadosEAYG = this.obtenerDiasSolicitados(eayg.DETALLES);
+        this.casoEAYG = true;
       }
-      //this.detalles = filtro_periodos.map((periodo) => periodo.DETALLES);
-      let detalles_map = filtro_periodos.map(function (
-        periodo: MesmprInterface
-      ) {
-        return {
-          DETALLES: periodo.DETALLES,
-          PERIODO_DIVIDER: periodo.PERIODO,
-        };
+
+      if (verPeriodos.length > 0){
+        let actual:MesmprInterface = verPeriodos.pop()!;
+
+        this.periodoActual = this.formatoPeriodo(actual.PERIODO) ; // Periodo en años 'Periodo EAYG'
+        this.fechaVencimientoActual = this.formatoFecha(actual.PERIODO.split('|')[1]); // Fecha de vencimiento del periodo
+        this.diasPeriodoActual = this.obtenerDiasPeriodos(actual.DETALLES) + actual.VACACIONESDISPONIBLES; // Cantidad de días disponibles por periodo 'Días por periodo' EAYG
+        this.diasDisponiblesActual = actual.VACACIONESDISPONIBLES; // Cantidad de 'Días disponibles' EAYG
+        this.diasTomadosActual = this.obtenerDiasTomados(actual.DETALLES) // Cantidad de días tomados 'Días tomados' EAYG
+        this.casoActual = true;
+      }
+      
+      if (verPeriodos.length > 0){
+        let anterior:MesmprInterface = verPeriodos.pop()!;
+
+        this.periodoAnterior = this.formatoPeriodo(anterior.PERIODO) ; // Periodo en años 'Periodo EAYG'
+        this.fechaVencimientoAnterior = this.formatoFecha(anterior.PERIODO.split('|')[1]); // Fecha de vencimiento del periodo
+        this.diasPeriodoAnterior = this.obtenerDiasPeriodos(anterior.DETALLES) + anterior.VACACIONESDISPONIBLES; // Cantidad de días disponibles por periodo 'Días por periodo' EAYG
+        this.diasDisponiblesAnterior = anterior.VACACIONESDISPONIBLES; // Cantidad de 'Días disponibles' EAYG
+        this.diasTomadosAnterior = this.obtenerDiasTomados(anterior.DETALLES) // Cantidad de días tomados 'Días tomados' EAYG
+
+        this.casoAnterior = true;
+      }
+    }
+  }
+  
+  private obtenerDiasPeriodos(detalles: Array<MesmprVacacionesInterface>){
+    if (detalles.length > 0) {
+      let total:number = 0;
+      
+      detalles.map( detalle => {
+        if(detalle.DIASTOMADOS === 0){
+          total += detalle.DIASSOLICITADOS
+        }
+        total += detalle.DIASTOMADOS
+      });
+      return total;
+    }else{
+      return 0;
+    }
+  }
+
+  private obtenerDiasTomados(detalles: Array<MesmprVacacionesInterface>){
+    if (detalles.length > 0) {
+      let total:number = 0;
+      detalles.map( detalle => {
+        total += detalle.DIASTOMADOS
+      });
+      return total;
+    }else{
+      
+      return 0;
+    }
+  }
+
+  public formatoDetalles(detalles: Array<MesmprVacacionesInterface>):Array<any>{
+    let respuesta = detalles.map(element => {
+      let arrFecha = element.FECHASVACACIONES.split('|');
+      return {
+        fecha_inicio: arrFecha[0],
+        fecha_fin: arrFecha[0],
+        dias_tomados: element.DIASTOMADOS
+      }
+    });    
+    return respuesta;
+  }
+
+  private obtenerDiasSolicitados(detalles:Array<MesmprVacacionesInterface> ){
+    if (detalles.length > 0) {
+      let total:number = 0;
+      detalles.map( detalle => {
+        total += detalle.DIASSOLICITADOS
       });
+      return total;
+    }else{
+      
+      return 0;
+    }
+  }
 
-      this.detalles = detalles_map as MESMPRDetallesInterface[];
-      this.detalles = this.detalles.filter(
-        (detalle) =>
-          detalle.DETALLES.filter((detalle) => detalle.DIASTOMADOS > 0).length >
-          0
-      );
-    }    
+  construirPeriodo(periodo:String){
+    let arr_periodo = periodo.split("|");
+    let anio_inicio = arr_periodo[0].split("-")[0];
+    let anio_final = arr_periodo[1].split("-")[0];
+    return `${anio_inicio}-${anio_final}`
   }
 
-  obtenerAnios(periodo: String): String {
+
+  formatoPeriodo(periodo: String): string {
     let anios = periodo.split('|');
     return anios[0].split('-')[0] + '-' + anios[1].split('-')[0];
   }
 
+  formatoDosPeriodo(periodo: String): string {
+    let anios = periodo.split('|');
+    return anios[0].split('/')[0] 
+  }
+
   formatoFecha(fecha: string): string {
     let split = fecha.split('-');
     return `${split[2]}-${split[1]}-${split[0]}`;

+ 3 - 3
vacaciones/src/app/components/mes/mesmre/mesmre.component.html

@@ -213,7 +213,7 @@
           Número días
         </th>
         <td mat-cell *matCellDef="let element">
-          {{ element.NUMERODIAS }}
+          {{ element.VACACIONESANTES - element.VACACIONESDESPUES }}
         </td>
       </ng-container>
   
@@ -240,7 +240,7 @@
           Vacaciones antes
         </th>
         <td mat-cell *matCellDef="let element">
-          {{ element.VACACIONESANTES != 0 ? element.VACACIONESANTES : 'N/A' }}
+          {{ element.VACACIONESANTES !== null ? element.VACACIONESANTES : 'N/A' }}
         </td>
       </ng-container>
   
@@ -249,7 +249,7 @@
           Vacaciones después
         </th>
         <td mat-cell *matCellDef="let element">
-          {{ element.VACACIONESDESPUES != 0 ? element.VACACIONESDESPUES : 'N/A' }}
+          {{ element.VACACIONESDESPUES !== null ? element.VACACIONESDESPUES : 'N/A' }}
         </td>
       </ng-container>
   

+ 2 - 2
vacaciones/src/app/components/mes/mesmre/mesmre.component.ts

@@ -127,7 +127,7 @@ export class MESMREComponent implements AfterViewInit {
       if (res.status == 'Token is Expired') {
         this._iamService.logout();
         this.snackAlert('Sesión expirada. Vuelva a iniciar sesión');
-      }else if (!res.status && res.response.length > 0) {
+      }else if (!res.status) {
         this.solicitudes = res.response;
         this.cargarTabla(this.solicitudes);
         this.filtroEstatus();
@@ -474,7 +474,7 @@ export class MESMREComponent implements AfterViewInit {
   mapearTabla() {
     this.solicitudes.map(function (
       solicitud: MESMREInterface
-    ) {
+    ) {      
       if (solicitud.PERIODOVACACIONAL == null) {
         solicitud.PERIODOVACACIONAL = 'N/A';
       }

+ 2 - 2
vacaciones/src/app/interfaces/mes/mesmpr/mesmpr-interface.ts

@@ -1,9 +1,9 @@
 import { MesmprVacacionesInterface } from "../../mes/mesmpr/mesmpr-vacaciones-interface";
 
 export interface MesmprInterface {
-    PERIODO: String;
+    PERIODO: string;
     VACACIONESDISPONIBLES: number,
     CADUCADO: string,
     ESEAYG: string,
-    DETALLES: MesmprVacacionesInterface [],
+    DETALLES: Array<MesmprVacacionesInterface>,
 }

+ 4 - 2
vacaciones/src/app/interfaces/mes/mesmpr/mesmpr-vacaciones-interface.ts

@@ -1,4 +1,6 @@
 export interface MesmprVacacionesInterface {
-    FECHASVACACIONES: String;
-    DIASTOMADOS: number
+    FECHASVACACIONES: string;
+    DIASTOMADOS: number;
+    DIASSOLICITADOS: number;
+    ESTADO: string;
 }

+ 2 - 1
vacaciones/src/app/services/mes/mesmpr/mesmpr.service.ts

@@ -2,6 +2,7 @@ import { HttpClient, HttpHeaders } from '@angular/common/http';
 import { Injectable, OnInit } from '@angular/core';
 import { MatSnackBar } from '@angular/material/snack-bar';
 import { MesmprInterface } from 'src/app/interfaces/mes/mesmpr/mesmpr-interface';
+import { ResponseData } from 'src/app/interfaces/response-data';
 import { USERInterface } from 'src/app/interfaces/user-interface';
 import { ENCService } from '../../enc/enc.service';
 import { IAMService } from '../../iam/iam.service';
@@ -31,7 +32,7 @@ export class MESMPRService implements OnInit{
 
   obtener() {
     this.ngOnInit();
-    return this.http.get<MesmprInterface>(
+    return this.http.get<ResponseData>(
       `${this._url}/consultar/${this._encService.desencriptar(this.usuario_session.IDUSUARIO)}/${this.formatoRFC(this.usuario_session.RFCEMPRESA)}`,
       { headers: this.header }
     );

+ 1 - 1
vacaciones/src/styles.css

@@ -474,7 +474,7 @@ mat-form-field.mat-form-field {
 }
 
 .display-text-small {
-  font-size: 48px;
+  font-size: 36px;
 }
 
 .mat-progress-spinner circle,