Browse Source

Merge branch 'development' into feature-general_fixes

Francisco huezo 5 years ago
parent
commit
2ee60f6932
26 changed files with 1606 additions and 121 deletions
  1. 120 2
      src/app/components/instruments/pbur/pbur.component.html
  2. 48 13
      src/app/components/instruments/pbur/pbur.component.ts
  3. 120 2
      src/app/components/instruments/vcn/vcn.component.html
  4. 49 13
      src/app/components/instruments/vcn/vcn.component.ts
  5. 189 0
      src/app/components/investment-proposals/approve/approve.component.html
  6. 6 0
      src/app/components/investment-proposals/approve/approve.component.scss
  7. 429 0
      src/app/components/investment-proposals/approve/approve.component.ts
  8. 16 2
      src/app/components/investment-proposals/investment-proposals.component.html
  9. 28 6
      src/app/components/investment-proposals/investment-proposals.component.ts
  10. 4 5
      src/app/components/investment-proposals/payment-info/payment-info.component.html
  11. 80 32
      src/app/components/investment-proposals/payment-info/payment-info.component.ts
  12. 43 0
      src/app/components/investment-proposals/payment-requirement/payment-requirement.component.html
  13. 81 9
      src/app/components/investment-proposals/payment-requirement/payment-requirement.component.ts
  14. 4 5
      src/app/components/investment-proposals/proposal-detail/proposal-detail.component.ts
  15. 10 0
      src/app/components/investment-proposals/result/result.component.html
  16. 79 11
      src/app/components/investment-proposals/result/result.component.ts
  17. 5 4
      src/app/components/investment-proposals/review/review.component.ts
  18. 100 1
      src/app/components/investments/investments.component.html
  19. 10 0
      src/app/components/investments/investments.component.scss
  20. 148 5
      src/app/components/investments/investments.component.ts
  21. 3 3
      src/app/components/shared/sidebar/sidebar.component.ts
  22. 2 0
      src/app/layouts/admin/admin.module.ts
  23. 5 0
      src/app/layouts/admin/admin.routing.ts
  24. 2 1
      src/app/services/catalogs.service.ts
  25. 0 7
      src/app/services/instruments.service.ts
  26. 25 0
      src/app/services/investments.service.ts

+ 120 - 2
src/app/components/instruments/pbur/pbur.component.html

@@ -7,6 +7,19 @@
     [formGroup]="investmentProposalForm"
     [formGroup]="investmentProposalForm"
   >
   >
     <div class="row">
     <div class="row">
+      <div class="col-lg-6 col-sm-12 pr-xl-3">
+        <div class="form-group form-check">
+          <input
+            type="checkbox"
+            class="form-check-input"
+            id="valor_par"
+            formControlName="valor_par"
+            [checked]="f.valor_par.value"
+          />
+          <label class="form-check-label" for="valor_par">Valor par</label>
+        </div>
+      </div>
+
       <div class="col-lg-6 col-sm-12 pr-xl-3">
       <div class="col-lg-6 col-sm-12 pr-xl-3">
         <div class="form-group">
         <div class="form-group">
           <label for="valor_nominal">Valor nominal: </label>
           <label for="valor_nominal">Valor nominal: </label>
@@ -65,8 +78,6 @@
           </div>
           </div>
         </div>
         </div>
       </div>
       </div>
-    </div>
-    <div class="row">
       <div class="col-lg-6 col-sm-12 pr-xl-3">
       <div class="col-lg-6 col-sm-12 pr-xl-3">
         <div class="form-group">
         <div class="form-group">
           <label for="comision_casa_porcentaje">Comisión casa: </label>
           <label for="comision_casa_porcentaje">Comisión casa: </label>
@@ -414,6 +425,107 @@
       </div>
       </div>
     </div>
     </div>
 
 
+    <br />
+
+    <!-- Tabla de proyecciones del instrumento-->
+    <div *ngIf="hasProjections" class="instrument-calcs">
+      <div class="row">
+        <div class="col-12">
+          <span class="badge badge-success badge-custom"
+            >Proyecciones del instrumento</span
+          >
+        </div>
+
+        <div class="cete-table-container">
+          <table mat-table [dataSource]="dataSource" class="example-table">
+            <ng-container matColumnDef="posicion">
+              <th mat-header-cell *matHeaderCellDef>#</th>
+              <td mat-cell *matCellDef="let row">
+                {{ row.posicion }}
+              </td>
+            </ng-container>
+            <ng-container matColumnDef="plazo">
+              <th mat-header-cell *matHeaderCellDef>Plazo</th>
+              <td mat-cell *matCellDef="let row">
+                {{ row.plazo }}
+              </td>
+            </ng-container>
+
+            <ng-container matColumnDef="fecha_pago">
+              <th mat-header-cell *matHeaderCellDef>Fecha pago</th>
+              <td mat-cell *matCellDef="let row">
+                {{
+                  row.fecha_pago == "" || row.fecha_pago == undefined
+                    ? "-"
+                    : row.fecha_pago
+                }}
+              </td>
+            </ng-container>
+
+            <ng-container matColumnDef="monto">
+              <th mat-header-cell *matHeaderCellDef>Monto</th>
+              <td mat-cell *matCellDef="let row">
+                {{
+                  row.monto == "" || row.monto == undefined
+                    ? "-"
+                    : (row.monto | number: "1.2-4")
+                }}
+              </td>
+            </ng-container>
+            <ng-container matColumnDef="ingreso_neto">
+              <th mat-header-cell *matHeaderCellDef>Ingreso neto</th>
+              <td mat-cell *matCellDef="let row">
+                {{
+                  row.ingreso_neto == "" || row.ingreso_neto == undefined
+                    ? "-"
+                    : (row.ingreso_neto | number: "1.2-4")
+                }}
+              </td>
+            </ng-container>
+            <ng-container matColumnDef="costo_cedeval">
+              <th mat-header-cell *matHeaderCellDef>Costo CEDEVAL</th>
+              <td mat-cell *matCellDef="let row">
+                {{ row.costo_cedeval | number: "1.2-4" }}
+              </td>
+            </ng-container>
+            <ng-container matColumnDef="renta">
+              <th mat-header-cell *matHeaderCellDef>Renta</th>
+              <td mat-cell *matCellDef="let row">
+                {{ row.renta | number: "1.2-4" }}
+              </td>
+            </ng-container>
+            <ng-container matColumnDef="costo_transferencia">
+              <th mat-header-cell *matHeaderCellDef>Costo transferencia</th>
+              <td mat-cell *matCellDef="let row">
+                {{ row.costo_transferencia | number: "1.2-4" }}
+              </td>
+            </ng-container>
+            <ng-container matColumnDef="costo_banco">
+              <th mat-header-cell *matHeaderCellDef>Costo banco</th>
+              <td mat-cell *matCellDef="let row">
+                {{ row.costo_banco | number: "1.2-4" }}
+              </td>
+            </ng-container>
+            <ng-container matColumnDef="otros_costos">
+              <th mat-header-cell *matHeaderCellDef>Otros costos</th>
+              <td mat-cell *matCellDef="let row">
+                {{ row.otros_costos | number: "1.2-4" }}
+              </td>
+            </ng-container>
+
+            <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
+            <tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
+          </table>
+
+          <mat-paginator
+            [pageSizeOptions]="[10, 15, 25]"
+            [pageIndex]="0"
+            [pageSize]="10"
+          ></mat-paginator>
+        </div>
+      </div>
+    </div>
+
     <br />
     <br />
     <div class="form-group text-center space-20">
     <div class="form-group text-center space-20">
       <button
       <button
@@ -440,6 +552,12 @@
 <div *ngIf="summary">
 <div *ngIf="summary">
   <div class="timeline-body">
   <div class="timeline-body">
     <div class="row">
     <div class="row">
+      <div class="col-lg-3 col-md-4 col-sm-6">
+        <h4>Valor par:</h4>
+        <div class="field">
+          {{ instrument_work.valor_par == true ? "Si" : "No" }}
+        </div>
+      </div>
       <div class="col-lg-3 col-md-4 col-sm-6">
       <div class="col-lg-3 col-md-4 col-sm-6">
         <h4>Valor nominal:</h4>
         <h4>Valor nominal:</h4>
         <div class="field">
         <div class="field">

+ 48 - 13
src/app/components/instruments/pbur/pbur.component.ts

@@ -1,4 +1,4 @@
-import { Component, OnInit, Input } from "@angular/core";
+import { Component, OnInit, Input, ViewChild } from "@angular/core";
 import { InstrumentComponent } from "@app/components/investment-proposals/instrument/instrument.component";
 import { InstrumentComponent } from "@app/components/investment-proposals/instrument/instrument.component";
 import { FormBuilder, FormGroup, Validators } from "@angular/forms";
 import { FormBuilder, FormGroup, Validators } from "@angular/forms";
 import { IAngularMyDpOptions, IMyDateModel } from "angular-mydatepicker";
 import { IAngularMyDpOptions, IMyDateModel } from "angular-mydatepicker";
@@ -10,6 +10,7 @@ import { InstrumentCalculations } from "@app/services/instrument-calculations.se
 import Swal from "sweetalert2";
 import Swal from "sweetalert2";
 import { GeneralInfo } from "@app/models/investment-proposal-form";
 import { GeneralInfo } from "@app/models/investment-proposal-form";
 import { parse } from "date-fns";
 import { parse } from "date-fns";
