Browse Source

Merge branch 'features-o' of onunez/frontend-inversiones into development

Oscar José Nuñez Chávez 5 năm trước cách đây
mục cha
commit
9f50d686dd

+ 93 - 25
src/app/components/instruments/titulos/titulos.component.html

@@ -8,7 +8,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">
           <div class="col-12">
             <h5>Compra</h5>
@@ -460,7 +482,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>
@@ -907,7 +935,9 @@
             {{ fecha_inicio_vigencia }}
           </div>
         </div>
+      </div>
 
+      <div class="row" *ngIf="tipoEjecucion == 1">
         <div class="col-12">
           <h3>
             Instrumento de venta
@@ -984,16 +1014,36 @@
             $USD {{ valor_transado_venta | number: "1.2-4" }}
           </div>
         </div>
-
+        <div class="col-sm-4">
+          <h4>Monto a recibir:</h4>
+          <div class="field">$USD {{ monto_recibir | 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 transado compra:</h4>
+            <div class="field">
+              $USD {{ valor_transado_compra | number: "1.2-4" }}
+            </div>
+          </div>
+          <div class="col-sm-4">
+            <h4>Precio compra:</h4>
+            <div class="field">
+              {{ precio_compra }}
+            </div>
+          </div>
+          <div class="col-sm-4">
+            <h4>Precio venta:</h4>
+            <div class="field">
+              {{ precio_venta }}
+            </div>
           </div>
           <div class="col-sm-4">
             <h4>Días tenencia total:</h4>
@@ -1031,21 +1081,21 @@
             </div>
           </div>
           <div class="col-sm-4">
-            <h4>Interés neto antes de impuesto (%):</h4>
+            <h4>Interés neto antes de renta (%):</h4>
             <div class="field">
               {{ neto_antes_impuesto_porcentaje | number: "1.2-4" }}
               %
             </div>
           </div>
           <div class="col-sm-4">
-            <h4>Interés neto después de impuesto (%):</h4>
+            <h4>Interés neto después de renta (%):</h4>
             <div class="field">
               {{ neto_despues_impuesto_porcentaje | number: "1.2-4" }}
               %
             </div>
           </div>
           <div class="col-sm-4">
-            <h4>Total de ingresos recibidos:</h4>
+            <h4>Total de intereses recibidos:</h4>
             <div class="field">
               $USD
               {{ total_ingresos_recibidos | number: "1.2-4" }}
@@ -1136,7 +1186,6 @@
                 }}
               </td>
               <td mat-footer-cell *matFooterCellDef>
-                
                 ${{
                   consolidado_proyeccion.total_amortizacion_capital
                     | number: "1.2-4"
@@ -1153,7 +1202,6 @@
                 }}
               </td>
               <td mat-footer-cell *matFooterCellDef>
-                
                 ${{
                   consolidado_proyeccion.total_ingreso_bruto | number: "1.2-4"
                 }}
@@ -1169,7 +1217,6 @@
                 }}
               </td>
               <td mat-footer-cell *matFooterCellDef>
-                
                 ${{ consolidado_proyeccion.total_renta | number: "1.2-4" }}
               </td>
             </ng-container>
@@ -1183,7 +1230,6 @@
                 }}
               </td>
               <td mat-footer-cell *matFooterCellDef>
-                
                 ${{
                   consolidado_proyeccion.total_ingreso_neto | number: "1.2-4"
                 }}
@@ -1439,8 +1485,7 @@
       </div>
     </div>
 
-    <!--
-    <div class="row">
+    <div class="row" *ngIf="tipoEjecucion == 1">
       <div class="col-12">
         <h3>
           Instrumento de venta
@@ -1616,10 +1661,24 @@
           Resultado de la operación
         </h3>
       </div>
+
       <div class="col-lg-3 col-md-4 col-sm-6">
-        <h4>Valor nominal compra:</h4>
+        <h4>Valor transado compra:</h4>
         <div class="field">
-          $USD{{ operation_results_work.valor_nominal_compra }}
+          $USD
+          {{ operation_results_work.valor_transado_compra | number: "1.2-4" }}
+        </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">
@@ -1641,14 +1700,16 @@
         </div>
       </div>
       <div class="col-lg-3 col-md-4 col-sm-6">
