Prechádzať zdrojové kódy

Info del instrumento, correcciones en servicios del instrumento, formulario de info de pago

Oscar José Nuñez Chávez 5 rokov pred
rodič
commit
e1bff69749

+ 6 - 0
src/app/components/instruments/pbur/pbur.component.ts

@@ -126,6 +126,10 @@ export class PBUR implements InstrumentComponent {
           Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
         ]
       ],
+      plazo: [
+        this.instrument_exists ? "" : this.instrument_work.plazo,
+        [Validators.required]
+      ],
       rendimiento_bruto: [
         this.instrument_exists ? "" : this.instrument_work.rendimiento_bruto,
         [
@@ -220,6 +224,7 @@ export class PBUR implements InstrumentComponent {
         .comision_bolsa_porcentaje,
       rendimiento_bruto: this.investmentProposalForm.value.rendimiento_bruto,
       otros_costos: this.investmentProposalForm.value.otros_costos,
+      plazo: this.investmentProposalForm.value.plazo,
       //id_formato_ingreso: this.investmentProposalForm.value.id_formato_ingreso,
 
       fecha_operacion: this.investmentProposalForm.value.fecha_operacion
@@ -271,6 +276,7 @@ export class PBUR implements InstrumentComponent {
             this.f.comision_bolsa_porcentaje.value / 100,
           rendimiento_bruto: this.f.rendimiento_bruto.value / 100,
           otros_costos: this.f.otros_costos.value,
+          plazo: this.f.plazo.value,
           renta_porcentaje: this.f.renta_porcentaje.value,
           //id_formato_ingreso: this.f.formato_ingreso.value,
           fecha_operacion: this.f.fecha_operacion.value.singleDate.formatted,

+ 6 - 1
src/app/components/instruments/vcn/vcn.component.ts

@@ -104,6 +104,10 @@ export class VCN implements InstrumentComponent {
         this.instrument_exists ? "" : this.instrument_work.otros_costos,
         [Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)]
       ],
+      plazo: [
+        this.instrument_exists ? "" : this.instrument_work.plazo,
+        [Validators.required]
+      ],
       renta_porcentaje: [
         this.instrument_exists ? "" : this.instrument_work.renta_porcentaje,
         [Validators.required]
@@ -221,7 +225,7 @@ export class VCN implements InstrumentComponent {
       rendimiento_bruto: this.investmentProposalForm.value.rendimiento_bruto,
       otros_costos: this.investmentProposalForm.value.otros_costos,
       //id_formato_ingreso: this.investmentProposalForm.value.id_formato_ingreso,
-
+      plazo: this.investmentProposalForm.value.plazo,
       fecha_operacion: this.investmentProposalForm.value.fecha_operacion
         .singleDate.formatted,
       fecha_liquidacion:
@@ -271,6 +275,7 @@ export class VCN implements InstrumentComponent {
             this.f.comision_bolsa_porcentaje.value / 100,
           rendimiento_bruto: this.f.rendimiento_bruto.value / 100,
           otros_costos: this.f.otros_costos.value,
+          plazo: this.f.plazo.value,
           renta_porcentaje: this.f.renta_porcentaje.value,
           //id_formato_ingreso: this.f.formato_ingreso.value,
           fecha_operacion: this.f.fecha_operacion.value.singleDate.formatted,

+ 0 - 20
src/app/components/investment-proposals/general-info/general-info.component.html

@@ -100,26 +100,6 @@
                           </div>
                         </div>
                       </div>
-                      <!--
-                      <div class="form-group">
-                        <label for="codigo">Codigo: </label>
-                        <input
-                          type="text"
-                          formControlName="codigo"
-                          class="form-control"
-                          [ngClass]="{
-                            'is-invalid': submitted && f.codigo.errors
-                          }"
-                        />
-                        <div
-                          *ngIf="submitted && f.codigo.errors"
-                          class="invalid-feedback"
-                        >
-                          <div *ngIf="f.codigo.errors.required">
-                            Campo requerido
-                          </div>
-                        </div>
-                      </div>-->
                     </div>
                     <div class="col-lg-6 col-sm-12 pr-xl-3">
                       <div class="form-group">

+ 7 - 2
src/app/components/investment-proposals/general-info/general-info.component.ts

@@ -96,6 +96,7 @@ export class InvestmentProposalGeneralInfoComponent
   ) {}
 
   ngOnInit() {
+    Swal.close();
     this.route.params.subscribe(params => {
       this.investmentProposalID = params["id"];
     });
@@ -186,11 +187,13 @@ export class InvestmentProposalGeneralInfoComponent
 
             // Setear objeto dinamico con valores obtenidos del endpoint
             this.general = this.formDataService.getGeneralInfo();
-
+            console.log("GENERAL");
+            console.log(this.general);
             // Validar que el objeto dinamico contenga valores, si no, setear con valores obtenidos del endpoint
             if (
               Object.values(this.general).every(x => x === null || x === "")
             ) {
+              console.log("I GOT HERE");
               this.formDataService.setGeneralInfo(this.gInfo);
               this.general = this.formDataService.getGeneralInfo();
               this.generalInfoDontExists = this.general == undefined;
@@ -286,7 +289,9 @@ export class InvestmentProposalGeneralInfoComponent
     this.callForm(this.generalInfoDontExists, this.general);
   }
 
-  ngOnChanges() {}
+  ngOnChanges() {
+    console.log("CHANGES");
+  }
 
   save(form: any): boolean {
     if (!form.valid) {

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

@@ -107,8 +107,7 @@
                         "
                         title="Editar"
                         class="btn btn-primary btn-custom-small"
-                        [routerLink]="['/investment-proposal/general-info']"
-                        [queryParams]="{ id: row.id_inversion }"
+                        (click)="modify_investment_proposal(row.id_inversion)"
                       >
                         <i class="fas fa-edit"></i>
                       </a>
@@ -138,6 +137,17 @@
                       >
                         <i class="fas fa-spell-check"></i>
                       </a>
+                      <a
+                        title="Informacion de pago"
+                        class="btn btn-warning btn-custom-small"
+                        [routerLink]="[
+                          '/investment-proposal',
+                          row.id_inversion,
+                          'payment-info'
+                        ]"
+                      >
+                        <i class="fas fa-money-check-alt"></i>
+                      </a>
                       <a
                         title="Historico"
                         class="btn btn-link btn-custom-small"

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

@@ -9,6 +9,8 @@ import { AuthService } from "@app/services/auth2.service";
 import { JwtHelperService } from "@auth0/angular-jwt";
 import { InvestmentProposal } from "@app/models/investment-proposal";
 import { from } from "rxjs";
+import { FormInvestmentProposalService } from "@app/services/form-investment-proposal.service";
+import { Router } from "@angular/router";
 
 @Component({
   selector: "app-investment-proposals",
@@ -46,7 +48,8 @@ export class InvestmentProposalsComponent implements OnInit {
     private catalogService: CatalogsService,
     private investmentsService: InvestmentsService,
     private authService: AuthService,
-    private investmentService: InvestmentsService
+    private formInvestmentProposal: FormInvestmentProposalService,
+    private router: Router
   ) {
     const decodedToken = this.helper.decodeToken(
       this.authService.getJwtToken()
@@ -57,9 +60,9 @@ export class InvestmentProposalsComponent implements OnInit {
     });
     console.log(decodedToken);
     this.userRole = decodedToken.groups;
-    console.log("User role");
-    console.log(this.userRole);
-    console.log(this.userRole.length == 0);
+    //    console.log("User role");
+    //  console.log(this.userRole);
+    //console.log(this.userRole.length == 0);
 
     this.dataSource.filterPredicate = (data, filter) => {
       const dataStr =
@@ -114,6 +117,22 @@ export class InvestmentProposalsComponent implements OnInit {
     }
   }
 
+  modify_investment_proposal(id: string) {
+    this.formInvestmentProposal.resetFormData();
+
+    Swal.fire({
+      allowOutsideClick: false,
+      icon: "info",
+      text: "Espere por favor..."
+    });
+    Swal.showLoading();
+    setTimeout(() => {
+      this.router.navigate(["/investment-proposal/general-info"], {
+        queryParams: { id: id }
+      });
+    }, 1000);
+  }
+
   // Verifica permisos para mostrar boton de edicion y/o envio a revision,
   // segun los permisos del usuario y el estado de la propuesta
   can_modify_or_send_to_review(status: string) {
@@ -157,7 +176,7 @@ export class InvestmentProposalsComponent implements OnInit {
           comentario: comentario
         };
 
-        this.investmentService
+        this.investmentsService
           .sendReviewProposalInvestment(reviewProposal)
           .subscribe(
             success => {

+ 225 - 0
src/app/components/investment-proposals/payment-info/payment-info.component.html

@@ -0,0 +1,225 @@
+<h2 class="floating-title">{{ title }}</h2>
+
+<div class="main-content">
+  <div class="container-fluid">
+    <div class="row">
+      <div class="col-12 align-right">
+        <div class="align-container">
+          <nav aria-label="breadcrumb">
+            <ol class="breadcrumb">
+              <li class="breadcrumb-item">
+                <a [routerLink]="['/']">Dashboard</a>
+              </li>
+              <li class="breadcrumb-item">
+                <a [routerLink]="['/investment-proposals']">
+                  Propuestas de inversión
+                </a>
+              </li>
+              <li class="breadcrumb-item">Nueva</li>
+            </ol>
+          </nav>
+        </div>
+      </div>
+
+      <br />
+    </div>
+    <br />
+    <div class="row justify-content-center">
+      <div class="col-12">
+        <div class="card borderless card-wrapper">
+          <div class="card-header card-header-icon card-header-rose">
+            <br />
+            <h4 class="card-title">
+              Información de pago para la inversión: {{ inversionCode }}
+            </h4>
+          </div>
+          <div class="card-body">
+            <form
+              class="form-auth-small ng-untouched ng-pristine ng-valid"
+              [formGroup]="investmentProposalForm"
+            >
+              <div class="row">
+                <!-- Valor nominal -->
+                <div class="col-lg-6 col-sm-12 pr-xl-3">
+                  <div class="form-group">
+                    <label for="monto">Monto: </label>
+                    <div class="input-box-container">
+                      <p>
+                        <i class="fas fa-dollar-sign"></i>
+                      </p>
+                      <input
+                        type="text"
+                        formControlName="monto"
+                        class="form-control"
+                        [ngClass]="{
+                          'is-invalid': submitted && f.monto.errors
+                        }"
+                      />
+                      <div
+                        *ngIf="submitted && f.monto.errors"
+                        class="invalid-feedback"
+                      >
+                        <div *ngIf="f.monto.errors.required">
+                          Campo requerido
+                        </div>
+                        <div *ngIf="f.monto.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="payment_types">Tipo pago: </label>
+
+                    <select
+                      class="custom-select"
+                      formControlName="payment_types"
+                      [ngClass]="{
+                        'is-invalid': submitted && f.payment_types.errors
+                      }"
+                    >
+                      <option
+                        *ngFor="let item of funds"
+                        [value]="item.id_payment_types"
+                        [selected]="
+                          item.id_payment_types == general.payment_types
+                        "
+                      >
+                        {{ item.nombre }}</option
+                      >
+                    </select>
+                    <div
+                      *ngIf="submitted && f.payment_types.errors"
+                      class="invalid-feedback"
+                    >
+                      <div *ngIf="f.payment_types.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="cuenta_bancaria">Cuenta bancaria: </label>
+
+                    <select
+                      class="custom-select"
+                      formControlName="cuenta_bancaria"
+                      [ngClass]="{
+                        'is-invalid': submitted && f.cuenta_bancaria.errors
+                      }"
+                    >
+                      <option
+                        *ngFor="let item of funds"
+                        [value]="item.id_cuenta_bancaria"
+                        [selected]="
+                          item.id_cuenta_bancaria == general.cuenta_bancaria
+                        "
+                      >
+                        {{ item.nombre }}</option
+                      >
+                    </select>
+                    <div
+                      *ngIf="submitted && f.cuenta_bancaria.errors"
+                      class="invalid-feedback"
+                    >
+                      <div *ngIf="f.cuenta_bancaria.errors.required">
+                        Campo requerido
+                      </div>
+                    </div>
+                  </div>
+                </div>
+
+                <!-- Fecha operación -->
+                <div class="col-lg-6 col-sm-12 pr-xl-3">
+                  <div class="form-group">
+                    <label for="fecha_pago">Fecha pago: </label>
+                    <div class="input-box-container">
+                      <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_pago"
+                        (click)="dp.toggleCalendar()"
+                        [options]="myDpOptions"
+                        #dp="angular-mydatepicker"
+                        [ngClass]="{
+                          'is-invalid': submitted && f.fecha_pago.errors
+                        }"
+                      />
+                    </div>
+
+                    <div
+                      *ngIf="submitted && f.fecha_pago.errors"
+                      class="invalid-feedback"
+                    >
+                      <div *ngIf="f.fecha_pago.errors.required">
+                        Campo requerido
+                      </div>
+                    </div>
+                  </div>
+                </div>
+
+                <!-- Fecha vencimiento -->
+                <div class="col-lg-6 col-sm-12 pr-xl-3">
+                  <div class="form-group">
+                    <label for="fecha_vencimiento">Fecha vencimiento: </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_vencimiento"
+                          (click)="dp2.toggleCalendar()"
+                          [options]="myDpOptions"
+                          #dp2="angular-mydatepicker"
+                          [ngClass]="{
+                            'is-invalid':
+                              submitted && f.fecha_vencimiento.errors
+                          }"
+                        />
+                      </div>
+                    </div>
+
+                    <div
+                      *ngIf="submitted && f.fecha_vencimiento.errors"
+                      class="invalid-feedback"
+                    >
+                      <div *ngIf="f.fecha_vencimiento.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 class="btn btn-primary center-component">
+                      Enviar información de pago
+                    </button>
+                  </div>
+                </div>
+              </div>
+
+              <!-- [disabled]="!investmentProposalForm.valid"
+                                        <div *ngIf="error" class="alert alert-danger mt-3 mb-0">{{error}}</div>-->
+            </form>
+          </div>
+        </div>
+      </div>
+    </div>
+  </div>
+</div>

+ 163 - 0
src/app/components/investment-proposals/payment-info/payment-info.component.ts

@@ -0,0 +1,163 @@
+import { Component, OnInit } from "@angular/core";
+import { FormInvestmentProposalService } from "@app/services/form-investment-proposal.service";
+import { FormBuilder, FormGroup, Validators } from "@angular/forms";
+import { CatalogsService } from "@app/services/catalogs.service";
+import { IAngularMyDpOptions, IMyDateModel } from "angular-mydatepicker";
+import { formatDate, DatePipe } from "@angular/common";
+import { parse } from "date-fns";
+import { Router, ActivatedRoute } from "@angular/router";
+import { InvestmentsService } from "@app/services/investments.service";
+import Swal from "sweetalert2";
+
+@Component({
+  selector: "app-payment-info",
+  templateUrl: "./payment-info.component.html"
+})
+export class PaymentInfoComponent implements OnInit {
+  title: string = "Formulario de información para el pago";
+
+  form: any;
+
+  // 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"
+  };
+  myDpOptions: IAngularMyDpOptions = {
+    dateRange: false,
+    dateFormat: "dd/mm/yyyy",
+    dayLabels: this.daysLabels,
+    monthLabels: this.monthsLabels
+  };
+  myDateInit: boolean = true;
+
+  investmentProposalForm: FormGroup;
+  submitted: boolean = false;
+  role_number: any;
+  markets: any;
+  emitters: any;
+  periodicities: any;
+  rate_agencies: any;
+  scores: any;
+  investmentProposalID: string;
+  countries: any;
+  companies: any;
+  format_incomes: any;
+  operations: any;
+  payment_terms: any;
+  payment_types: any;
+  inversionCode: any;
+
+  constructor(
+    private router: Router,
+    private route: ActivatedRoute,
+    private formBuilder: FormBuilder,
+    private formDataService: FormInvestmentProposalService,
+    private catalogService: CatalogsService,
+    private investmentsService: InvestmentsService
+  ) {}
+
+  ngOnInit() {
+    this.route.params.subscribe(params => {
+      this.investmentProposalID = params["id"];
+    });
+    if (this.investmentProposalID == undefined)
+      this.investmentProposalID = this.route.snapshot.queryParamMap.get("id");
+
+    this.investmentsService
+      .getProposalInvestment(this.investmentProposalID)
+      .subscribe(
+        res => {
+          console.log("results");
+          console.log(res);
+          console.log("-------");
+          this.inversionCode = res["result"]["codigo_inversion"];
+        },
+        err => {
+          Swal.fire({
+            icon: "error",
+            title: "Error en el servidor",
+            text: err.message
+          });
+        }
+      );
+
+    this.catalogService.getPaymentTypes().subscribe(res => {
+      this.payment_types = res;
+    });
+    this.catalogService.getCountries().subscribe(res => {
+      this.countries = res;
+    });
+
+    this.investmentProposalForm = this.formBuilder.group({
+      monto: [
+        "",
+        [
+          Validators.required,
+          Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
+        ]
+      ],
+      payment_types: ["", [Validators.required]],
+      cuenta_bancaria: [""],
+      fecha_pago: ["", Validators.required],
+      fecha_vencimiento: ["", Validators.required]
+    });
+  }
+
+  get f() {
+    return this.investmentProposalForm.controls;
+  }
+
+  save(form: any): boolean {
+    //if (!form.valid) {
+    //return false;
+    //}
+    console.log(this.investmentProposalForm.value);
+    this.formDataService.setComplementInfo(this.investmentProposalForm.value);
+    return true;
+  }
+
+  goToPrevious(form: any) {
+    this.submitted = true;
+    if (this.investmentProposalID != undefined) {
+      this.router.navigate(["/investment-proposal/instrument-work"], {
+        queryParams: { id: this.investmentProposalID }
+      });
+    } else {
+      this.router.navigate(["/investment-proposal/instrument-work"]);
+    }
+  }
+
+  goToNext(form: any) {
+    this.submitted = true;
+
+    if (this.save(form)) {
+      if (this.investmentProposalID != undefined) {
+        this.router.navigate(["/investment-proposal/result"], {
+          queryParams: { id: this.investmentProposalID }
+        });
+      } else {
+        this.router.navigate(["/investment-proposal/result"]);
+      }
+    }
+  }
+}

+ 12 - 1
src/app/components/investment-proposals/result/result.component.html

@@ -152,7 +152,18 @@
                               {{ countries }}
                             </div>
                           </div>
-
+                          <div class="col-lg-3 col-md-4 col-sm-6">
+                            <h4>Plazo:</h4>
+                            <div class="field">
+                              {{ payment_terms }}
+                            </div>
+                          </div>
+                          <div class="col-lg-3 col-md-4 col-sm-6">
+                            <h4>Tipos de operaciones:</h4>
+                            <div class="field">
+                              {{ operations }}
+                            </div>
+                          </div>
                           <div class="col-lg-3 col-md-4 col-sm-6">
                             <h4>Comentarios:</h4>
                             <div class="field">

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

@@ -51,8 +51,7 @@ export class ResultComponent implements OnInit {
   markets: any;
   emitters: any;
   periodicities: any;
-  rate_agencies: any;
-  scores: any;
+  operations: any;
   format_incomes: any;
   base_types: any;
   payment_terms: any;
@@ -189,16 +188,17 @@ export class ResultComponent implements OnInit {
       this.periodicities =
         this.periodicities != undefined ? this.periodicities.nombre : "-";
     });
-    this.catalogService.getRateAgencies().subscribe(res => {
-      this.rate_agencies = res.find(
+    this.catalogService.getPaymentTerms().subscribe(res => {
+      this.payment_terms = res.find(
         e => e.codigo == this.complement.calificadora_riesgo
       );
-      this.rate_agencies =
-        this.rate_agencies != undefined ? this.rate_agencies.nombre : "-";
+      this.payment_terms =
+        this.payment_terms != undefined ? this.payment_terms.nombre : "-";
     });
-    this.catalogService.getScores().subscribe(res => {
-      this.scores = res.find(e => e.codigo == this.complement.calificacion);
-      this.scores = this.scores != undefined ? this.scores.nombre : "-";
+    this.catalogService.getOperationTypes().subscribe(res => {
+      this.operations = res.find(e => e.codigo == this.complement.operaciones);
+      this.operations =
+        this.operations != undefined ? this.operations.nombre : "-";
     });
 
     //getIncomeFormat

+ 54 - 49
src/app/components/investment-proposals/review/review.component.html

@@ -49,114 +49,119 @@
                           <div class="col-lg-3 col-md-4 col-sm-6">
                             <h4>Asunto:</h4>
                             <div class="field">
-                              {{ general.asunto }}
+                              {{ subject }}
                             </div>
+                          </div>
+                          <div class="col-lg-3 col-md-4 col-sm-6">
                             <h4>Orígenes de fondo:</h4>
                             <div class="field">
-                              {{ general.origenes_fondo }}
+                              {{ funds }}
                             </div>
                           </div>
                           <div class="col-lg-3 col-md-4 col-sm-6">
                             <h4>Nombre:</h4>
                             <div class="field">
-                              {{ general.name }}
-                            </div>
-                            <h4>Fecha:</h4>
-                            <div class="field">
-                              {{ general.date }}
+                              {{ investmentName }}
                             </div>
                           </div>
                           <div class="col-lg-3 col-md-4 col-sm-6">
                             <h4>Tipo Tasa:</h4>
                             <div class="field">
-                              {{ general.tipo_tasa }}
+                              {{ rates }}
                             </div>
+                          </div>
+                          <div class="col-lg-3 col-md-4 col-sm-6">
                             <h4>Tipo Renta:</h4>
                             <div class="field">
-                              {{ general.tipo_renta }}
+                              {{ revenues }}
                             </div>
                           </div>
                           <div class="col-lg-3 col-md-4 col-sm-6">
-                            <h4>Empresa:</h4>
+                            <h4>Periodicidad:</h4>
                             <div class="field">
-                              {{ general.empresa }}
+                              {{ periodicities }}
                             </div>
-                            <h4>País:</h4>
+                          </div>
+                          <div class="col-lg-3 col-md-4 col-sm-6">
+                            <h4>Instrumentos:</h4>
                             <div class="field">
-                              {{ general.pais }}
+                              {{ instrumentTypes }}
                             </div>
                           </div>
                           <div class="col-lg-3 col-md-4 col-sm-6">
-                            <h4>Instrumentos:</h4>
+                            <h4>Casa:</h4>
                             <div class="field">
-                              {{ general.instrumentos }}
+                              {{ financials }}
+                            </div>
+                          </div>
+                          <div class="col-lg-3 col-md-4 col-sm-6">
+                            <h4>Base:</h4>
+                            <div class="field">
+                              {{ base_types }}
                             </div>
                           </div>
-                        </div>
-                      </div>
-                    </div>
-                  </li>
-                  <li class="timeline-inverted">
-                    <div class="timeline-badge"></div>
-                    <div class="timeline-panel">
-                      <div class="timeline-heading">
-                        <span class="badge badge-warning">Instrumento</span>
-                        <ng-template instrument-host></ng-template>
-                      </div>
-                    </div>
-                  </li>
-                  <li class="timeline-inverted">
-                    <div class="timeline-badge"></div>
-                    <div class="timeline-panel">
-                      <div class="timeline-heading">
-                        <span class="badge badge-primary"
-                          >Información complementaria</span
-                        >
-                      </div>
-                      <div class="timeline-body">
-                        <div class="row">
                           <div class="col-lg-3 col-md-4 col-sm-6">
                             <h4>Tipo de mercado:</h4>
                             <div class="field">
-                              {{ complement.tipo_mercado }}
+                              {{ markets }}
                             </div>
+                          </div>
+                          <div class="col-lg-3 col-md-4 col-sm-6">
                             <h4>Emisores:</h4>
                             <div class="field">
-                              {{ complement.emisores }}
+                              {{ emitters }}
                             </div>
                           </div>
                           <div class="col-lg-3 col-md-4 col-sm-6">
-                            <h4>Periodicidad:</h4>
+                            <h4>Empresa:</h4>
+                            <div class="field">
+                              {{ companies }}
+                            </div>
+                          </div>
+                          <div class="col-lg-3 col-md-4 col-sm-6">
+                            <h4>País:</h4>
                             <div class="field">
-                              {{ complement.periodicidad }}
+                              {{ countries }}
                             </div>
-                            <h4>Calificadora de riesgo:</h4>
+                          </div>
+                          <div class="col-lg-3 col-md-4 col-sm-6">
+                            <h4>Plazo:</h4>
                             <div class="field">
-                              {{ complement.calificadora_riesgo }}
+                              {{ payment_terms }}
                             </div>
                           </div>
                           <div class="col-lg-3 col-md-4 col-sm-6">
-                            <h4>Calificación de riesgo:</h4>
+                            <h4>Tipos de operaciones:</h4>
                             <div class="field">
-                              {{ complement.calificacion }}
+                              {{ operations }}
                             </div>
+                          </div>
+                          <div class="col-lg-3 col-md-4 col-sm-6">
                             <h4>Comentarios:</h4>
                             <div class="field">
-                              {{ complement.comentarios }}
+                              {{ comment }}
                             </div>
                           </div>
                           <div class="col-lg-3 col-md-4 col-sm-6">
                             <h4>Justificación:</h4>
                             <div class="field">
-                              {{ complement.justificacion }}
+                              {{ justification }}
                             </div>
                           </div>
                         </div>
                       </div>
                     </div>
                   </li>
+                  <li class="timeline-inverted">
+                    <div class="timeline-badge"></div>
+                    <div class="timeline-panel">
+                      <div class="timeline-heading">
+                        <span class="badge badge-warning">Instrumento</span>
+                        <ng-template instrument-host></ng-template>
+                      </div>
+                    </div>
+                  </li>
                 </ul>
-
                 <div class="review-buttons">
                   <button class="btn btn-danger " (click)="dismiss_proposal()">
                     Rechazar propuesta

+ 323 - 29
src/app/components/investment-proposals/review/review.component.ts

@@ -5,7 +5,7 @@ import {
   ViewChild,
   ComponentFactoryResolver
 } from "@angular/core";
-import { Router } from "@angular/router";
+import { Router, ActivatedRoute } from "@angular/router";
 import { InvestmentProposalForm } from "@app/models/investment-proposal-form";
 import { FormInvestmentProposalService } from "@app/services/form-investment-proposal.service";
 import { Instrument } from "@app/models/instrument";
@@ -14,6 +14,8 @@ import { InstrumentDirective } from "../instrument/instrument.directive";
 import { InstrumentComponent } from "../instrument/instrument.component";
 import { InstrumentsService } from "@app/services/instruments.service";
 import Swal from "sweetalert2";
+import { CatalogsService } from "@app/services/catalogs.service";
+import { InvestmentsService } from "@app/services/investments.service";
 
 @Component({
   selector: "app-investment-proposal-review",
@@ -36,6 +38,31 @@ export class InvestmentProposalReviewComponent implements OnInit {
   currentAdIndex = -1;
   interval: any;
   indexDynamicComponent: number;
+  investmentProposalID: string;
+  investmentExists;
+  state;
+  financials;
+  base_types;
+  countries;
+  companies;
+  rates;
+  revenues;
+  funds;
+  instrumentTypes;
+  markets;
+  emitters;
+  periodicities;
+  format_incomes;
+  payment_terms;
+  operations;
+  gInfo: any;
+  gInstrument: any;
+  gComplement: any;
+  subject: any;
+  investmentName: any;
+  comment: any;
+  justification: any;
+  reviewProposal: {};
 
   constructor(
     private router: Router,
@@ -43,33 +70,242 @@ export class InvestmentProposalReviewComponent implements OnInit {
     private formDataService: FormInvestmentProposalService,
     private componentFactoryResolver: ComponentFactoryResolver,
     private instrumentService: InvestmentProposalWorkflowService,
-    private loadInstrumentsService: InstrumentsService
+    private loadInstrumentsService: InstrumentsService,
+    private catalogService: CatalogsService,
+    private route: ActivatedRoute,
+    private investmentService: InvestmentsService
   ) {}
 
   ngOnInit() {
-    this.formData = this.formDataService.getFormData();
-    this.isFormValid = this.formDataService.isFormValid();
+    //this.formDataService
     this.ads = this.loadInstrumentsService.getInstruments();
-    this.formData.instrumentos;
+    this.route.params.subscribe(params => {
+      this.investmentProposalID = params["id"];
+    });
+    if (this.investmentProposalID == undefined)
+      this.investmentProposalID = this.route.snapshot.queryParamMap.get("id");
 
-    this.indexDynamicComponent = this.ads.findIndex(
-      x => x.component.name == this.formData.instrumentos
-    );
-    if (this.indexDynamicComponent >= 0) {
-      this.loadComponent();
-    } else {
-      console.log("No existe el componente");
-    }
+    if (this.investmentProposalID != undefined) {
+      this.investmentExists = true;
+      this.investmentService
+        .getProposalInvestment(this.investmentProposalID)
+        .subscribe(res => {
+          this.state = res["result"]["id_estado_inversion"]["codigo"];
+
+          this.gInfo = {
+            asunto: res["result"]["asunto"],
+            origenes_fondo:
+              res["result"]["id_origen_fondo"] == null
+                ? ""
+                : res["result"]["id_origen_fondo"]["id_origen_fondo"],
+            name: res["result"]["nombre_inversion"],
+            //date: "",
+            tipo_tasa: res["result"]["id_tipo_tasa"] || "",
+            tipo_renta:
+              res["result"]["id_tipo_renta"] == null
+                ? ""
+                : res["result"]["id_tipo_renta"]["id_tipo_renta"],
+            periodicidad:
+              res["result"]["id_periodicidad"] == null
+                ? ""
+                : res["result"]["id_periodicidad"]["id_periodicidad"],
+
+            instrumentos:
+              res["result"]["id_inversion_instrumento"]["id_tipo_instrumento"][
+                "codigo"
+              ],
+            base_anual:
+              res["result"]["id_tipo_base"] == null
+                ? ""
+                : res["result"]["id_tipo_base"]["id_tipo_base"],
+            casa:
+              res["result"]["id_entidad"] == null
+                ? ""
+                : res["result"]["id_entidad"]["id_entidad_financiera"],
+            formato_ingreso:
+              res["result"]["id_formato_ingreso"] == null
+                ? ""
+                : res["result"]["id_formato_ingreso"]["id_formato_ingreso"]
+          };
+
+          this.gInstrument =
+            res["result"]["id_inversion_instrumento"]["instrumento"];
+
+          this.gInstrument["id_inversion_instrumento"] =
+            res["result"]["id_inversion_instrumento"][
+              "id_inversion_instrumento"
+            ];
+
+          this.gComplement = {
+            tipo_mercado:
+              res["result"]["id_tipo_mercado"] == null
+                ? ""
+                : res["result"]["id_tipo_mercado"]["id_tipo_mercado"],
+            emisores:
+              res["result"]["id_tipo_emisor"] == null
+                ? ""
+                : res["result"]["id_tipo_emisor"]["id_tipo_emisor"],
+            empresa:
+              res["result"]["id_empresa"] == null
+                ? ""
+                : res["result"]["id_empresa"]["id_empresa"],
+            pais:
+              res["result"]["id_pais"] == null
+                ? ""
+                : res["result"]["id_pais"]["id_pais"],
+            plazo:
+              res["result"]["id_plazo"] == null
+                ? ""
+                : res["result"]["id_plazo"]["id_plazo"],
+            operaciones:
+              res["result"]["id_tipo_operacion"] == null
+                ? ""
+                : res["result"]["id_tipo_operacion"]["id_tipo_operacion"],
+            comentarios: res["result"]["comentario"],
+            justificacion: res["result"]["justificacion"]
+          };
+          this.formDataService.setGeneralInfo(this.gInfo);
+
+          this.formDataService.setWork(this.gInstrument);
+
+          this.formDataService.setComplementInfo(this.gComplement);
+
+          this.general = this.formDataService.getGeneralInfo();
+          this.instrument = this.formDataService.getWork();
+          this.complement = this.formDataService.getComplementInfo();
+          this.formData = this.formDataService.getFormData();
 
-    this.general = this.formDataService.getGeneralInfo();
-    this.instrument = this.formDataService.getWork();
-    this.complement = this.formDataService.getComplementInfo();
+          this.formData.instrumentos;
 
-    this.final = {};
+          this.indexDynamicComponent = this.ads.findIndex(
+            x => x.component.name == this.formData.instrumentos
+          );
+          if (this.indexDynamicComponent >= 0) {
+            this.loadComponent();
+          } else {
+            console.log("No existe el componente");
+          }
+          if (this.general != undefined) {
+            this.subject = this.general.asunto;
+            this.investmentName = this.general.name;
+            this.comment = this.complement.comment;
+            this.justification = this.complement.comment;
+
+            this.catalogService.getFinancialEntities().subscribe(res => {
+              this.financials = res.find(
+                e => e.id_entidad_financiera == this.general.casa
+              );
+              this.financials =
+                this.financials != undefined ? this.financials.nombre : "-";
+            });
+
+            this.catalogService.getBaseTypes().subscribe(res => {
+              this.base_types = res.find(
+                e => e.id_tipo_base == this.general.base_anual
+              );
+              this.base_types =
+                this.base_types != undefined
+                  ? ` ${this.base_types.tipo_base} / ${this.base_types.tipo_base_dias}`
+                  : "-";
+            });
+
+            this.catalogService.getCountries().subscribe(res => {
+              this.countries = res.find(e => e.id_pais == this.complement.pais);
+              this.countries =
+                this.countries != undefined ? this.countries.nombre : "-";
+            });
+            this.catalogService.getCompanies().subscribe(res => {
+              this.companies = res.find(
+                e => e.id_empresa == this.complement.empresa
+              );
+              this.companies =
+                this.companies != undefined ? this.companies.nombre : "-";
+            });
+            this.catalogService.getRateTypes().subscribe(res => {
+              this.rates = res.find(
+                e => e.id_tipo_tasa == this.general.tipo_tasa
+              );
+              this.rates = this.rates != undefined ? this.rates.nombre : "-";
+            });
+            this.catalogService.getRevenueTypes().subscribe(res => {
+              this.revenues = res.find(
+                e => e.id_tipo_renta == this.general.tipo_renta
+              );
+              this.revenues =
+                this.revenues != undefined ? this.revenues.nombre : "-";
+            });
+
+            this.catalogService.getFundsOrigins().subscribe(res => {
+              this.funds = res.find(
+                e => e.id_origen_fondo == this.general.origenes_fondo
+              );
+              this.funds = this.funds != undefined ? this.funds.nombre : "-";
+            });
+            this.catalogService.getInstrumentTypes().subscribe(res => {
+              this.instrumentTypes = res.find(
+                e => e.codigo == this.general.instrumentos
+              );
+              this.instrumentTypes =
+                this.instrumentTypes != undefined
+                  ? this.instrumentTypes.nombre
+                  : "-";
+            });
+
+            this.catalogService.getMarketTypes().subscribe(res => {
+              this.markets = res.find(
+                e => e.id_tipo_mercado == this.complement.tipo_mercado
+              );
+              this.markets =
+                this.markets != undefined ? this.markets.nombre : "-";
+            });
+            this.catalogService.getEmitterTypes().subscribe(res => {
+              this.emitters = res.find(
+                e => e.id_tipo_emisor == this.complement.emisores
+              );
+              this.emitters =
+                this.emitters != undefined ? this.emitters.nombre : "-";
+            });
+            this.catalogService.getPeriodicities().subscribe(res => {
+              this.periodicities = res.find(
+                e => e.id_periodicidad == this.general.periodicidad
+              );
+              this.periodicities =
+                this.periodicities != undefined
+                  ? this.periodicities.nombre
+                  : "-";
+            });
 
-    Object.assign(this.final, this.general, this.instrument, this.complement);
-    console.log("Result feature loaded!");
-    console.log(this.final);
+            this.catalogService.getPaymentTerms().subscribe(res => {
+              this.payment_terms = res.find(
+                e => e.codigo == this.complement.calificadora_riesgo
+              );
+              this.payment_terms =
+                this.payment_terms != undefined
+                  ? this.payment_terms.nombre
+                  : "-";
+            });
+            this.catalogService.getOperationTypes().subscribe(res => {
+              this.operations = res.find(
+                e => e.codigo == this.complement.operaciones
+              );
+              this.operations =
+                this.operations != undefined ? this.operations.nombre : "-";
+            });
+            //getIncomeFormat
+            this.catalogService.getIncomeFormat().subscribe(res => {
+              this.format_incomes = res.find(
+                e => e.id_formato_ingreso == this.general.formato_ingreso
+              );
+              this.format_incomes =
+                this.format_incomes != undefined
+                  ? this.format_incomes.nombre
+                  : "-";
+            });
+          }
+        });
+    } else {
+      this.investmentExists = false;
+    }
   }
 
   loadComponent() {
@@ -89,12 +325,12 @@ export class InvestmentProposalReviewComponent implements OnInit {
 
   approve_proposal() {
     (async () => {
-      const { value: formValues } = await Swal.fire({
-        title: "<h3>Aprobar propuesta de inversión</h3>",
+      const { value: comentario } = await Swal.fire({
+        title: "<h3>Enviar a revisión propuesta de inversión</h3>",
         icon: "info",
         input: "textarea",
         showCancelButton: true,
-        confirmButtonText: "Aprobar propuesta",
+        confirmButtonText: "Enviar propuesta",
         cancelButtonText: "Cancelar",
         inputValidator: value => {
           if (!value) {
@@ -103,16 +339,45 @@ export class InvestmentProposalReviewComponent implements OnInit {
         }
       });
 
-      if (formValues) {
-        Swal.fire(JSON.stringify(formValues));
+      if (comentario) {
+        this.reviewProposal = {
+          id_inversion: this.investmentProposalID,
+          step: "next",
+          comentario: comentario
+        };
+
+        this.investmentService
+          .sendProposalInvestmentToNextStep(this.reviewProposal)
+          .subscribe(
+            success => {
+              if (success) {
+                Swal.fire({
+                  allowOutsideClick: false,
+                  icon: "success",
+                  showCancelButton: false,
+                  title: "Exito",
+                  confirmButtonText: "La propuesta ha sido aprobada"
+                }).then(result => {
+                  Swal.close();
+                });
+              }
+            },
+            err => {
+              Swal.fire({
+                icon: "error",
+                title: "Error al guardar",
+                text: err.message
+              });
+            }
+          );
       }
     })();
   }
 
   dismiss_proposal() {
     (async () => {
-      const { value: formValues } = await Swal.fire({
-        title: "<h3>Rechazar propuesta de inversión</h3>",
+      const { value: comentario } = await Swal.fire({
+        title: "<h3>Enviar a revisión propuesta de inversión</h3>",
         icon: "info",
         input: "textarea",
         showCancelButton: true,
@@ -126,8 +391,37 @@ export class InvestmentProposalReviewComponent implements OnInit {
         }
       });
 
-      if (formValues) {
-        Swal.fire(JSON.stringify(formValues));
+      if (comentario) {
+        this.reviewProposal = {
+          id_inversion: this.investmentProposalID,
+          step: "next",
+          comentario: comentario
+        };
+
+        this.investmentService
+          .sendProposalInvestmentToNextStep(this.reviewProposal)
+          .subscribe(
+            success => {
+              if (success) {
+                Swal.fire({
+                  allowOutsideClick: false,
+                  icon: "success",
+                  showCancelButton: false,
+                  title: "Exito",
+                  confirmButtonText: "La propuesta ha sido aprobada"
+                }).then(result => {
+                  Swal.close();
+                });
+              }
+            },
+            err => {
+              Swal.fire({
+                icon: "error",
+                title: "Error en el servidor",
+                text: err.message
+              });
+            }
+          );
       }
     })();
   }

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

@@ -71,7 +71,9 @@ import { APNComponent } from "@app/components/instruments/apn/apn.component";
 import { InstrumentDirective } from "@app/components/investment-proposals/instrument/instrument.directive";
 import { WorkflowGuard } from "@app/services/investment-proposal-workflow.guard";
 import { ChangeHistoryComponent } from "@app/components/investment-proposals/change-history/change-history.component";
+
 import { PaymentRequirementComponent } from "@app/components/investment-proposals/payment-requirement/payment-requirement.component";
+import { PaymentInfoComponent } from "@app/components/investment-proposals/payment-info/payment-info.component";
 
 // This array defines which "componentId" maps to which lazy-loaded module.
 
@@ -134,6 +136,7 @@ import { PaymentRequirementComponent } from "@app/components/investment-proposal
     ANCComponent,
     APNComponent,
     InstrumentDirective,
+    PaymentInfoComponent,
     PaymentRequirementComponent
   ],
   entryComponents: [

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

@@ -17,6 +17,8 @@ import { ResultComponent } from "@app/components/investment-proposals/result/res
 import { WorkflowGuard } from "@app/services/investment-proposal-workflow.guard";
 import { InvestmentProposalReviewComponent } from "@app/components/investment-proposals/review/review.component";
 import { ChangeHistoryComponent } from "@app/components/investment-proposals/change-history/change-history.component";
+import { PaymentInfoComponent } from "@app/components/investment-proposals/payment-info/payment-info.component";
+
 import { PaymentRequirementComponent } from "@app/components/investment-proposals/payment-requirement/payment-requirement.component";
 import { NgModule } from "@angular/core";
 import { from } from "rxjs";
@@ -169,6 +171,10 @@ export const AdminLayoutRoutes: Routes = [
     path: "investment-proposal/:id/change-history",
     component: ChangeHistoryComponent
   },
+  {
+    path: "investment-proposal/:id/payment-info",
+    component: PaymentInfoComponent
+  },
   {
     path: "investment-proposal/:id/payment",
     component: PaymentRequirementComponent

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

@@ -40,6 +40,7 @@ export class InvestmentProposalForm {
     this.casa = "";
     this.plazo = "";
     this.operaciones = "";
+    this.formato_ingreso = "";
   }
 }
 

+ 2 - 1
src/app/services/form-investment-proposal.service.ts

@@ -108,10 +108,11 @@ export class FormInvestmentProposalService {
 
   resetFormData(): InvestmentProposalForm {
     // Reset the workflow
-    this.workflowService.resetSteps();
     // Return the form data after all this.* members had been reset
     this.formData.clear();
+
     this.isGeneralInfoFormValid = this.isWorkFormValid = this.isComplementInfoFormValid = false;
+    this.workflowService.resetSteps();
     return this.formData;
   }
 

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

@@ -89,6 +89,7 @@ export class InstrumentCalculations {
       comision_bolsa_porcentaje: number;
       rendimiento_bruto: number;
       otros_costos: number;
+      plazo: number;
       renta_porcentaje: number;
       fecha_operacion: string;
       fecha_liquidacion: string;

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

@@ -72,6 +72,17 @@ export class InvestmentsService {
       );
   }
 
+  sendProposalInvestmentToNextStep(inversion: Object): Observable<boolean> {
+    return this.http
+      .post<any>(`${environment.productionApiUrl}/auditoria`, inversion)
+      .pipe(
+        map(response => {
+          return response;
+        }),
+        catchError(this.errorHandl)
+      );
+  }
+
   //if(error.error instanceof ErrorEvent) {
   errorHandl(error) {
     let errorMessage = "";