Переглянути джерело

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

Oscar José Nuñez Chávez 5 роки тому
батько
коміт
0219672760

+ 745 - 0
src/app/components/instruments/fondos/fondos.component.html

@@ -0,0 +1,745 @@
+<div *ngIf="!summary">
+  <h4 class="card-title">
+    Bonos
+  </h4>
+  <form
+    class="form-auth-small ng-untouched ng-pristine ng-valid"
+    [formGroup]="investmentProposalForm"
+  >
+    <div class="row">
+      <div class="col-lg-6 col-sm-12 pr-xl-3">
+        <div class="form-group">
+          <label for="cuota_participacion">Cuota de participación: </label>
+          <div class="input-box-container">
+            <p>
+              <i class="fas fa-dollar-sign" aria-hidden="true"></i>
+            </p>
+            <input
+              type="text"
+              formControlName="cuota_participacion"
+              class="form-control"
+              [ngClass]="{
+                'is-invalid': submitted && f.cuota_participacion.errors
+              }"
+            />
+            <div
+              *ngIf="submitted && f.cuota_participacion.errors"
+              class="invalid-feedback"
+            >
+              <div *ngIf="f.cuota_participacion.errors.required">
+                Campo requerido
+              </div>
+              <div *ngIf="f.cuota_participacion.errors.pattern">
+                Debe ingresar una cifra válida
+              </div>
+            </div>
+          </div>
+        </div>
+      </div>
+
+      <div class="col-lg-6 col-sm-12 pr-xl-3">
+        <div class="form-group">
+          <label for="valor_participacion">Valor participación: </label>
+          <div class="input-box-container">
+            <p>
+              <i class="fas fa-dollar-sign"></i>
+            </p>
+            <input
+              type="text"
+              formControlName="valor_participacion"
+              class="form-control"
+              [ngClass]="{
+                'is-invalid': submitted && f.valor_participacion.errors
+              }"
+            />
+            <div
+              *ngIf="submitted && f.valor_participacion.errors"
+              class="invalid-feedback"
+            >
+              <div *ngIf="f.valor_participacion.errors.required">
+                Campo requerido
+              </div>
+              <div *ngIf="f.valor_participacion.errors.pattern">
+                Debe ingresar una cifra válida
+              </div>
+            </div>
+          </div>
+        </div>
+      </div>
+
+      <!-- Comisión casa -->
+      <div class="col-lg-6 col-sm-12 pr-xl-3">
+        <div class="form-group">
+          <label for="comision_casa_porcentaje">Comisión casa: </label>
+          <div class="input-box-container">
+            <p>
+              <i class="fas fa-percent" aria-hidden="true"></i>
+            </p>
+            <input
+              type="text"
+              formControlName="comision_casa_porcentaje"
+              class="form-control"
+              [ngClass]="{
+                'is-invalid': submitted && f.comision_casa_porcentaje.errors
+              }"
+            />
+            <div
+              *ngIf="submitted && f.comision_casa_porcentaje.errors"
+              class="invalid-feedback"
+            >
+              <div *ngIf="f.comision_casa_porcentaje.errors.required">
+                Campo requerido
+              </div>
+              <div *ngIf="f.comision_casa_porcentaje.errors.pattern">
+                Debe ingresar una cifra válida
+              </div>
+            </div>
+          </div>
+        </div>
+      </div>
+
+      <!-- Comisión bolsa -->
+      <div class="col-lg-6 col-sm-12 pr-xl-3">
+        <div class="form-group">
+          <label for="comision_bolsa_porcentaje">Comisión bolsa: </label>
+          <div class="input-box-container">
+            <p>
+              <i class="fas fa-percent" aria-hidden="true"></i>
+            </p>
+            <input
+              type="text"
+              formControlName="comision_bolsa_porcentaje"
+              class="form-control"
+              [ngClass]="{
+                'is-invalid': submitted && f.comision_bolsa_porcentaje.errors
+              }"
+            />
+            <div
+              *ngIf="submitted && f.comision_bolsa_porcentaje.errors"
+              class="invalid-feedback"
+            >
+              <div *ngIf="f.comision_bolsa_porcentaje.errors.required">
+                Campo requerido
+              </div>
+              <div *ngIf="f.comision_bolsa_porcentaje.errors.pattern">
+                Debe ingresar una cifra válida
+              </div>
+            </div>
+          </div>
+        </div>
+      </div>
+
+      <!-- Dividendo porcentaje -->
+      <div class="col-lg-6 col-sm-12 pr-xl-3">
+        <div class="form-group">
+          <label for="dividendo_porcentaje">Dividendo </label>
+          <div class="input-box-container">
+            <p>
+              <i class="fas fa-percent" aria-hidden="true"></i>
+            </p>
+            <input
+              type="text"
+              formControlName="dividendo_porcentaje"
+              class="form-control"
+              [ngClass]="{
+                'is-invalid': submitted && f.dividendo_porcentaje.errors
+              }"
+            />
+            <div
+              *ngIf="submitted && f.dividendo_porcentaje.errors"
+              class="invalid-feedback"
+            >
+              <div *ngIf="f.dividendo_porcentaje.errors.required">
+                Campo requerido
+              </div>
+              <div *ngIf="f.dividendo_porcentaje.errors.pattern">
+                Debe ingresar una cifra válida
+              </div>
+            </div>
+          </div>
+        </div>
+      </div>
+
+      <!-- Rendimiento -->
+      <div class="col-lg-6 col-sm-12 pr-xl-3">
+        <div class="form-group">
+          <label for="rendimiento_porcentaje">Rendimiento: </label>
+          <div class="input-box-container">
+            <p>
+              <i class="fas fa-percent"></i>
+            </p>
+            <input
+              type="text"
+              formControlName="rendimiento_porcentaje"
+              class="form-control"
+              [ngClass]="{
+                'is-invalid': submitted && f.rendimiento_porcentaje.errors
+              }"
+            />
+            <div
+              *ngIf="submitted && f.rendimiento_porcentaje.errors"
+              class="invalid-feedback"
+            >
+              <div *ngIf="f.rendimiento_porcentaje.errors.required">
+                Campo requerido
+              </div>
+              <div *ngIf="f.rendimiento_porcentaje.errors.pattern">
+                Debe ingresar una cifra válida
+              </div>
+            </div>
+          </div>
+        </div>
+      </div>
+
+      <!-- Días liquidación -->
+      <div class="col-lg-6 col-sm-12 pr-xl-3">
+        <div class="form-group">
+          <label for="dias_liquidacion">Días liquidación: </label>
+          <div class="input-box-container">
+            <p>
+              <i class="fas fa-calendar-alt"></i>
+            </p>
+            <input
+              type="text"
+              formControlName="dias_liquidacion"
+              class="form-control"
+              [ngClass]="{
+                'is-invalid': submitted && f.dias_liquidacion.errors
+              }"
+            />
+            <div
+              *ngIf="submitted && f.dias_liquidacion.errors"
+              class="invalid-feedback"
+            >
+              <div *ngIf="f.dias_liquidacion.errors.required">
+                Campo requerido
+              </div>
+              <div *ngIf="f.dias_liquidacion.errors.pattern">
+                Debe ingresar una cifra válida
+              </div>
+            </div>
+          </div>
+        </div>
+      </div>
+
+      <!-- Días vencimiento -->
+      <div class="col-lg-6 col-sm-12 pr-xl-3">
+        <div class="form-group">
+          <label for="dias_vencimiento">Días vencimiento: </label>
+          <div class="input-box-container">
+            <p>
+              <i class="fas fa-calendar-alt"></i>
+            </p>
+            <input
+              type="text"
+              formControlName="dias_vencimiento"
+              class="form-control"
+              [ngClass]="{
+                'is-invalid': submitted && f.dias_vencimiento.errors
+              }"
+            />
+            <div
+              *ngIf="submitted && f.dias_vencimiento.errors"
+              class="invalid-feedback"
+            >
+              <div *ngIf="f.dias_vencimiento.errors.required">
+                Campo requerido
+              </div>
+              <div *ngIf="f.dias_vencimiento.errors.pattern">
+                Debe ingresar una cifra válida
+              </div>
+            </div>
+          </div>
+        </div>
+      </div>
+
+      <!-- Fecha de operación -->
+      <div class="col-lg-6 col-sm-12 pr-xl-3">
+        <div class="form-group">
+          <label for="fecha_operacion">Fecha de operación </label>
+
+          <div class="input-box-container">
+            <div>
+              <p>
+                <i class="far fa-calendar" aria-hidden="true"></i>
+              </p>
+              <input
+                class="input-box form-control"
+                placeholder="Seleccione una fecha"
+                angular-mydatepicker
+                formControlName="fecha_operacion"
+                (click)="dp1.toggleCalendar()"
+                [options]="myDpOptions"
+                #dp1="angular-mydatepicker"
+                [ngClass]="{
+                  'is-invalid': submitted && f.fecha_operacion.errors
+                }"
+              />
+            </div>
+          </div>
+
+          <div
+            *ngIf="submitted && f.fecha_operacion.errors"
+            class="invalid-feedback"
+          >
+            <div *ngIf="f.fecha_operacion.errors.required">
+              Campo requerido
+            </div>
+          </div>
+        </div>
+      </div>
+
+      <div class="col-lg-12 col-sm-12 pr-xl-12">
+        <div class="form-group text-right">
+          <br />
+          <button
+            type="button"
+            class="btn btn-success center-component"
+            (click)="getCalculations(investmentProposalForm, false)"
+          >
+            Realizar cálculos
+          </button>
+        </div>
+      </div>
+    </div>
+
+    <br />
+    <!-- Calculos del instrumento-->
+    <div class="instrument-calcs">
+      <div class="row">
+        <div class="col-12">
+          <span class="badge badge-success badge-custom"
+            >Cálculos del instrumento</span
+          >
+        </div>
+
+        <div class="col-sm-4">
+          <h4>Cuota participación:</h4>
+          <div class="field">
+            $USD {{ cuota_participacion | number: "1.2-4" }}
+          </div>
+        </div>
+
+        <div class="col-sm-4">
+          <h4>Valor participación:</h4>
+          <div class="field">
+            $USD {{ valor_participacion | number: "1.2-4" }}
+          </div>
+        </div>
+
+        <div class="col-sm-4">
+          <h4>Días liquidación:</h4>
+          <div class="field">
+            {{ dias_liquidacion }}
+          </div>
+        </div>
+
+        <div class="col-sm-4">
+          <h4>Días vencimiento:</h4>
+          <div class="field">
+            {{ dias_vencimiento }}
+          </div>
+        </div>
+
+        <div class="col-sm-4">
+          <h4>Valor nominal:</h4>
+          <div class="field">$USD {{ valor_nominal | number: "1.2-4" }}</div>
+        </div>
+
+        <div class="col-sm-4">
+          <h4>Valor transado:</h4>
+          <div class="field">$USD {{ valor_transado | number: "1.2-4" }}</div>
+        </div>
+        <div class="col-sm-4">
+          <h4>Comisión casa (%):</h4>
+          <div class="field">
+            {{ comision_casa_porcentaje | number: "1.2-4" }}
+            %
+          </div>
+        </div>
+        <div class="col-sm-4">
+          <div class="field">
+            <h4>Comisión casa:</h4>
+            $USD {{ comision_casa | number: "1.2-4" }}
+          </div>
+        </div>
+        <div class="col-sm-4">
+          <h4>Comisión bolsa (%):</h4>
+          <div class="field">
+            {{ comision_bolsa_porcentaje | number: "1.2-4" }}
+            %
+          </div>
+        </div>
+        <div class="col-sm-4">
+          <div class="field">
+            <h4>Comisión bolsa:</h4>
+            $USD {{ comision_bolsa | number: "1.2-4" }}
+          </div>
+        </div>
+
+        <div class="col-sm-4">
+          <h4>Rendimiento (%):</h4>
+          <div class="field">
+            {{ rendimiento_porcentaje | number: "1.2-4" }}
+            %
+          </div>
+        </div>
+
+        <div class="col-sm-4">
+          <h4>Dividendo (%):</h4>
+          <div class="field">
+            {{ dividendo_porcentaje | number: "1.2-4" }}
+            %
+          </div>
+        </div>
+
+        <div class="col-sm-4">
+          <h4>Fecha operación:</h4>
+          <div class="field">
+            {{ fecha_operacion }}
+          </div>
+        </div>
+
+        <div class="col-sm-4">
+          <h4>Fecha liquidación:</h4>
+          <div class="field">
+            {{ fecha_liquidacion }}
+          </div>
+        </div>
+
+        <div class="col-sm-4">
+          <h4>Fecha vencimiento:</h4>
+          <div class="field">
+            {{ fecha_vencimiento }}
+          </div>
+        </div>
+      </div>
+    </div>
+    <br />
+    <!-- Tabla de proyecciones del instrumento-->
+    <div class="instrument-calcs">
+      <div class="row">
+        <div class="col-12">
+          <span class="badge badge-success badge-custom"
+            >Proyecciones del instrumento</span
+          >
+        </div>
+
+        <div class="cete-table-container">
+          <table mat-table [dataSource]="dataSource" class="example-table">
+            <!-- Name Column -->
+            <ng-container matColumnDef="posicion">
+              <th mat-header-cell *matHeaderCellDef>#</th>
+              <td mat-cell *matCellDef="let row">
+                {{ row.posicion }}
+              </td>
+            </ng-container>
+            <!-- Country Column -->
+            <ng-container matColumnDef="plazo">
+              <th mat-header-cell *matHeaderCellDef>Plazo</th>
+              <td mat-cell *matCellDef="let row">
+                {{ row.plazo }}
+              </td>
+            </ng-container>
+
+            <ng-container matColumnDef="fecha_pago">
+              <th mat-header-cell *matHeaderCellDef>Fecha pago</th>
+              <td mat-cell *matCellDef="let row">
+                {{
+                  row.fecha_pago == "" || row.fecha_pago == undefined
+                    ? "-"
+                    : row.fecha_pago
+                }}
+              </td>
+            </ng-container>
+            <ng-container matColumnDef="ingreso_bruto">
+              <th mat-header-cell *matHeaderCellDef>Ingreso bruto</th>
+              <td mat-cell *matCellDef="let row">
+                {{
+                  row.ingreso_bruto == "" || row.ingreso_bruto == undefined
+                    ? "-"
+                    : row.ingreso_bruto
+                }}
+              </td>
+            </ng-container>
+            <ng-container matColumnDef="ingreso_neto">
+              <th mat-header-cell *matHeaderCellDef>Ingreso neto</th>
+              <td mat-cell *matCellDef="let row">
+                {{
+                  row.ingreso_neto == "" || row.ingreso_neto == undefined
+                    ? "-"
+                    : row.ingreso_neto
+                }}
+              </td>
+            </ng-container>
+            <ng-container matColumnDef="dividendo_porcentaje">
+              <th mat-header-cell *matHeaderCellDef>Dividendo (%)</th>
+              <td mat-cell *matCellDef="let row">
+                {{
+                  row.dividendo_porcentaje == "" ||
+                  row.dividendo_porcentaje == undefined
+                    ? "-"
+                    : row.dividendo_porcentaje
+                }}
+              </td>
+            </ng-container>
+            <ng-container matColumnDef="rendimiento_porcentaje">
+              <th mat-header-cell *matHeaderCellDef>Rendimiento (%)</th>
+              <td mat-cell *matCellDef="let row">
+                {{
+                  row.rendimiento_porcentaje == "" ||
+                  row.rendimiento_porcentaje == undefined
+                    ? "-"
+                    : row.rendimiento_porcentaje
+                }}
+              </td>
+            </ng-container>
+            <ng-container matColumnDef="rendimiento">
+              <th mat-header-cell *matHeaderCellDef>Rendimiento ($)</th>
+              <td mat-cell *matCellDef="let row">
+                {{
+                  row.rendimiento == "" || row.rendimiento == undefined
+                    ? "-"
+                    : row.rendimiento
+                }}
+              </td>
+            </ng-container>
+
+            <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
+            <tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
+          </table>
+        </div>
+      </div>
+    </div>
+
+    <br />
+    <div class="form-group text-center space-20">
+      <button
+        type="button"
+        class="btn btn-default center-component margin-right"
+        (click)="goToPrevious()"
+      >
+        Anterior
+      </button>
+      <button
+        type="submit"
+        class="btn btn-primary center-component margin-right"
+        (click)="goToNext(investmentProposalForm)"
+      >
+        Siguiente
+      </button>
+    </div>
+  </form>
+</div>
+
+<div *ngIf="summary">
+  <div class="timeline-body">
+    <div class="row">
+      <div class="col-lg-3 col-md-4 col-sm-6">
+        <h4>Cuota participación:</h4>
+        <div class="field">
+          $USD
+          {{ instrument_work_summary.cuota_participacion | number: "1.2-4" }}
+        </div>
+      </div>
+
+      <div class="col-lg-3 col-md-4 col-sm-6">
+        <h4>Valor participación:</h4>
+        <div class="field">
+          $USD
+          {{ instrument_work_summary.valor_participacion | number: "1.2-4" }}
+        </div>
+      </div>
+
+      <div class="col-lg-3 col-md-4 col-sm-6">
+        <h4>Días liquidación:</h4>
+        <div class="field">
+          {{ instrument_work_summary.dias_liquidacion }}
+        </div>
+      </div>
+
+      <div class="col-lg-3 col-md-4 col-sm-6">
+        <h4>Días vencimiento:</h4>
+        <div class="field">
+          {{ instrument_work_summary.dias_vencimiento }}
+        </div>
+      </div>
+
+      <div class="col-lg-3 col-md-4 col-sm-6">
+        <h4>Valor nominal:</h4>
+        <div class="field">
+          $USD {{ instrument_work_summary.valor_nominal | number: "1.2-4" }}
+        </div>
+      </div>
+
+      <div class="col-lg-3 col-md-4 col-sm-6">
+        <h4>Valor transado:</h4>
+        <div class="field">
+          $USD {{ instrument_work_summary.valor_transado | number: "1.2-4" }}
+        </div>
+      </div>
+      <div class="col-lg-3 col-md-4 col-sm-6">
+        <h4>Comisión casa (%):</h4>
+        <div class="field">
+          {{
+            instrument_work_summary.comision_casa_porcentaje | number: "1.2-4"
+          }}
+          %
+        </div>
+      </div>
+      <div class="col-lg-3 col-md-4 col-sm-6">
+        <div class="field">
+          <h4>Comisión casa:</h4>
+          $USD {{ instrument_work_summary.comision_casa | number: "1.2-4" }}
+        </div>
+      </div>
+      <div class="col-lg-3 col-md-4 col-sm-6">
+        <h4>Comisión bolsa (%):</h4>
+        <div class="field">
+          {{
+            instrument_work_summary.comision_bolsa_porcentaje | number: "1.2-4"
+          }}
+          %
+        </div>
+      </div>
+      <div class="col-lg-3 col-md-4 col-sm-6">
+        <div class="field">
+          <h4>Comisión bolsa:</h4>
+          $USD {{ instrument_work_summary.comision_bolsa | number: "1.2-4" }}
+        </div>
+      </div>
+
+      <div class="col-lg-3 col-md-4 col-sm-6">
+        <h4>Rendimiento (%):</h4>
+        <div class="field">
+          {{ instrument_work_summary.rendimiento_porcentaje | number: "1.2-4" }}
+          %
+        </div>
+      </div>
+
+      <div class="col-lg-3 col-md-4 col-sm-6">
+        <h4>Dividendo (%):</h4>
+        <div class="field">
+          {{ instrument_work_summary.dividendo_porcentaje | number: "1.2-4" }}
+          %
+        </div>
+      </div>
+
+      <div class="col-lg-3 col-md-4 col-sm-6">
+        <h4>Fecha operación:</h4>
+        <div class="field">
+          {{ instrument_work_summary.fecha_operacion }}
+        </div>
+      </div>
+
+      <div class="col-lg-3 col-md-4 col-sm-6">
+        <h4>Fecha liquidación:</h4>
+        <div class="field">
+          {{ instrument_work_summary.fecha_liquidacion }}
+        </div>
+      </div>
+
+      <div class="col-lg-3 col-md-4 col-sm-6">
+        <h4>Fecha vencimiento:</h4>
+        <div class="field">
+          {{ instrument_work_summary.fecha_vencimiento }}
+        </div>
+      </div>
+    </div>
+
+    <div *ngIf="hasProjections" class="instrument-calcs-summary">
+      <div class="row">
+        <div class="col-12">
+          <span class="badge-warning badge-custom-instrument"
+            >Proyecciones del instrumento</span
+          >
+        </div>
+
+        <div class="cete-table-container">
+          <table mat-table [dataSource]="dataSource2" class="example-table">
+            <!-- Name Column -->
+            <ng-container matColumnDef="posicion">
+              <th mat-header-cell *matHeaderCellDef>#</th>
+              <td mat-cell *matCellDef="let row">
+                {{ row.posicion }}
+              </td>
+            </ng-container>
+            <!-- Country Column -->
+            <ng-container matColumnDef="plazo">
+              <th mat-header-cell *matHeaderCellDef>Plazo</th>
+              <td mat-cell *matCellDef="let row">
+                {{ row.plazo }}
+              </td>
+            </ng-container>
+
+            <ng-container matColumnDef="fecha_pago">
+              <th mat-header-cell *matHeaderCellDef>Fecha pago</th>
+              <td mat-cell *matCellDef="let row">
+                {{
+                  row.fecha_pago == "" || row.fecha_pago == undefined
+                    ? "-"
+                    : row.fecha_pago
+                }}
+              </td>
+            </ng-container>
+            <ng-container matColumnDef="ingreso_bruto">
+              <th mat-header-cell *matHeaderCellDef>Ingreso bruto</th>
+              <td mat-cell *matCellDef="let row">
+                {{
+                  row.ingreso_bruto == "" || row.ingreso_bruto == undefined
+                    ? "-"
+                    : row.ingreso_bruto
+                }}
+              </td>
+            </ng-container>
+            <ng-container matColumnDef="ingreso_neto">
+              <th mat-header-cell *matHeaderCellDef>Ingreso neto</th>
+              <td mat-cell *matCellDef="let row">
+                {{
+                  row.ingreso_neto == "" || row.ingreso_neto == undefined
+                    ? "-"
+                    : row.ingreso_neto
+                }}
+              </td>
+            </ng-container>
+            <ng-container matColumnDef="dividendo_porcentaje">
+              <th mat-header-cell *matHeaderCellDef>Dividendo (%)</th>
+              <td mat-cell *matCellDef="let row">
+                {{
+                  row.dividendo_porcentaje == "" ||
+                  row.dividendo_porcentaje == undefined
+                    ? "-"
+                    : row.dividendo_porcentaje
+                }}
+              </td>
+            </ng-container>
+            <ng-container matColumnDef="rendimiento_porcentaje">
+              <th mat-header-cell *matHeaderCellDef>Rendimiento (%)</th>
+              <td mat-cell *matCellDef="let row">
+                {{
+                  row.rendimiento_porcentaje == "" ||
+                  row.rendimiento_porcentaje == undefined
+                    ? "-"
+                    : row.rendimiento_porcentaje
+                }}
+              </td>
+            </ng-container>
+            <ng-container matColumnDef="rendimiento">
+              <th mat-header-cell *matHeaderCellDef>Rendimiento ($)</th>
+              <td mat-cell *matCellDef="let row">
+                {{
+                  row.rendimiento == "" || row.rendimiento == undefined
+                    ? "-"
+                    : row.rendimiento
+                }}
+              </td>
+            </ng-container>
+
+            <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
+            <tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
+          </table>
+        </div>
+      </div>
+    </div>
+  </div>
+</div>