-        <h4>Ganancia / Pérdida total:</h4>
+        <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">
-        <h4>Ganancia / Pérdida de capital:</h4>
+        <h4>Ganancia o pérdida de capital:</h4>
         <div class="field">
           {{
             operation_results_work.ganancia_perdida_capital_porcentaje
@@ -1664,27 +1725,34 @@
         </div>
       </div>
       <div class="col-lg-3 col-md-4 col-sm-6">
-        <h4>Interés neto antes de impuesto (%):</h4>
+        <h4>Interés neto antes de renta (%):</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>
       </div>
       <div class="col-lg-3 col-md-4 col-sm-6">
-        <h4>Interés neto después de impuesto (%):</h4>
+        <h4>Interés neto después de renta (%):</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 de intereses recibidos:</h4>
+        <div class="field">
+          $USD
+          {{
+            operation_results_work.total_intereses_recibidos | number: "1.2-4"
+          }}
+        </div>
+      </div>
     </div>
--->
     <br />
     <div *ngIf="hasProjections" class="instrument-calcs-summary">
       <div class="row">

+ 64 - 28
src/app/components/instruments/titulos/titulos.component.ts

@@ -34,7 +34,6 @@ export class TIT implements InstrumentComponent {
     "amortizacion_porcentaje",
     "amortizacion_capital",
     "ingreso_bruto",
-    "impuesto",
     "ingreso_neto",
     "renta",
     "saldo"
@@ -137,6 +136,13 @@ export class TIT 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;
+  precio_compra: any;
+  precio_venta: any;
 
   constructor(
     private formBuilder: FormBuilder,
@@ -155,6 +161,12 @@ export class TIT implements InstrumentComponent {
       this.instrument_work != undefined &&
       this.instrument_work.proyecciones != ""
     ) {
+      if (
+        this.instrument_work["valor_nominal_venta"] != undefined &&
+        +this.instrument_work["valor_nominal_venta"] > 0
+      ) {
+        this.tipoEjecucion = 1;
+      }
       this.hasProjections = true;
       this.consolidado_proyeccion = this.instrument_work.proyecciones[
         this.instrument_work.proyecciones.length - 1
@@ -184,6 +196,8 @@ export class TIT implements InstrumentComponent {
     }
 
     this.investmentProposalForm = this.formBuilder.group({
+      ejecucion: [this.instrument_exists ? "" : this.tipoEjecucion],
+
       renta_porcentaje: [
         this.instrument_exists ? "" : this.instrument_work.renta_porcentaje,
         [
@@ -476,6 +490,7 @@ export class TIT 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,
@@ -497,19 +512,31 @@ export class TIT 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,
           fecha_emision: this.f.fecha_emision.value.singleDate.formatted,
           amortizacion_porcentajes: this.amortizaciones
         }
@@ -586,6 +613,12 @@ export class TIT implements InstrumentComponent {
 
           // Resultado de la operacion
           this.operation_result = true;
+          this.valor_transado_compra =
+            ans["result"]["resultado_operacion"]["valor_transado_compra"];
+          this.precio_compra =
+            ans["result"]["resultado_operacion"]["precio_compra"];
+          this.precio_venta =
+            ans["result"]["resultado_operacion"]["precio_venta"];
           this.dias_tenencia_total =
             ans["result"]["resultado_operacion"]["dias_tenencia_total"];
           this.ganancia_perdida_capital =
@@ -595,7 +628,7 @@ export class TIT implements InstrumentComponent {
           this.costos_totales =
             ans["result"]["resultado_operacion"]["costos_totales"];
           this.ganancia_perdida_total =
-            ans["result"]["resultado_operacion"]["ganancia_perdida_total"];
+            ans["result"]["resultado_operacion"]["ganancia_perdida_total_neto"];
           this.ganancia_perdida_capital_porcentaje =
             ans["result"]["resultado_operacion"][
               "ganancia_perdida_capital_porcentaje"
@@ -603,15 +636,13 @@ export class TIT implements InstrumentComponent {
           this.intereses_porcentaje =
             ans["result"]["resultado_operacion"]["intereses_porcentaje"];
           this.neto_antes_impuesto_porcentaje =
-            ans["result"]["resultado_operacion"][
-              "neto_antes_impuesto_porcentaje"
-            ];
+            ans["result"]["resultado_operacion"]["neto_antes_renta_porcentaje"];
           this.neto_despues_impuesto_porcentaje =
             ans["result"]["resultado_operacion"][
-              "neto_despues_impuesto_porcentaje"
+              "neto_despues_renta_porcentaje"
             ];
           this.total_ingresos_recibidos =
-            ans["result"]["resultado_operacion"]["total_ingresos_recibidos"];
+            ans["result"]["resultado_operacion"]["total_interes_recibidos"];
 
           // Proyecciones
           this.proyecciones = ans["result"]["proyecciones"];
@@ -631,6 +662,8 @@ export class TIT implements InstrumentComponent {
 
           // Obj
           this.titulosObject = {
+            completo: this.tipoEjecucion,
+            cancelado: this.tipoEjecucion,
             renta_porcentaje: this.investmentProposalForm.value
               .renta_porcentaje,
             costo_cedeval: this.investmentProposalForm.value.costo_cedeval,
@@ -648,6 +681,13 @@ export class TIT implements InstrumentComponent {
             comision_bolsa_porcentaje_compra: this.investmentProposalForm.value
               .comision_bolsa_porcentaje_compra,
 
+            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,
+
             valor_nominal_venta: this.investmentProposalForm.value
               .valor_nominal_venta,
             precio_venta: this.investmentProposalForm.value.precio_venta,
@@ -659,14 +699,6 @@ export class TIT implements InstrumentComponent {
               .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
-              .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
@@ -768,4 +800,8 @@ export class TIT implements InstrumentComponent {
   goToNext(form: any) {
     this.getCalculations(form, true);
   }
+
+  toggle_ejecucion(input: any) {
+    this.tipoEjecucion = +input;
+  }
 }

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

@@ -132,6 +132,7 @@ export class InstrumentCalculations {
       id_formato_ingreso: number;
     },
     info_instrumento: {
+      completo: number;
       comision_casa_porcentaje_compra: number;
       comision_bolsa_porcentaje_compra: number;
       cupon_porcentaje_compra: number;