+import { MatPaginator, MatSort, MatTableDataSource } from "@angular/material";
 
 
 @Component({
 @Component({
   selector: "app-pbur",
   selector: "app-pbur",
@@ -24,6 +25,19 @@ export class PBUR implements InstrumentComponent {
   form: any;
   form: any;
   general: GeneralInfo;
   general: GeneralInfo;
 
 
+  displayedColumns: string[] = [
+    "posicion",
+    "plazo",
+    "fecha_pago",
+    "monto",
+    "ingreso_neto",
+    "costo_cedeval",
+    "renta",
+    "costo_transferencia",
+    "costo_banco",
+    "otros_costos"
+  ];
+
   // For daterange
   // For daterange
   daysLabels: any = {
   daysLabels: any = {
     su: "Dom",
     su: "Dom",
@@ -73,7 +87,12 @@ export class PBUR implements InstrumentComponent {
   plazo: number = 0;
   plazo: number = 0;
   interes_acumulado: number = 0;
   interes_acumulado: number = 0;
   fecha_inicio_vigencia: string;
   fecha_inicio_vigencia: string;
-  instrumentSaved: boolean;
+  proyecciones: any;
+  hasProjections: boolean;
+
+  @ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
+  @ViewChild(MatSort, { static: true }) sort: MatSort;
+  dataSource = new MatTableDataSource(this.proyecciones);
 
 
   constructor(
   constructor(
     private formBuilder: FormBuilder,
     private formBuilder: FormBuilder,
@@ -96,6 +115,9 @@ export class PBUR implements InstrumentComponent {
     });
     });
 
 
     this.investmentProposalForm = this.formBuilder.group({
     this.investmentProposalForm = this.formBuilder.group({
+      valor_par: [
+        this.instrument_exists ? false : this.instrument_work.valor_par
+      ],
       valor_nominal: [
       valor_nominal: [
         this.instrument_exists ? "" : this.instrument_work.valor_nominal,
         this.instrument_exists ? "" : this.instrument_work.valor_nominal,
         [
         [
@@ -242,7 +264,7 @@ export class PBUR implements InstrumentComponent {
           id_formato_ingreso: this.general.formato_ingreso
           id_formato_ingreso: this.general.formato_ingreso
         },
         },
         {
         {
-          valor_par: false,
+          valor_par: this.f.valor_par.value,
           valor_nominal: +this.f.valor_nominal.value,
           valor_nominal: +this.f.valor_nominal.value,
           comision_casa_porcentaje: this.f.comision_casa_porcentaje.value,
           comision_casa_porcentaje: this.f.comision_casa_porcentaje.value,
           comision_bolsa_porcentaje: this.f.comision_bolsa_porcentaje.value,
           comision_bolsa_porcentaje: this.f.comision_bolsa_porcentaje.value,
@@ -272,8 +294,20 @@ export class PBUR implements InstrumentComponent {
           this.plazo = ans["result"]["plazo"];
           this.plazo = ans["result"]["plazo"];
           this.interes_acumulado = ans["result"]["interes_acumulado"];
           this.interes_acumulado = ans["result"]["interes_acumulado"];
           this.fecha_inicio_vigencia = ans["result"]["fecha_inicio_vigencia"];
           this.fecha_inicio_vigencia = ans["result"]["fecha_inicio_vigencia"];
+          this.proyecciones = ans["result"]["proyecciones"];
+
+          if (this.f.valor_par.value == true) {
+            this.hasProjections = true;
+          } else {
+            this.hasProjections = false;
+          }
+
+          this.dataSource.data = this.proyecciones;
+          this.dataSource.paginator = this.paginator;
+          this.dataSource.sort = this.sort;
 
 
           this.pburObject = {
           this.pburObject = {
+            valor_par: this.investmentProposalForm.value.valor_par,
             valor_nominal: this.investmentProposalForm.value.valor_nominal,
             valor_nominal: this.investmentProposalForm.value.valor_nominal,
             renta_porcentaje: this.investmentProposalForm.value
             renta_porcentaje: this.investmentProposalForm.value
               .renta_porcentaje,
               .renta_porcentaje,
@@ -281,20 +315,21 @@ export class PBUR implements InstrumentComponent {
               .comision_casa_porcentaje,
               .comision_casa_porcentaje,
             comision_bolsa_porcentaje: this.investmentProposalForm.value
             comision_bolsa_porcentaje: this.investmentProposalForm.value
               .comision_bolsa_porcentaje,
               .comision_bolsa_porcentaje,
-            comision_casa: ans["result"]["comision_casa"],
-            comision_bolsa: ans["result"]["comision_bolsa"],
+            comision_casa: this.comision_casa,
+            comision_bolsa: this.comision_bolsa,
             rendimiento_bruto: this.investmentProposalForm.value
             rendimiento_bruto: this.investmentProposalForm.value
               .rendimiento_bruto,
               .rendimiento_bruto,
             otros_costos: this.investmentProposalForm.value.otros_costos,
             otros_costos: this.investmentProposalForm.value.otros_costos,
-            ingreso_bruto: ans["result"]["ingreso_bruto"],
-            ingreso_neto: ans["result"]["ingreso_neto"],
+            ingreso_bruto: this.ingreso_bruto,
+            ingreso_neto: this.ingreso_neto,
 
 
-            valor_transado: ans["result"]["valor_transado"],
-            precio_porcentaje: ans["result"]["precio_porcentaje"],
-            rendimiento_neto: ans["result"]["rendimiento_neto"],
-            total_pagar: ans["result"]["total_pagar"],
-            interes_acumulado: ans["result"]["interes_acumulado"],
-            fecha_inicio_vigencia: ans["result"]["fecha_inicio_vigencia"],
+            valor_transado: this.valor_transado,
+            precio_porcentaje: this.precio_porcentaje,
+            rendimiento_neto: this.rendimiento_neto,
+            total_pagar: this.total_pagar,
+            interes_acumulado: this.interes_acumulado,
+            fecha_inicio_vigencia: this.fecha_inicio_vigencia,
+            proyecciones: this.proyecciones,
             plazo: this.investmentProposalForm.value.plazo,
             plazo: this.investmentProposalForm.value.plazo,
             //id_formato_ingreso: this.investmentProposalForm.value.id_formato_ingreso,
             //id_formato_ingreso: this.investmentProposalForm.value.id_formato_ingreso,
 
 

+ 120 - 2
src/app/components/instruments/vcn/vcn.component.html

@@ -7,6 +7,19 @@
     [formGroup]="investmentProposalForm"
     [formGroup]="investmentProposalForm"
   >
   >
     <div class="row">
     <div class="row">
+      <div class="col-lg-6 col-sm-12 pr-xl-3">
+        <div class="form-group form-check">
+          <input
+            type="checkbox"
+            class="form-check-input"
+            id="valor_par"
+            formControlName="valor_par"
+            [checked]="f.valor_par.value"
+          />
+          <label class="form-check-label" for="valor_par">Valor par</label>
+        </div>
+      </div>
+
       <div class="col-lg-6 col-sm-12 pr-xl-3">
       <div class="col-lg-6 col-sm-12 pr-xl-3">
         <div class="form-group">
         <div class="form-group">
           <label for="valor_nominal">Valor nominal: </label>
           <label for="valor_nominal">Valor nominal: </label>
@@ -65,8 +78,6 @@
           </div>
           </div>
         </div>
         </div>
       </div>
       </div>
-    </div>
-    <div class="row">
       <div class="col-lg-6 col-sm-12 pr-xl-3">
       <div class="col-lg-6 col-sm-12 pr-xl-3">
         <div class="form-group">
         <div class="form-group">
           <label for="comision_casa_porcentaje">Comisión casa: </label>
           <label for="comision_casa_porcentaje">Comisión casa: </label>
@@ -416,6 +427,107 @@
       </div>
       </div>
     </div>
     </div>
 
 
+    <br />
+
+    <!-- Tabla de proyecciones del instrumento-->
+    <div *ngIf="hasProjections" class="instrument-calcs">
+      <div class="row">
+        <div class="col-12">
+          <span class="badge badge-success badge-custom"
+            >Proyecciones del instrumento</span
+          >
+        </div>
+
+        <div class="cete-table-container">
+          <table mat-table [dataSource]="dataSource" class="example-table">
+            <ng-container matColumnDef="posicion">
+              <th mat-header-cell *matHeaderCellDef>#</th>
+              <td mat-cell *matCellDef="let row">
+                {{ row.posicion }}
+              </td>
+            </ng-container>
+            <ng-container matColumnDef="plazo">
+              <th mat-header-cell *matHeaderCellDef>Plazo</th>
+              <td mat-cell *matCellDef="let row">
+                {{ row.plazo }}
+              </td>
+            </ng-container>
+
+            <ng-container matColumnDef="fecha_pago">
+              <th mat-header-cell *matHeaderCellDef>Fecha pago</th>
+              <td mat-cell *matCellDef="let row">
+                {{
+                  row.fecha_pago == "" || row.fecha_pago == undefined
+                    ? "-"
+                    : row.fecha_pago
+                }}
+              </td>
+            </ng-container>
+
+            <ng-container matColumnDef="monto">
+              <th mat-header-cell *matHeaderCellDef>Monto</th>
+              <td mat-cell *matCellDef="let row">
+                {{
+                  row.monto == "" || row.monto == undefined
+                    ? "-"
+                    : (row.monto | number: "1.2-4")
+                }}
+              </td>
+            </ng-container>
+            <ng-container matColumnDef="ingreso_neto">
+              <th mat-header-cell *matHeaderCellDef>Ingreso neto</th>
+              <td mat-cell *matCellDef="let row">
+                {{
+                  row.ingreso_neto == "" || row.ingreso_neto == undefined
+                    ? "-"
+                    : (row.ingreso_neto | number: "1.2-4")
+                }}
+              </td>
+            </ng-container>
+            <ng-container matColumnDef="costo_cedeval">
+              <th mat-header-cell *matHeaderCellDef>Costo CEDEVAL</th>
+              <td mat-cell *matCellDef="let row">
+                {{ row.costo_cedeval | number: "1.2-4" }}
+              </td>
+            </ng-container>
+            <ng-container matColumnDef="renta">
+              <th mat-header-cell *matHeaderCellDef>Renta</th>
+              <td mat-cell *matCellDef="let row">
+                {{ row.renta | number: "1.2-4" }}
+              </td>
+            </ng-container>
+            <ng-container matColumnDef="costo_transferencia">
+              <th mat-header-cell *matHeaderCellDef>Costo transferencia</th>
+              <td mat-cell *matCellDef="let row">
+                {{ row.costo_transferencia | number: "1.2-4" }}
+              </td>
+            </ng-container>
+            <ng-container matColumnDef="costo_banco">
+              <th mat-header-cell *matHeaderCellDef>Costo banco</th>
+              <td mat-cell *matCellDef="let row">
+                {{ row.costo_banco | number: "1.2-4" }}
+              </td>
+            </ng-container>
+            <ng-container matColumnDef="otros_costos">
+              <th mat-header-cell *matHeaderCellDef>Otros costos</th>
+              <td mat-cell *matCellDef="let row">
+                {{ row.otros_costos | number: "1.2-4" }}
+              </td>
+            </ng-container>
+
+            <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
+            <tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
+          </table>
+
+          <mat-paginator
+            [pageSizeOptions]="[10, 15, 25]"
+            [pageIndex]="0"
+            [pageSize]="10"
+          ></mat-paginator>
+        </div>
+      </div>
+    </div>
+
     <br />
     <br />
     <div class="form-group text-center space-20">
     <div class="form-group text-center space-20">
       <button
       <button
@@ -442,6 +554,12 @@
 <div *ngIf="summary">
 <div *ngIf="summary">
   <div class="timeline-body">
   <div class="timeline-body">
     <div class="row">
     <div class="row">
+      <div class="col-lg-3 col-md-4 col-sm-6">
+        <h4>Valor par:</h4>
+        <div class="field">
+          {{ instrument_work.valor_par == true ? "Si" : "No" }}
+        </div>
+      </div>
       <div class="col-lg-3 col-md-4 col-sm-6">
       <div class="col-lg-3 col-md-4 col-sm-6">
         <h4>Valor nominal:</h4>
         <h4>Valor nominal:</h4>
         <div class="field">$USD {{ instrument_work.valor_nominal }}</div>
         <div class="field">$USD {{ instrument_work.valor_nominal }}</div>

+ 49 - 13
src/app/components/instruments/vcn/vcn.component.ts

@@ -1,4 +1,4 @@
-import { Component, OnInit, Input } from "@angular/core";
+import { Component, OnInit, Input, ViewChild } from "@angular/core";
 import { InstrumentComponent } from "@app/components/investment-proposals/instrument/instrument.component";
 import { InstrumentComponent } from "@app/components/investment-proposals/instrument/instrument.component";
 import { FormBuilder, FormGroup, Validators } from "@angular/forms";
 import { FormBuilder, FormGroup, Validators } from "@angular/forms";
 import { IAngularMyDpOptions, IMyDateModel } from "angular-mydatepicker";
 import { IAngularMyDpOptions, IMyDateModel } from "angular-mydatepicker";
@@ -10,6 +10,7 @@ import { InstrumentCalculations } from "@app/services/instrument-calculations.se
 import Swal from "sweetalert2";
 import Swal from "sweetalert2";
 import { GeneralInfo } from "@app/models/investment-proposal-form";
 import { GeneralInfo } from "@app/models/investment-proposal-form";
 import { parse } from "date-fns";
 import { parse } from "date-fns";
+import { MatTableDataSource, MatPaginator, MatSort } from "@angular/material";
 
 
 @Component({
 @Component({
   selector: "app-vcn",
   selector: "app-vcn",
@@ -24,6 +25,19 @@ export class VCN implements InstrumentComponent {
   form: any;
   form: any;
   general: GeneralInfo;
   general: GeneralInfo;
 
 
+  displayedColumns: string[] = [
+    "posicion",
+    "plazo",
+    "fecha_pago",
+    "monto",
+    "ingreso_neto",
+    "costo_cedeval",
+    "renta",
+    "costo_transferencia",
+    "costo_banco",
+    "otros_costos"
+  ];
+
   // For daterange
   // For daterange
   daysLabels: any = {
   daysLabels: any = {
     su: "Dom",
     su: "Dom",
@@ -73,6 +87,12 @@ export class VCN implements InstrumentComponent {
   plazo: number = 0;
   plazo: number = 0;
   interes_acumulado: number = 0;
   interes_acumulado: number = 0;
   fecha_inicio_vigencia: string;
   fecha_inicio_vigencia: string;
+  proyecciones: any;
+  hasProjections: boolean;
+
+  @ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
+  @ViewChild(MatSort, { static: true }) sort: MatSort;
+  dataSource = new MatTableDataSource(this.proyecciones);
 
 
   constructor(
   constructor(
     private formBuilder: FormBuilder,
     private formBuilder: FormBuilder,
@@ -93,6 +113,9 @@ export class VCN implements InstrumentComponent {
     });
     });
 
 
     this.investmentProposalForm = this.formBuilder.group({
     this.investmentProposalForm = this.formBuilder.group({
+      valor_par: [
+        this.instrument_exists ? false : this.instrument_work.valor_par
+      ],
       valor_nominal: [
       valor_nominal: [
         this.instrument_exists ? "" : this.instrument_work.valor_nominal,
         this.instrument_exists ? "" : this.instrument_work.valor_nominal,
         [
         [
@@ -234,14 +257,14 @@ export class VCN implements InstrumentComponent {
 
 
     this.instrumentCalcService
     this.instrumentCalcService
       .vcnCalc(
       .vcnCalc(
-        "PBUR", // Codigo del instrumento
+        "VCN", // Codigo del instrumento
         {
         {
           id_tipo_base: this.general.base_anual,
           id_tipo_base: this.general.base_anual,
           id_periodicidad: this.general.periodicidad,
           id_periodicidad: this.general.periodicidad,
           id_formato_ingreso: this.general.formato_ingreso
           id_formato_ingreso: this.general.formato_ingreso
         },
         },
         {
         {
-          valor_par: false,
+          valor_par: this.f.valor_par.value,
           valor_nominal: +this.f.valor_nominal.value,
           valor_nominal: +this.f.valor_nominal.value,
           comision_casa_porcentaje: this.f.comision_casa_porcentaje.value,
           comision_casa_porcentaje: this.f.comision_casa_porcentaje.value,
           comision_bolsa_porcentaje: this.f.comision_bolsa_porcentaje.value,
           comision_bolsa_porcentaje: this.f.comision_bolsa_porcentaje.value,
@@ -271,8 +294,20 @@ export class VCN implements InstrumentComponent {
           this.plazo = ans["result"]["plazo"];
           this.plazo = ans["result"]["plazo"];
           this.interes_acumulado = ans["result"]["interes_acumulado"];
           this.interes_acumulado = ans["result"]["interes_acumulado"];
           this.fecha_inicio_vigencia = ans["result"]["fecha_inicio_vigencia"];
           this.fecha_inicio_vigencia = ans["result"]["fecha_inicio_vigencia"];
+          this.proyecciones = ans["result"]["proyecciones"];
+
+          if (this.f.valor_par.value == true) {
+            this.hasProjections = true;
+          } else {
+            this.hasProjections = false;
+          }
+
+          this.dataSource.data = this.proyecciones;
+          this.dataSource.paginator = this.paginator;
+          this.dataSource.sort = this.sort;
 
 
           this.vcnObject = {
           this.vcnObject = {
+            valor_par: this.investmentProposalForm.value.valor_par,
             valor_nominal: this.investmentProposalForm.value.valor_nominal,
             valor_nominal: this.investmentProposalForm.value.valor_nominal,
             renta_porcentaje: this.investmentProposalForm.value
             renta_porcentaje: this.investmentProposalForm.value
               .renta_porcentaje,
               .renta_porcentaje,
@@ -280,20 +315,21 @@ export class VCN implements InstrumentComponent {
               .comision_casa_porcentaje,
               .comision_casa_porcentaje,
             comision_bolsa_porcentaje: this.investmentProposalForm.value
             comision_bolsa_porcentaje: this.investmentProposalForm.value
               .comision_bolsa_porcentaje,
               .comision_bolsa_porcentaje,
-            comision_casa: ans["result"]["comision_casa"],
-            comision_bolsa: ans["result"]["comision_bolsa"],
+            comision_casa: this.comision_casa,
+            comision_bolsa: this.comision_bolsa,
             rendimiento_bruto: this.investmentProposalForm.value
             rendimiento_bruto: this.investmentProposalForm.value
               .rendimiento_bruto,
               .rendimiento_bruto,
             otros_costos: this.investmentProposalForm.value.otros_costos,
             otros_costos: this.investmentProposalForm.value.otros_costos,
-            ingreso_bruto: ans["result"]["ingreso_bruto"],
-            ingreso_neto: ans["result"]["ingreso_neto"],
+            ingreso_bruto: this.ingreso_bruto,
+            ingreso_neto: this.ingreso_neto,
 
 
-            valor_transado: ans["result"]["valor_transado"],
-            precio_porcentaje: ans["result"]["precio_porcentaje"],
-            rendimiento_neto: ans["result"]["rendimiento_neto"],
-            total_pagar: ans["result"]["total_pagar"],
-            interes_acumulado: ans["result"]["interes_acumulado"],
-            fecha_inicio_vigencia: ans["result"]["fecha_inicio_vigencia"],
+            valor_transado: this.valor_transado,
+            precio_porcentaje: this.precio_porcentaje,
+            rendimiento_neto: this.rendimiento_neto,
+            total_pagar: this.total_pagar,
+            interes_acumulado: this.interes_acumulado,
+            fecha_inicio_vigencia: this.fecha_inicio_vigencia,
+            proyecciones: this.proyecciones,
             plazo: this.investmentProposalForm.value.plazo,
             plazo: this.investmentProposalForm.value.plazo,
             //id_formato_ingreso: this.investmentProposalForm.value.id_formato_ingreso,
             //id_formato_ingreso: this.investmentProposalForm.value.id_formato_ingreso,
 
 

+ 189 - 0
src/app/components/investment-proposals/approve/approve.component.html

@@ -0,0 +1,189 @@
+<h2 class="floating-title">{{ title }}</h2>
+
+<div class="main-content">
+  <div class="container-fluid">
+    <div class="row">
+      <div class="col-12 align-right">
+        <div class="align-container">
+          <nav aria-label="breadcrumb">
+            <ol class="breadcrumb">
+              <li class="breadcrumb-item">
+                <a [routerLink]="['/']">Dashboard</a>
+              </li>
+              <li class="breadcrumb-item">
+                <a [routerLink]="['/investment-proposals']">
+                  Propuestas de inversión
+                </a>
+              </li>
+              <li class="breadcrumb-item">Aprobar</li>
+            </ol>
+          </nav>
+        </div>
+      </div>
+
+      <br />
+    </div>
+    <br />
+    <div class="row justify-content-center">
+      <div class="col-12">
+        <div class="align-container">
+          <div class="card borderless">
+            <div class="card-header card-header-icon card-header-rose">
+              <h4 class="card-title">
+                Resumen de la propuesta
+              </h4>
+            </div>
+            <div class="card-body">
+              <div class="align-container">
+                <ul class="timeline timeline-simple">
+                  <li class="timeline-inverted">
+                    <div class="timeline-badge"></div>
+                    <div class="timeline-panel">
+                      <div class="timeline-heading">
+                        <span class="badge badge-success"
+                          >Información general</span
+                        >
+                      </div>
+                      <div class="timeline-body">
+                        <div class="row">
+                          <div class="col-lg-3 col-md-4 col-sm-6">
+                            <h4>Asunto:</h4>
+                            <div class="field">
+                              {{ subject }}
+                            </div>
+                          </div>
+                          <div class="col-lg-3 col-md-4 col-sm-6">
+                            <h4>Orígenes de fondo:</h4>
+                            <div class="field">
+                              {{ funds }}
+                            </div>
+                          </div>
+                          <div class="col-lg-3 col-md-4 col-sm-6">
+                            <h4>Nombre:</h4>
+                            <div class="field">
+                              {{ investmentName }}
+                            </div>
+                          </div>
+                          <div class="col-lg-3 col-md-4 col-sm-6">
+                            <h4>Tipo Tasa:</h4>
+                            <div class="field">
+                              {{ rates }}
+                            </div>
+                          </div>
+                          <div class="col-lg-3 col-md-4 col-sm-6">
+                            <h4>Tipo Renta:</h4>
+                            <div class="field">
+                              {{ revenues }}
+                            </div>
+                          </div>
+                          <div class="col-lg-3 col-md-4 col-sm-6">
+                            <h4>Periodicidad:</h4>
+                            <div class="field">
+                              {{ periodicities }}
+                            </div>
+                          </div>
+                          <div class="col-lg-3 col-md-4 col-sm-6">
+                            <h4>Instrumentos:</h4>
+                            <div class="field">
+                              {{ instrumentTypes }}
+                            </div>
+                          </div>
+                          <div class="col-lg-3 col-md-4 col-sm-6">
+                            <h4>Casa:</h4>
+                            <div class="field">
+                              {{ financials }}
+                            </div>
+                          </div>
+                          <div class="col-lg-3 col-md-4 col-sm-6">
+                            <h4>Base:</h4>
+                            <div class="field">
+                              {{ base_types }}
+                            </div>
+                          </div>
+                          <div class="col-lg-3 col-md-4 col-sm-6">
+                            <h4>Tipo de mercado:</h4>
+                            <div class="field">
+                              {{ markets }}
+                            </div>
+                          </div>
+                          <div class="col-lg-3 col-md-4 col-sm-6">
+                            <h4>Emisores:</h4>
+                            <div class="field">
+                              {{ emitters }}
+                            </div>
+                          </div>
+                          <div class="col-lg-3 col-md-4 col-sm-6">
+                            <h4>Empresa:</h4>
+                            <div class="field">
+                              {{ companies }}
+                            </div>
+                          </div>
+                          <div class="col-lg-3 col-md-4 col-sm-6">
+                            <h4>País:</h4>
+                            <div class="field">
+                              {{ countries }}
+                            </div>
+                          </div>
+                          <div class="col-lg-3 col-md-4 col-sm-6">
+                            <h4>Plazo:</h4>
+                            <div class="field">
+                              {{ payment_terms }}
+                            </div>
+                          </div>
+                          <div class="col-lg-3 col-md-4 col-sm-6">
+                            <h4>Tipos de operaciones:</h4>
+                            <div class="field">
+                              {{ operations }}
+                            </div>
+                          </div>
+                          <div class="col-lg-3 col-md-4 col-sm-6">
+                            <h4>Comentarios:</h4>
+                            <div class="field">
+                              {{ comment }}
+                            </div>
+                          </div>
+                          <div class="col-lg-3 col-md-4 col-sm-6">
+                            <h4>Justificación:</h4>
+                            <div class="field">
+                              {{ justification }}
+                            </div>
+                          </div>
+                        </div>
+                      </div>
+                    </div>
+                  </li>
+                  <li class="timeline-inverted">
+                    <div class="timeline-badge"></div>
+                    <div class="timeline-panel">
+                      <div class="timeline-heading">
+                        <span class="badge badge-warning">Instrumento</span>
+                        <ng-template instrument-host></ng-template>
+                      </div>
+                    </div>
+                  </li>
+                </ul>
+                <div class="review-buttons">
+                  <button
+                    class="btn btn-danger "
+                    (click)="dismiss_proposal()"
+                    type="button"
+                  >
+                    Rechazar propuesta
+                  </button>
+
+                  <button
+                    class="btn btn-success "
+                    (click)="approve_proposal()"
+                    type="button"
+                  >
+                    Aprobar propuesta
+                  </button>
+                </div>
+              </div>
+            </div>
+          </div>
+        </div>
+      </div>
+    </div>
+  </div>
+</div>

+ 6 - 0
src/app/components/investment-proposals/approve/approve.component.scss

@@ -0,0 +1,6 @@
+.review-buttons {
+  text-align: center;
+  button {
+    margin: 0 20px;
+  }
+}

+ 429 - 0
src/app/components/investment-proposals/approve/approve.component.ts

@@ -0,0 +1,429 @@
+import {
+  Component,
+  OnInit,
+  Input,
+  ViewChild,
+  ComponentFactoryResolver
+} from "@angular/core";
+import { Router, ActivatedRoute } from "@angular/router";
+import { InvestmentProposalForm } from "@app/models/investment-proposal-form";
+import { FormInvestmentProposalService } from "@app/services/form-investment-proposal.service";
+import { Instrument } from "@app/models/instrument";
+import { InvestmentProposalWorkflowService } from "@app/services/investment-proposal-workflow.service";
+import { InstrumentDirective } from "../instrument/instrument.directive";
+import { InstrumentComponent } from "../instrument/instrument.component";
+import { InstrumentsService } from "@app/services/instruments.service";
+import Swal from "sweetalert2";
+import { CatalogsService } from "@app/services/catalogs.service";
+import { InvestmentsService } from "@app/services/investments.service";
+
+@Component({
+  selector: "app-investment-proposal-approve",
+  templateUrl: "./approve.component.html",
+  styleUrls: ["./approve.component.scss"]
+})
+export class InvestmentProposalApproveComponent implements OnInit {
+  title = "Aprobación de propuesta";
+  @Input() ads: Instrument[];
+  @Input() formData: InvestmentProposalForm;
+  @ViewChild(InstrumentDirective, { static: true })
+  adHost: InstrumentDirective;
+  isFormValid: boolean = false;
+  general: any;
+  instrument: any;
+  complement: any;
+  final: any;
+  workType: string;
+  form: any;
+  currentAdIndex = -1;
+  interval: any;
+  indexDynamicComponent: number;
+  investmentProposalID: string;
+  investmentExists;
+  state;
+  financials;
+  base_types;
+  countries;
+  companies;
+  rates;
+  revenues;
+  funds;
+  instrumentTypes;
+  markets;
+  emitters;
+  periodicities;
+  format_incomes;
+  payment_terms;
+  operations;
+  gInfo: any;
+  gInstrument: any;
+  gComplement: any;
+  subject: any;
+  investmentName: any;
+  comment: any;
+  justification: any;
+  reviewProposal: {};
+
+  constructor(
+    private router: Router,
+
+    private formDataService: FormInvestmentProposalService,
+    private componentFactoryResolver: ComponentFactoryResolver,
+    private instrumentService: InvestmentProposalWorkflowService,
+    private loadInstrumentsService: InstrumentsService,
+    private catalogService: CatalogsService,
+    private route: ActivatedRoute,
+    private investmentService: InvestmentsService
+  ) {}
+
+  ngOnInit() {
+    //this.formDataService
+    this.ads = this.loadInstrumentsService.getInstruments();
+    this.route.params.subscribe(params => {
+      this.investmentProposalID = params["id"];
+    });
+    if (this.investmentProposalID == undefined)
+      this.investmentProposalID = this.route.snapshot.queryParamMap.get("id");
+
+    if (this.investmentProposalID != undefined) {
+      this.investmentExists = true;
+      this.investmentService
+        .getProposalInvestment(this.investmentProposalID)
+        .subscribe(res => {
+          this.state = res["result"]["id_estado_inversion"]["codigo"];
+
+          this.gInfo = {
+            asunto: res["result"]["asunto"],
+            origenes_fondo:
+              res["result"]["id_origen_fondo"] == null
+                ? ""
+                : res["result"]["id_origen_fondo"]["id_origen_fondo"],
+            name: res["result"]["nombre_inversion"],
+            //date: "",
+            tipo_tasa: res["result"]["id_tipo_tasa"] || "",
+            tipo_renta:
+              res["result"]["id_tipo_renta"] == null
+                ? ""
+                : res["result"]["id_tipo_renta"]["id_tipo_renta"],
+            periodicidad:
+              res["result"]["id_periodicidad"] == null
+                ? ""
+                : res["result"]["id_periodicidad"]["id_periodicidad"],
+
+            instrumentos:
+              res["result"]["id_inversion_instrumento"]["id_tipo_instrumento"][
+                "codigo"
+              ],
+            base_anual:
+              res["result"]["id_tipo_base"] == null
+                ? ""
+                : res["result"]["id_tipo_base"]["id_tipo_base"],
+            casa:
+              res["result"]["id_entidad"] == null
+                ? ""
+                : res["result"]["id_entidad"]["id_entidad_financiera"],
+            formato_ingreso:
+              res["result"]["id_formato_ingreso"] == null
+                ? ""
+                : res["result"]["id_formato_ingreso"]["id_formato_ingreso"]
+          };
+
+          this.gInstrument =
+            res["result"]["id_inversion_instrumento"]["instrumento"];
+
+          this.gInstrument["id_inversion_instrumento"] =
+            res["result"]["id_inversion_instrumento"][
+              "id_inversion_instrumento"
+            ];
+
+          this.gComplement = {
+            tipo_mercado:
+              res["result"]["id_tipo_mercado"] == null
+                ? ""
+                : res["result"]["id_tipo_mercado"]["id_tipo_mercado"],
+            emisores:
+              res["result"]["id_tipo_emisor"] == null
+                ? ""
+                : res["result"]["id_tipo_emisor"]["id_tipo_emisor"],
+            empresa:
+              res["result"]["id_empresa"] == null
+                ? ""
+                : res["result"]["id_empresa"]["id_empresa"],
+            pais:
+              res["result"]["id_pais"] == null
+                ? ""
+                : res["result"]["id_pais"]["id_pais"],
+            plazo:
+              res["result"]["id_plazo"] == null
+                ? ""
+                : res["result"]["id_plazo"]["id_plazo"],
+            operaciones:
+              res["result"]["id_tipo_operacion"] == null
+                ? ""
+                : res["result"]["id_tipo_operacion"]["id_tipo_operacion"],
+            comentarios: res["result"]["comentario"],
+            justificacion: res["result"]["justificacion"]
+          };
+          this.formDataService.setGeneralInfo(this.gInfo);
+
+          this.formDataService.setWork(this.gInstrument);
+
+          this.formDataService.setComplementInfo(this.gComplement);
+
+          this.general = this.formDataService.getGeneralInfo();
+          this.instrument = this.formDataService.getWork();
+          this.complement = this.formDataService.getComplementInfo();
+          this.formData = this.formDataService.getFormData();
+
+          this.formData.instrumentos;
+
+          this.indexDynamicComponent = this.ads.findIndex(
+            x => x.data.key == this.formData.instrumentos
+          );
+          if (this.indexDynamicComponent >= 0) {
+            this.loadComponent();
+          } else {
+            console.log("No existe el componente");
+          }
+          if (this.general != undefined) {
+            this.subject = this.general.asunto;
+            this.investmentName = this.general.name;
+            this.comment = this.complement.comment;
+            this.justification = this.complement.comment;
+
+            this.catalogService.getFinancialEntities().subscribe(res => {
+              this.financials = res.find(
+                e => e.id_entidad_financiera == this.general.casa
+              );
+              this.financials =
+                this.financials != undefined ? this.financials.nombre : "-";
+            });
+
+            this.catalogService.getBaseTypes().subscribe(res => {
+              this.base_types = res.find(
+                e => e.id_tipo_base == this.general.base_anual
+              );
+              this.base_types =
+                this.base_types != undefined
+                  ? ` ${this.base_types.tipo_base} / ${this.base_types.tipo_base_dias}`
+                  : "-";
+            });
+
+            this.catalogService.getCountries().subscribe(res => {
+              this.countries = res.find(e => e.id_pais == this.complement.pais);
+              this.countries =
+                this.countries != undefined ? this.countries.nombre : "-";
+            });
+            this.catalogService.getCompanies().subscribe(res => {
+              this.companies = res.find(
+                e => e.id_empresa == this.complement.empresa
+              );
+              this.companies =
+                this.companies != undefined ? this.companies.nombre : "-";
+            });
+            this.catalogService.getRateTypes().subscribe(res => {
+              this.rates = res.find(
+                e => e.id_tipo_tasa == this.general.tipo_tasa
+              );
+              this.rates = this.rates != undefined ? this.rates.nombre : "-";
+            });
+            this.catalogService.getRevenueTypes().subscribe(res => {
+              this.revenues = res.find(
+                e => e.id_tipo_renta == this.general.tipo_renta
+              );
+              this.revenues =
+                this.revenues != undefined ? this.revenues.nombre : "-";
+            });
+
+            this.catalogService.getFundsOrigins().subscribe(res => {
+              this.funds = res.find(
+                e => e.id_origen_fondo == this.general.origenes_fondo
+              );
+              this.funds = this.funds != undefined ? this.funds.nombre : "-";
+            });
+            this.catalogService.getInstrumentTypes().subscribe(res => {
+              this.instrumentTypes = res.find(
+                e => e.codigo == this.general.instrumentos
+              );
+              this.instrumentTypes =
+                this.instrumentTypes != undefined
+                  ? this.instrumentTypes.nombre
+                  : "-";
+            });
+
+            this.catalogService.getMarketTypes().subscribe(res => {
+              this.markets = res.find(
+                e => e.id_tipo_mercado == this.complement.tipo_mercado
+              );
+              this.markets =
+                this.markets != undefined ? this.markets.nombre : "-";
+            });
+            this.catalogService.getEmitterTypes().subscribe(res => {
+              this.emitters = res.find(
+                e => e.id_tipo_emisor == this.complement.emisores
+              );
+              this.emitters =
+                this.emitters != undefined ? this.emitters.nombre : "-";
+            });
+            this.catalogService.getPeriodicities().subscribe(res => {
+              this.periodicities = res.find(
+                e => e.id_periodicidad == this.general.periodicidad
+              );
+              this.periodicities =
+                this.periodicities != undefined
+                  ? this.periodicities.nombre
+                  : "-";
+            });
+
+            this.catalogService.getPaymentTerms().subscribe(res => {
+              this.payment_terms = res.find(
+                e => e.codigo == this.complement.calificadora_riesgo
+              );
+              this.payment_terms =
+                this.payment_terms != undefined
+                  ? this.payment_terms.nombre
+                  : "-";
+            });
+            this.catalogService.getOperationTypes().subscribe(res => {
+              this.operations = res.find(
+                e => e.codigo == this.complement.operaciones
+              );
+              this.operations =
+                this.operations != undefined ? this.operations.nombre : "-";
+            });
+            //getIncomeFormat
+            this.catalogService.getIncomeFormat().subscribe(res => {
+              this.format_incomes = res.find(
+                e => e.id_formato_ingreso == this.general.formato_ingreso
+              );
+              this.format_incomes =
+                this.format_incomes != undefined
+                  ? this.format_incomes.nombre
+                  : "-";
+            });
+          }
+        });
+    } else {
+      this.investmentExists = false;
+    }
+  }
+
+  loadComponent() {
+    const adItem = this.ads[this.indexDynamicComponent];
+    const componentFactory = this.componentFactoryResolver.resolveComponentFactory(
+      adItem.component
+    );
+
+    const viewContainerRef = this.adHost.viewContainerRef;
+    viewContainerRef.clear();
+
+    const componentRef = viewContainerRef.createComponent(componentFactory);
+    (<InstrumentComponent>componentRef.instance).data = adItem.data;
+    (<InstrumentComponent>componentRef.instance).summary = true;
+  }
+
+  approve_proposal() {
+    (async () => {
+      const { value: comentario } = await Swal.fire({
+        title: "<h3>Aprobación de propuesta de inversión</h3>",
+        icon: "info",
+        input: "textarea",
+        showCancelButton: true,
+        confirmButtonText: "Enviar propuesta",
+        cancelButtonText: "Cancelar",
+        inputValidator: value => {
+          if (!value) {
+            return "Debe ingresar un comentario";
+          }
+        }
+      });
+
+      if (comentario) {
+        this.reviewProposal = {
+          id_inversion: this.investmentProposalID,
+          step: "next",
+          comentario: comentario
+        };
+
+        this.investmentService
+          .sendProposalInvestmentToNextStep(this.reviewProposal)
+          .subscribe(
+            success => {
+              if (success) {
+                Swal.fire({
+                  allowOutsideClick: false,
+                  icon: "success",
+                  showCancelButton: false,
+                  title: "Exito",
+                  confirmButtonText: "La propuesta ha sido aprobada"
+                }).then(result => {
+                  Swal.close();
+                  window.location.href = "#/investment-proposals";
+                });
+              }
+            },
+            err => {
+              Swal.fire({
+                icon: "error",
+                title: "Error al guardar",
+                text: err.message
+              });
+            }
+          );
+      }
+    })();
+  }
+
+  dismiss_proposal() {
+    (async () => {
+      const { value: comentario } = await Swal.fire({
+        title: "<h3>Aprobación de propuesta de inversión</h3>",
+        icon: "info",
+        input: "textarea",
+        showCancelButton: true,
+        confirmButtonText: "Rechazar propuesta",
+        confirmButtonColor: "#C82333",
+        cancelButtonText: "Cancelar",
+        inputValidator: value => {
+          if (!value) {
+            return "Debe ingresar un comentario";
+          }
+        }
+      });
+
+      if (comentario) {
+        this.reviewProposal = {
+          id_inversion: this.investmentProposalID,
+          step: "previous",
+          comentario: comentario
+        };
+
+        this.investmentService
+          .sendProposalInvestmentToNextStep(this.reviewProposal)
+          .subscribe(
+            success => {
+              if (success) {
+                Swal.fire({
+                  allowOutsideClick: false,
+                  icon: "warning",
+                  showCancelButton: false,
+                  title: "Exito",
+                  confirmButtonText: "La propuesta ha sido rechazada"
+                }).then(result => {
+                  window.location.href = "#/investment-proposals";
+                  Swal.close();
+                });
+              }
+            },
+            err => {
+              Swal.fire({
+                icon: "error",
+                title: "Error en el servidor",
+                text: err.message
+              });
+            }
+          );
+      }
+    })();
+  }
+}

+ 16 - 2
src/app/components/investment-proposals/investment-proposals.component.html

@@ -107,7 +107,8 @@
                         *ngIf="
                         *ngIf="
                           can_modify_or_send_to_review(
                           can_modify_or_send_to_review(
                             row.id_estado_inversion.codigo
                             row.id_estado_inversion.codigo
-                          )
+                          ) ||
+                          can_finish_proposal(row.id_estado_inversion.codigo)
                         "
                         "
                         title="Editar"
                         title="Editar"
                         class="btn btn-primary btn-custom-small"
                         class="btn btn-primary btn-custom-small"
@@ -141,6 +142,19 @@
                       >
                       >
                         <i class="fas fa-spell-check"></i>
                         <i class="fas fa-spell-check"></i>
                       </a>
                       </a>
+                      <a
+                        *ngIf="can_approve(row.id_estado_inversion.codigo)"
+                        title="Aprobar"
+                        class="btn btn-warning btn-custom-small"
+                        [routerLink]="[
+                          '/investment-proposal',
+                          row.id_inversion,
+                          'approve'
+                        ]"
+                      >
+                        <i class="far fa-thumbs-up"></i>
+                      </a>
+
                       <a
                       <a
                         *ngIf="
                         *ngIf="
                           can_write_payment_info(row.id_estado_inversion.codigo)
                           can_write_payment_info(row.id_estado_inversion.codigo)
@@ -157,7 +171,7 @@
                       </a>
                       </a>
                       <a
                       <a
                         *ngIf="
                         *ngIf="
-                          can_write_payment_info(row.id_estado_inversion.codigo)
+                          can_upload_payment(row.id_estado_inversion.codigo)
                         "
                         "
                         title="Requisición de pago"
                         title="Requisición de pago"
                         class="btn btn-success btn-custom-small"
                         class="btn btn-success btn-custom-small"

+ 28 - 6
src/app/components/investment-proposals/investment-proposals.component.ts

@@ -54,11 +54,6 @@ export class InvestmentProposalsComponent implements OnInit {
     const decodedToken = this.helper.decodeToken(
     const decodedToken = this.helper.decodeToken(
       this.authService.getJwtToken()
       this.authService.getJwtToken()
     );
     );
-    this.catalogService.getGenericURL("empresas").subscribe(ans => {
-      console.log(ans);
-      console.log("--empresas");
-    });
-    console.log(decodedToken);
     this.userRole = decodedToken.groups;
     this.userRole = decodedToken.groups;
     //    console.log("User role");
     //    console.log("User role");
     //  console.log(this.userRole);
     //  console.log(this.userRole);
@@ -180,7 +175,7 @@ export class InvestmentProposalsComponent implements OnInit {
     }
     }
   }
   }
 
 
-  can_write_payment_info(status: string) {
+  can_approve(status: string) {
     if (status == "REVIS" && (this.userRole.length == 0 || this.userRole)) {
     if (status == "REVIS" && (this.userRole.length == 0 || this.userRole)) {
       // TO DO ver que el codigo de los tipos de usuario
       // TO DO ver que el codigo de los tipos de usuario
       return true;
       return true;
@@ -189,6 +184,33 @@ export class InvestmentProposalsComponent implements OnInit {
     }
     }
   }
   }
 
 
+  can_write_payment_info(status: string) {
+    if (status == "APROB" && (this.userRole.length == 0 || this.userRole)) {
+      // TO DO ver que el codigo de los tipos de usuario
+      return true;
+    } else {
+      return false;
+    }
+  }
+
+  can_upload_payment(status: string) {
+    if (status == "COMPR" && (this.userRole.length == 0 || this.userRole)) {
+      // TO DO ver que el codigo de los tipos de usuario
+      return true;
+    } else {
+      return false;
+    }
+  }
+
+  can_finish_proposal(status: string) {
+    if (status == "LIQUI" && (this.userRole.length == 0 || this.userRole)) {
+      // TO DO ver que el codigo de los tipos de usuario
+      return true;
+    } else {
+      return false;
+    }
+  }
+
   sendToReview(investmentProposalID: number, investmentCode: string) {
   sendToReview(investmentProposalID: number, investmentCode: string) {
     (async () => {
     (async () => {
       const { value: comentario } = await Swal.fire({
       const { value: comentario } = await Swal.fire({

+ 4 - 5
src/app/components/investment-proposals/payment-info/payment-info.component.html

@@ -15,7 +15,7 @@
                   Propuestas de inversión
                   Propuestas de inversión
                 </a>
                 </a>
               </li>
               </li>
-              <li class="breadcrumb-item">Nueva</li>
+              <li class="breadcrumb-item">Información de pago</li>
             </ol>
             </ol>
           </nav>
           </nav>
         </div>
         </div>
@@ -111,9 +111,10 @@
                       }"
                       }"
                     >
                     >
                       <option
                       <option
-                        *ngFor="let item of funds"
+                        *ngFor="let item of accounts"
                         [value]="item.id_cuenta_bancaria"
                         [value]="item.id_cuenta_bancaria"
                       >
                       >
+                        {{ nameBankAccounts(item.id_banco) }} -
                         {{ item.nombre }}</option
                         {{ item.nombre }}</option
                       >
                       >
                     </select>
                     </select>
@@ -204,15 +205,13 @@
                     <button
                     <button
                       class="btn btn-primary center-component"
                       class="btn btn-primary center-component"
                       type="submit"
                       type="submit"
+                      (click)="sendPaymentInfo(investmentProposalForm)"
                     >
                     >
                       Enviar información de pago
                       Enviar información de pago
                     </button>
                     </button>
                   </div>
                   </div>
                 </div>
                 </div>
               </div>
               </div>
-
-              <!-- [disabled]="!investmentProposalForm.valid"
-                                        <div *ngIf="error" class="alert alert-danger mt-3 mb-0">{{error}}</div>-->
             </form>
             </form>
           </div>
           </div>
         </div>
         </div>

+ 80 - 32
src/app/components/investment-proposals/payment-info/payment-info.component.ts

@@ -66,6 +66,10 @@ export class PaymentInfoComponent implements OnInit {
   payment_terms: any;
   payment_terms: any;
   payment_types: any;
   payment_types: any;
   inversionCode: any;
   inversionCode: any;
+  paymentProposal: any;
+  banks: any;
+  accounts: any;
+  paymentObject: Object;
 
 
   constructor(
   constructor(
     private router: Router,
     private router: Router,
@@ -83,13 +87,12 @@ export class PaymentInfoComponent implements OnInit {
     if (this.investmentProposalID == undefined)
     if (this.investmentProposalID == undefined)
       this.investmentProposalID = this.route.snapshot.queryParamMap.get("id");
       this.investmentProposalID = this.route.snapshot.queryParamMap.get("id");
 
 
+    console.log(this.investmentProposalID);
+
     this.investmentsService
     this.investmentsService
       .getProposalInvestment(this.investmentProposalID)
       .getProposalInvestment(this.investmentProposalID)
       .subscribe(
       .subscribe(
         res => {
         res => {
-          console.log("results");
-          console.log(res);
-          console.log("-------");
           this.inversionCode = res["result"]["codigo_inversion"];
           this.inversionCode = res["result"]["codigo_inversion"];
         },
         },
         err => {
         err => {
@@ -103,11 +106,17 @@ export class PaymentInfoComponent implements OnInit {
 
 
     this.catalogService.getPaymentTypes().subscribe(res => {
     this.catalogService.getPaymentTypes().subscribe(res => {
       this.payment_types = res;
       this.payment_types = res;
-      console.log(this.payment_types);
     });
     });
     this.catalogService.getCountries().subscribe(res => {
     this.catalogService.getCountries().subscribe(res => {
       this.funds = res;
       this.funds = res;
     });
     });
+    this.catalogService.getCatalogInfo("bancos").subscribe(res => {
+      this.banks = res;
+      this.catalogService.getCatalogInfo("cuentas-bancarias").subscribe(res => {
+        this.accounts = res;
+      });
+      //this.payment_types = res;
+    });
 
 
     this.investmentProposalForm = this.formBuilder.group({
     this.investmentProposalForm = this.formBuilder.group({
       monto: [
       monto: [
@@ -117,8 +126,8 @@ export class PaymentInfoComponent implements OnInit {
           Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
           Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
         ]
         ]
       ],
       ],
-      tipo_pago: ["", [Validators.required]],
-      cuenta_bancaria: [""],
+      tipo_pago: ["", Validators.required],
+      cuenta_bancaria: ["", Validators.required],
       fecha_pago: ["", Validators.required],
       fecha_pago: ["", Validators.required],
       fecha_vencimiento: ["", Validators.required]
       fecha_vencimiento: ["", Validators.required]
     });
     });
@@ -128,37 +137,76 @@ export class PaymentInfoComponent implements OnInit {
     return this.investmentProposalForm.controls;
     return this.investmentProposalForm.controls;
   }
   }
 
 
-  save(form: any): boolean {
-    //if (!form.valid) {
-    //return false;
-    //}
-    console.log(this.investmentProposalForm.value);
-    this.formDataService.setComplementInfo(this.investmentProposalForm.value);
-    return true;
+  nameBankAccounts(id: string) {
+    let bank;
+    bank = this.banks.find(e => e.id_banco == id);
+    return bank.nombre;
   }
   }
 
 
-  goToPrevious(form: any) {
+  sendPaymentInfo(form: any) {
     this.submitted = true;
     this.submitted = true;
-    if (this.investmentProposalID != undefined) {
-      this.router.navigate(["/investment-proposal/instrument-work"], {
-        queryParams: { id: this.investmentProposalID }
-      });
-    } else {
-      this.router.navigate(["/investment-proposal/instrument-work"]);
+    console.log(form);
+    if (!form.valid) {
+      return false;
     }
     }
-  }
 
 
-  goToNext(form: any) {
-    this.submitted = true;
+    this.paymentProposal = {
+      id_inversion: this.investmentProposalID,
+      step: "next",
+      comentario: "Informacion de pago"
+    };
 
 
-    if (this.save(form)) {
-      if (this.investmentProposalID != undefined) {
-        this.router.navigate(["/investment-proposal/result"], {
-          queryParams: { id: this.investmentProposalID }
-        });
-      } else {
-        this.router.navigate(["/investment-proposal/result"]);
-      }
-    }
+    this.paymentObject = {
+      monto: this.investmentProposalForm.value.monto,
+      id_tipo_pago: this.investmentProposalForm.value.tipo_pago,
+      id_cuenta_bancaria: this.investmentProposalForm.value.cuenta_bancaria,
+      fecha_pago: this.investmentProposalForm.value.fecha_pago.singleDate
+        .formatted,
+      fecha_vencimiento: this.investmentProposalForm.value.fecha_vencimiento
+        .singleDate.formatted,
+      id_inversion: this.investmentProposalID
+    };
+
+    this.investmentsService
+      .sendPaymentInfoProposalInvestment(
+        this.investmentProposalID,
+        this.paymentObject
+      )
+      .subscribe(
+        success => {
+          this.investmentsService
+            .sendProposalInvestmentToNextStep(this.paymentProposal)
+            .subscribe(
+              success => {
+                if (success) {
+                  Swal.fire({
+                    allowOutsideClick: false,
+                    icon: "success",
+                    showCancelButton: false,
+                    title: "Exito",
+                    confirmButtonText: "La propuesta ha sido enviada a revisión"
+                  }).then(result => {
+                    Swal.close();
+                    window.location.href = "#/investment-proposals";
+                  });
+                }
+              },
+              err => {
+                Swal.fire({
+                  icon: "error",
+                  title: "Error al guardar",
+                  text: err.message
+                });
+              }
+            );
+        },
+        err => {
+          Swal.fire({
+            icon: "error",
+            title: "Error al guardar",
+            text: err.message
+          });
+        }
+      );
   }
   }
 }
 }

+ 43 - 0
src/app/components/investment-proposals/payment-requirement/payment-requirement.component.html

@@ -35,6 +35,49 @@
             </div>
             </div>
             <div class="card-body">
             <div class="card-body">
               <div class="align-container">
               <div class="align-container">
+                <div class="instrument-calcs">
+                  <div class="row">
+                    <div class="col-12">
+                      <span class="badge badge-success badge-custom"
+                        >Información del pago</span
+                      >
+                    </div>
+
+                    <div class="col-sm-6">
+                      <h4>Código de la propuesta de inversión:</h4>
+                      <div class="field">{{ codigo_inversion }}</div>
+                    </div>
+                    <div class="col-sm-6">
+                      <h4>Monto:</h4>
+                      <div class="field">
+                        $USD {{ monto | number: "1.2-4" }}
+                      </div>
+                    </div>
+                    <div class="col-sm-6">
+                      <h4>Código:</h4>
+                      <div class="field">{{ codigo }}</div>
+                    </div>
+                    <div class="col-sm-6">
+                      <h4>Tipo pago:</h4>
+                      <div class="field">{{ tipo_pago }}</div>
+                    </div>
+                    <div class="col-sm-6">
+                      <h4>Cuenta bancaria:</h4>
+                      <div class="field">{{ cuenta_bancaria }}</div>
+                    </div>
+                    <div class="col-sm-6">
+                      <h4>Fecha de pago:</h4>
+                      <div class="field">{{ fecha_pago }}</div>
+                    </div>
+                    <div class="col-sm-6">
+                      <h4>Fecha de vencimiento:</h4>
+                      <div class="field">{{ fecha_vencimiento }}</div>
+                    </div>
+                  </div>
+                </div>
+
+                <br />
+
                 <form>
                 <form>
                   <div class="row">
                   <div class="row">
                     <div class="col-lg-6 col-sm-12 pr-xl-6">
                     <div class="col-lg-6 col-sm-12 pr-xl-6">

+ 81 - 9
src/app/components/investment-proposals/payment-requirement/payment-requirement.component.ts

@@ -1,8 +1,15 @@
-import { Component, OnInit } from "@angular/core";
+import { Component, OnInit, ComponentFactoryResolver } from "@angular/core";
 import { FileUploader, FileLikeObject } from "ng2-file-upload";
 import { FileUploader, FileLikeObject } from "ng2-file-upload";
 import { concat } from "rxjs";
 import { concat } from "rxjs";
 import { FormBuilder, FormGroup } from "@angular/forms";
 import { FormBuilder, FormGroup } from "@angular/forms";
 import { HttpClient, HttpEventType } from "@angular/common/http";
 import { HttpClient, HttpEventType } from "@angular/common/http";
+import { FormInvestmentProposalService } from "@app/services/form-investment-proposal.service";
+import { InvestmentProposalWorkflowService } from "@app/services/investment-proposal-workflow.service";
+import { InstrumentsService } from "@app/services/instruments.service";
+import { CatalogsService } from "@app/services/catalogs.service";
+import { ActivatedRoute } from "@angular/router";
+import { InvestmentsService } from "@app/services/investments.service";
+import Swal from "sweetalert2";
 
 
 @Component({
 @Component({
   selector: "app-payment-requirement",
   selector: "app-payment-requirement",
@@ -17,9 +24,52 @@ export class PaymentRequirementComponent implements OnInit {
   previewUrl: any = null;
   previewUrl: any = null;
   fileUploadProgress: string = null;
   fileUploadProgress: string = null;
   uploadedFilePath: string = null;
   uploadedFilePath: string = null;
-  constructor(private http: HttpClient) {}
+  interval: any;
+  indexDynamicComponent: number;
+  investmentProposalID: string;
+  investmentExists;
+  monto: string = "";
+  codigo_inversion: string = "";
+  codigo: string = "";
+  tipo_pago: string = "";
+  cuenta_bancaria: string = "";
+  fecha_pago: string = "";
+  fecha_vencimiento: string = "";
 
 
-  ngOnInit() {}
+  constructor(
+    private http: HttpClient,
+
+    private formDataService: FormInvestmentProposalService,
+    private componentFactoryResolver: ComponentFactoryResolver,
+    private instrumentService: InvestmentProposalWorkflowService,
+    private loadInstrumentsService: InstrumentsService,
+    private catalogService: CatalogsService,
+    private route: ActivatedRoute,
+    private investmentService: InvestmentsService
+  ) {}
+
+  ngOnInit() {
+    //this.formDataService
+    //this.ads = this.loadInstrumentsService.getInstruments();
+    this.route.params.subscribe(params => {
+      this.investmentProposalID = params["id"];
+    });
+    if (this.investmentProposalID == undefined)
+      this.investmentProposalID = this.route.snapshot.queryParamMap.get("id");
+
+    this.investmentService
+      .getPaymentInfoProposalInvestment(this.investmentProposalID)
+      .subscribe(resp => {
+        this.monto = resp["result"]["monto"];
+        this.codigo_inversion =
+          resp["result"]["id_inversion"]["codigo_inversion"];
+        this.codigo = resp["result"]["codigo"];
+        this.tipo_pago = resp["result"]["id_tipo_pago"]["nombre"];
+        this.cuenta_bancaria = resp["result"]["id_cuenta_bancaria"]["nombre"];
+        this.fecha_pago = resp["result"]["fecha_pago"];
+        this.fecha_vencimiento = resp["result"]["fecha_pago"];
+      });
+  }
 
 
   fileProgress(fileInput: any) {
   fileProgress(fileInput: any) {
     this.fileData = <File>fileInput.target.files[0];
     this.fileData = <File>fileInput.target.files[0];
@@ -42,11 +92,33 @@ export class PaymentRequirementComponent implements OnInit {
 
 
   onSubmit() {
   onSubmit() {
     const formData = new FormData();
     const formData = new FormData();
-    formData.append("file", this.fileData);
-    this.http.post("url/to/your/api", formData).subscribe(res => {
-      console.log(res);
-      //this.uploadedFilePath = res.data.filePath;
-      alert("SUCCESS !!");
-    });
+    formData.append("id_inversion", this.investmentProposalID);
+    formData.append("evidencia", this.fileData);
+    formData.append("step", "next");
+    formData.append("comentario", "comentario");
+
+    this.investmentService.sendProposalInvestmentToNextStep(formData).subscribe(
+      success => {
+        if (success) {
+          Swal.fire({
+            allowOutsideClick: false,
+            icon: "success",
+            showCancelButton: false,
+            title: "Exito",
+            confirmButtonText: "La propuesta ha sido liquidada"
+          }).then(result => {
+            Swal.close();
+            window.location.href = "#/investment-proposals";
+          });
+        }
+      },
+      err => {
+        Swal.fire({
+          icon: "error",
+          title: "Error en el servidor",
+          text: err.message
+        });
+      }
+    );
   }
   }
 }
 }

+ 4 - 5
src/app/components/investment-proposals/proposal-detail/proposal-detail.component.ts

@@ -274,10 +274,9 @@ export class InvestmentProposalDetailComponent implements OnInit {
                   ? this.periodicities.nombre
                   ? this.periodicities.nombre
                   : "-";
                   : "-";
             });
             });
-
             this.catalogService.getPaymentTerms().subscribe(res => {
             this.catalogService.getPaymentTerms().subscribe(res => {
               this.payment_terms = res.find(
               this.payment_terms = res.find(
-                e => e.codigo == this.complement.calificadora_riesgo
+                e => e.id_plazo == this.complement.plazo
               );
               );
               this.payment_terms =
               this.payment_terms =
                 this.payment_terms != undefined
                 this.payment_terms != undefined
@@ -286,11 +285,12 @@ export class InvestmentProposalDetailComponent implements OnInit {
             });
             });
             this.catalogService.getOperationTypes().subscribe(res => {
             this.catalogService.getOperationTypes().subscribe(res => {
               this.operations = res.find(
               this.operations = res.find(
-                e => e.codigo == this.complement.operaciones
+                e => e.id_tipo_operacion == this.complement.operaciones
               );
               );
               this.operations =
               this.operations =
                 this.operations != undefined ? this.operations.nombre : "-";
                 this.operations != undefined ? this.operations.nombre : "-";
             });
             });
+
             //getIncomeFormat
             //getIncomeFormat
             this.catalogService.getIncomeFormat().subscribe(res => {
             this.catalogService.getIncomeFormat().subscribe(res => {
               this.format_incomes = res.find(
               this.format_incomes = res.find(
@@ -310,8 +310,7 @@ export class InvestmentProposalDetailComponent implements OnInit {
   }
   }
 
 
   loadComponent() {
   loadComponent() {
-    this.currentAdIndex = this.indexDynamicComponent % this.ads.length;
-    const adItem = this.ads[this.currentAdIndex];
+    const adItem = this.ads[this.indexDynamicComponent];
     const componentFactory = this.componentFactoryResolver.resolveComponentFactory(
     const componentFactory = this.componentFactoryResolver.resolveComponentFactory(
       adItem.component
       adItem.component
     );
     );

+ 10 - 0
src/app/components/investment-proposals/result/result.component.html

@@ -202,6 +202,16 @@
                   </a>
                   </a>
 
 
                   <button
                   <button
+                    *ngIf="can_finish_proposal(state)"
+                    class="btn btn-primary center-component float-right"
+                    type="button"
+                    (click)="finishProposal()"
+                  >
+                    Finalizar
+                  </button>
+
+                  <button
+                    *ngIf="can_send_to_review(state)"
                     class="btn btn-primary center-component float-right"
                     class="btn btn-primary center-component float-right"
                     type="button"
                     type="button"
                     (click)="sendToReview()"
                     (click)="sendToReview()"

+ 79 - 11
src/app/components/investment-proposals/result/result.component.ts

@@ -214,8 +214,6 @@ export class ResultComponent implements OnInit {
     this.final = {};
     this.final = {};
 
 
     Object.assign(this.final, this.general, this.instrument, this.complement);
     Object.assign(this.final, this.general, this.instrument, this.complement);
-    console.log("info instrument");
-    console.log(this.instrument);
     this.inversion = {
     this.inversion = {
       codigo_instrumento: this.general.instrumentos,
       codigo_instrumento: this.general.instrumentos,
       info_inversion: {
       info_inversion: {
@@ -243,19 +241,18 @@ export class ResultComponent implements OnInit {
 
 
     if (
     if (
       (this.inversion["codigo_instrumento"] == "CETE" ||
       (this.inversion["codigo_instrumento"] == "CETE" ||
-        this.inversion["codigo_instrumento"] == "DAP") &&
+        this.inversion["codigo_instrumento"] == "DAP" ||
+        this.inversion["codigo_instrumento"] == "VCN" ||
+        this.inversion["codigo_instrumento"] == "PBUR") &&
       (this.instrument["proyecciones"] != undefined ||
       (this.instrument["proyecciones"] != undefined ||
         this.instrument["proyecciones"] != "")
         this.instrument["proyecciones"] != "")
     ) {
     ) {
-      console.log("is an required object");
       this.inversion["proyecciones"] = this.instrument["proyecciones"];
       this.inversion["proyecciones"] = this.instrument["proyecciones"];
-      console.log(this.inversion);
     }
     }
   }
   }
 
 
   loadComponent() {
   loadComponent() {
-    this.currentAdIndex = this.indexDynamicComponent % this.ads.length;
-    const adItem = this.ads[this.currentAdIndex];
+    const adItem = this.ads[this.indexDynamicComponent];
     const componentFactory = this.componentFactoryResolver.resolveComponentFactory(
     const componentFactory = this.componentFactoryResolver.resolveComponentFactory(
       adItem.component
       adItem.component
     );
     );
@@ -270,8 +267,6 @@ export class ResultComponent implements OnInit {
 
 
   // Guardar propuesta de inversion (Crear)
   // Guardar propuesta de inversion (Crear)
   submit() {
   submit() {
-    console.log(this.inversion);
-
     if (this.investmentProposalID != undefined) {
     if (this.investmentProposalID != undefined) {
     } else {
     } else {
       this.investmentService.createProposalInvestment(this.inversion).subscribe(
       this.investmentService.createProposalInvestment(this.inversion).subscribe(
@@ -338,6 +333,7 @@ export class ResultComponent implements OnInit {
                   confirmButtonText: "La propuesta ha sido enviada a revisión"
                   confirmButtonText: "La propuesta ha sido enviada a revisión"
                 }).then(result => {
                 }).then(result => {
                   Swal.close();
                   Swal.close();
+                  window.location.href = "#/investment-proposals";
                 });
                 });
               }
               }
             },
             },
@@ -355,8 +351,6 @@ export class ResultComponent implements OnInit {
 
 
   // Actualizar la propuesta de inversion si se han realizado cambios
   // Actualizar la propuesta de inversion si se han realizado cambios
   update_proposal() {
   update_proposal() {
-    console.log("update inversion");
-    console.log(this.inversion);
     this.investmentService
     this.investmentService
       .updateProposalInvestment(this.investmentProposalID, this.inversion)
       .updateProposalInvestment(this.investmentProposalID, this.inversion)
       .subscribe(
       .subscribe(
@@ -382,6 +376,7 @@ export class ResultComponent implements OnInit {
         }
         }
       );
       );
   }
   }
+
   goToPrevious() {
   goToPrevious() {
     this.submitted = true;
     this.submitted = true;
     if (this.investmentProposalID != undefined) {
     if (this.investmentProposalID != undefined) {
@@ -392,4 +387,77 @@ export class ResultComponent implements OnInit {
       this.router.navigate(["/investment-proposal/complement-info"]);
       this.router.navigate(["/investment-proposal/complement-info"]);
     }
     }
   }
   }
+
+  //Enviar a revision la propuesta de inversion
+  finishProposal() {
+    (async () => {
+      const { value: comentario } = await Swal.fire({
+        title: "<h3>Finalizar propuesta de inversión</h3>",
+        icon: "info",
+        input: "textarea",
+        showCancelButton: true,
+        confirmButtonText: "Finalizar",
+        cancelButtonText: "Cancelar",
+        inputValidator: value => {
+          if (!value) {
+            return "Debe ingresar un comentario";
+          }
+        }
+      });
+
+      if (comentario) {
+        this.reviewProposal = {
+          id_inversion: this.investmentProposalID,
+          step: "next",
+          comentario: comentario
+        };
+
+        this.investmentService
+          .sendReviewProposalInvestment(this.reviewProposal)
+          .subscribe(
+            success => {
+              if (success) {
+                Swal.fire({
+                  allowOutsideClick: false,
+                  icon: "success",
+                  showCancelButton: false,
+                  title: "Exito",
+                  confirmButtonText: "La propuesta ha sido finalizada"
+                }).then(result => {
+                  Swal.close();
+                  window.location.href = "#/investment-proposals";
+                });
+              }
+            },
+            err => {
+              Swal.fire({
+                icon: "error",
+                title: "Error al guardar",
+                text: err.message
+              });
+            }
+          );
+      }
+    })();
+  }
+
+  // Verifica permisos para mostrar boton de edicion y/o envio a revision,
+  // segun los permisos del usuario y el estado de la propuesta
+  can_send_to_review(status: string) {
+    if (status == "NUEVA" && (this.userRole.length == 0 || this.userRole)) {
+      // TO DO ver que el codigo de los tipos de usuario
+      return true;
+    } else {
+      return false;
+    }
+  }
+
+  can_finish_proposal(status: string) {
+    if (status == "LIQUI" && (this.userRole.length == 0 || this.userRole)) {
+      // TO DO ver que el codigo de los tipos de usuario
+      return true;
+    } else {
+      return false;
+    }
+  }
 }
 }

+ 5 - 4
src/app/components/investment-proposals/review/review.component.ts

@@ -309,8 +309,7 @@ export class InvestmentProposalReviewComponent implements OnInit {
   }
   }
 
 
   loadComponent() {
   loadComponent() {
-    this.currentAdIndex = this.indexDynamicComponent % this.ads.length;
-    const adItem = this.ads[this.currentAdIndex];
+    const adItem = this.ads[this.indexDynamicComponent];
     const componentFactory = this.componentFactoryResolver.resolveComponentFactory(
     const componentFactory = this.componentFactoryResolver.resolveComponentFactory(
       adItem.component
       adItem.component
     );
     );
@@ -326,7 +325,7 @@ export class InvestmentProposalReviewComponent implements OnInit {
   approve_proposal() {
   approve_proposal() {
     (async () => {
     (async () => {
       const { value: comentario } = await Swal.fire({
       const { value: comentario } = await Swal.fire({
-        title: "<h3>Enviar a revisión propuesta de inversión</h3>",
+        title: "<h3>Revisión propuesta de inversión</h3>",
         icon: "info",
         icon: "info",
         input: "textarea",
         input: "textarea",
         showCancelButton: true,
         showCancelButton: true,
@@ -359,6 +358,7 @@ export class InvestmentProposalReviewComponent implements OnInit {
                   confirmButtonText: "La propuesta ha sido aprobada"
                   confirmButtonText: "La propuesta ha sido aprobada"
                 }).then(result => {
                 }).then(result => {
                   Swal.close();
                   Swal.close();
+                  window.location.href = "#/investment-proposals";
                 });
                 });
               }
               }
             },
             },
@@ -377,7 +377,7 @@ export class InvestmentProposalReviewComponent implements OnInit {
   dismiss_proposal() {
   dismiss_proposal() {
     (async () => {
     (async () => {
       const { value: comentario } = await Swal.fire({
       const { value: comentario } = await Swal.fire({
-        title: "<h3>Enviar a revisión propuesta de inversión</h3>",
+        title: "<h3>Revisión propuesta de inversión</h3>",
         icon: "info",
         icon: "info",
         input: "textarea",
         input: "textarea",
         showCancelButton: true,
         showCancelButton: true,
@@ -411,6 +411,7 @@ export class InvestmentProposalReviewComponent implements OnInit {
                   confirmButtonText: "La propuesta ha sido aprobada"
                   confirmButtonText: "La propuesta ha sido aprobada"
                 }).then(result => {
                 }).then(result => {
                   Swal.close();
                   Swal.close();
+                  window.location.href = "#/investment-proposals";
                 });
                 });
               }
               }
             },
             },

+ 100 - 1
src/app/components/investments/investments.component.html

@@ -10,7 +10,7 @@
               <li class="breadcrumb-item">
               <li class="breadcrumb-item">
                 <a [routerLink]="['/']">Dashboard</a>
                 <a [routerLink]="['/']">Dashboard</a>
               </li>
               </li>
-              <li class="breadcrumb-item">Inversiones</li>
+              <li class="breadcrumb-item">Inversiones activas</li>
             </ol>
             </ol>
           </nav>
           </nav>
         </div>
         </div>
@@ -19,6 +19,105 @@
       <div class="col-12">
       <div class="col-12">
         <div class="align-container">
         <div class="align-container">
           <h4><b>Listado de inversiones</b></h4>
           <h4><b>Listado de inversiones</b></h4>
+          <br />
+          <div class="form-group">
+            <label for="filter" class="control-label">Filtro: </label>
+            <input
+              name="filter"
+              (keyup)="applyFilter($event)"
+              class="form-control input-md"
+              placeholder="Codigo, Instrumento, Asunto o Comentario"
+            />
+          </div>
+          <br />
+          <div class="example-container mat-elevation-z8">
+            <div class="example-table-container">
+              <table mat-table [dataSource]="dataSource" class="example-table">
+                <!-- Name Column -->
+                <ng-container matColumnDef="codigo_inversion">
+                  <th mat-header-cell *matHeaderCellDef>Codigo</th>
+                  <td mat-cell *matCellDef="let row">
+                    {{ row.codigo_inversion }}
+                  </td>
+                </ng-container>
+                <!-- Country Column -->
+                <ng-container matColumnDef="asunto">
+                  <th mat-header-cell *matHeaderCellDef>Asunto</th>
+                  <td mat-cell *matCellDef="let row">
+                    {{ row.asunto }}
+                  </td>
+                </ng-container>
+
+                <!-- Country Column -->
+                <ng-container matColumnDef="id_tipo_mercado">
+                  <th mat-header-cell *matHeaderCellDef>Tipo de mercado</th>
+                  <td mat-cell *matCellDef="let row">
+                    {{
+                      row.id_tipo_mercado == "" ||
+                      row.id_tipo_mercado == undefined
+                        ? "-"
+                        : row.id_tipo_mercado.nombre
+                    }}
+                  </td>
+                </ng-container>
+
+                <!-- Country Column -->
+                <ng-container matColumnDef="id_inversion_instrumento">
+                  <th mat-header-cell *matHeaderCellDef>Instrumento</th>
+                  <td mat-cell *matCellDef="let row">
+                    {{
+                      row.id_inversion_instrumento.id_tipo_instrumento == "" ||
+                      row.id_inversion_instrumento.id_tipo_instrumento ==
+                        undefined
+                        ? "-"
+                        : row.id_inversion_instrumento.id_tipo_instrumento
+                            .nombre
+                    }}
+                  </td>
+                </ng-container>
+
+                <!--  Column -->
+                <ng-container matColumnDef="id">
+                  <th mat-header-cell *matHeaderCellDef>&nbsp;</th>
+                  <td mat-cell *matCellDef="let row">
+                    <div class="action-buttons">
+                      <a
+                        title="Detalle propuesta"
+                        class="btn btn-primary btn-custom-small"
+                        (click)="view_investment_proposal(row.id_inversion)"
+                      >
+                        <i class="fas fa-info"></i>
+                      </a>
+                      <a
+                        *ngIf="
+                          can_modify_or_send_to_review(
+                            row.id_estado_inversion.codigo
+                          )
+                        "
+                        title="Editar"
+                        class="btn btn-primary btn-custom-small"
+                        (click)="modify_investment_proposal(row.id_inversion)"
+                      >
+                        <i class="fas fa-edit"></i>
+                      </a>
+                    </div>
+                  </td>
+                </ng-container>
+
+                <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
+                <tr
+                  mat-row
+                  *matRowDef="let row; columns: displayedColumns"
+                ></tr>
+              </table>
+
+              <mat-paginator
+                [pageSizeOptions]="[10, 15, 25]"
+                [pageIndex]="0"
+                [pageSize]="10"
+              ></mat-paginator>
+            </div>
+          </div>
         </div>
         </div>
       </div>
       </div>
       <br />
       <br />

+ 10 - 0
src/app/components/investments/investments.component.scss

@@ -0,0 +1,10 @@
+.action-buttons {
+  i {
+    font-size: 18px;
+  }
+}
+
+.btn-custom-small {
+  padding: 7px 12px 5px 13px;
+  margin: 0 4px;
+}

+ 148 - 5
src/app/components/investments/investments.component.ts

@@ -1,14 +1,157 @@
-import { Component, OnInit } from "@angular/core";
+import { Component, ViewChild, OnInit } from "@angular/core";
+import { MatPaginator } from "@angular/material/paginator";
+import { MatSort } from "@angular/material/sort";
+import { MatTableDataSource } from "@angular/material/table";
+import Swal from "sweetalert2";
+import { CatalogsService } from "src/app/services/catalogs.service";
+import { InvestmentsService } from "@app/services/investments.service";
+import { AuthService } from "@app/services/auth2.service";
+import { JwtHelperService } from "@auth0/angular-jwt";
+import { InvestmentProposal } from "@app/models/investment-proposal";
+import { from } from "rxjs";
+import { FormInvestmentProposalService } from "@app/services/form-investment-proposal.service";
+import { Router } from "@angular/router";
 
 
 @Component({
 @Component({
-  selector: "app-investments",
+  selector: "app-investment-proposals",
   templateUrl: "./investments.component.html",
   templateUrl: "./investments.component.html",
   styleUrls: ["./investments.component.scss"]
   styleUrls: ["./investments.component.scss"]
 })
 })
 export class InvestmentsComponent implements OnInit {
 export class InvestmentsComponent implements OnInit {
-  title: string = "Inversiones";
+  helper = new JwtHelperService();
 
 
-  constructor() {}
+  title: string = "Inversiones activas";
 
 
-  ngOnInit() {}
+  displayedColumns: string[] = [
+    "codigo_inversion",
+    "asunto",
+    "id_tipo_mercado",
+    "id_inversion_instrumento",
+    "id"
+  ];
+  //displayedColumns: string[] = ['state'];
+
+  listProposals: InvestmentProposal[];
+  dataSource = new MatTableDataSource(this.listProposals);
+
+  resultsLength = 0;
+  isLoadingResults = true;
+  isRateLimitReached = false;
+  userRole: any;
+
+  @ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
+  @ViewChild(MatSort, { static: true }) sort: MatSort;
+  role_number: any;
+
+  constructor(
+    private catalogService: CatalogsService,
+    private investmentsService: InvestmentsService,
+    private authService: AuthService,
+    private formInvestmentProposal: FormInvestmentProposalService,
+    private router: Router
+  ) {
+    const decodedToken = this.helper.decodeToken(
+      this.authService.getJwtToken()
+    );
+    this.userRole = decodedToken.groups;
+    //    console.log("User role");
+    //  console.log(this.userRole);
+    //console.log(this.userRole.length == 0);
+
+    this.dataSource.filterPredicate = (data, filter) => {
+      const dataStr =
+        data.id_inversion_instrumento.id_tipo_instrumento.nombre +
+        data.codigo_inversion +
+        data.nombre_inversion +
+        data.asunto +
+        data.comentario +
+        data.justificacion;
+      return dataStr.indexOf(filter) != -1;
+    };
+
+    Swal.fire({
+      allowOutsideClick: false,
+      icon: "info",
+      text: "Espere por favor..."
+    });
+    Swal.showLoading();
+  }
+
+  ngOnInit() {
+    this.investmentsService.getProposalInvestmentsList().subscribe(
+      ans => {
+        this.listProposals = ans.result;
+
+        this.listProposals = this.listProposals.filter(
+          proposals => proposals["id_estado_inversion"]["codigo"] == "FINAL"
+        );
+
+        console.log(this.listProposals);
+        this.dataSource.data = this.listProposals;
+
+        this.dataSource.paginator = this.paginator;
+        this.dataSource.sort = this.sort;
+      },
+      err => {
+        Swal.fire({
+          icon: "error",
+          title: "Error en el servidor",
+          text: err.message
+        });
+      }
+    );
+
+    setTimeout(() => {
+      Swal.close();
+    }, 1200);
+  }
+
+  applyFilter(event: Event) {
+    const filterValue = (event.target as HTMLInputElement).value;
+    this.dataSource.filter = filterValue;
+
+    if (this.dataSource.paginator) {
+      this.dataSource.paginator.firstPage();
+    }
+  }
+
+  view_investment_proposal(id: string) {
+    this.formInvestmentProposal.resetFormData();
+    Swal.fire({
+      allowOutsideClick: false,
+      icon: "info",
+      text: "Espere por favor..."
+    });
+    Swal.showLoading();
+    setTimeout(() => {
+      this.router.navigate([`/investment-proposal/${id}`]);
+    }, 1000);
+  }
+
+  modify_investment_proposal(id: string) {
+    this.formInvestmentProposal.resetFormData();
+
+    Swal.fire({
+      allowOutsideClick: false,
+      icon: "info",
+      text: "Espere por favor..."
+    });
+    Swal.showLoading();
+    setTimeout(() => {
+      this.router.navigate(["/investment-proposal/general-info"], {
+        queryParams: { id: id }
+      });
+    }, 1000);
+  }
+
+  // Verifica permisos para mostrar boton de edicion y/o envio a revision,
+  // segun los permisos del usuario y el estado de la propuesta
+  can_modify_or_send_to_review(status: string) {
+    if (status == "NUEVA" && (this.userRole.length == 0 || this.userRole)) {
+      // TO DO ver que el codigo de los tipos de usuario
+      return true;
+    } else {
+      return false;
+    }
+  }
 }
 }

+ 3 - 3
src/app/components/shared/sidebar/sidebar.component.ts

@@ -24,15 +24,15 @@ export const ROUTES: RouteInfo[] = [
     icon: "wb_incandescent",
     icon: "wb_incandescent",
     class: ""
     class: ""
     //allowed_roles: [2, 3]
     //allowed_roles: [2, 3]
-  }
-  /*
+  },
   {
   {
     path: "/investments",
     path: "/investments",
     title: "Inversiones",
     title: "Inversiones",
     icon: "work",
     icon: "work",
     class: ""
     class: ""
     //allowed_roles: [2, 3]
     //allowed_roles: [2, 3]
-  },
+  }
+  /*
   {
   {
     path: "/arbitrations",
     path: "/arbitrations",
     title: "Arbitrajes",
     title: "Arbitrajes",

+ 2 - 0
src/app/layouts/admin/admin.module.ts

@@ -69,6 +69,7 @@ import { ChangeHistoryComponent } from "@app/components/investment-proposals/cha
 import { PaymentRequirementComponent } from "@app/components/investment-proposals/payment-requirement/payment-requirement.component";
 import { PaymentRequirementComponent } from "@app/components/investment-proposals/payment-requirement/payment-requirement.component";
 import { PaymentInfoComponent } from "@app/components/investment-proposals/payment-info/payment-info.component";
 import { PaymentInfoComponent } from "@app/components/investment-proposals/payment-info/payment-info.component";
 import { InvestmentProposalDetailComponent } from "@app/components/investment-proposals/proposal-detail/proposal-detail.component";
 import { InvestmentProposalDetailComponent } from "@app/components/investment-proposals/proposal-detail/proposal-detail.component";
+import { InvestmentProposalApproveComponent } from "@app/components/investment-proposals/approve/approve.component";
 
 
 // This array defines which "componentId" maps to which lazy-loaded module.
 // This array defines which "componentId" maps to which lazy-loaded module.
 
 
@@ -114,6 +115,7 @@ import { InvestmentProposalDetailComponent } from "@app/components/investment-pr
     InvestmentProposalsComponent,
     InvestmentProposalsComponent,
     InvestmentProposalGeneralInfoComponent,
     InvestmentProposalGeneralInfoComponent,
     InvestmentProposalReviewComponent,
     InvestmentProposalReviewComponent,
+    InvestmentProposalApproveComponent,
     ChangeHistoryComponent,
     ChangeHistoryComponent,
     InvestmentsComponent,
     InvestmentsComponent,
     ArbitrationsComponent,
     ArbitrationsComponent,

+ 5 - 0
src/app/layouts/admin/admin.routing.ts

@@ -24,6 +24,7 @@ import { InvestmentProposalDetailComponent } from "@app/components/investment-pr
 
 
 import { NgModule } from "@angular/core";
 import { NgModule } from "@angular/core";
 import { from } from "rxjs";
 import { from } from "rxjs";
+import { InvestmentProposalApproveComponent } from "@app/components/investment-proposals/approve/approve.component";
 
 
 export const AdminLayoutRoutes: Routes = [
 export const AdminLayoutRoutes: Routes = [
   {
   {
@@ -169,6 +170,10 @@ export const AdminLayoutRoutes: Routes = [
     path: "investment-proposal/:id/review",
     path: "investment-proposal/:id/review",
     component: InvestmentProposalReviewComponent
     component: InvestmentProposalReviewComponent
   },
   },
+  {
+    path: "investment-proposal/:id/approve",
+    component: InvestmentProposalApproveComponent
+  },
   {
   {
     path: "investment-proposal/:id/change-history",
     path: "investment-proposal/:id/change-history",
     component: ChangeHistoryComponent
     component: ChangeHistoryComponent

+ 2 - 1
src/app/services/catalogs.service.ts

@@ -14,7 +14,7 @@ export class CatalogsService {
 
 
   constructor(private http: HttpClient) {}
   constructor(private http: HttpClient) {}
 
 
-  getGenericURL(url: string) {
+  getCatalogInfo(url: string) {
     return this.http
     return this.http
       .get<any>(`${environment.productionApiUrl}/${url}`, {})
       .get<any>(`${environment.productionApiUrl}/${url}`, {})
       .pipe(
       .pipe(
@@ -24,6 +24,7 @@ export class CatalogsService {
         catchError(this.errorHandl)
         catchError(this.errorHandl)
       );
       );
   }
   }
+
   // paises
   // paises
   getCountries() {
   getCountries() {
     return this.http
     return this.http

+ 0 - 7
src/app/services/instruments.service.ts

@@ -15,13 +15,6 @@ import { APNComponent } from "@app/components/instruments/apn/apn.component";
   providedIn: "root"
   providedIn: "root"
 })
 })
 export class InstrumentsService {
 export class InstrumentsService {
-  workflow = [
-    { step: STEPS.general, valid: true }, // test purposes
-    { step: STEPS.work, valid: true },
-    { step: STEPS.complement, valid: true },
-    { step: STEPS.result, valid: true }
-  ];
-
   getInstruments() {
   getInstruments() {
     return [
     return [
       new Instrument(LETE, { key: "LETE", name: "Lete" }),
       new Instrument(LETE, { key: "LETE", name: "Lete" }),

+ 25 - 0
src/app/services/investments.service.ts

@@ -83,6 +83,31 @@ export class InvestmentsService {
       );
       );
   }
   }
 
 
+  sendPaymentInfoProposalInvestment(
+    id: string,
+    inversion: Object
+  ): Observable<boolean> {
+    return this.http
+      .post<any>(`${environment.productionApiUrl}/pagos/${id}`, inversion)
+      .pipe(
+        map(response => {
+          return response;
+        }),
+        catchError(this.errorHandl)
+      );
+  }
+
+  getPaymentInfoProposalInvestment(id: string): Observable<boolean> {
+    return this.http
+      .get<any>(`${environment.productionApiUrl}/pagos/${id}`)
+      .pipe(
+        map(response => {
+          return response;
+        }),
+        catchError(this.errorHandl)
+      );
+  }
+
   //if(error.error instanceof ErrorEvent) {
   //if(error.error instanceof ErrorEvent) {
   errorHandl(error) {
   errorHandl(error) {
     let errorMessage = "";
     let errorMessage = "";