+ 380 - 0
src/app/components/instruments/fondos/fondos.component.ts

@@ -0,0 +1,380 @@
+import { Component, OnInit, Input, ViewChild } from "@angular/core";
+import { InstrumentComponent } from "@app/components/investment-proposals/instrument/instrument.component";
+import { FormBuilder, FormGroup, Validators } from "@angular/forms";
+import { IAngularMyDpOptions, IMyDateModel } from "angular-mydatepicker";
+import { formatDate, DatePipe } from "@angular/common";
+import { Router } from "@angular/router";
+import { FormInvestmentProposalService } from "@app/services/form-investment-proposal.service";
+import { CatalogsService } from "@app/services/catalogs.service";
+import { InstrumentCalculations } from "@app/services/instrument-calculations.service";
+import Swal from "sweetalert2";
+import { GeneralInfo } from "@app/models/investment-proposal-form";
+import { parse } from "date-fns";
+import { MatPaginator } from "@angular/material/paginator";
+import { MatSort } from "@angular/material/sort";
+import { MatTableDataSource } from "@angular/material/table";
+
+@Component({
+  selector: "app-fondos",
+  templateUrl: "./fondos.component.html"
+})
+export class FINV implements InstrumentComponent {
+  title: string = "Fondos de inversión";
+  @Input() data: any;
+  @Input() summary: boolean;
+  @Input() investmentID: string;
+
+  displayedColumns: string[] = [
+    "posicion",
+    "plazo",
+    "fecha_pago",
+    "ingreso_bruto",
+    "ingreso_neto",
+    "dividendo_porcentaje",
+    "rendimiento_porcentaje",
+    "rendimiento"
+  ];
+
+  @ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
+  @ViewChild(MatSort, { static: true }) sort: MatSort;
+
+  form: any;
+  general: GeneralInfo;
+
+  // For daterange
+  daysLabels: any = {
+    su: "Dom",
+    mo: "Lun",
+    tu: "Mar",
+    we: "Mie",
+    th: "Jue",
+    fr: "Vie",
+    sa: "Sab"
+  };
+  monthsLabels: any = {
+    1: "Ene",
+    2: "Feb",
+    3: "Mar",
+    4: "Abr",
+    5: "May",
+    6: "Jun",
+    7: "Jul",
+    8: "Ago",
+    9: "Sep",
+    10: "Oct",
+    11: "Nov",
+    12: "Dic"
+  };
+  investmentProposalForm: FormGroup;
+  myDpOptions: IAngularMyDpOptions = {
+    dateRange: false,
+    dateFormat: "dd/mm/yyyy",
+    dayLabels: this.daysLabels,
+    monthLabels: this.monthsLabels
+  };
+  myDateInit: boolean = true;
+  m_fecha_vencimiento_compra: IMyDateModel;
+  m_fecha_operacion: IMyDateModel;
+  m_fecha_rendencion: IMyDateModel;
+  m_fecha_liquidacion_compra: IMyDateModel;
+
+  submitted: boolean = false;
+  instrument_exists: boolean;
+  instrument_work: any = [];
+  financials: any;
+  base_types: any;
+
+  proyecciones: any;
+
+  fondosObject: {};
+  dataSource = new MatTableDataSource(this.proyecciones);
+  dataSource2 = new MatTableDataSource(this.proyecciones);
+  hasProjections: boolean;
+  fecha_vencimiento: any;
+  operation_result: boolean = false;
+  operation_results_work: any = [];
+  instrument_work_summary: any = [];
+  cuota_participacion: any;
+  valor_participacion: any;
+  dias_liquidacion: any;
+  dias_vencimiento: any;
+  valor_nominal: any;
+  valor_transado: any;
+  comision_casa_porcentaje: any;
+  comision_casa: any;
+  comision_bolsa_porcentaje: any;
+  comision_bolsa: any;
+  rendimiento_porcentaje: any;
+  dividendo_porcentaje: any;
+  fecha_operacion: any;
+  fecha_liquidacion: any;
+
+  constructor(
+    private formBuilder: FormBuilder,
+    private router: Router,
+    private formDataService: FormInvestmentProposalService,
+    private catalogService: CatalogsService,
+    private instrumentCalcService: InstrumentCalculations,
+    public datepipe: DatePipe
+  ) {
+    this.instrument_work = this.formDataService.getWork();
+
+    this.instrument_exists = this.instrument_work == undefined;
+    this.general = this.formDataService.getGeneralInfo();
+
+    if (
+      this.instrument_work != undefined &&
+      this.instrument_work.proyecciones != ""
+    ) {
+      this.hasProjections = true;
+      this.operation_results_work = this.instrument_work["resultado_operacion"];
+
+      if (this.instrument_work["instrumento"] != undefined) {
+        this.instrument_work = this.instrument_work["instrumento"];
+      }
+      this.instrument_work_summary = this.instrument_work;
+
+      this.dataSource2.data = this.instrument_work.proyecciones;
+      this.dataSource2.paginator = this.paginator;
+      this.dataSource2.sort = this.sort;
+    } else {
+      this.hasProjections = false;
+    }
+
+    if (
+      this.operation_results_work != undefined &&
+      this.operation_results_work != ""
+    ) {
+      this.operation_result = true;
+    }
+
+    this.investmentProposalForm = this.formBuilder.group({
+      cuota_participacion: [
+        this.instrument_exists ? "" : this.instrument_work.cuota_participacion,
+        [
+          Validators.required,
+          Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
+        ]
+      ],
+      valor_participacion: [
+        this.instrument_exists ? "" : this.instrument_work.valor_participacion,
+        [
+          Validators.required,
+          Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
+        ]
+      ],
+
+      comision_casa_porcentaje: [
+        this.instrument_exists
+          ? ""
+          : this.instrument_work.comision_casa_porcentaje,
+        [
+          Validators.required,
+          Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
+        ]
+      ],
+
+      comision_bolsa_porcentaje: [
+        this.instrument_exists
+          ? ""
+          : this.instrument_work.comision_bolsa_porcentaje,
+        [
+          Validators.required,
+          Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
+        ]
+      ],
+
+      dividendo_porcentaje: [
+        this.instrument_exists ? "" : this.instrument_work.dividendo_porcentaje,
+        [
+          Validators.required,
+          Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
+        ]
+      ],
+
+      rendimiento_porcentaje: [
+        this.instrument_exists
+          ? ""
+          : this.instrument_work.rendimiento_porcentaje,
+        [
+          Validators.required,
+          Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
+        ]
+      ],
+
+      dias_liquidacion: [
+        this.instrument_exists ? "" : this.instrument_work.dias_liquidacion,
+        [
+          Validators.required,
+          Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
+        ]
+      ],
+      dias_vencimiento: [
+        this.instrument_exists ? "" : this.instrument_work.dias_vencimiento,
+        [
+          Validators.required,
+          Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
+        ]
+      ],
+
+      fecha_operacion: [
+        this.instrument_exists
+          ? ""
+          : {
+              isRange: false,
+              singleDate: {
+                jsDate: parse(
+                  this.instrument_work.fecha_operacion,
+                  "dd/MM/yyyy",
+                  new Date()
+                ),
+                formatted: this.instrument_work.fecha_operacion
+              }
+            },
+        Validators.required
+      ]
+    });
+  }
+
+  get f() {
+    return this.investmentProposalForm.controls;
+  }
+
+  save(form: any): boolean {
+    if (!form.valid) {
+      return false;
+    }
+
+    this.formDataService.setWork(this.fondosObject);
+    return true;
+  }
+
+  getCalculations(form: any, saveForm: boolean) {
+    this.submitted = true;
+
+    if (!form.valid) {
+      return false;
+    }
+    Swal.fire({
+      allowOutsideClick: false,
+      icon: "info",
+      text: "Espere por favor..."
+    });
+    Swal.showLoading();
+    this.instrumentCalcService
+      .fondosCalc(
+        "FINV", // Codigo del instrumento
+        {
+          id_tipo_base: +this.general.base_anual,
+          id_formato_ingreso: +this.general.formato_ingreso,
+          id_periodicidad: +this.general.periodicidad
+        },
+        {
+          cuota_participacion: +this.f.cuota_participacion.value,
+          valor_participacion: +this.f.valor_participacion.value,
+          comision_bolsa_porcentaje: +this.f.comision_bolsa_porcentaje.value,
+          comision_casa_porcentaje: +this.f.comision_casa_porcentaje.value,
+          dividendo_porcentaje: +this.f.dividendo_porcentaje.value,
+          rendimiento_porcentaje: +this.f.rendimiento_porcentaje.value,
+          dias_liquidacion: this.f.dias_liquidacion.value,
+          dias_vencimiento: this.f.dias_vencimiento.value,
+          fecha_operacion: this.f.fecha_operacion.value.singleDate.formatted
+        }
+      )
+      .subscribe(
+        ans => {
+          this.cuota_participacion = ans["result"]["cuota_participacion"];
+          this.valor_participacion = ans["result"]["valor_participacion"];
+          this.dias_liquidacion = ans["result"]["dias_liquidacion"];
+          this.dias_vencimiento = ans["result"]["dias_vencimiento"];
+          this.valor_nominal = ans["result"]["valor_nominal"];
+          this.valor_transado = ans["result"]["valor_transado"];
+          this.comision_casa_porcentaje =
+            ans["result"]["comision_casa_porcentaje"];
+          this.comision_casa = ans["result"]["comision_casa"];
+          this.comision_bolsa_porcentaje =
+            ans["result"]["comision_bolsa_porcentaje"];
+          this.comision_bolsa = ans["result"]["comision_bolsa"];
+          this.rendimiento_porcentaje = ans["result"]["rendimiento_porcentaje"];
+          this.dividendo_porcentaje = ans["result"]["dividendo_porcentaje"];
+          this.fecha_operacion = ans["result"]["fecha_operacion"];
+          this.fecha_liquidacion = ans["result"]["fecha_liquidacion"];
+          this.fecha_vencimiento = ans["result"]["fecha_vencimiento"];
+
+          // Proyecciones
+          this.proyecciones = ans["result"]["proyecciones"];
+
+          this.operation_result = true;
+          this.dataSource.data = this.proyecciones;
+          this.dataSource2.data = this.proyecciones;
+          this.dataSource.paginator = this.paginator;
+          this.dataSource.sort = this.sort;
+
+          this.fondosObject = {
+            cuota_participacion: this.investmentProposalForm.value
+              .cuota_participacion,
+            valor_participacion: this.investmentProposalForm.value
+              .valor_participacion,
+            comision_bolsa_porcentaje: this.investmentProposalForm.value
+              .comision_bolsa_porcentaje,
+            comision_casa_porcentaje: this.investmentProposalForm.value
+              .comision_casa_porcentaje,
+            dividendo_porcentaje: this.investmentProposalForm.value
+              .dividendo_porcentaje,
+            rendimiento_porcentaje: this.investmentProposalForm.value
+              .rendimiento_porcentaje,
+            dias_liquidacion: this.investmentProposalForm.value
+              .dias_liquidacion,
+            dias_vencimiento: this.investmentProposalForm.value
+              .dias_vencimiento,
+
+            fecha_operacion: this.f.fecha_operacion.value.singleDate.formatted,
+            valor_nominal: this.valor_nominal,
+            valor_transado: this.valor_transado,
+            comision_casa: this.comision_casa,
+            comision_bolsa: this.comision_bolsa,
+            fecha_liquidacion: this.fecha_liquidacion,
+            fecha_vencimiento: this.fecha_vencimiento,
+
+            // Proyecciones
+            proyecciones: this.proyecciones
+          };
+
+          this.formDataService.setWork(this.fondosObject);
+          Swal.close();
+          if (saveForm == true) {
+            if (this.investmentID != undefined) {
+              this.router.navigate(["/investment-proposal/complement-info"], {
+                queryParams: { id: this.investmentID }
+              });
+            } else {
+              this.router.navigate(["/investment-proposal/complement-info"]);
+            }
+          }
+        },
+        err => {
+          Swal.fire({
+            icon: "error",
+            title: "Error en el servidor",
+            text: "No su pudo obtener la informacion"
+          });
+          return false;
+        }
+      );
+  }
+
+  goToPrevious() {
+    this.submitted = true;
+    if (this.investmentID != undefined) {
+      this.router.navigate(["/investment-proposal/general-info"], {
+        queryParams: { id: this.investmentID }
+      });
+    } else {
+      this.router.navigate(["/investment-proposal/general-info"]);
+    }
+  }
+
+  goToNext(form: any) {
+    this.getCalculations(form, true);
+  }
+}

