Преглед изворни кода

Merge branch 'development' into feature-general_fixes

Francisco huezo пре 5 година
родитељ
комит
64b4fe5baf

+ 103 - 29
src/app/components/instruments/bonos/bonos.component.html

@@ -19,16 +19,17 @@
           <option
             *ngFor="let item of ejecuciones"
             [value]="item.codigo"
-            [selected]="item.codigo == ejecucion"
+            [selected]="item.codigo == tipoEjecucion"
           >
             {{ item.nombre }}</option
           >
         </select>
       </div>
-
       <br />
-
-      <div class=" col-md-6 col-sm-12 border border-light">
+    </div>
+    <br />
+    <div class="row">
+      <div class=" col-md-12 col-sm-12 border border-light">
         <div class="row no-gutters">
           <!-- Valor nominal compra -->
 
@@ -445,8 +446,13 @@
           </div>
         </div>
       </div>
-
-      <div class=" col-md-6 col-sm-12 border border-light">
+    </div>
+    <br />
+    <div class="row">
+      <div
+        class=" col-md-12 col-sm-12 border border-light"
+        *ngIf="tipoEjecucion == 1"
+      >
         <div class="row no-gutters">
           <div class="col-12">
             <h5>Venta</h5>
@@ -874,7 +880,9 @@
             {{ fecha_inicio_vigencia }}
           </div>
         </div>
+      </div>
 
+      <div class="row" *ngIf="tipoEjecucion == 1">
         <div class="col-12">
           <h3>
             Instrumento de venta
@@ -950,71 +958,113 @@
             $USD {{ valor_transado_venta | number: "1.2-4" }}
           </div>
         </div>
-
+      </div>
+      <div class="row">
         <div class="row align-container" *ngIf="operation_result">
           <div class="col-12">
             <h3>
               Resultado de la operación
             </h3>
           </div>
+
           <div class="col-sm-4">
-            <h4>Monto a recibir:</h4>
-            <div class="field">$USD {{ monto_recibir | number: "1.2-4" }}</div>
+            <h4>Valor nominal compra:</h4>
+            <div class="field">
+              $USD{{ operation_results_work.valor_transado_compra }}
+            </div>
           </div>
+
           <div class="col-sm-4">
             <h4>Días tenencia total:</h4>
             <div class="field">
-              {{ dias_tenencia_total }}
+              {{ operation_results_work.dias_tenencia_total }}
             </div>
           </div>
+
+          <div class="col-sm-4">
+            <h4>Precio compra:</h4>
+            <div class="field">
+              {{ operation_results_work.precio_compra }}
+            </div>
+          </div>
+
+          <div class="col-sm-4">
+            <h4>Precio venta:</h4>
+            <div class="field">
+              {{ operation_results_work.precio_venta }}
+            </div>
+          </div>
+
           <div class="col-sm-4">
             <h4>Ingresos intereses:</h4>
             <div class="field">
-              $USD {{ ingresos_intereses | number: "1.2-4" }}
+              $USD
+              {{ operation_results_work.ingresos_intereses | number: "1.2-4" }}
             </div>
           </div>
           <div class="col-sm-4">
             <h4>Costos totales:</h4>
-            <div class="field">$USD {{ costos_totales | number: "1.2-4" }}</div>
+            <div class="field">
+              $USD {{ operation_results_work.costos_totales | number: "1.2-4" }}
+            </div>
           </div>
           <div class="col-sm-4">
-            <h4>Ganancia / Pérdida total:</h4>
+            <h4>Ganancia o pérdida total:</h4>
             <div class="field">
-              $USD {{ ganancia_perdida_total | number: "1.2-4" }}
+              $USD
+              {{
+                operation_results_work.ganancia_perdida_total_neto
+                  | number: "1.2-4"
+              }}
             </div>
           </div>
           <div class="col-sm-4">
-            <h4>Ganancia / Pérdida de capital:</h4>
+            <h4>Ganancia o pérdida de capital:</h4>
             <div class="field">
-              {{ ganancia_perdida_capital_porcentaje | number: "1.2-4" }}%
+              {{
+                operation_results_work.ganancia_perdida_capital_porcentaje
+                  | number: "1.2-4"
+              }}%
             </div>
           </div>
 
           <div class="col-sm-4">
             <h4>Interés (%):</h4>
             <div class="field">
-              {{ intereses_porcentaje | number: "1.2-4" }} %
+              {{
+                operation_results_work.intereses_porcentaje | number: "1.2-4"
+              }}
+              %
             </div>
           </div>
           <div class="col-sm-4">
             <h4>Interés neto antes de impuesto (%):</h4>
             <div class="field">
-              {{ neto_antes_impuesto_porcentaje | number: "1.2-4" }}
+              {{
+                operation_results_work.neto_antes_renta_porcentaje
+                  | number: "1.2-4"
+              }}
               %
             </div>
           </div>
           <div class="col-sm-4">
             <h4>Interés neto después de impuesto (%):</h4>
             <div class="field">
-              {{ neto_despues_impuesto_porcentaje | number: "1.2-4" }}
+              {{
+                operation_results_work.neto_despues_renta_porcentaje
+                  | number: "1.2-4"
+              }}
               %
             </div>
           </div>
           <div class="col-sm-4">
-            <h4>Total de ingresos recibidos:</h4>
+            <h4>Total Ingresos Recibidos:</h4>
             <div class="field">
               $USD
-              {{ total_ingresos_recibidos | number: "1.2-4" }}
+              {{
+                operation_results_work.total_ingresos_recibidos
+                  | number: "1.2-4"
+              }}
             </div>
           </div>
         </div>
@@ -1331,8 +1381,7 @@
       </div>
     </div>
 
-    <!--
-    <div class="row">
+    <div class="row" *ngIf="tipoEjecucion == 1">
       <div class="col-12">
         <h3>
           Instrumento de venta
@@ -1511,7 +1560,7 @@
       <div class="col-lg-3 col-md-4 col-sm-6">
         <h4>Valor nominal compra:</h4>
         <div class="field">
-          $USD{{ operation_results_work.valor_nominal_compra }}
+          $USD{{ operation_results_work.valor_transado_compra }}
         </div>
       </div>
       <div class="col-lg-3 col-md-4 col-sm-6">
@@ -1520,6 +1569,21 @@
           {{ operation_results_work.dias_tenencia_total }}
         </div>
       </div>
+
+      <div class="col-lg-3 col-md-4 col-sm-6">
+        <h4>Precio compra:</h4>
+        <div class="field">
+          {{ operation_results_work.precio_compra }}
+        </div>
+      </div>
+
+      <div class="col-lg-3 col-md-4 col-sm-6">
+        <h4>Precio venta:</h4>
+        <div class="field">
+          {{ operation_results_work.precio_venta }}
+        </div>
+      </div>
+
       <div class="col-lg-3 col-md-4 col-sm-6">
         <h4>Ingresos intereses:</h4>
         <div class="field">
@@ -1536,7 +1600,9 @@
         <h4>Ganancia o pérdida total:</h4>
         <div class="field">
           $USD
-          {{ operation_results_work.ganancia_perdida_total | number: "1.2-4" }}
+          {{
+            operation_results_work.ganancia_perdida_total_neto | number: "1.2-4"
+          }}
         </div>
       </div>
       <div class="col-lg-3 col-md-4 col-sm-6">
@@ -1559,8 +1625,7 @@
         <h4>Interés neto antes de impuesto (%):</h4>
         <div class="field">
           {{
-            operation_results_work.neto_antes_impuesto_porcentaje
-              | number: "1.2-4"
+            operation_results_work.neto_antes_renta_porcentaje | number: "1.2-4"
           }}
           %
         </div>
@@ -1569,14 +1634,23 @@
         <h4>Interés neto después de impuesto (%):</h4>
         <div class="field">
           {{
-            operation_results_work.neto_despues_impuesto_porcentaje
+            operation_results_work.neto_despues_renta_porcentaje
               | number: "1.2-4"
           }}
           %
         </div>
       </div>
+      <div class="col-lg-3 col-md-4 col-sm-6">
+        <h4>Total Ingresos Recibidos:</h4>
+        <div class="field">
+          $USD
+          {{
+            operation_results_work.total_ingresos_recibidos | number: "1.2-4"
+          }}
+        </div>
+      </div>
     </div>
-  -->
+
     <br />
     <div *ngIf="hasProjections" class="instrument-calcs-summary">
       <div class="row">

+ 132 - 113
src/app/components/instruments/bonos/bonos.component.ts