+ 131 - 20
src/app/components/investment-proposals/complement-info/complement-info.component.ts

@@ -65,8 +65,9 @@ export class ComplementInfoComponent implements OnInit {
   operations: any;
   payment_terms: any;
 
-  complementInfoExists: boolean;
+  complementInfoDontExists: boolean;
   companyValue: any;
+  instrumentInfo: any;
   constructor(
     private router: Router,
     private route: ActivatedRoute,
@@ -83,9 +84,13 @@ export class ComplementInfoComponent implements OnInit {
       this.investmentProposalID = this.route.snapshot.queryParamMap.get("id");
 
     this.complementInfo = this.formDataService.getComplementInfo();
-    this.complementInfoExists = this.complementInfo == undefined;
+    this.complementInfoDontExists = this.complementInfo == undefined;
 
-    this.catalogService.getCompanies().subscribe(res => {
+    this.instrumentInfo = this.formDataService.getGeneralInfo().instrumentos;
+    console.log("instrumento");
+    console.log(this.instrumentInfo);
+
+    this.catalogService.getCatalogInfo("companies").subscribe(res => {
       this.companies = res;
 
       if (this.investmentProposalID != undefined) {
@@ -97,14 +102,14 @@ export class ComplementInfoComponent implements OnInit {
           this.companyValue != undefined ? this.companyValue.nombre : "-";
       }
     });
-    this.catalogService.getCountries().subscribe(res => {
+    this.catalogService.getCatalogInfo("paises").subscribe(res => {
       this.countries = res;
     });
 
-    this.catalogService.getMarketTypes().subscribe(res => {
+    this.catalogService.getCatalogInfo("tipos-mercados").subscribe(res => {
       this.markets = res;
     });
-    this.catalogService.getEmitterTypes().subscribe(res => {
+    this.catalogService.getCatalogInfo("tipos-emisores").subscribe(res => {
       this.emitters = res;
     });
 
@@ -120,46 +125,153 @@ export class ComplementInfoComponent implements OnInit {
       this.payment_terms = res;
     });
 
-    this.catalogService.getOperationTypes().subscribe(res => {
+    this.catalogService.getCatalogInfo("tipos-operaciones").subscribe(res => {
       this.operations = res;
     });
 
     this.investmentProposalForm = this.formBuilder.group({
       tipo_mercado: [
-        this.complementInfoExists ? "" : this.complementInfo.tipo_mercado,
+        this.complementInfoDontExists ? "" : this.complementInfo.tipo_mercado,
         [Validators.required]
       ],
 
       emisores: [
-        this.complementInfoExists ? "" : this.complementInfo.emisores,
+        this.complementInfoDontExists ? "" : this.complementInfo.emisores,
         [Validators.required]
       ],
       empresa: [
-        this.complementInfoExists ? "" : this.complementInfo.empresa,
+        this.complementInfoDontExists ? "" : this.complementInfo.empresa,
         [Validators.required]
       ],
       pais: [
-        this.complementInfoExists ? "" : this.complementInfo.pais,
+        this.complementInfoDontExists ? "" : this.complementInfo.pais,
         [Validators.required]
       ],
       plazo: [
-        this.complementInfoExists ? "" : this.complementInfo.plazo,
+        this.complementInfoDontExists ? "" : this.complementInfo.plazo,
         [Validators.required]
       ],
       operaciones: [
-        this.complementInfoExists ? "" : this.complementInfo.operaciones,
+        this.complementInfoDontExists ? "" : this.complementInfo.operaciones,
         [Validators.required]
       ],
 
       comentarios: [
-        this.complementInfoExists ? "" : this.complementInfo.comentarios,
+        this.complementInfoDontExists ? "" : this.complementInfo.comentarios,
         []
       ],
       justificacion: [
-        this.complementInfoExists ? "" : this.complementInfo.justificacion,
+        this.complementInfoDontExists ? "" : this.complementInfo.justificacion,
         []
       ]
     });
+
+    // Set default values depending of the instrument
+    if (this.complementInfoDontExists == true) {
+      switch (this.instrumentInfo) {
+        case "LETE":
+          this.investmentProposalForm.patchValue({
+            emisores: this.investmentProposalForm.value.emisores = 985,
+            pais: this.investmentProposalForm.value.pais = 210
+          });
+
+        case "CETE":
+          this.investmentProposalForm.patchValue({
+            emisores: this.investmentProposalForm.value.emisores = 985,
+            pais: this.investmentProposalForm.value.pais = 210,
+            operaciones: this.investmentProposalForm.value.operaciones = 2
+          });
+          break;
+
+        case "VCN":
+          this.investmentProposalForm.patchValue({
+            operaciones: this.investmentProposalForm.value.operaciones = 2
+          });
+          break;
+
+        case "PBUR":
+          this.investmentProposalForm.patchValue({
+            pais: this.investmentProposalForm.value.pais = 210,
+            operaciones: this.investmentProposalForm.value.operaciones = 2
+          });
+          break;
+
+        case "DAP":
+          this.investmentProposalForm.patchValue({
+            tipo_mercado: this.investmentProposalForm.value.tipo_mercado = 5,
+            operaciones: this.investmentProposalForm.value.operaciones = 2
+          });
+          break;
+
+        case "BONO":
+          this.investmentProposalForm.patchValue({
+            pais: this.investmentProposalForm.value.pais = 210,
+            operaciones: this.investmentProposalForm.value.operaciones = 2
+          });
+          break;
+
+        case "EURB":
+          this.investmentProposalForm.patchValue({
+            pais: this.investmentProposalForm.value.pais = 210,
+            operaciones: this.investmentProposalForm.value.operaciones = 2
+          });
+          break;
+
+        case "CINV":
+          this.investmentProposalForm.patchValue({
+            pais: this.investmentProposalForm.value.pais = 210,
+            operaciones: this.investmentProposalForm.value.operaciones = 2
+          });
+          break;
+
+        case "TIT":
+          this.investmentProposalForm.patchValue({
+            pais: this.investmentProposalForm.value.pais = 210,
+            operaciones: this.investmentProposalForm.value.operaciones = 2
+          });
+          break;
+
+        case "FINV":
+          this.investmentProposalForm.patchValue({
+            tipo_mercado: this.investmentProposalForm.value.tipo_mercado = 5,
+            pais: this.investmentProposalForm.value.pais = 210,
+            operaciones: this.investmentProposalForm.value.operaciones = 2
+          });
+          break;
+
+        case "OPC":
+          this.investmentProposalForm.patchValue({
+            //tipo_mercado: this.investmentProposalForm.value.tipo_mercado = 0,
+            pais: this.investmentProposalForm.value.pais = 233,
+            operaciones: this.investmentProposalForm.value.operaciones = 2
+          });
+          break;
+
+        case "FUTU":
+          this.investmentProposalForm.patchValue({
+            //tipo_mercado: this.investmentProposalForm.value.tipo_mercado = 0,
+            pais: this.investmentProposalForm.value.pais = 233,
+            operaciones: this.investmentProposalForm.value.operaciones = 2
+          });
+          break;
+
+        case "PEMP":
+          this.investmentProposalForm.patchValue({
+            tipo_mercado: this.investmentProposalForm.value.tipo_mercado = 5,
+            pais: this.investmentProposalForm.value.pais = 210,
+            operaciones: this.investmentProposalForm.value.operaciones = 2
+          });
+          break;
+
+        case "PPER":
+          this.investmentProposalForm.patchValue({
+            tipo_mercado: this.investmentProposalForm.value.tipo_mercado = 5,
+            pais: this.investmentProposalForm.value.pais = 210,
+            operaciones: this.investmentProposalForm.value.operaciones = 2
+          });
+          break;
+      }
+    }
   }
 
   get f() {
@@ -167,9 +279,10 @@ export class ComplementInfoComponent implements OnInit {
   }
 
   save(form: any): boolean {
-    //if (!form.valid) {
-    //return false;
-    //}
+    this.submitted = true;
+    if (!form.valid) {
+      return false;
+    }
     this.formDataService.setComplementInfo(this.investmentProposalForm.value);
     return true;
   }
@@ -186,8 +299,6 @@ export class ComplementInfoComponent implements OnInit {
   }
 
   goToNext(form: any) {
-    this.submitted = true;
-
     if (this.save(form)) {
       if (this.investmentProposalID != undefined) {
         this.router.navigate(["/investment-proposal/result"], {

+ 55 - 53
src/app/components/investment-proposals/general-info/general-info.component.html

@@ -128,6 +128,60 @@
                         </div>
                       </div>
                     </div>
+
+                    <div class="col-lg-6 col-sm-12 pr-xl-3">
+                      <div class="form-group">
+                        <label for="instrumentos">Instrumentos: </label>
+                        <ng-container
+                          *ngIf="
+                            investmentProposalID == undefined;
+                            else elseTemplate
+                          "
+                        >
+                          <select
+                            class="custom-select"
+                            formControlName="instrumentos"
+                            [ngClass]="{
+                              'is-invalid': submitted && f.instrumentos.errors
+                            }"
+                            (change)="pre_filled_fields($event)"
+                          >
+                            <option
+                              *ngFor="let item of instrumentTypes"
+                              [selected]="item.codigo == general.instrumentos"
+                              [value]="item.codigo"
+                            >
+                              {{ item.nombre }}</option
+                            >
+                          </select>
+                        </ng-container>
+                        <ng-template #elseTemplate>
+                          <input
+                            type="text"
+                            [value]="instrumentValue"
+                            name="x"
+                            class="form-control"
+                            readonly
+                          />
+                          <input
+                            type="hidden"
+                            formControlName="instrumentos"
+                            class="form-control"
+                            [value]="general.instrumentos"
+                            readonly
+                          />
+                        </ng-template>
+                        <div
+                          *ngIf="submitted && f.instrumentos.errors"
+                          class="invalid-feedback"
+                        >
+                          <div *ngIf="f.instrumentos.errors.required">
+                            Campo requerido
+                          </div>
+                        </div>
+                      </div>
+                    </div>
+
                     <div class="col-lg-6 col-sm-12 pr-xl-3">
                       <div class="form-group">
                         <label for="tipo_tasa">Tipo Tasa: </label>
@@ -156,8 +210,7 @@
                         </div>
                       </div>
                     </div>
-                  </div>
-                  <div class="row">
+
                     <div class="col-lg-6 col-sm-12 pr-xl-3">
                       <div class="form-group">
                         <label for="tipo_renta">Tipo Renta: </label>
@@ -188,57 +241,6 @@
                         </div>
                       </div>
                     </div>
-                    <div class="col-lg-6 col-sm-12 pr-xl-3">
-                      <div class="form-group">
-                        <label for="instrumentos">Instrumentos: </label>
-                        <ng-container
-                          *ngIf="
-                            investmentProposalID == undefined;
-                            else elseTemplate
-                          "
-                        >
-                          <select
-                            class="custom-select"
-                            formControlName="instrumentos"
-                            [ngClass]="{
-                              'is-invalid': submitted && f.instrumentos.errors
-                            }"
-                          >
-                            <option
-                              *ngFor="let item of instrumentTypes"
-                              [selected]="item.codigo == general.instrumentos"
-                              [value]="item.codigo"
-                            >
-                              {{ item.nombre }}</option
-                            >
-                          </select>
-                        </ng-container>
-                        <ng-template #elseTemplate>
-                          <input
-                            type="text"
-                            [value]="instrumentValue"
-                            name="x"
-                            class="form-control"
-                            readonly
-                          />
-                          <input
-                            type="hidden"
-                            formControlName="instrumentos"
-                            class="form-control"
-                            [value]="general.instrumentos"
-                            readonly
-                          />
-                        </ng-template>
-                        <div
-                          *ngIf="submitted && f.instrumentos.errors"
-                          class="invalid-feedback"
-                        >
-                          <div *ngIf="f.instrumentos.errors.required">
-                            Campo requerido
-                          </div>
-                        </div>
-                      </div>
-                    </div>
 
                     <div class="col-lg-6 col-sm-12 pr-xl-3">
                       <div class="form-group">

+ 116 - 0
src/app/components/investment-proposals/general-info/general-info.component.ts

@@ -350,4 +350,120 @@ export class InvestmentProposalGeneralInfoComponent
   get f() {
     return this.investmentProposalForm.controls;
   }
+
+  pre_filled_fields(event: any) {
+    const selectedInstrument = (event.target as HTMLInputElement).value;
+    switch (selectedInstrument) {
+      case "LETE":
+        this.investmentProposalForm.patchValue({
+          tipo_tasa: this.investmentProposalForm.value.tipo_tasa = 2,
+          tipo_renta: this.investmentProposalForm.value.tipo_renta = 2,
+          periodicidad: this.investmentProposalForm.value.periodicidad = 7,
+          base_anual: 6
+        });
+
+      case "CETE":
+        this.investmentProposalForm.patchValue({
+          tipo_tasa: this.investmentProposalForm.value.tipo_tasa = 2,
+          tipo_renta: this.investmentProposalForm.value.tipo_renta = 2,
+          periodicidad: this.investmentProposalForm.value.periodicidad = 7,
+          base_anual: 6
+        });
+        break;
+
+      case "VCN":
+        this.investmentProposalForm.patchValue({
+          tipo_tasa: this.investmentProposalForm.value.tipo_tasa = 2,
+          tipo_renta: this.investmentProposalForm.value.tipo_renta = 2
+        });
+        break;
+
+      case "PBUR":
+        this.investmentProposalForm.patchValue({
+          tipo_tasa: this.investmentProposalForm.value.tipo_tasa = 2,
+          tipo_renta: this.investmentProposalForm.value.tipo_renta = 2
+        });
+        break;
+
+      case "DAP":
+        this.investmentProposalForm.patchValue({
+          tipo_tasa: this.investmentProposalForm.value.tipo_tasa = 2,
+          tipo_renta: this.investmentProposalForm.value.tipo_renta = 2,
+          base_anual: 8
+        });
+        break;
+
+      case "BONO":
+        this.investmentProposalForm.patchValue({
+          tipo_tasa: this.investmentProposalForm.value.tipo_tasa = 2,
+          tipo_renta: this.investmentProposalForm.value.tipo_renta = 2,
+          base_anual: 7
+        });
+        break;
+
+      case "EURB":
+        this.investmentProposalForm.patchValue({
+          tipo_tasa: this.investmentProposalForm.value.tipo_tasa = 2,
+          tipo_renta: this.investmentProposalForm.value.tipo_renta = 2,
+          base_anual: 6
+        });
+        break;
+
+      case "CINV":
+        this.investmentProposalForm.patchValue({
+          tipo_tasa: this.investmentProposalForm.value.tipo_tasa = 2,
+          tipo_renta: this.investmentProposalForm.value.tipo_renta = 2,
+          base_anual: 7
+        });
+        break;
+
+      case "TIT":
+        this.investmentProposalForm.patchValue({
+          tipo_tasa: this.investmentProposalForm.value.tipo_tasa = 2,
+          tipo_renta: this.investmentProposalForm.value.tipo_renta = 2,
+          base_anual: 7
+        });
+        break;
+
+      case "FINV":
+        this.investmentProposalForm.patchValue({
+          tipo_tasa: this.investmentProposalForm.value.tipo_tasa = 2,
+          tipo_renta: this.investmentProposalForm.value.tipo_renta = 2,
+          base_anual: 7
+        });
+        break;
+
+      case "OPC":
+        this.investmentProposalForm.patchValue({
+          tipo_tasa: this.investmentProposalForm.value.tipo_tasa = 3,
+          tipo_renta: this.investmentProposalForm.value.tipo_renta = 3,
+          base_anual: 7
+        });
+        break;
+
+      case "FUTU":
+        this.investmentProposalForm.patchValue({
+          tipo_tasa: this.investmentProposalForm.value.tipo_tasa = 3,
+          tipo_renta: this.investmentProposalForm.value.tipo_renta = 3,
+          base_anual: 7
+        });
+        break;
+
+      case "PEMP":
+        this.investmentProposalForm.patchValue({
+          tipo_tasa: this.investmentProposalForm.value.tipo_tasa = 2,
+          tipo_renta: this.investmentProposalForm.value.tipo_renta = 2,
+          base_anual: 7
+        });
+        break;
+
+      case "PPER":
+        this.investmentProposalForm.patchValue({
+          tipo_tasa: this.investmentProposalForm.value.tipo_tasa = 2,
+          tipo_renta: this.investmentProposalForm.value.tipo_renta = 2,
+          base_anual: 7
+        });
+        break;
+    }
+  }
 }

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

@@ -81,6 +81,7 @@ import { TIT } from "@app/components/instruments/titulos/titulos.component";
 import { EURB } from "@app/components/instruments/eurobonos/eurobonos.component";
 import { CINV } from "@app/components/instruments/certificados/certificados.component";
 import { MatPaginatorIntlSpa } from "@app/models/i18n-paginator";
+import { FINV } from "@app/components/instruments/fondos/fondos.component";
 
 // This array defines which "componentId" maps to which lazy-loaded module.
 
@@ -146,6 +147,7 @@ import { MatPaginatorIntlSpa } from "@app/models/i18n-paginator";
     TIT,
     EURB,
     CINV,
+    FINV,
     ANCComponent,
     APNComponent,
     InstrumentDirective,
@@ -169,6 +171,7 @@ import { MatPaginatorIntlSpa } from "@app/models/i18n-paginator";
     TIT,
     EURB,
     CINV,
+    FINV,
     ANCComponent,
     APNComponent
   ]

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

@@ -166,6 +166,40 @@ export class InstrumentCalculations {
       );
   }
 
+  // Fondos de inversion
+  fondosCalc(
+    codigo_instrumento: string,
+    info_inversion: {
+      id_tipo_base: number;
+      id_periodicidad: number;
+      id_formato_ingreso: number;
+    },
+    info_instrumento: {
+      cuota_participacion: number;
+      valor_participacion: number;
+      comision_bolsa_porcentaje: number;
+      comision_casa_porcentaje: number;
+      dividendo_porcentaje: number;
+      rendimiento_porcentaje: number;
+      dias_liquidacion: number;
+      dias_vencimiento: number;
+      fecha_operacion: string;
+    }
+  ): Observable<boolean> {
+    return this.http
+      .post<any>(`${environment.productionApiUrl}/autocomplete`, {
+        codigo_instrumento,
+        info_inversion,
+        info_instrumento
+      })
+      .pipe(
+        map(response => {
+          return response;
+        }),
+        catchError(this.errorHandl)
+      );
+  }
+
   // Para vcn
   vcnCalc(
     codigo_instrumento: string,

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

@@ -13,6 +13,7 @@ import { APNComponent } from "@app/components/instruments/apn/apn.component";
 import { CINV } from "@app/components/instruments/certificados/certificados.component";
 import { EURB } from "@app/components/instruments/eurobonos/eurobonos.component";
 import { TIT } from "@app/components/instruments/titulos/titulos.component";
+import { FINV } from "@app/components/instruments/fondos/fondos.component";
 
 @Injectable({
   providedIn: "root"
@@ -37,6 +38,8 @@ export class InstrumentsService {
         key: "DAP",
         name: "Depósitos a plazo"
       }),
+      new Instrument(FINV, { key: "FINV", name: "Fondo de inversión" }),
+
       new Instrument(ANCComponent, {
         key: "ANC",
         name: "Acciones nacionales comunes"