@@ -128,12 +128,11 @@ export class BONO implements InstrumentComponent {
   ytm_vencimiento_porcentaje_venta: any;
   comision_bolsa_venta: any;
   consolidado_proyeccion: any;
-  ejecucion: boolean = false;
   ejecuciones = [
     { codigo: 1, nombre: "Completa" },
     { codigo: 0, nombre: "Parcial" }
   ];
-  tipoEjecucion: number;
+  tipoEjecucion: number = 0;
 
   constructor(
     private formBuilder: FormBuilder,
@@ -144,7 +143,6 @@ export class BONO implements InstrumentComponent {
     public datepipe: DatePipe
   ) {
     this.instrument_work = this.formDataService.getWork();
-
     this.instrument_exists = this.instrument_work == undefined;
     this.general = this.formDataService.getGeneralInfo();
 
@@ -177,8 +175,14 @@ export class BONO implements InstrumentComponent {
       this.operation_result = true;
     }
 
+    if (+this.instrument_work["valor_nominal_venta"] > 0) {
+      this.tipoEjecucion = 1;
+    }
+    console.log("EJECUCION");
+    console.log(this.tipoEjecucion);
+
     this.investmentProposalForm = this.formBuilder.group({
-      ejecucion: [this.instrument_exists ? "" : this.ejecucion],
+      ejecucion: [this.instrument_exists ? "" : this.tipoEjecucion],
 
       renta_porcentaje: [
         this.instrument_exists ? "" : this.instrument_work.renta_porcentaje,
@@ -418,6 +422,7 @@ export class BONO implements InstrumentComponent {
           id_periodicidad: +this.general.periodicidad
         },
         {
+          completo: this.tipoEjecucion,
           renta_porcentaje: +this.f.renta_porcentaje.value,
           costo_cedeval: +this.f.costo_cedeval.value,
           costo_transferencia: +this.f.costo_transferencia.value,
@@ -439,19 +444,31 @@ export class BONO implements InstrumentComponent {
           comision_bolsa_porcentaje_venta: this.f
             .comision_bolsa_porcentaje_venta.value,
 
-          fecha_vencimiento_compra: this.f.fecha_vencimiento_compra.value
-            .singleDate.formatted,
-          fecha_ultima_cupon_compra: this.f.fecha_ultima_cupon_compra.value
-            .singleDate.formatted,
-          fecha_liquidacion_compra: this.f.fecha_liquidacion_compra.value
-            .singleDate.formatted,
-
-          fecha_vencimiento_venta: this.f.fecha_vencimiento_venta.value
-            .singleDate.formatted,
-          fecha_ultima_cupon_venta: this.f.fecha_ultima_cupon_venta.value
-            .singleDate.formatted,
-          fecha_liquidacion_venta: this.f.fecha_liquidacion_venta.value
-            .singleDate.formatted
+          fecha_vencimiento_compra:
+            this.f.fecha_vencimiento_compra.value == ""
+              ? ""
+              : this.f.fecha_vencimiento_compra.value.singleDate.formatted,
+          fecha_ultima_cupon_compra:
+            this.f.fecha_ultima_cupon_compra.value == ""
+              ? ""
+              : this.f.fecha_ultima_cupon_compra.value.singleDate.formatted,
+          fecha_liquidacion_compra:
+            this.f.fecha_liquidacion_compra.value == ""
+              ? ""
+              : this.f.fecha_liquidacion_compra.value.singleDate.formatted,
+
+          fecha_vencimiento_venta:
+            this.f.fecha_vencimiento_venta.value == ""
+              ? ""
+              : this.f.fecha_vencimiento_venta.value.singleDate.formatted,
+          fecha_ultima_cupon_venta:
+            this.f.fecha_ultima_cupon_venta.value == ""
+              ? ""
+              : this.f.fecha_ultima_cupon_venta.value.singleDate.formatted,
+          fecha_liquidacion_venta:
+            this.f.fecha_liquidacion_venta.value == ""
+              ? ""
+              : this.f.fecha_liquidacion_venta.value.singleDate.formatted
         }
       )
       .subscribe(
@@ -492,64 +509,43 @@ export class BONO implements InstrumentComponent {
             ans["result"]["instrumento_compra"]["fecha_inicio_vigencia"];
 
           // Instrumento de venta
-          this.comision_casa_venta =
-            ans["result"]["instrumento_venta"]["comision_casa_venta"];
-          this.comision_bolsa_venta =
-            ans["result"]["instrumento_venta"]["comision_bolsa_venta"];
-          this.fecha_siguiente_cupon_venta =
-            ans["result"]["instrumento_venta"]["fecha_siguiente_cupon_venta"];
-          this.dias_vencimiento_venta =
-            ans["result"]["instrumento_venta"]["dias_vencimiento_venta"];
-          this.dias_acumulados_venta =
-            ans["result"]["instrumento_venta"]["dias_acumulados_venta"];
-          this.ytm_vencimiento_comision_porcentaje_venta =
-            ans["result"]["instrumento_venta"][
-              "ytm_vencimiento_comision_porcentaje_venta"
-            ];
-          this.ytm_vencimiento_porcentaje_venta =
-            ans["result"]["instrumento_venta"][
-              "ytm_vencimiento_porcentaje_venta"
-            ];
-          this.interes_acumulado_venta =
-            ans["result"]["instrumento_venta"]["interes_acumulado_venta"];
-          this.interes_acumulado_porcentaje_venta =
-            ans["result"]["instrumento_venta"][
-              "interes_acumulado_porcentaje_venta"
-            ];
-          this.precio_sucio_porcentaje_venta =
-            ans["result"]["instrumento_venta"]["precio_sucio_porcentaje_venta"];
-          this.valor_transado_venta =
-            ans["result"]["instrumento_venta"]["valor_transado_venta"];
-          this.monto_recibir =
-            ans["result"]["instrumento_venta"]["monto_recibir"];
-
-          // Resultado de la operacion
-          this.dias_tenencia_total =
-            ans["result"]["resultado_operacion"]["dias_tenencia_total"];
-          this.ganancia_perdida_capital =
-            ans["result"]["resultado_operacion"]["ganancia_perdida_capital"];
-          this.ingresos_intereses =
-            ans["result"]["resultado_operacion"]["ingresos_intereses"];
-          this.costos_totales =
-            ans["result"]["resultado_operacion"]["costos_totales"];
-          this.ganancia_perdida_total =
-            ans["result"]["resultado_operacion"]["ganancia_perdida_total"];
-          this.ganancia_perdida_capital_porcentaje =
-            ans["result"]["resultado_operacion"][
-              "ganancia_perdida_capital_porcentaje"
-            ];
-          this.intereses_porcentaje =
-            ans["result"]["resultado_operacion"]["intereses_porcentaje"];
-          this.neto_antes_impuesto_porcentaje =
-            ans["result"]["resultado_operacion"][
-              "neto_antes_impuesto_porcentaje"
-            ];
-          this.neto_despues_impuesto_porcentaje =
-            ans["result"]["resultado_operacion"][
-              "neto_despues_impuesto_porcentaje"
-            ];
-          this.total_ingresos_recibidos =
-            ans["result"]["resultado_operacion"]["total_ingresos_recibidos"];
+          if (this.tipoEjecucion == 1) {
+            this.comision_casa_venta =
+              ans["result"]["instrumento_venta"]["comision_casa_venta"];
+            this.comision_bolsa_venta =
+              ans["result"]["instrumento_venta"]["comision_bolsa_venta"];
+            this.fecha_siguiente_cupon_venta =
+              ans["result"]["instrumento_venta"]["fecha_siguiente_cupon_venta"];
+            this.dias_vencimiento_venta =
+              ans["result"]["instrumento_venta"]["dias_vencimiento_venta"];
+            this.dias_acumulados_venta =
+              ans["result"]["instrumento_venta"]["dias_acumulados_venta"];
+            this.ytm_vencimiento_comision_porcentaje_venta =
+              ans["result"]["instrumento_venta"][
+                "ytm_vencimiento_comision_porcentaje_venta"
+              ];
+            this.ytm_vencimiento_porcentaje_venta =
+              ans["result"]["instrumento_venta"][
+                "ytm_vencimiento_porcentaje_venta"
+              ];
+            this.interes_acumulado_venta =
+              ans["result"]["instrumento_venta"]["interes_acumulado_venta"];
+            this.interes_acumulado_porcentaje_venta =
+              ans["result"]["instrumento_venta"][
+                "interes_acumulado_porcentaje_venta"
+              ];
+            this.precio_sucio_porcentaje_venta =
+              ans["result"]["instrumento_venta"][
+                "precio_sucio_porcentaje_venta"
+              ];
+            this.valor_transado_venta =
+              ans["result"]["instrumento_venta"]["valor_transado_venta"];
+            this.monto_recibir =
+              ans["result"]["instrumento_venta"]["monto_recibir"];
+
+            this.operation_results_work = ans["result"]["resultado_operacion"];
+            this.operation_result = true;
+          }
 
           // Proyecciones
           this.proyecciones = ans["result"]["proyecciones"];
@@ -561,13 +557,14 @@ export class BONO implements InstrumentComponent {
             this.proyecciones = ans["result"]["proyecciones"];
           }
 
-          this.operation_result = true;
           this.dataSource.data = this.proyecciones.slice(0, -1);
           this.dataSource2.data = this.proyecciones.slice(0, -1);
           this.dataSource.paginator = this.paginator;
           this.dataSource.sort = this.sort;
 
           this.bonosObject = {
+            completo: this.tipoEjecucion,
+            cancelado: this.tipoEjecucion,
             renta_porcentaje: this.investmentProposalForm.value
               .renta_porcentaje,
             costo_cedeval: this.investmentProposalForm.value.costo_cedeval,
@@ -585,18 +582,6 @@ export class BONO implements InstrumentComponent {
             comision_bolsa_porcentaje_compra: this.investmentProposalForm.value
               .comision_bolsa_porcentaje_compra,
 
-            valor_nominal_venta: this.investmentProposalForm.value
-              .valor_nominal_venta,
-            precio_venta: this.investmentProposalForm.value.precio_venta,
-            precio_vencimiento_venta: this.investmentProposalForm.value
-              .precio_vencimiento_venta,
-            cupon_porcentaje_venta: this.investmentProposalForm.value
-              .cupon_porcentaje_venta,
-            comision_casa_porcentaje_venta: this.investmentProposalForm.value
-              .comision_casa_porcentaje_venta,
-            comision_bolsa_porcentaje_venta: this.investmentProposalForm.value
-              .comision_bolsa_porcentaje_venta,
-
             fecha_vencimiento_compra: this.f.fecha_vencimiento_compra.value
               .singleDate.formatted,
             fecha_ultima_cupon_compra: this.f.fecha_ultima_cupon_compra.value
@@ -604,13 +589,6 @@ export class BONO implements InstrumentComponent {
             fecha_liquidacion_compra: this.f.fecha_liquidacion_compra.value
               .singleDate.formatted,
 
-            fecha_vencimiento_venta: this.f.fecha_vencimiento_venta.value
-              .singleDate.formatted,
-            fecha_ultima_cupon_venta: this.f.fecha_ultima_cupon_venta.value
-              .singleDate.formatted,
-            fecha_liquidacion_venta: this.f.fecha_liquidacion_venta.value
-              .singleDate.formatted,
-
             // Instrumento de compra
 
             comision_casa_compra: this.comision_casa_compra,
@@ -629,24 +607,7 @@ export class BONO implements InstrumentComponent {
             valor_transado_compra: this.valor_transado_compra,
             monto_pagar: this.monto_pagar,
             fecha_inicio_vigencia: this.fecha_inicio_vigencia,
-            // Instrumento de venta
-
-            comision_casa_venta: this.comision_casa_venta,
-            comision_bolsa_venta: this.comision_bolsa_venta,
-
-            fecha_siguiente_cupon_venta: this.fecha_siguiente_cupon_venta,
-            dias_vencimiento_venta: this.dias_vencimiento_venta,
-            dias_acumulados_venta: this.dias_acumulados_venta,
-            ytm_vencimiento_porcentaje_venta: this
-              .ytm_vencimiento_porcentaje_venta,
-            ytm_vencimiento_comision_porcentaje_venta: this
-              .ytm_vencimiento_comision_porcentaje_venta,
-
-            interes_acumulado_venta: this.interes_acumulado_venta,
-            interes_acumulado_porcentaje_venta: this
-              .interes_acumulado_porcentaje_venta,
-            precio_sucio_porcentaje_venta: this.precio_sucio_porcentaje_venta,
-            valor_transado_venta: this.valor_transado_venta,
+
             // Resultado de la operacion
             /*
             monto_recibir: this.monto_recibir,
@@ -664,8 +625,66 @@ export class BONO implements InstrumentComponent {
             total_ingresos_recibidos: this.total_ingresos_recibidos,
             */
             // Proyecciones
+
             proyecciones: this.proyecciones
           };
+          if (this.tipoEjecucion == 1) {
+            this.bonosObject[
+              "valor_nominal_venta"
+            ] = this.investmentProposalForm.value.valor_nominal_venta;
+            this.bonosObject[
+              "precio_venta"
+            ] = this.investmentProposalForm.value.precio_venta;
+            this.bonosObject[
+              "precio_vencimiento_venta"
+            ] = this.investmentProposalForm.value.precio_vencimiento_venta;
+            this.bonosObject[
+              "comision_casa_porcentaje_venta"
+            ] = this.investmentProposalForm.value.comision_casa_porcentaje_venta;
+            this.bonosObject[
+              "comision_bolsa_porcentaje_venta"
+            ] = this.investmentProposalForm.value.comision_bolsa_porcentaje_venta;
+            this.bonosObject[
+              "fecha_vencimiento_venta"
+            ] = this.f.fecha_vencimiento_venta.value.singleDate.formatted;
+            this.bonosObject[
+              "fecha_ultima_cupon_venta"
+            ] = this.f.fecha_ultima_cupon_venta.value.singleDate.formatted;
+            this.bonosObject[
+              "fecha_liquidacion_venta"
+            ] = this.f.fecha_liquidacion_venta.value.singleDate.formatted;
+            this.bonosObject["comision_casa_venta"] = this.comision_casa_venta;
+            this.bonosObject[
+              "comision_bolsa_venta"
+            ] = this.comision_bolsa_venta;
+            this.bonosObject[
+              "fecha_siguiente_cupon_venta"
+            ] = this.fecha_siguiente_cupon_venta;
+            this.bonosObject[
+              "dias_vencimiento_venta"
+            ] = this.dias_vencimiento_venta;
+            this.bonosObject[
+              "dias_acumulados_venta"
+            ] = this.dias_acumulados_venta;
+            this.bonosObject[
+              "ytm_vencimiento_porcentaje_venta"
+            ] = this.ytm_vencimiento_porcentaje_venta;
+            this.bonosObject[
+              "ytm_vencimiento_comision_porcentaje_venta"
+            ] = this.ytm_vencimiento_comision_porcentaje_venta;
+            this.bonosObject[
+              "interes_acumulado_venta"
+            ] = this.interes_acumulado_venta;
+            this.bonosObject[
+              "interes_acumulado_porcentaje_venta"
+            ] = this.interes_acumulado_porcentaje_venta;
+            this.bonosObject[
+              "precio_sucio_porcentaje_venta"
+            ] = this.precio_sucio_porcentaje_venta;
+            this.bonosObject[
+              "valor_transado_venta"
+            ] = this.valor_transado_venta;
+          }
 
           this.formDataService.setWork(this.bonosObject);
           Swal.close();

+ 122 - 26
src/app/components/instruments/certificados/certificados.component.html

@@ -7,7 +7,29 @@
     [formGroup]="investmentProposalForm"
   >
     <div class="row">
-      <div class=" col-md-6 col-sm-12 border border-light">
+      <div class="col-6">
+        <div class="form-group">
+          <label>Tipo de ejecución: </label>
+        </div>
+        <select
+          class="custom-select"
+          formControlName="ejecucion"
+          (change)="toggle_ejecucion($event.target.value)"
+        >
+          <option
+            *ngFor="let item of ejecuciones"
+            [value]="item.codigo"
+            [selected]="item.codigo == tipoEjecucion"
+          >
+            {{ item.nombre }}</option
+          >
+        </select>
+      </div>
+      <br />
+    </div>
+    <br />
+    <div class="row">
+      <div class=" col-md-12 col-sm-12 border border-light">
         <div class="row no-gutters">
           <!-- Valor nominal compra -->
 
@@ -424,8 +446,13 @@
           </div>
         </div>
       </div>
-
-      <div class=" col-md-6 col-sm-12 border border-light">
+    </div>
+    <br />
+    <div class="row">
+      <div
+        class=" col-md-12 col-sm-12 border border-light"
+        *ngIf="tipoEjecucion == 1"
+      >
         <div class="row no-gutters">
           <div class="col-12">
             <h5>Venta</h5>
@@ -853,7 +880,9 @@
             {{ fecha_inicio_vigencia }}
           </div>
         </div>
+      </div>
 
+      <div class="row" *ngIf="tipoEjecucion == 1">
         <div class="col-12">
           <h3>
             Instrumento de venta
@@ -929,71 +958,113 @@
             $USD {{ valor_transado_venta | number: "1.2-4" }}
           </div>
         </div>
-
+      </div>
+      <div class="row">
         <div class="row align-container" *ngIf="operation_result">
           <div class="col-12">
             <h3>
               Resultado de la operación
             </h3>
           </div>
+
           <div class="col-sm-4">
-            <h4>Monto a recibir:</h4>
-            <div class="field">$USD {{ monto_recibir | number: "1.2-4" }}</div>
+            <h4>Valor nominal compra:</h4>
+            <div class="field">
+              $USD{{ operation_results_work.valor_transado_compra }}
+            </div>
           </div>
+
           <div class="col-sm-4">
             <h4>Días tenencia total:</h4>
             <div class="field">
-              {{ dias_tenencia_total }}
+              {{ operation_results_work.dias_tenencia_total }}
             </div>
           </div>
+
+          <div class="col-sm-4">
+            <h4>Precio compra:</h4>
+            <div class="field">
+              {{ operation_results_work.precio_compra }}
+            </div>
+          </div>
+
+          <div class="col-sm-4">
+            <h4>Precio venta:</h4>
+            <div class="field">
+              {{ operation_results_work.precio_venta }}
+            </div>
+          </div>
+
           <div class="col-sm-4">
             <h4>Ingresos intereses:</h4>
             <div class="field">
-              $USD {{ ingresos_intereses | number: "1.2-4" }}
+              $USD
+              {{ operation_results_work.ingresos_intereses | number: "1.2-4" }}
             </div>
           </div>
           <div class="col-sm-4">
             <h4>Costos totales:</h4>
-            <div class="field">$USD {{ costos_totales | number: "1.2-4" }}</div>
+            <div class="field">
+              $USD {{ operation_results_work.costos_totales | number: "1.2-4" }}
+            </div>
           </div>
           <div class="col-sm-4">
-            <h4>Ganancia / Pérdida total:</h4>
+            <h4>Ganancia o pérdida total:</h4>
             <div class="field">
-              $USD {{ ganancia_perdida_total | number: "1.2-4" }}
+              $USD
+              {{
+                operation_results_work.ganancia_perdida_total_neto
+                  | number: "1.2-4"
+              }}
             </div>
           </div>
           <div class="col-sm-4">
-            <h4>Ganancia / Pérdida de capital:</h4>
+            <h4>Ganancia o pérdida de capital:</h4>
             <div class="field">
-              {{ ganancia_perdida_capital_porcentaje | number: "1.2-4" }}%
+              {{
+                operation_results_work.ganancia_perdida_capital_porcentaje
+                  | number: "1.2-4"
+              }}%
             </div>
           </div>
 
           <div class="col-sm-4">
             <h4>Interés (%):</h4>
             <div class="field">
-              {{ intereses_porcentaje | number: "1.2-4" }} %
+              {{
+                operation_results_work.intereses_porcentaje | number: "1.2-4"
+              }}
+              %
             </div>
           </div>
           <div class="col-sm-4">
             <h4>Interés neto antes de impuesto (%):</h4>
             <div class="field">
-              {{ neto_antes_impuesto_porcentaje | number: "1.2-4" }}
+              {{
+                operation_results_work.neto_antes_renta_porcentaje
+                  | number: "1.2-4"
+              }}
               %
             </div>
           </div>
           <div class="col-sm-4">
             <h4>Interés neto después de impuesto (%):</h4>
             <div class="field">
-              {{ neto_despues_impuesto_porcentaje | number: "1.2-4" }}
+              {{
+                operation_results_work.neto_despues_renta_porcentaje
+                  | number: "1.2-4"
+              }}
               %
             </div>
           </div>
           <div class="col-sm-4">
-            <h4>Total de ingresos recibidos:</h4>
+            <h4>Total Ingresos Recibidos:</h4>
             <div class="field">
               $USD
-              {{ total_ingresos_recibidos | number: "1.2-4" }}
+              {{
+                operation_results_work.total_ingresos_recibidos
+                  | number: "1.2-4"
+              }}
             </div>
           </div>
         </div>
@@ -1309,8 +1380,8 @@
         </div>
       </div>
     </div>
-    <!--
-    <div class="row">
+
+    <div class="row" *ngIf="tipoEjecucion == 1">
       <div class="col-12">
         <h3>
           Instrumento de venta
@@ -1489,7 +1560,7 @@
       <div class="col-lg-3 col-md-4 col-sm-6">
         <h4>Valor nominal compra:</h4>
         <div class="field">
-          $USD{{ operation_results_work.valor_nominal_compra }}
+          $USD{{ operation_results_work.valor_transado_compra }}
         </div>
       </div>
       <div class="col-lg-3 col-md-4 col-sm-6">
@@ -1498,6 +1569,21 @@
           {{ operation_results_work.dias_tenencia_total }}
         </div>
       </div>
+
+      <div class="col-lg-3 col-md-4 col-sm-6">
+        <h4>Precio compra:</h4>
+        <div class="field">
+          {{ operation_results_work.precio_compra }}
+        </div>
+      </div>
+
+      <div class="col-lg-3 col-md-4 col-sm-6">
+        <h4>Precio venta:</h4>
+        <div class="field">
+          {{ operation_results_work.precio_venta }}
+        </div>
+      </div>
+
       <div class="col-lg-3 col-md-4 col-sm-6">
         <h4>Ingresos intereses:</h4>
         <div class="field">
@@ -1514,7 +1600,9 @@
         <h4>Ganancia o pérdida total:</h4>
         <div class="field">
           $USD
-          {{ operation_results_work.ganancia_perdida_total | number: "1.2-4" }}
+          {{
+            operation_results_work.ganancia_perdida_total_neto | number: "1.2-4"
+          }}
         </div>
       </div>
       <div class="col-lg-3 col-md-4 col-sm-6">
@@ -1537,8 +1625,7 @@
         <h4>Interés neto antes de impuesto (%):</h4>
         <div class="field">
           {{
-            operation_results_work.neto_antes_impuesto_porcentaje
-              | number: "1.2-4"
+            operation_results_work.neto_antes_renta_porcentaje | number: "1.2-4"
           }}
           %
         </div>
@@ -1547,14 +1634,23 @@
         <h4>Interés neto después de impuesto (%):</h4>
         <div class="field">
           {{
-            operation_results_work.neto_despues_impuesto_porcentaje
+            operation_results_work.neto_despues_renta_porcentaje
               | number: "1.2-4"
           }}
           %
         </div>
       </div>
+      <div class="col-lg-3 col-md-4 col-sm-6">
+        <h4>Total Ingresos Recibidos:</h4>
+        <div class="field">
+          $USD
+          {{
+            operation_results_work.total_ingresos_recibidos | number: "1.2-4"
+          }}
+        </div>
+      </div>
     </div>
-  -->
+
     <br />
     <div *ngIf="hasProjections" class="instrument-calcs-summary">
       <div class="row">

+ 143 - 115
src/app/components/instruments/certificados/certificados.component.ts

@@ -128,6 +128,11 @@ export class CINV implements InstrumentComponent {
   ytm_vencimiento_porcentaje_venta: any;
   comision_bolsa_venta: any;
   consolidado_proyeccion: any;
+  ejecuciones = [
+    { codigo: 1, nombre: "Completa" },
+    { codigo: 0, nombre: "Parcial" }
+  ];
+  tipoEjecucion: number = 0;
 
   constructor(
     private formBuilder: FormBuilder,
@@ -138,7 +143,6 @@ export class CINV implements InstrumentComponent {
     public datepipe: DatePipe
   ) {
     this.instrument_work = this.formDataService.getWork();
-
     this.instrument_exists = this.instrument_work == undefined;
     this.general = this.formDataService.getGeneralInfo();
 
@@ -171,7 +175,15 @@ export class CINV implements InstrumentComponent {
       this.operation_result = true;
     }
 
+    if (+this.instrument_work["valor_nominal_venta"] > 0) {
+      this.tipoEjecucion = 1;
+    }
+    console.log("EJECUCION");
+    console.log(this.tipoEjecucion);
+
     this.investmentProposalForm = this.formBuilder.group({
+      ejecucion: [this.instrument_exists ? "" : this.tipoEjecucion],
+
       renta_porcentaje: [
         this.instrument_exists ? "" : this.instrument_work.renta_porcentaje,
         [
@@ -410,6 +422,7 @@ export class CINV implements InstrumentComponent {
           id_periodicidad: +this.general.periodicidad
         },
         {
+          completo: this.tipoEjecucion,
           renta_porcentaje: +this.f.renta_porcentaje.value,
           costo_cedeval: +this.f.costo_cedeval.value,
           costo_transferencia: +this.f.costo_transferencia.value,
@@ -431,19 +444,31 @@ export class CINV implements InstrumentComponent {
           comision_bolsa_porcentaje_venta: this.f
             .comision_bolsa_porcentaje_venta.value,
 
-          fecha_vencimiento_compra: this.f.fecha_vencimiento_compra.value
-            .singleDate.formatted,
-          fecha_ultima_cupon_compra: this.f.fecha_ultima_cupon_compra.value
-            .singleDate.formatted,
-          fecha_liquidacion_compra: this.f.fecha_liquidacion_compra.value
-            .singleDate.formatted,
-
-          fecha_vencimiento_venta: this.f.fecha_vencimiento_venta.value
-            .singleDate.formatted,
-          fecha_ultima_cupon_venta: this.f.fecha_ultima_cupon_venta.value
-            .singleDate.formatted,
-          fecha_liquidacion_venta: this.f.fecha_liquidacion_venta.value
-            .singleDate.formatted
+          fecha_vencimiento_compra:
+            this.f.fecha_vencimiento_compra.value == ""
+              ? ""
+              : this.f.fecha_vencimiento_compra.value.singleDate.formatted,
+          fecha_ultima_cupon_compra:
+            this.f.fecha_ultima_cupon_compra.value == ""
+              ? ""
+              : this.f.fecha_ultima_cupon_compra.value.singleDate.formatted,
+          fecha_liquidacion_compra:
+            this.f.fecha_liquidacion_compra.value == ""
+              ? ""
+              : this.f.fecha_liquidacion_compra.value.singleDate.formatted,
+
+          fecha_vencimiento_venta:
+            this.f.fecha_vencimiento_venta.value == ""
+              ? ""
+              : this.f.fecha_vencimiento_venta.value.singleDate.formatted,
+          fecha_ultima_cupon_venta:
+            this.f.fecha_ultima_cupon_venta.value == ""
+              ? ""
+              : this.f.fecha_ultima_cupon_venta.value.singleDate.formatted,
+          fecha_liquidacion_venta:
+            this.f.fecha_liquidacion_venta.value == ""
+              ? ""
+              : this.f.fecha_liquidacion_venta.value.singleDate.formatted
         }
       )
       .subscribe(
@@ -484,66 +509,43 @@ export class CINV implements InstrumentComponent {
             ans["result"]["instrumento_compra"]["fecha_inicio_vigencia"];
 
           // Instrumento de venta
-          this.comision_casa_venta =
-            ans["result"]["instrumento_venta"]["comision_casa_venta"];
-
-          this.comision_bolsa_venta =
-            ans["result"]["instrumento_venta"]["comision_bolsa_venta"];
-
-          this.fecha_siguiente_cupon_venta =
-            ans["result"]["instrumento_venta"]["fecha_siguiente_cupon_venta"];
-          this.dias_vencimiento_venta =
-            ans["result"]["instrumento_venta"]["dias_vencimiento_venta"];
-          this.dias_acumulados_venta =
-            ans["result"]["instrumento_venta"]["dias_acumulados_venta"];
-          this.ytm_vencimiento_comision_porcentaje_venta =
-            ans["result"]["instrumento_venta"][
-              "ytm_vencimiento_comision_porcentaje_venta"
-            ];
-          this.ytm_vencimiento_porcentaje_venta =
-            ans["result"]["instrumento_venta"][
-              "ytm_vencimiento_porcentaje_venta"
-            ];
-          this.interes_acumulado_venta =
-            ans["result"]["instrumento_venta"]["interes_acumulado_venta"];
-          this.interes_acumulado_porcentaje_venta =
-            ans["result"]["instrumento_venta"][
-              "interes_acumulado_porcentaje_venta"
-            ];
-          this.precio_sucio_porcentaje_venta =
-            ans["result"]["instrumento_venta"]["precio_sucio_porcentaje_venta"];
-          this.valor_transado_venta =
-            ans["result"]["instrumento_venta"]["valor_transado_venta"];
-          this.monto_recibir =
-            ans["result"]["instrumento_venta"]["monto_recibir"];
-
-          // Resultado de la operacion
-          this.dias_tenencia_total =
-            ans["result"]["resultado_operacion"]["dias_tenencia_total"];
-          this.ganancia_perdida_capital =
-            ans["result"]["resultado_operacion"]["ganancia_perdida_capital"];
-          this.ingresos_intereses =
-            ans["result"]["resultado_operacion"]["ingresos_intereses"];
-          this.costos_totales =
-            ans["result"]["resultado_operacion"]["costos_totales"];
-          this.ganancia_perdida_total =
-            ans["result"]["resultado_operacion"]["ganancia_perdida_total"];
-          this.ganancia_perdida_capital_porcentaje =
-            ans["result"]["resultado_operacion"][
-              "ganancia_perdida_capital_porcentaje"
-            ];
-          this.intereses_porcentaje =
-            ans["result"]["resultado_operacion"]["intereses_porcentaje"];
-          this.neto_antes_impuesto_porcentaje =
-            ans["result"]["resultado_operacion"][
-              "neto_antes_impuesto_porcentaje"
-            ];
-          this.neto_despues_impuesto_porcentaje =
-            ans["result"]["resultado_operacion"][
-              "neto_despues_impuesto_porcentaje"
-            ];
-          this.total_ingresos_recibidos =
-            ans["result"]["resultado_operacion"]["total_ingresos_recibidos"];
+          if (this.tipoEjecucion == 1) {
+            this.comision_casa_venta =
+              ans["result"]["instrumento_venta"]["comision_casa_venta"];
+            this.comision_bolsa_venta =
+              ans["result"]["instrumento_venta"]["comision_bolsa_venta"];
+            this.fecha_siguiente_cupon_venta =
+              ans["result"]["instrumento_venta"]["fecha_siguiente_cupon_venta"];
+            this.dias_vencimiento_venta =
+              ans["result"]["instrumento_venta"]["dias_vencimiento_venta"];
+            this.dias_acumulados_venta =
+              ans["result"]["instrumento_venta"]["dias_acumulados_venta"];
+            this.ytm_vencimiento_comision_porcentaje_venta =
+              ans["result"]["instrumento_venta"][
+                "ytm_vencimiento_comision_porcentaje_venta"
+              ];
+            this.ytm_vencimiento_porcentaje_venta =
+              ans["result"]["instrumento_venta"][
+                "ytm_vencimiento_porcentaje_venta"
+              ];
+            this.interes_acumulado_venta =
+              ans["result"]["instrumento_venta"]["interes_acumulado_venta"];
+            this.interes_acumulado_porcentaje_venta =
+              ans["result"]["instrumento_venta"][
+                "interes_acumulado_porcentaje_venta"
+              ];
+            this.precio_sucio_porcentaje_venta =
+              ans["result"]["instrumento_venta"][
+                "precio_sucio_porcentaje_venta"
+              ];
+            this.valor_transado_venta =
+              ans["result"]["instrumento_venta"]["valor_transado_venta"];
+            this.monto_recibir =
+              ans["result"]["instrumento_venta"]["monto_recibir"];
+
+            this.operation_results_work = ans["result"]["resultado_operacion"];
+            this.operation_result = true;
+          }
 
           // Proyecciones
           this.proyecciones = ans["result"]["proyecciones"];
@@ -555,14 +557,14 @@ export class CINV implements InstrumentComponent {
             this.proyecciones = ans["result"]["proyecciones"];
           }
 
-          this.operation_result = true;
           this.dataSource.data = this.proyecciones.slice(0, -1);
           this.dataSource2.data = this.proyecciones.slice(0, -1);
           this.dataSource.paginator = this.paginator;
           this.dataSource.sort = this.sort;
 
-          // Obj
           this.bonosObject = {
+            completo: this.tipoEjecucion,
+            cancelado: this.tipoEjecucion,
             renta_porcentaje: this.investmentProposalForm.value
               .renta_porcentaje,
             costo_cedeval: this.investmentProposalForm.value.costo_cedeval,
@@ -580,18 +582,6 @@ export class CINV implements InstrumentComponent {
             comision_bolsa_porcentaje_compra: this.investmentProposalForm.value
               .comision_bolsa_porcentaje_compra,
 
-            valor_nominal_venta: this.investmentProposalForm.value
-              .valor_nominal_venta,
-            precio_venta: this.investmentProposalForm.value.precio_venta,
-            precio_vencimiento_venta: this.investmentProposalForm.value
-              .precio_vencimiento_venta,
-            cupon_porcentaje_venta: this.investmentProposalForm.value
-              .cupon_porcentaje_venta,
-            comision_casa_porcentaje_venta: this.investmentProposalForm.value
-              .comision_casa_porcentaje_venta,
-            comision_bolsa_porcentaje_venta: this.investmentProposalForm.value
-              .comision_bolsa_porcentaje_venta,
-
             fecha_vencimiento_compra: this.f.fecha_vencimiento_compra.value
               .singleDate.formatted,
             fecha_ultima_cupon_compra: this.f.fecha_ultima_cupon_compra.value
@@ -599,13 +589,6 @@ export class CINV implements InstrumentComponent {
             fecha_liquidacion_compra: this.f.fecha_liquidacion_compra.value
               .singleDate.formatted,
 
-            fecha_vencimiento_venta: this.f.fecha_vencimiento_venta.value
-              .singleDate.formatted,
-            fecha_ultima_cupon_venta: this.f.fecha_ultima_cupon_venta.value
-              .singleDate.formatted,
-            fecha_liquidacion_venta: this.f.fecha_liquidacion_venta.value
-              .singleDate.formatted,
-
             // Instrumento de compra
 
             comision_casa_compra: this.comision_casa_compra,
@@ -624,26 +607,9 @@ export class CINV implements InstrumentComponent {
             valor_transado_compra: this.valor_transado_compra,
             monto_pagar: this.monto_pagar,
             fecha_inicio_vigencia: this.fecha_inicio_vigencia,
-            // Instrumento de venta
-
-            comision_casa_venta: this.comision_casa_venta,
-            comision_bolsa_venta: this.comision_bolsa_venta,
-
-            fecha_siguiente_cupon_venta: this.fecha_siguiente_cupon_venta,
-            dias_vencimiento_venta: this.dias_vencimiento_venta,
-            dias_acumulados_venta: this.dias_acumulados_venta,
-            ytm_vencimiento_porcentaje_venta: this
-              .ytm_vencimiento_porcentaje_venta,
-            ytm_vencimiento_comision_porcentaje_venta: this
-              .ytm_vencimiento_comision_porcentaje_venta,
-
-            interes_acumulado_venta: this.interes_acumulado_venta,
-            interes_acumulado_porcentaje_venta: this
-              .interes_acumulado_porcentaje_venta,
-            precio_sucio_porcentaje_venta: this.precio_sucio_porcentaje_venta,
-            valor_transado_venta: this.valor_transado_venta,
-            // Resultado de la operacion
 
+            // Resultado de la operacion
+            /*
             monto_recibir: this.monto_recibir,
             dias_tenencia_total: this.dias_tenencia_total,
             ganancia_perdida_capital: this.ganancia_perdida_capital,
@@ -657,10 +623,68 @@ export class CINV implements InstrumentComponent {
             neto_despues_impuesto_porcentaje: this
               .neto_despues_impuesto_porcentaje,
             total_ingresos_recibidos: this.total_ingresos_recibidos,
-
+            */
             // Proyecciones
+
             proyecciones: this.proyecciones
           };
+          if (this.tipoEjecucion == 1) {
+            this.bonosObject[
+              "valor_nominal_venta"
+            ] = this.investmentProposalForm.value.valor_nominal_venta;
+            this.bonosObject[
+              "precio_venta"
+            ] = this.investmentProposalForm.value.precio_venta;
+            this.bonosObject[
+              "precio_vencimiento_venta"
+            ] = this.investmentProposalForm.value.precio_vencimiento_venta;
+            this.bonosObject[
+              "comision_casa_porcentaje_venta"
+            ] = this.investmentProposalForm.value.comision_casa_porcentaje_venta;
+            this.bonosObject[
+              "comision_bolsa_porcentaje_venta"
+            ] = this.investmentProposalForm.value.comision_bolsa_porcentaje_venta;
+            this.bonosObject[
+              "fecha_vencimiento_venta"
+            ] = this.f.fecha_vencimiento_venta.value.singleDate.formatted;
+            this.bonosObject[
+              "fecha_ultima_cupon_venta"
+            ] = this.f.fecha_ultima_cupon_venta.value.singleDate.formatted;
+            this.bonosObject[
+              "fecha_liquidacion_venta"
+            ] = this.f.fecha_liquidacion_venta.value.singleDate.formatted;
+            this.bonosObject["comision_casa_venta"] = this.comision_casa_venta;
+            this.bonosObject[
+              "comision_bolsa_venta"
+            ] = this.comision_bolsa_venta;
+            this.bonosObject[
+              "fecha_siguiente_cupon_venta"
+            ] = this.fecha_siguiente_cupon_venta;
+            this.bonosObject[
+              "dias_vencimiento_venta"
+            ] = this.dias_vencimiento_venta;
+            this.bonosObject[
+              "dias_acumulados_venta"
+            ] = this.dias_acumulados_venta;
+            this.bonosObject[
+              "ytm_vencimiento_porcentaje_venta"
+            ] = this.ytm_vencimiento_porcentaje_venta;
+            this.bonosObject[
+              "ytm_vencimiento_comision_porcentaje_venta"
+            ] = this.ytm_vencimiento_comision_porcentaje_venta;
+            this.bonosObject[
+              "interes_acumulado_venta"
+            ] = this.interes_acumulado_venta;
+            this.bonosObject[
+              "interes_acumulado_porcentaje_venta"
+            ] = this.interes_acumulado_porcentaje_venta;
+            this.bonosObject[
+              "precio_sucio_porcentaje_venta"
+            ] = this.precio_sucio_porcentaje_venta;
+            this.bonosObject[
+              "valor_transado_venta"
+            ] = this.valor_transado_venta;
+          }
 
           this.formDataService.setWork(this.bonosObject);
           Swal.close();
@@ -699,4 +723,8 @@ export class CINV implements InstrumentComponent {
   goToNext(form: any) {
     this.getCalculations(form, true);
   }
+
+  toggle_ejecucion(input: any) {
+    this.tipoEjecucion = +input;
+  }
 }

+ 124 - 28
src/app/components/instruments/eurobonos/eurobonos.component.html

@@ -1,13 +1,35 @@
 <div *ngIf="!summary">
   <h4 class="card-title">
-    Eurobonos
+    EuroBonos
   </h4>
   <form
     class="form-auth-small ng-untouched ng-pristine ng-valid"
     [formGroup]="investmentProposalForm"
   >
     <div class="row">
-      <div class=" col-md-6 col-sm-12 border border-light">
+      <div class="col-6">
+        <div class="form-group">
+          <label>Tipo de ejecución: </label>
+        </div>
+        <select
+          class="custom-select"
+          formControlName="ejecucion"
+          (change)="toggle_ejecucion($event.target.value)"
+        >
+          <option
+            *ngFor="let item of ejecuciones"
+            [value]="item.codigo"
+            [selected]="item.codigo == tipoEjecucion"
+          >
+            {{ item.nombre }}</option
+          >
+        </select>
+      </div>
+      <br />
+    </div>
+    <br />
+    <div class="row">
+      <div class=" col-md-12 col-sm-12 border border-light">
         <div class="row no-gutters">
           <!-- Valor nominal compra -->
 
@@ -38,7 +60,7 @@
                     Campo requerido
                   </div>
                   <div *ngIf="f.renta_porcentaje.errors.pattern">
-                    Debe ingresar una cifra válida
+                    Debe ingresar una cifra válida
                   </div>
                 </div>
               </div>
@@ -424,8 +446,13 @@
           </div>
         </div>
       </div>
-
-      <div class=" col-md-6 col-sm-12 border border-light">
+    </div>
+    <br />
+    <div class="row">
+      <div
+        class=" col-md-12 col-sm-12 border border-light"
+        *ngIf="tipoEjecucion == 1"
+      >
         <div class="row no-gutters">
           <div class="col-12">
             <h5>Venta</h5>
@@ -853,7 +880,9 @@
             {{ fecha_inicio_vigencia }}
           </div>
         </div>
+      </div>
 
+      <div class="row" *ngIf="tipoEjecucion == 1">
         <div class="col-12">
           <h3>
             Instrumento de venta
@@ -929,71 +958,113 @@
             $USD {{ valor_transado_venta | number: "1.2-4" }}
           </div>
         </div>
-
+      </div>
+      <div class="row">
         <div class="row align-container" *ngIf="operation_result">
           <div class="col-12">
             <h3>
               Resultado de la operación
             </h3>
           </div>
+
           <div class="col-sm-4">
-            <h4>Monto a recibir:</h4>
-            <div class="field">$USD {{ monto_recibir | number: "1.2-4" }}</div>
+            <h4>Valor nominal compra:</h4>
+            <div class="field">
+              $USD{{ operation_results_work.valor_transado_compra }}
+            </div>
           </div>
+
           <div class="col-sm-4">
             <h4>Días tenencia total:</h4>
             <div class="field">
-              {{ dias_tenencia_total }}
+              {{ operation_results_work.dias_tenencia_total }}
             </div>
           </div>
+
+          <div class="col-sm-4">
+            <h4>Precio compra:</h4>
+            <div class="field">
+              {{ operation_results_work.precio_compra }}
+            </div>
+          </div>
+
+          <div class="col-sm-4">
+            <h4>Precio venta:</h4>
+            <div class="field">
+              {{ operation_results_work.precio_venta }}
+            </div>
+          </div>
+
           <div class="col-sm-4">
             <h4>Ingresos intereses:</h4>
             <div class="field">
-              $USD {{ ingresos_intereses | number: "1.2-4" }}
+              $USD
+              {{ operation_results_work.ingresos_intereses | number: "1.2-4" }}
             </div>
           </div>
           <div class="col-sm-4">
             <h4>Costos totales:</h4>
-            <div class="field">$USD {{ costos_totales | number: "1.2-4" }}</div>
+            <div class="field">
+              $USD {{ operation_results_work.costos_totales | number: "1.2-4" }}
+            </div>
           </div>
           <div class="col-sm-4">
-            <h4>Ganancia / Pérdida total:</h4>
+            <h4>Ganancia o pérdida total:</h4>
             <div class="field">
-              $USD {{ ganancia_perdida_total | number: "1.2-4" }}
+              $USD
+              {{
+                operation_results_work.ganancia_perdida_total_neto
+                  | number: "1.2-4"
+              }}
             </div>
           </div>
           <div class="col-sm-4">
-            <h4>Ganancia / Pérdida de capital:</h4>
+            <h4>Ganancia o pérdida de capital:</h4>
             <div class="field">
-              {{ ganancia_perdida_capital_porcentaje | number: "1.2-4" }}%
+              {{
+                operation_results_work.ganancia_perdida_capital_porcentaje
+                  | number: "1.2-4"
+              }}%
             </div>
           </div>
 
           <div class="col-sm-4">
             <h4>Interés (%):</h4>
             <div class="field">
-              {{ intereses_porcentaje | number: "1.2-4" }} %
+              {{
+                operation_results_work.intereses_porcentaje | number: "1.2-4"
+              }}
+              %
             </div>
           </div>
           <div class="col-sm-4">
             <h4>Interés neto antes de impuesto (%):</h4>
             <div class="field">
-              {{ neto_antes_impuesto_porcentaje | number: "1.2-4" }}
+              {{
+                operation_results_work.neto_antes_renta_porcentaje
+                  | number: "1.2-4"
+              }}
               %
             </div>
           </div>
           <div class="col-sm-4">
             <h4>Interés neto después de impuesto (%):</h4>
             <div class="field">
-              {{ neto_despues_impuesto_porcentaje | number: "1.2-4" }}
+              {{
+                operation_results_work.neto_despues_renta_porcentaje
+                  | number: "1.2-4"
+              }}
               %
             </div>
           </div>
           <div class="col-sm-4">
-            <h4>Total de ingresos recibidos:</h4>
+            <h4>Total Ingresos Recibidos:</h4>
             <div class="field">
               $USD
-              {{ total_ingresos_recibidos | number: "1.2-4" }}
+              {{
+                operation_results_work.total_ingresos_recibidos
+                  | number: "1.2-4"
+              }}
             </div>
           </div>
         </div>
@@ -1309,8 +1380,8 @@
         </div>
       </div>
     </div>
-    <!--
-    <div class="row">
+
+    <div class="row" *ngIf="tipoEjecucion == 1">
       <div class="col-12">
         <h3>
           Instrumento de venta
@@ -1489,7 +1560,7 @@
       <div class="col-lg-3 col-md-4 col-sm-6">
         <h4>Valor nominal compra:</h4>
         <div class="field">
-          $USD{{ operation_results_work.valor_nominal_compra }}
+          $USD{{ operation_results_work.valor_transado_compra }}
         </div>
       </div>
       <div class="col-lg-3 col-md-4 col-sm-6">
@@ -1498,6 +1569,21 @@
           {{ operation_results_work.dias_tenencia_total }}
         </div>
       </div>
+
+      <div class="col-lg-3 col-md-4 col-sm-6">
+        <h4>Precio compra:</h4>
+        <div class="field">
+          {{ operation_results_work.precio_compra }}
+        </div>
+      </div>
+
+      <div class="col-lg-3 col-md-4 col-sm-6">
+        <h4>Precio venta:</h4>
+        <div class="field">
+          {{ operation_results_work.precio_venta }}
+        </div>
+      </div>
+
       <div class="col-lg-3 col-md-4 col-sm-6">
         <h4>Ingresos intereses:</h4>
         <div class="field">
@@ -1514,7 +1600,9 @@
         <h4>Ganancia o pérdida total:</h4>
         <div class="field">
           $USD
-          {{ operation_results_work.ganancia_perdida_total | number: "1.2-4" }}
+          {{
+            operation_results_work.ganancia_perdida_total_neto | number: "1.2-4"
+          }}
         </div>
       </div>
       <div class="col-lg-3 col-md-4 col-sm-6">
@@ -1537,8 +1625,7 @@
         <h4>Interés neto antes de impuesto (%):</h4>
         <div class="field">
           {{
-            operation_results_work.neto_antes_impuesto_porcentaje
-              | number: "1.2-4"
+            operation_results_work.neto_antes_renta_porcentaje | number: "1.2-4"
           }}
           %
         </div>
@@ -1547,14 +1634,23 @@
         <h4>Interés neto después de impuesto (%):</h4>
         <div class="field">
           {{
-            operation_results_work.neto_despues_impuesto_porcentaje
+            operation_results_work.neto_despues_renta_porcentaje
               | number: "1.2-4"
           }}
           %
         </div>
       </div>
+      <div class="col-lg-3 col-md-4 col-sm-6">
+        <h4>Total Ingresos Recibidos:</h4>
+        <div class="field">
+          $USD
+          {{
+            operation_results_work.total_ingresos_recibidos | number: "1.2-4"
+          }}
+        </div>
+      </div>
     </div>
-  -->
+
     <br />
     <div *ngIf="hasProjections" class="instrument-calcs-summary">
       <div class="row">

+ 143 - 114
src/app/components/instruments/eurobonos/eurobonos.component.ts

@@ -128,6 +128,11 @@ export class EURB implements InstrumentComponent {
   ytm_vencimiento_porcentaje_venta: any;
   comision_bolsa_venta: any;
   consolidado_proyeccion: any;
+  ejecuciones = [
+    { codigo: 1, nombre: "Completa" },
+    { codigo: 0, nombre: "Parcial" }
+  ];
+  tipoEjecucion: number = 0;
 
   constructor(
     private formBuilder: FormBuilder,
@@ -138,7 +143,6 @@ export class EURB implements InstrumentComponent {
     public datepipe: DatePipe
   ) {
     this.instrument_work = this.formDataService.getWork();
-
     this.instrument_exists = this.instrument_work == undefined;
     this.general = this.formDataService.getGeneralInfo();
 
@@ -171,7 +175,15 @@ export class EURB implements InstrumentComponent {
       this.operation_result = true;
     }
 
+    if (+this.instrument_work["valor_nominal_venta"] > 0) {
+      this.tipoEjecucion = 1;
+    }
+    console.log("EJECUCION");
+    console.log(this.tipoEjecucion);
+
     this.investmentProposalForm = this.formBuilder.group({
+      ejecucion: [this.instrument_exists ? "" : this.tipoEjecucion],
+
       renta_porcentaje: [
         this.instrument_exists ? "" : this.instrument_work.renta_porcentaje,
         [
@@ -410,6 +422,7 @@ export class EURB implements InstrumentComponent {
           id_periodicidad: +this.general.periodicidad
         },
         {
+          completo: this.tipoEjecucion,
           renta_porcentaje: +this.f.renta_porcentaje.value,
           costo_cedeval: +this.f.costo_cedeval.value,
           costo_transferencia: +this.f.costo_transferencia.value,
@@ -431,19 +444,31 @@ export class EURB implements InstrumentComponent {
           comision_bolsa_porcentaje_venta: this.f
             .comision_bolsa_porcentaje_venta.value,
 
-          fecha_vencimiento_compra: this.f.fecha_vencimiento_compra.value
-            .singleDate.formatted,
-          fecha_ultima_cupon_compra: this.f.fecha_ultima_cupon_compra.value
-            .singleDate.formatted,
-          fecha_liquidacion_compra: this.f.fecha_liquidacion_compra.value
-            .singleDate.formatted,
-
-          fecha_vencimiento_venta: this.f.fecha_vencimiento_venta.value
-            .singleDate.formatted,
-          fecha_ultima_cupon_venta: this.f.fecha_ultima_cupon_venta.value
-            .singleDate.formatted,
-          fecha_liquidacion_venta: this.f.fecha_liquidacion_venta.value
-            .singleDate.formatted
+          fecha_vencimiento_compra:
+            this.f.fecha_vencimiento_compra.value == ""
+              ? ""
+              : this.f.fecha_vencimiento_compra.value.singleDate.formatted,
+          fecha_ultima_cupon_compra:
+            this.f.fecha_ultima_cupon_compra.value == ""
+              ? ""
+              : this.f.fecha_ultima_cupon_compra.value.singleDate.formatted,
+          fecha_liquidacion_compra:
+            this.f.fecha_liquidacion_compra.value == ""
+              ? ""
+              : this.f.fecha_liquidacion_compra.value.singleDate.formatted,
+
+          fecha_vencimiento_venta:
+            this.f.fecha_vencimiento_venta.value == ""
+              ? ""
+              : this.f.fecha_vencimiento_venta.value.singleDate.formatted,
+          fecha_ultima_cupon_venta:
+            this.f.fecha_ultima_cupon_venta.value == ""
+              ? ""
+              : this.f.fecha_ultima_cupon_venta.value.singleDate.formatted,
+          fecha_liquidacion_venta:
+            this.f.fecha_liquidacion_venta.value == ""
+              ? ""
+              : this.f.fecha_liquidacion_venta.value.singleDate.formatted
         }
       )
       .subscribe(
@@ -484,65 +509,43 @@ export class EURB implements InstrumentComponent {
             ans["result"]["instrumento_compra"]["fecha_inicio_vigencia"];
 
           // Instrumento de venta
-          this.comision_casa_venta =
-            ans["result"]["instrumento_venta"]["comision_casa_venta"];
-
-          this.comision_bolsa_venta =
-            ans["result"]["instrumento_venta"]["comision_bolsa_venta"];
-          this.fecha_siguiente_cupon_venta =
-            ans["result"]["instrumento_venta"]["fecha_siguiente_cupon_venta"];
-          this.dias_vencimiento_venta =
-            ans["result"]["instrumento_venta"]["dias_vencimiento_venta"];
-          this.dias_acumulados_venta =
-            ans["result"]["instrumento_venta"]["dias_acumulados_venta"];
-          this.ytm_vencimiento_comision_porcentaje_venta =
-            ans["result"]["instrumento_venta"][
-              "ytm_vencimiento_comision_porcentaje_venta"
-            ];
-          this.ytm_vencimiento_porcentaje_venta =
-            ans["result"]["instrumento_venta"][
-              "ytm_vencimiento_porcentaje_venta"
-            ];
-          this.interes_acumulado_venta =
-            ans["result"]["instrumento_venta"]["interes_acumulado_venta"];
-          this.interes_acumulado_porcentaje_venta =
-            ans["result"]["instrumento_venta"][
-              "interes_acumulado_porcentaje_venta"
-            ];
-          this.precio_sucio_porcentaje_venta =
-            ans["result"]["instrumento_venta"]["precio_sucio_porcentaje_venta"];
-          this.valor_transado_venta =
-            ans["result"]["instrumento_venta"]["valor_transado_venta"];
-          this.monto_recibir =
-            ans["result"]["instrumento_venta"]["monto_recibir"];
-
-          // Resultado de la operacion
-          this.dias_tenencia_total =
-            ans["result"]["resultado_operacion"]["dias_tenencia_total"];
-          this.ganancia_perdida_capital =
-            ans["result"]["resultado_operacion"]["ganancia_perdida_capital"];
-          this.ingresos_intereses =
-            ans["result"]["resultado_operacion"]["ingresos_intereses"];
-          this.costos_totales =
-            ans["result"]["resultado_operacion"]["costos_totales"];
-          this.ganancia_perdida_total =
-            ans["result"]["resultado_operacion"]["ganancia_perdida_total"];
-          this.ganancia_perdida_capital_porcentaje =
-            ans["result"]["resultado_operacion"][
-              "ganancia_perdida_capital_porcentaje"
-            ];
-          this.intereses_porcentaje =
-            ans["result"]["resultado_operacion"]["intereses_porcentaje"];
-          this.neto_antes_impuesto_porcentaje =
-            ans["result"]["resultado_operacion"][
-              "neto_antes_impuesto_porcentaje"
-            ];
-          this.neto_despues_impuesto_porcentaje =
-            ans["result"]["resultado_operacion"][
-              "neto_despues_impuesto_porcentaje"
-            ];
-          this.total_ingresos_recibidos =
-            ans["result"]["resultado_operacion"]["total_ingresos_recibidos"];
+          if (this.tipoEjecucion == 1) {
+            this.comision_casa_venta =
+              ans["result"]["instrumento_venta"]["comision_casa_venta"];
+            this.comision_bolsa_venta =
+              ans["result"]["instrumento_venta"]["comision_bolsa_venta"];
+            this.fecha_siguiente_cupon_venta =
+              ans["result"]["instrumento_venta"]["fecha_siguiente_cupon_venta"];
+            this.dias_vencimiento_venta =
+              ans["result"]["instrumento_venta"]["dias_vencimiento_venta"];
+            this.dias_acumulados_venta =
+              ans["result"]["instrumento_venta"]["dias_acumulados_venta"];
+            this.ytm_vencimiento_comision_porcentaje_venta =
+              ans["result"]["instrumento_venta"][
+                "ytm_vencimiento_comision_porcentaje_venta"
+              ];
+            this.ytm_vencimiento_porcentaje_venta =
+              ans["result"]["instrumento_venta"][
+                "ytm_vencimiento_porcentaje_venta"
+              ];
+            this.interes_acumulado_venta =
+              ans["result"]["instrumento_venta"]["interes_acumulado_venta"];
+            this.interes_acumulado_porcentaje_venta =
+              ans["result"]["instrumento_venta"][
+                "interes_acumulado_porcentaje_venta"
+              ];
+            this.precio_sucio_porcentaje_venta =
+              ans["result"]["instrumento_venta"][
+                "precio_sucio_porcentaje_venta"
+              ];
+            this.valor_transado_venta =
+              ans["result"]["instrumento_venta"]["valor_transado_venta"];
+            this.monto_recibir =
+              ans["result"]["instrumento_venta"]["monto_recibir"];
+
+            this.operation_results_work = ans["result"]["resultado_operacion"];
+            this.operation_result = true;
+          }
 
           // Proyecciones
           this.proyecciones = ans["result"]["proyecciones"];
@@ -554,14 +557,14 @@ export class EURB implements InstrumentComponent {
             this.proyecciones = ans["result"]["proyecciones"];
           }
 
-          this.operation_result = true;
           this.dataSource.data = this.proyecciones.slice(0, -1);
           this.dataSource2.data = this.proyecciones.slice(0, -1);
           this.dataSource.paginator = this.paginator;
           this.dataSource.sort = this.sort;
 
-          // Obj
           this.bonosObject = {
+            completo: this.tipoEjecucion,
+            cancelado: this.tipoEjecucion,
             renta_porcentaje: this.investmentProposalForm.value
               .renta_porcentaje,
             costo_cedeval: this.investmentProposalForm.value.costo_cedeval,
@@ -579,18 +582,6 @@ export class EURB implements InstrumentComponent {
             comision_bolsa_porcentaje_compra: this.investmentProposalForm.value
               .comision_bolsa_porcentaje_compra,
 
-            valor_nominal_venta: this.investmentProposalForm.value
-              .valor_nominal_venta,
-            precio_venta: this.investmentProposalForm.value.precio_venta,
-            precio_vencimiento_venta: this.investmentProposalForm.value
-              .precio_vencimiento_venta,
-            cupon_porcentaje_venta: this.investmentProposalForm.value
-              .cupon_porcentaje_venta,
-            comision_casa_porcentaje_venta: this.investmentProposalForm.value
-              .comision_casa_porcentaje_venta,
-            comision_bolsa_porcentaje_venta: this.investmentProposalForm.value
-              .comision_bolsa_porcentaje_venta,
-
             fecha_vencimiento_compra: this.f.fecha_vencimiento_compra.value
               .singleDate.formatted,
             fecha_ultima_cupon_compra: this.f.fecha_ultima_cupon_compra.value
@@ -598,13 +589,6 @@ export class EURB implements InstrumentComponent {
             fecha_liquidacion_compra: this.f.fecha_liquidacion_compra.value
               .singleDate.formatted,
 
-            fecha_vencimiento_venta: this.f.fecha_vencimiento_venta.value
-              .singleDate.formatted,
-            fecha_ultima_cupon_venta: this.f.fecha_ultima_cupon_venta.value
-              .singleDate.formatted,
-            fecha_liquidacion_venta: this.f.fecha_liquidacion_venta.value
-              .singleDate.formatted,
-
             // Instrumento de compra
 
             comision_casa_compra: this.comision_casa_compra,
@@ -623,26 +607,9 @@ export class EURB implements InstrumentComponent {
             valor_transado_compra: this.valor_transado_compra,
             monto_pagar: this.monto_pagar,
             fecha_inicio_vigencia: this.fecha_inicio_vigencia,
-            // Instrumento de venta
-
-            comision_casa_venta: this.comision_casa_venta,
-            comision_bolsa_venta: this.comision_bolsa_venta,
-
-            fecha_siguiente_cupon_venta: this.fecha_siguiente_cupon_venta,
-            dias_vencimiento_venta: this.dias_vencimiento_venta,
-            dias_acumulados_venta: this.dias_acumulados_venta,
-            ytm_vencimiento_porcentaje_venta: this
-              .ytm_vencimiento_porcentaje_venta,
-            ytm_vencimiento_comision_porcentaje_venta: this
-              .ytm_vencimiento_comision_porcentaje_venta,
-
-            interes_acumulado_venta: this.interes_acumulado_venta,
-            interes_acumulado_porcentaje_venta: this
-              .interes_acumulado_porcentaje_venta,
-            precio_sucio_porcentaje_venta: this.precio_sucio_porcentaje_venta,
-            valor_transado_venta: this.valor_transado_venta,
-            // Resultado de la operacion
 
+            // Resultado de la operacion
+            /*
             monto_recibir: this.monto_recibir,
             dias_tenencia_total: this.dias_tenencia_total,
             ganancia_perdida_capital: this.ganancia_perdida_capital,
@@ -656,10 +623,68 @@ export class EURB implements InstrumentComponent {
             neto_despues_impuesto_porcentaje: this
               .neto_despues_impuesto_porcentaje,
             total_ingresos_recibidos: this.total_ingresos_recibidos,
-
+            */
             // Proyecciones
+
             proyecciones: this.proyecciones
           };
+          if (this.tipoEjecucion == 1) {
+            this.bonosObject[
+              "valor_nominal_venta"
+            ] = this.investmentProposalForm.value.valor_nominal_venta;
+            this.bonosObject[
+              "precio_venta"
+            ] = this.investmentProposalForm.value.precio_venta;
+            this.bonosObject[
+              "precio_vencimiento_venta"
+            ] = this.investmentProposalForm.value.precio_vencimiento_venta;
+            this.bonosObject[
+              "comision_casa_porcentaje_venta"
+            ] = this.investmentProposalForm.value.comision_casa_porcentaje_venta;
+            this.bonosObject[
+              "comision_bolsa_porcentaje_venta"
+            ] = this.investmentProposalForm.value.comision_bolsa_porcentaje_venta;
+            this.bonosObject[
+              "fecha_vencimiento_venta"
+            ] = this.f.fecha_vencimiento_venta.value.singleDate.formatted;
+            this.bonosObject[
+              "fecha_ultima_cupon_venta"
+            ] = this.f.fecha_ultima_cupon_venta.value.singleDate.formatted;
+            this.bonosObject[
+              "fecha_liquidacion_venta"
+            ] = this.f.fecha_liquidacion_venta.value.singleDate.formatted;
+            this.bonosObject["comision_casa_venta"] = this.comision_casa_venta;
+            this.bonosObject[
+              "comision_bolsa_venta"
+            ] = this.comision_bolsa_venta;
+            this.bonosObject[
+              "fecha_siguiente_cupon_venta"
+            ] = this.fecha_siguiente_cupon_venta;
+            this.bonosObject[
+              "dias_vencimiento_venta"
+            ] = this.dias_vencimiento_venta;
+            this.bonosObject[
+              "dias_acumulados_venta"
+            ] = this.dias_acumulados_venta;
+            this.bonosObject[
+              "ytm_vencimiento_porcentaje_venta"
+            ] = this.ytm_vencimiento_porcentaje_venta;
+            this.bonosObject[
+              "ytm_vencimiento_comision_porcentaje_venta"
+            ] = this.ytm_vencimiento_comision_porcentaje_venta;
+            this.bonosObject[
+              "interes_acumulado_venta"
+            ] = this.interes_acumulado_venta;
+            this.bonosObject[
+              "interes_acumulado_porcentaje_venta"
+            ] = this.interes_acumulado_porcentaje_venta;
+            this.bonosObject[
+              "precio_sucio_porcentaje_venta"
+            ] = this.precio_sucio_porcentaje_venta;
+            this.bonosObject[
+              "valor_transado_venta"
+            ] = this.valor_transado_venta;
+          }
 
           this.formDataService.setWork(this.bonosObject);
           Swal.close();
@@ -698,4 +723,8 @@ export class EURB implements InstrumentComponent {
   goToNext(form: any) {
     this.getCalculations(form, true);
   }
+
+  toggle_ejecucion(input: any) {
+    this.tipoEjecucion = +input;
+  }
 }

+ 3 - 0
src/app/components/investment-proposals/proposal-detail/proposal-detail.component.ts

@@ -154,6 +154,9 @@ export class InvestmentProposalDetailComponent implements OnInit {
               "id_inversion_instrumento"
             ];
 
+          this.gInstrument["resultado_operacion"] =
+            res["result"]["id_inversion_instrumento"]["resultado_operacion"];
+
           this.gComplement = {
             tipo_mercado:
               res["result"]["id_tipo_mercado"] == null

+ 360 - 0
src/app/components/investments/costs/pemp/pemp.costs.component.html

@@ -0,0 +1,360 @@
+<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]="['/investments']">
+                  Inversiones activas
+                </a>
+              </li>
+              <li class="breadcrumb-item">Préstamos empresariales</li>
+            </ol>
+          </nav>
+        </div>
+      </div>
+
+      <div class="col-12">
+        <div class="align-container">
+          <div class="card borderless card-wrapper">
+            <div class="wrapper-costs">
+              <h4 class="card-title">
+                Detalle de proyecciones para el préstamo empresarial
+              </h4>
+              <br />
+
+              <div class="align-container">
+                <div>
+                  <div class="costs-summary" *ngIf="instrument_exists">
+                    <div class="row">
+                      <div class="col-lg-3 col-md-4 col-sm-6">
+                        <h4>Valor nominal:</h4>
+                        <div class="field">
+                          $USD
+                          {{ instrument_work.monto_prestamo | number: "1.2-4" }}
+                        </div>
+                      </div>
+
+                      <div class="col-lg-3 col-md-4 col-sm-6">
+                        <h4>Monto préstamo:</h4>
+                        <div class="field">
+                          $USD
+                          {{ instrument_work.monto_prestamo | number: "1.2-4" }}
+                        </div>
+                      </div>
+                      <div class="col-lg-3 col-md-4 col-sm-6">
+                        <h4>Tasa (%):</h4>
+                        <div class="field">
+                          {{
+                            instrument_work.tasa_porcentaje | number: "1.2-4"
+                          }}%
+                        </div>
+                      </div>
+                      <div class="col-lg-3 col-md-4 col-sm-6">
+                        <h4>IVA (%):</h4>
+                        <div class="field">
+                          {{
+                            instrument_work.iva_porcentaje | number: "1.2-4"
+                          }}%
+                        </div>
+                      </div>
+                      <div class="col-lg-3 col-md-4 col-sm-6">
+                        <h4>Renta (%):</h4>
+                        <div class="field">
+                          {{
+                            instrument_work.renta_porcentaje | number: "1.2-4"
+                          }}%
+                        </div>
+                      </div>
+                      <div class="col-lg-3 col-md-4 col-sm-6">
+                        <h4>IVA ($):</h4>
+                        <div class="field">
+                          $USD {{ instrument_work.iva | number: "1.2-4" }}
+                        </div>
+                      </div>
+
+                      <div class="col-lg-3 col-md-4 col-sm-6">
+                        <h4>Comisión desembolso (%):</h4>
+                        <div class="field">
+                          {{
+                            instrument_work.comision_desembolso_porcentaje
+                              | number: "1.2-4"
+                          }}%
+                        </div>
+                      </div>
+                      <div class="col-lg-3 col-md-4 col-sm-6">
+                        <h4>Comisión desembolso ($):</h4>
+                        <div class="field">
+                          $USD
+                          {{
+                            instrument_work.comision_desembolso
+                              | number: "1.2-4"
+                          }}
+                        </div>
+                      </div>
+                      <div class="col-lg-3 col-md-4 col-sm-6">
+                        <h4>Plazo:</h4>
+                        <div class="field">
+                          {{ instrument_work.plazo | number: "1.2-4" }}
+                        </div>
+                      </div>
+                      <div class="col-lg-3 col-md-4 col-sm-6">
+                        <h4>Fecha de operacion:</h4>
+                        <div class="field">
+                          {{ instrument_work.fecha_operacion }}
+                        </div>
+                      </div>
+                      <div class="col-lg-3 col-md-4 col-sm-6">
+                        <h4>Fecha de vencimiento:</h4>
+                        <div class="field">
+                          {{ instrument_work.fecha_vencimiento }}
+                        </div>
+                      </div>
+                    </div>
+                  </div>
+                </div>
+              </div>
+              <br />
+              <br />
+              <div class="align-container">
+                <form *ngIf="dataRetrieved" [formGroup]="form">
+                  <div *ngFor="let group of form.controls; let i = index">
+                    <div class="wrapper-form" [formGroup]="group">
+                      <div class="costs-input-small-container">
+                        <div class="form-group">
+                          <label for="posicion">Posicion: </label>
+
+                          <div class="input-box-container">
+                            <input
+                              type="text"
+                              formControlName="posicion"
+                              class="form-control"
+                              readonly
+                            />
+                          </div>
+                        </div>
+                      </div>
+
+                      <div class="costs-input-small-container">
+                        <div class="form-group">
+                          <label for="plazo">Plazo: </label>
+
+                          <div class="input-box-container">
+                            <div>
+                              <p>
+                                <i class="far fa-clock" aria-hidden="true"></i>
+                              </p>
+                              <input
+                                type="text"
+                                formControlName="plazo"
+                                class="form-control"
+                                readonly
+                              />
+                            </div>
+                          </div>
+                        </div>
+                      </div>
+
+                      <div class="costs-input-normal-container">
+                        <div class="form-group">
+                          <label for="fecha_pago">Fecha pago: </label>
+
+                          <div class="input-box-container">
+                            <div>
+                              <p>
+                                <i
+                                  class="far fa-calendar"
+                                  aria-hidden="true"
+                                ></i>
+                              </p>
+                              <input
+                                type="text"
+                                formControlName="fecha_pago"
+                                class="form-control"
+                                readonly
+                              />
+                            </div>
+                          </div>
+                        </div>
+                      </div>
+
+                      <div class="costs-input-normal-container">
+                        <div class="form-group">
+                          <label for="ingreso_bruto">Ingreso bruto: </label>
+
+                          <div class="input-box-container">
+                            <div>
+                              <p>
+                                <i class="fas fa-dollar-sign"></i>
+                              </p>
+                              <input
+                                type="text"
+                                formControlName="ingreso_bruto"
+                                class="form-control"
+                                readonly
+                              />
+                            </div>
+                          </div>
+                        </div>
+                      </div>
+                      <div class="costs-input-normal-container">
+                        <div class="form-group">
+                          <label for="ingreso_neto">Ingreso neto: </label>
+
+                          <div class="input-box-container">
+                            <div>
+                              <p>
+                                <i class="fas fa-dollar-sign"></i>
+                              </p>
+                              <input
+                                type="text"
+                                formControlName="ingreso_neto"
+                                class="form-control"
+                                readonly
+                              />
+                            </div>
+                          </div>
+                        </div>
+                      </div>
+                      <div class="costs-input-normal-container">
+                        <div class="form-group">
+                          <label for="tasa_porcentaje">Tasa: </label>
+
+                          <div class="input-box-container">
+                            <div>
+                              <p>
+                                <i class="fas fa-percent"></i>
+                              </p>
+                              <input
+                                type="number"
+                                formControlName="tasa_porcentaje"
+                                class="form-control"
+                              />
+                            </div>
+                          </div>
+                        </div>
+                      </div>
+                      <div class="costs-input-normal-container">
+                        <div class="form-group">
+                          <label for="amortizacion_capital"
+                            >Amortización capital:
+                          </label>
+
+                          <div class="input-box-container">
+                            <div>
+                              <p>
+                                <i class="fas fa-dollar-sign"></i>
+                              </p>
+                              <input
+                                type="number"
+                                formControlName="amortizacion_capital"
+                                class="form-control"
+                              />
+                            </div>
+                          </div>
+                        </div>
+                      </div>
+                      <div class="costs-input-normal-container">
+                        <div class="form-group">
+                          <label for="monto_recibir">Monto a recibir: </label>
+
+                          <div class="input-box-container">
+                            <div>
+                              <p>
+                                <i class="fas fa-dollar-sign"></i>
+                              </p>
+                              <input
+                                type="number"
+                                formControlName="monto_recibir"
+                                class="form-control"
+                                readonly
+                              />
+                            </div>
+                          </div>
+                        </div>
+                      </div>
+
+                      <div class="costs-input-normal-container">
+                        <div class="form-group">
+                          <label for="iva">IVA: </label>
+
+                          <div class="input-box-container">
+                            <div>
+                              <p>
+                                <i class="fas fa-dollar-sign"></i>
+                              </p>
+                              <input
+                                type="text"
+                                formControlName="iva"
+                                class="form-control"
+                                readonly
+                              />
+                            </div>
+                          </div>
+                        </div>
+                      </div>
+                      <div class="costs-input-normal-container">
+                        <div class="form-group">
+                          <label for="capital_restante"
+                            >Capital restante:
+                          </label>
+
+                          <div class="input-box-container">
+                            <div>
+                              <p>
+                                <i class="fas fa-dollar-sign"></i>
+                              </p>
+                              <input
+                                type="number"
+                                formControlName="capital_restante"
+                                class="form-control"
+                                readonly
+                              />
+                            </div>
+                          </div>
+                        </div>
+                      </div>
+
+                      <input
+                        type="hidden"
+                        formControlName="id_proyeccion_ingreso"
+                      />
+                      <div class="clear"></div>
+                    </div>
+                  </div>
+                  <br />
+                  <div class="form-group text-right space-20">
+                    <button
+                      type="button"
+                      class="btn btn-success center-component float-left"
+                      (click)="saveProjection()"
+                    >
+                      Guardar información de proyecciones
+                    </button>
+
+                    <button
+                      type="button"
+                      class="btn btn-primary center-component float-right"
+                      (click)="recalculateProjectionChanges()"
+                    >
+                      Recalcular proyecciones
+                    </button>
+                  </div>
+                  <br />
+                </form>
+              </div>
+            </div>
+          </div>
+        </div>
+      </div>
+      <br />
+    </div>
+  </div>
+</div>

+ 225 - 0
src/app/components/investments/costs/pemp/pemp.costs.component.ts

@@ -0,0 +1,225 @@
+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 { InstrumentCalculations } from "@app/services/instrument-calculations.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, ActivatedRoute } from "@angular/router";
+import {
+  FormBuilder,
+  FormGroup,
+  FormControl,
+  FormArray,
+  Validators
+} from "@angular/forms";
+
+@Component({
+  selector: "app-pemp-costs",
+  templateUrl: "./pemp.costs.component.html"
+  //styleUrls: ["./dap.costs.component.scss"]
+})
+export class PEMPCostsComponent implements OnInit {
+  helper = new JwtHelperService();
+
+  title: string = "Proyecciones para préstamos empresariales";
+
+  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;
+  investmentProposalID: string;
+
+  form: FormArray;
+  investmentProposalForm: FormGroup;
+
+  proyecciones: any;
+  proyeccionesProps = [];
+  dataRetrieved: boolean = false;
+
+  array1;
+  array2;
+  array3;
+  investment: any;
+  instrument_work: any;
+  instrument_exists: boolean;
+
+  constructor(
+    private catalogService: CatalogsService,
+    private investmentsService: InvestmentsService,
+    private authService: AuthService,
+    private formInvestmentProposal: FormInvestmentProposalService,
+    private router: Router,
+    private route: ActivatedRoute,
+    private instrumentService: InstrumentCalculations,
+
+    private formBuilder: FormBuilder
+  ) {
+    const decodedToken = this.helper.decodeToken(
+      this.authService.getJwtToken()
+    );
+    this.userRole = decodedToken.groups;
+
+    Swal.fire({
+      allowOutsideClick: false,
+      icon: "info",
+      text: "Espere por favor..."
+    });
+    Swal.showLoading();
+  }
+
+  ngOnInit() {
+    Swal.close();
+    const formDataObj = {};
+
+    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.investmentsService
+        .getProposalInvestment(this.investmentProposalID)
+        .subscribe(
+          res => {
+            this.investment = res["result"];
+            this.instrument_work =
+              res["result"]["id_inversion_instrumento"]["instrumento"];
+            this.instrument_exists = true;
+          },
+          err => {}
+        );
+
+      this.investmentsService
+        .getProposalInvestment(this.investmentProposalID)
+        .subscribe(
+          res => {
+            this.proyecciones =
+              res["result"]["id_inversion_instrumento"]["instrumento"][
+                "proyecciones"
+              ];
+            this.proyecciones.pop();
+            this.form = new FormArray(this.buildForm(this.proyecciones));
+            this.dataRetrieved = true;
+          },
+          err => {
+            Swal.fire({
+              icon: "error",
+              title: "Error en el servidor",
+              text: err.message
+            });
+          }
+        );
+    }
+
+    setTimeout(() => {
+      Swal.close();
+    }, 1200);
+  }
+
+  recalculateProjectionChanges() {
+    let objProjection = { proyecciones: this.form.value };
+    Swal.fire({
+      allowOutsideClick: false,
+      icon: "info",
+      text: "Espere por favor..."
+    });
+    Swal.showLoading();
+
+    this.instrumentService
+      .projectionCalc(this.investmentProposalID, this.form.value)
+      .subscribe(
+        result => {
+          Swal.fire({
+            allowOutsideClick: false,
+            icon: "success",
+            showCancelButton: false,
+            title: "Exito"
+          });
+          this.proyecciones = result["result"]["proyecciones"];
+          this.proyecciones.pop();
+          this.form.clear();
+          this.form = new FormArray(this.buildForm(this.proyecciones));
+          Swal.close();
+          //window.location.reload();
+        },
+        err => {
+          Swal.fire({
+            icon: "error",
+            title: "Error al guardar",
+            text: err.message
+          });
+        }
+      );
+  }
+
+  saveProjection() {
+    let objProjection = { proyecciones: this.form.value };
+    Swal.fire({
+      allowOutsideClick: false,
+      icon: "info",
+      text: "Espere por favor..."
+    });
+    Swal.showLoading();
+
+    this.instrumentService
+      .projectionModification(this.investmentProposalID, objProjection)
+      .subscribe(
+        resp => {
+          Swal.fire({
+            allowOutsideClick: false,
+            icon: "success",
+            showCancelButton: false,
+            title: "Exito",
+            confirmButtonText: "La información ha sido actualizada"
+          }).then(result => {
+            Swal.close();
+            //window.location.reload();
+          });
+        },
+        err => {
+          Swal.fire({
+            icon: "error",
+            title: "Error al guardar",
+            text: err.message
+          });
+        }
+      );
+  }
+
+  buildForm(items: any[]): FormGroup[] {
+    return items.map(x => this.buildItem(x));
+  }
+  //return a formGroup
+  buildItem(item: any): FormGroup {
+    return new FormGroup({
+      id_proyeccion_ingreso: new FormControl(item.id_proyeccion_ingreso),
+      posicion: new FormControl(item.posicion),
+      plazo: new FormControl(item.plazo),
+      fecha_pago: new FormControl(item.fecha_pago),
+      ingreso_bruto: new FormControl(item.ingreso_bruto),
+      ingreso_neto: new FormControl(item.ingreso_neto),
+      tasa_porcentaje: new FormControl(item.tasa_porcentaje),
+      amortizacion_capital: new FormControl(item.amortizacion_capital),
+      monto_recibir: new FormControl(item.monto_recibir),
+      iva: new FormControl(item.iva),
+      capital_restante: new FormControl(item.capital_restante)
+    });
+  }
+}

+ 487 - 0
src/app/components/investments/costs/pper/pper.costs.component.html

@@ -0,0 +1,487 @@
+<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]="['/investments']">
+                  Inversiones activas
+                </a>
+              </li>
+              <li class="breadcrumb-item">Préstamos personales</li>
+            </ol>
+          </nav>
+        </div>
+      </div>
+
+      <div class="col-12">
+        <div class="align-container">
+          <div class="card borderless card-wrapper">
+            <div class="wrapper-costs">
+              <h4 class="card-title">
+                Detalle de proyecciones para el préstamo personal
+              </h4>
+              <br />
+
+              <div class="align-container">
+                <div>
+                  <div class="costs-summary" *ngIf="instrument_exists">
+                    <div class="row">
+                      <div class="col-lg-3 col-md-4 col-sm-6">
+                        <h4>Valor nominal:</h4>
+                        <div class="field">
+                          $USD
+                          {{ instrument_work.monto_prestamo | number: "1.2-4" }}
+                        </div>
+                      </div>
+
+                      <div class="col-lg-3 col-md-4 col-sm-6">
+                        <h4>Monto préstamo:</h4>
+                        <div class="field">
+                          $USD
+                          {{ instrument_work.monto_prestamo | number: "1.2-4" }}
+                        </div>
+                      </div>
+                      <div class="col-lg-3 col-md-4 col-sm-6">
+                        <h4>Tasa (%):</h4>
+                        <div class="field">
+                          {{
+                            instrument_work.tasa_porcentaje | number: "1.2-4"
+                          }}%
+                        </div>
+                      </div>
+                      <div class="col-lg-3 col-md-4 col-sm-6">
+                        <h4>IVA (%):</h4>
+                        <div class="field">
+                          {{
+                            instrument_work.iva_porcentaje | number: "1.2-4"
+                          }}%
+                        </div>
+                      </div>
+                      <div class="col-lg-3 col-md-4 col-sm-6">
+                        <h4>Renta (%):</h4>
+                        <div class="field">
+                          {{
+                            instrument_work.renta_porcentaje | number: "1.2-4"
+                          }}%
+                        </div>
+                      </div>
+                      <div class="col-lg-3 col-md-4 col-sm-6">
+                        <h4>IVA ($):</h4>
+                        <div class="field">
+                          $USD {{ instrument_work.iva | number: "1.2-4" }}
+                        </div>
+                      </div>
+
+                      <div class="col-lg-3 col-md-4 col-sm-6">
+                        <h4>Comisión desembolso (%):</h4>
+                        <div class="field">
+                          {{
+                            instrument_work.comision_desembolso_porcentaje
+                              | number: "1.2-4"
+                          }}%
+                        </div>
+                      </div>
+                      <div class="col-lg-3 col-md-4 col-sm-6">
+                        <h4>Comisión desembolso ($):</h4>
+                        <div class="field">
+                          $USD
+                          {{
+                            instrument_work.comision_desembolso
+                              | number: "1.2-4"
+                          }}
+                        </div>
+                      </div>
+                      <div class="col-lg-3 col-md-4 col-sm-6">
+                        <h4>Plazo:</h4>
+                        <div class="field">
+                          {{ instrument_work.plazo | number: "1.2-4" }}
+                        </div>
+                      </div>
+                      <div class="col-lg-3 col-md-4 col-sm-6">
+                        <h4>Fecha de operacion:</h4>
+                        <div class="field">
+                          {{ instrument_work.fecha_operacion }}
+                        </div>
+                      </div>
+                      <div class="col-lg-3 col-md-4 col-sm-6">
+                        <h4>Fecha de vencimiento:</h4>
+                        <div class="field">
+                          {{ instrument_work.fecha_vencimiento }}
+                        </div>
+                      </div>
+                    </div>
+                  </div>
+                </div>
+              </div>
+              <br />
+              <br />
+              <div class="align-container">
+                <form *ngIf="dataRetrieved" [formGroup]="form">
+                  <div *ngFor="let group of form.controls; let i = index">
+                    <div class="wrapper-form" [formGroup]="group">
+                      <div class="costs-input-small-container">
+                        <div class="form-group">
+                          <label for="posicion">Posicion: </label>
+
+                          <div class="input-box-container">
+                            <input
+                              type="text"
+                              formControlName="posicion"
+                              class="form-control"
+                              readonly
+                            />
+                          </div>
+                        </div>
+                      </div>
+
+                      <div class="costs-input-small-container">
+                        <div class="form-group">
+                          <label for="plazo">Plazo: </label>
+
+                          <div class="input-box-container">
+                            <div>
+                              <p>
+                                <i class="far fa-clock" aria-hidden="true"></i>
+                              </p>
+                              <input
+                                type="text"
+                                formControlName="plazo"
+                                class="form-control"
+                                readonly
+                              />
+                            </div>
+                          </div>
+                        </div>
+                      </div>
+
+                      <div class="costs-input-normal-container">
+                        <div class="form-group">
+                          <label for="fecha_pago">Fecha pago: </label>
+
+                          <div class="input-box-container">
+                            <div>
+                              <p>
+                                <i
+                                  class="far fa-calendar"
+                                  aria-hidden="true"
+                                ></i>
+                              </p>
+                              <input
+                                type="text"
+                                formControlName="fecha_pago"
+                                class="form-control"
+                                readonly
+                              />
+                            </div>
+                          </div>
+                        </div>
+                      </div>
+
+                      <div class="costs-input-normal-container">
+                        <div class="form-group">
+                          <label for="tasa_porcentaje">Tasa: </label>
+
+                          <div class="input-box-container">
+                            <div>
+                              <p>
+                                <i class="fas fa-percent"></i>
+                              </p>
+                              <input
+                                type="number"
+                                formControlName="tasa_porcentaje"
+                                class="form-control"
+                              />
+                            </div>
+                          </div>
+                        </div>
+                      </div>
+
+                      <div class="costs-input-normal-container">
+                        <div class="form-group">
+                          <label for="saldo_inicial">Saldo inicial: </label>
+
+                          <div class="input-box-container">
+                            <div>
+                              <p>
+                                <i class="fas fa-dollar-sign"></i>
+                              </p>
+                              <input
+                                type="text"
+                                formControlName="saldo_inicial"
+                                class="form-control"
+                                readonly
+                              />
+                            </div>
+                          </div>
+                        </div>
+                      </div>
+
+                      <div class="costs-input-normal-container">
+                        <div class="form-group">
+                          <label for="pago_cuota">Pago cuota: </label>
+
+                          <div class="input-box-container">
+                            <div>
+                              <p>
+                                <i class="fas fa-dollar-sign"></i>
+                              </p>
+                              <input
+                                type="text"
+                                formControlName="pago_cuota"
+                                class="form-control"
+                                readonly
+                              />
+                            </div>
+                          </div>
+                        </div>
+                      </div>
+
+                      <div class="costs-input-normal-container">
+                        <div class="form-group">
+                          <label for="ingreso_bruto">Ingreso bruto: </label>
+
+                          <div class="input-box-container">
+                            <div>
+                              <p>
+                                <i class="fas fa-dollar-sign"></i>
+                              </p>
+                              <input
+                                type="text"
+                                formControlName="ingreso_bruto"
+                                class="form-control"
+                                readonly
+                              />
+                            </div>
+                          </div>
+                        </div>
+                      </div>
+
+                      <div class="costs-input-normal-container">
+                        <div class="form-group">
+                          <label for="iva_interes">IVA (%): </label>
+
+                          <div class="input-box-container">
+                            <div>
+                              <p>
+                                <i class="fas fa-percent"></i>
+                              </p>
+                              <input
+                                type="number"
+                                formControlName="iva_interes"
+                                class="form-control"
+                                readonly
+                              />
+                            </div>
+                          </div>
+                        </div>
+                      </div>
+
+                      <div class="costs-input-normal-container">
+                        <div class="form-group">
+                          <label for="ingreso_neto">Ingreso neto: </label>
+
+                          <div class="input-box-container">
+                            <div>
+                              <p>
+                                <i class="fas fa-dollar-sign"></i>
+                              </p>
+                              <input
+                                type="text"
+                                formControlName="ingreso_neto"
+                                class="form-control"
+                                readonly
+                              />
+                            </div>
+                          </div>
+                        </div>
+                      </div>
+
+                      <div class="costs-input-normal-container">
+                        <div class="form-group">
+                          <label for="abono_capital">Abono capital: </label>
+
+                          <div class="input-box-container">
+                            <div>
+                              <p>
+                                <i class="fas fa-dollar-sign"></i>
+                              </p>
+                              <input
+                                type="text"
+                                formControlName="abono_capital"
+                                class="form-control"
+                                readonly
+                              />
+                            </div>
+                          </div>
+                        </div>
+                      </div>
+
+                      <div class="costs-input-normal-container">
+                        <div class="form-group">
+                          <label for="capital_restante"
+                            >Capital restante:
+                          </label>
+
+                          <div class="input-box-container">
+                            <div>
+                              <p>
+                                <i class="fas fa-dollar-sign"></i>
+                              </p>
+                              <input
+                                type="text"
+                                formControlName="capital_restante"
+                                class="form-control"
+                                readonly
+                              />
+                            </div>
+                          </div>
+                        </div>
+                      </div>
+
+                      <div class="costs-input-normal-container">
+                        <div class="form-group">
+                          <label for="pago_seguro_dano"
+                            >Pago seguro daño:
+                          </label>
+
+                          <div class="input-box-container">
+                            <div>
+                              <p>
+                                <i class="fas fa-dollar-sign"></i>
+                              </p>
+                              <input
+                                type="text"
+                                formControlName="pago_seguro_dano"
+                                class="form-control"
+                                readonly
+                              />
+                            </div>
+                          </div>
+                        </div>
+                      </div>
+                      <div class="costs-input-normal-container">
+                        <div class="form-group">
+                          <label for="pago_seguro_vivienda"
+                            >Pago seguro vivienda:
+                          </label>
+
+                          <div class="input-box-container">
+                            <div>
+                              <p>
+                                <i class="fas fa-dollar-sign"></i>
+                              </p>
+                              <input
+                                type="text"
+                                formControlName="pago_seguro_vivienda"
+                                class="form-control"
+                                readonly
+                              />
+                            </div>
+                          </div>
+                        </div>
+                      </div>
+
+                      <div class="costs-input-normal-container">
+                        <div class="form-group">
+                          <label for="total_cuota">Total cuota: </label>
+
+                          <div class="input-box-container">
+                            <div>
+                              <p>
+                                <i class="fas fa-dollar-sign"></i>
+                              </p>
+                              <input
+                                type="text"
+                                formControlName="total_cuota"
+                                class="form-control"
+                                readonly
+                              />
+                            </div>
+                          </div>
+                        </div>
+                      </div>
+
+                      <div class="costs-input-normal-container">
+                        <div class="form-group">
+                          <label for="amortizacion_capital"
+                            >Amortización capital:
+                          </label>
+
+                          <div class="input-box-container">
+                            <div>
+                              <p>
+                                <i class="fas fa-dollar-sign"></i>
+                              </p>
+                              <input
+                                type="number"
+                                formControlName="amortizacion_capital"
+                                class="form-control"
+                              />
+                            </div>
+                          </div>
+                        </div>
+                      </div>
+                      <div class="costs-input-normal-container">
+                        <div class="form-group">
+                          <label for="total_recibir">Total a recibir: </label>
+
+                          <div class="input-box-container">
+                            <div>
+                              <p>
+                                <i class="fas fa-dollar-sign"></i>
+                              </p>
+                              <input
+                                type="number"
+                                formControlName="total_recibir"
+                                class="form-control"
+                                readonly
+                              />
+                            </div>
+                          </div>
+                        </div>
+                      </div>
+
+                      <input
+                        type="hidden"
+                        formControlName="id_proyeccion_ingreso"
+                      />
+                      <div class="clear"></div>
+                    </div>
+                  </div>
+                  <br />
+                  <div class="form-group text-right space-20">
+                    <button
+                      type="button"
+                      class="btn btn-success center-component float-left"
+                      (click)="saveProjection()"
+                    >
+                      Guardar información de proyecciones
+                    </button>
+
+                    <button
+                      type="button"
+                      class="btn btn-primary center-component float-right"
+                      (click)="recalculateProjectionChanges()"
+                    >
+                      Recalcular proyecciones
+                    </button>
+                  </div>
+                  <br />
+                </form>
+              </div>
+            </div>
+          </div>
+        </div>
+      </div>
+      <br />
+    </div>
+  </div>
+</div>

+ 231 - 0
src/app/components/investments/costs/pper/pper.costs.component.ts

@@ -0,0 +1,231 @@
+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 { InstrumentCalculations } from "@app/services/instrument-calculations.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, ActivatedRoute } from "@angular/router";
+import {
+  FormBuilder,
+  FormGroup,
+  FormControl,
+  FormArray,
+  Validators
+} from "@angular/forms";
+
+@Component({
+  selector: "app-pper-costs",
+  templateUrl: "./pper.costs.component.html"
+  //styleUrls: ["./dap.costs.component.scss"]
+})
+export class PPERCostsComponent implements OnInit {
+  helper = new JwtHelperService();
+
+  title: string = "Proyecciones para préstamos personales";
+
+  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;
+  investmentProposalID: string;
+
+  form: FormArray;
+  investmentProposalForm: FormGroup;
+
+  proyecciones: any;
+  proyeccionesProps = [];
+  dataRetrieved: boolean = false;
+
+  array1;
+  array2;
+  array3;
+  investment: any;
+  instrument_work: any;
+  instrument_exists: boolean;
+
+  constructor(
+    private catalogService: CatalogsService,
+    private investmentsService: InvestmentsService,
+    private authService: AuthService,
+    private formInvestmentProposal: FormInvestmentProposalService,
+    private router: Router,
+    private route: ActivatedRoute,
+    private instrumentService: InstrumentCalculations,
+
+    private formBuilder: FormBuilder
+  ) {
+    const decodedToken = this.helper.decodeToken(
+      this.authService.getJwtToken()
+    );
+    this.userRole = decodedToken.groups;
+
+    Swal.fire({
+      allowOutsideClick: false,
+      icon: "info",
+      text: "Espere por favor..."
+    });
+    Swal.showLoading();
+  }
+
+  ngOnInit() {
+    Swal.close();
+    const formDataObj = {};
+
+    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.investmentsService
+        .getProposalInvestment(this.investmentProposalID)
+        .subscribe(
+          res => {
+            this.investment = res["result"];
+            this.instrument_work =
+              res["result"]["id_inversion_instrumento"]["instrumento"];
+            this.instrument_exists = true;
+          },
+          err => {}
+        );
+
+      this.investmentsService
+        .getProposalInvestment(this.investmentProposalID)
+        .subscribe(
+          res => {
+            this.proyecciones =
+              res["result"]["id_inversion_instrumento"]["instrumento"][
+                "proyecciones"
+              ];
+            this.proyecciones.pop();
+            this.form = new FormArray(this.buildForm(this.proyecciones));
+            this.dataRetrieved = true;
+          },
+          err => {
+            Swal.fire({
+              icon: "error",
+              title: "Error en el servidor",
+              text: err.message
+            });
+          }
+        );
+    }
+
+    setTimeout(() => {
+      Swal.close();
+    }, 1200);
+  }
+
+  recalculateProjectionChanges() {
+    let objProjection = { proyecciones: this.form.value };
+    Swal.fire({
+      allowOutsideClick: false,
+      icon: "info",
+      text: "Espere por favor..."
+    });
+    Swal.showLoading();
+
+    this.instrumentService
+      .projectionCalc(this.investmentProposalID, this.form.value)
+      .subscribe(
+        result => {
+          Swal.fire({
+            allowOutsideClick: false,
+            icon: "success",
+            showCancelButton: false,
+            title: "Exito"
+          });
+          this.proyecciones = result["result"]["proyecciones"];
+          this.proyecciones.pop();
+          this.form.clear();
+          this.form = new FormArray(this.buildForm(this.proyecciones));
+          Swal.close();
+          //window.location.reload();
+        },
+        err => {
+          Swal.fire({
+            icon: "error",
+            title: "Error al guardar",
+            text: err.message
+          });
+        }
+      );
+  }
+
+  saveProjection() {
+    let objProjection = { proyecciones: this.form.value };
+    Swal.fire({
+      allowOutsideClick: false,
+      icon: "info",
+      text: "Espere por favor..."
+    });
+    Swal.showLoading();
+
+    this.instrumentService
+      .projectionModification(this.investmentProposalID, objProjection)
+      .subscribe(
+        resp => {
+          Swal.fire({
+            allowOutsideClick: false,
+            icon: "success",
+            showCancelButton: false,
+            title: "Exito",
+            confirmButtonText: "La información ha sido actualizada"
+          }).then(result => {
+            Swal.close();
+            //window.location.reload();
+          });
+        },
+        err => {
+          Swal.fire({
+            icon: "error",
+            title: "Error al guardar",
+            text: err.message
+          });
+        }
+      );
+  }
+
+  buildForm(items: any[]): FormGroup[] {
+    return items.map(x => this.buildItem(x));
+  }
+  //return a formGroup
+  buildItem(item: any): FormGroup {
+    return new FormGroup({
+      id_proyeccion_ingreso: new FormControl(item.id_proyeccion_ingreso),
+      posicion: new FormControl(item.posicion),
+      plazo: new FormControl(item.plazo),
+      fecha_pago: new FormControl(item.fecha_pago),
+      tasa_porcentaje: new FormControl(item.tasa_porcentaje),
+      saldo_inicial: new FormControl(item.saldo_inicial),
+      pago_cuota: new FormControl(item.pago_cuota),
+      ingreso_bruto: new FormControl(item.ingreso_bruto),
+      iva_interes: new FormControl(item.iva_interes),
+      ingreso_neto: new FormControl(item.ingreso_neto),
+      abono_capital: new FormControl(item.abono_capital),
+      capital_restante: new FormControl(item.capital_restante),
+      pago_seguro_dano: new FormControl(item.pago_seguro_dano),
+      pago_seguro_vivienda: new FormControl(item.pago_seguro_vivienda),
+      total_cuota: new FormControl(item.total_cuota),
+      amortizacion_capital: new FormControl(item.amortizacion_capital),
+      total_recibir: new FormControl(item.total_recibir)
+    });
+  }
+}

+ 2 - 0
src/app/components/investments/investments.component.ts

@@ -141,6 +141,8 @@ export class InvestmentsComponent implements OnInit {
         }
         break;
       case "FINV":
+      case "PEMP":
+      case "PPER":
         return true;
       default:
         return false;

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

@@ -80,6 +80,8 @@ import { FINVCostsComponent } from "@app/components/investments/costs/fondos/fon
 import { InvestmentPrint } from "@app/components/plugins/investment-print/investment-print";
 import { PPER } from "@app/components/instruments/pper/pper.component";
 import { PEMP } from "@app/components/instruments/pemp/pemp.component";
+import { PEMPCostsComponent } from "@app/components/investments/costs/pemp/pemp.costs.component";
+import { PPERCostsComponent } from "@app/components/investments/costs/pper/pper.costs.component";
 
 // This array defines which "componentId" maps to which lazy-loaded module.
 
@@ -158,6 +160,8 @@ import { PEMP } from "@app/components/instruments/pemp/pemp.component";
     VCNCostsComponent,
     PBURCostsComponent,
     FINVCostsComponent,
+    PEMPCostsComponent,
+    PPERCostsComponent,
     IncomesComponent,
     GeneralIncomeFormComponent,
     PaymentApprovalComponent,

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

@@ -33,6 +33,8 @@ import { GeneralIncomeFormComponent } from "@app/components/incomes/general-form
 import { PaymentApprovalComponent } from "@app/components/investment-proposals/payment-approval/payment-approval.component";
 import { UploadLiquidationComponent } from "@app/components/investment-proposals/upload-liquidation/upload-liquidation.component";
 import { FINVCostsComponent } from "@app/components/investments/costs/fondos/fondos.costs.component";
+import { PEMPCostsComponent } from "@app/components/investments/costs/pemp/pemp.costs.component";
+import { PPERCostsComponent } from "@app/components/investments/costs/pper/pper.costs.component";
 
 export const AdminLayoutRoutes: Routes = [
   {
@@ -218,6 +220,14 @@ export const AdminLayoutRoutes: Routes = [
     path: "investment-costs/finv/:id",
     component: FINVCostsComponent
   },
+  {
+    path: "investment-costs/pemp/:id",
+    component: PEMPCostsComponent
+  },
+  {
+    path: "investment-costs/pper/:id",
+    component: PPERCostsComponent
+  },
   {
     path: "investment-costs/pbur/:id",
     component: PBURCostsComponent

+ 2 - 0
src/app/models/investment-proposal-form.ts

@@ -19,6 +19,7 @@ export class InvestmentProposalForm {
   formato_ingreso: string = "";
   plazo: string = "";
   operaciones: string = "";
+  resultado_operacion: string = "";
 
   clear() {
     this.asunto = "";
@@ -41,6 +42,7 @@ export class InvestmentProposalForm {
     this.plazo = "";
     this.operaciones = "";
     this.formato_ingreso = "";
+    this.resultado_operacion = "";
   }
 }
 

+ 1 - 0
src/app/services/instrument-calculations.service.ts

@@ -86,6 +86,7 @@ export class InstrumentCalculations {
       id_formato_ingreso: number;
     },
     info_instrumento: {
+      completo: number;
       renta_porcentaje: number;
       costo_cedeval: number;
       comision_casa_porcentaje_compra: number;