Browse Source

costos de fondos de inversion

Oscar José Nuñez Chávez 5 years ago
parent
commit
445fb004e2

+ 378 - 0
src/app/components/investments/costs/fondos/fondos.costs.component.html

@@ -0,0 +1,378 @@
+<h2 class="floating-title">{{ title }}</h2>
+
+<div class="main-content">
+  <div class="container-fluid">
+    <div class="row">
+      <div class="col-12 align-right">
+        <div class="align-container">
+          <nav aria-label="breadcrumb">
+            <ol class="breadcrumb">
+              <li class="breadcrumb-item">
+                <a [routerLink]="['/']">Dashboard</a>
+              </li>
+              <li class="breadcrumb-item">
+                <a [routerLink]="['/investments']">
+                  Inversiones activas
+                </a>
+              </li>
+              <li class="breadcrumb-item">Fondos de inversión</li>
+            </ol>
+          </nav>
+        </div>
+      </div>
+
+      <div class="col-12">
+        <div class="align-container">
+          <div class="card borderless card-wrapper">
+            <div class="wrapper-costs">
+              <h4 class="card-title">
+                Detalle de costos para el fondos de inversión
+              </h4>
+              <br />
+
+              <div class="align-container">
+                <div>
+                  <div class="costs-summary" *ngIf="instrument_exists">
+                    <div class="row">
+                      <div class="col-lg-3 col-md-4 col-sm-6">
+                        <h4>Cuota participación:</h4>
+                        <div class="field">
+                          $USD
+                          {{
+                            instrument_work.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">
+                          {{
+                            instrument_work.valor_participacion_porcentaje
+                              | 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.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.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.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.valor_transado | number: "1.2-4" }}
+                        </div>
+                      </div>
+                      <div class="col-lg-3 col-md-4 col-sm-6">
+                        <h4>Monto a pagar:</h4>
+                        <div class="field">
+                          $USD
+                          {{ instrument_work.monto_pagar | 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.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.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.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.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.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.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.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.fecha_liquidacion }}
+                        </div>
+                      </div>
+
+                      <div class="col-lg-3 col-md-4 col-sm-6">
+                        <h4>Fecha vencimiento:</h4>
+                        <div class="field">
+                          {{ instrument_work.fecha_vencimiento }}
+                        </div>
+                      </div>
+                    </div>
+                  </div>
+                </div>
+              </div>
+              <br />
+              <br />
+              <div class="align-container">
+                <form *ngIf="dataRetrieved" [formGroup]="form">
+                  <div *ngFor="let group of form.controls; let i = index">
+                    <div class="wrapper-form" [formGroup]="group">
+                      <div class="costs-input-small-container">
+                        <div class="form-group">
+                          <label for="posicion">Posicion: </label>
+
+                          <div class="input-box-container">
+                            <input
+                              type="text"
+                              formControlName="posicion"
+                              class="form-control"
+                              readonly
+                            />
+                          </div>
+                        </div>
+                      </div>
+
+                      <div class="costs-input-small-container">
+                        <div class="form-group">
+                          <label for="plazo">Plazo: </label>
+
+                          <div class="input-box-container">
+                            <div>
+                              <p>
+                                <i class="far fa-clock" aria-hidden="true"></i>
+                              </p>
+                              <input
+                                type="text"
+                                formControlName="plazo"
+                                class="form-control"
+                                readonly
+                              />
+                            </div>
+                          </div>
+                        </div>
+                      </div>
+
+                      <div class="costs-input-normal-container">
+                        <div class="form-group">
+                          <label for="fecha_pago">Fecha pago: </label>
+
+                          <div class="input-box-container">
+                            <div>
+                              <p>
+                                <i
+                                  class="far fa-calendar"
+                                  aria-hidden="true"
+                                ></i>
+                              </p>
+                              <input
+                                type="text"
+                                formControlName="fecha_pago"
+                                class="form-control"
+                                readonly
+                              />
+                            </div>
+                          </div>
+                        </div>
+                      </div>
+
+                      <div class="costs-input-normal-container">
+                        <div class="form-group">
+                          <label for="ingreso_bruto">Ingreso bruto: </label>
+
+                          <div class="input-box-container">
+                            <div>
+                              <p>
+                                <i class="fas fa-dollar-sign"></i>
+                              </p>
+                              <input
+                                type="text"
+                                formControlName="ingreso_bruto"
+                                class="form-control"
+                                readonly
+                              />
+                            </div>
+                          </div>
+                        </div>
+                      </div>
+                      <div class="costs-input-normal-container">
+                        <div class="form-group">
+                          <label for="ingreso_neto">Ingreso neto: </label>
+
+                          <div class="input-box-container">
+                            <div>
+                              <p>
+                                <i class="fas fa-dollar-sign"></i>
+                              </p>
+                              <input
+                                type="text"
+                                formControlName="ingreso_neto"
+                                class="form-control"
+                                readonly
+                              />
+                            </div>
+                          </div>
+                        </div>
+                      </div>
+
+                      <div class="costs-input-normal-container">
+                        <div class="form-group">
+                          <label for="dividendo_porcentaje"
+                            >Dividendo (%):
+                          </label>
+
+                          <div class="input-box-container">
+                            <div>
+                              <p>
+                                <i class="fas fa-percent"></i>
+                              </p>
+                              <input
+                                type="number"
+                                formControlName="dividendo_porcentaje"
+                                class="form-control"
+                              />
+                            </div>
+                          </div>
+                        </div>
+                      </div>
+                      <div class="costs-input-normal-container">
+                        <div class="form-group">
+                          <label for="rendimiento_porcentaje"
+                            >Rendimiento:
+                          </label>
+
+                          <div class="input-box-container">
+                            <div>
+                              <p>
+                                <i class="fas fa-percent"></i>
+                              </p>
+                              <input
+                                type="number"
+                                formControlName="rendimiento_porcentaje"
+                                class="form-control"
+                              />
+                            </div>
+                          </div>
+                        </div>
+                      </div>
+                      <div class="costs-input-normal-container">
+                        <div class="form-group">
+                          <label for="rendimiento">Rendimiento ($): </label>
+
+                          <div class="input-box-container">
+                            <div>
+                              <p>
+                                <i class="fas fa-dollar-sign"></i>
+                              </p>
+                              <input
+                                type="number"
+                                formControlName="rendimiento"
+                                class="form-control"
+                                readonly
+                              />
+                            </div>
+                          </div>
+                        </div>
+                      </div>
+
+                      <input
+                        type="hidden"
+                        formControlName="id_fondo_inversion"
+                      />
+                      <input
+                        type="hidden"
+                        formControlName="id_proyeccion_ingreso"
+                      />
+                      <div class="clear"></div>
+                    </div>
+                  </div>
+                  <br />
+                  <div class="form-group text-right space-20">
+                    <button
+                      type="button"
+                      class="btn btn-success center-component float-left"
+                      (click)="saveProjection()"
+                    >
+                      Guardar información de proyecciones
+                    </button>
+
+                    <button
+                      type="button"
+                      class="btn btn-primary center-component float-right"
+                      (click)="recalculateProjectionChanges()"
+                    >
+                      Recalcular proyecciones
+                    </button>
+                  </div>
+                  <br />
+                </form>
+              </div>
+            </div>
+          </div>
+        </div>
+      </div>
+      <br />
+    </div>
+  </div>
+</div>

+ 233 - 0
src/app/components/investments/costs/fondos/fondos.costs.component.ts

@@ -0,0 +1,233 @@
+import { Component, ViewChild, OnInit } from "@angular/core";
+import { MatPaginator } from "@angular/material/paginator";
+import { MatSort } from "@angular/material/sort";
+import { MatTableDataSource } from "@angular/material/table";
+import Swal from "sweetalert2";
+import { CatalogsService } from "src/app/services/catalogs.service";
+import { InvestmentsService } from "@app/services/investments.service";
+import { InstrumentCalculations } from "@app/services/instrument-calculations.service";
+
+import { AuthService } from "@app/services/auth2.service";
+import { JwtHelperService } from "@auth0/angular-jwt";
+import { InvestmentProposal } from "@app/models/investment-proposal";
+import { from } from "rxjs";
+import { FormInvestmentProposalService } from "@app/services/form-investment-proposal.service";
+import { Router, ActivatedRoute } from "@angular/router";
+import {
+  FormBuilder,
+  FormGroup,
+  FormControl,
+  FormArray,
+  Validators
+} from "@angular/forms";
+
+@Component({
+  selector: "app-fondos-costs",
+  templateUrl: "./fondos.costs.component.html"
+  //styleUrls: ["./dap.costs.component.scss"]
+})
+export class FINVCostsComponent implements OnInit {
+  helper = new JwtHelperService();
+
+  title: string = "Costos para fondos de inversión";
+
+  displayedColumns: string[] = [
+    "posicion",
+    "plazo",
+    "fecha_pago",
+    "ingreso_bruto",
+    "ingreso_neto",
+    "dividendo_porcentaje",
+    "rendimiento_porcentaje",
+    "rendimiento",
+    "id_fondo_inversion"
+  ];
+
+  //displayedColumns: string[] = ['state'];
+
+  listProposals: InvestmentProposal[];
+  dataSource = new MatTableDataSource(this.listProposals);
+
+  resultsLength = 0;
+  isLoadingResults = true;
+  isRateLimitReached = false;
+  userRole: any;
+
+  @ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
+  @ViewChild(MatSort, { static: true }) sort: MatSort;
+  role_number: any;
+  investmentProposalID: string;
+
+  form: FormArray;
+  investmentProposalForm: FormGroup;
+
+  proyecciones: any;
+  proyeccionesProps = [];
+  dataRetrieved: boolean = false;
+
+  array1;
+  array2;
+  array3;
+  investment: any;
+  instrument_work: any;
+  instrument_exists: boolean;
+
+  constructor(
+    private catalogService: CatalogsService,
+    private investmentsService: InvestmentsService,
+    private authService: AuthService,
+    private formInvestmentProposal: FormInvestmentProposalService,
+    private router: Router,
+    private route: ActivatedRoute,
+    private instrumentService: InstrumentCalculations,
+
+    private formBuilder: FormBuilder
+  ) {
+    const decodedToken = this.helper.decodeToken(
+      this.authService.getJwtToken()
+    );
+    this.userRole = decodedToken.groups;
+
+    Swal.fire({
+      allowOutsideClick: false,
+      icon: "info",
+      text: "Espere por favor..."
+    });
+    Swal.showLoading();
+  }
+
+  ngOnInit() {
+    Swal.close();
+    const formDataObj = {};
+
+    this.route.params.subscribe(params => {
+      this.investmentProposalID = params["id"];
+    });
+
+    if (this.investmentProposalID == undefined)
+      this.investmentProposalID = this.route.snapshot.queryParamMap.get("id");
+
+    if (this.investmentProposalID != undefined) {
+      this.investmentsService
+        .getProposalInvestment(this.investmentProposalID)
+        .subscribe(
+          res => {
+            this.investment = res["result"];
+            this.instrument_work =
+              res["result"]["id_inversion_instrumento"]["instrumento"];
+            this.instrument_exists = true;
+
+            this.proyecciones =
+              res["result"]["id_inversion_instrumento"]["instrumento"][
+                "proyecciones"
+              ];
+            this.proyecciones.pop();
+
+            this.form = new FormArray(this.buildForm(this.proyecciones));
+            this.dataRetrieved = true;
+          },
+          err => {
+            Swal.fire({
+              icon: "error",
+              title: "Error en el servidor",
+              text: err.message
+            });
+          }
+        );
+    }
+
+    setTimeout(() => {
+      Swal.close();
+    }, 1200);
+  }
+
+  recalculateProjectionChanges() {
+    let objProjection = { proyecciones: this.form.value };
+    Swal.fire({
+      allowOutsideClick: false,
+      icon: "info",
+      text: "Espere por favor..."
+    });
+    Swal.showLoading();
+    console.log(objProjection);
+    this.instrumentService
+      .projectionCalc(this.investmentProposalID, this.form.value)
+      .subscribe(
+        result => {
+          Swal.fire({
+            allowOutsideClick: false,
+            icon: "success",
+            showCancelButton: false,
+            title: "Exito"
+          });
+          this.proyecciones = result["result"]["proyecciones"];
+          this.proyecciones.pop();
+
+          this.form.clear();
+          this.form = new FormArray(this.buildForm(this.proyecciones));
+          Swal.close();
+          //window.location.reload();
+        },
+        err => {
+          Swal.fire({
+            icon: "error",
+            title: "Error al guardar",
+            text: err.message
+          });
+        }
+      );
+  }
+
+  saveProjection() {
+    let objProjection = { proyecciones: this.form.value };
+    Swal.fire({
+      allowOutsideClick: false,
+      icon: "info",
+      text: "Espere por favor..."
+    });
+    Swal.showLoading();
+
+    this.instrumentService
+      .projectionModification(this.investmentProposalID, objProjection)
+      .subscribe(
+        resp => {
+          Swal.fire({
+            allowOutsideClick: false,
+            icon: "success",
+            showCancelButton: false,
+            title: "Exito",
+            confirmButtonText: "La información ha sido actualizada"
+          }).then(result => {
+            Swal.close();
+            //window.location.reload();
+          });
+        },
+        err => {
+          Swal.fire({
+            icon: "error",
+            title: "Error al guardar",
+            text: err.message
+          });
+        }
+      );
+  }
+
+  buildForm(items: any[]): FormGroup[] {
+    return items.map(x => this.buildItem(x));
+  }
+  //return a formGroup
+  buildItem(item: any): FormGroup {
+    return new FormGroup({
+      id_proyeccion_ingreso: new FormControl(item.id_proyeccion_ingreso),
+      posicion: new FormControl(item.posicion),
+      plazo: new FormControl(item.plazo),
+      fecha_pago: new FormControl(item.fecha_pago),
+      ingreso_bruto: new FormControl(item.ingreso_bruto),
+      ingreso_neto: new FormControl(item.ingreso_neto),
+      dividendo_porcentaje: new FormControl(item.dividendo_porcentaje),
+      rendimiento_porcentaje: new FormControl(item.rendimiento_porcentaje),
+      rendimiento: new FormControl(item.rendimiento),
+      id_fondo_inversion: new FormControl(item.id_fondo_inversion)
+    });
+  }
+}

+ 2 - 1
src/app/components/investments/costs/pbur/pbur.costs.component.ts

@@ -211,7 +211,7 @@ export class PBURCostsComponent implements OnInit {
               res["result"]["id_inversion_instrumento"]["instrumento"][
               res["result"]["id_inversion_instrumento"]["instrumento"][
                 "proyecciones"
                 "proyecciones"
               ];
               ];
-
+            this.proyecciones.pop();
             this.form = new FormArray(this.buildForm(this.proyecciones));
             this.form = new FormArray(this.buildForm(this.proyecciones));
             this.dataRetrieved = true;
             this.dataRetrieved = true;
           },
           },
@@ -250,6 +250,7 @@ export class PBURCostsComponent implements OnInit {
             title: "Exito"
             title: "Exito"
           });
           });
           this.proyecciones = result["result"]["proyecciones"];
           this.proyecciones = result["result"]["proyecciones"];
+          this.proyecciones.pop();
           this.form.clear();
           this.form.clear();
           this.form = new FormArray(this.buildForm(this.proyecciones));
           this.form = new FormArray(this.buildForm(this.proyecciones));
           Swal.close();
           Swal.close();

+ 2 - 1
src/app/components/investments/costs/vcn/vcn.costs.component.ts

@@ -211,7 +211,7 @@ export class VCNCostsComponent implements OnInit {
               res["result"]["id_inversion_instrumento"]["instrumento"][
               res["result"]["id_inversion_instrumento"]["instrumento"][
                 "proyecciones"
                 "proyecciones"
               ];
               ];
-
+            this.proyecciones.pop();
             this.form = new FormArray(this.buildForm(this.proyecciones));
             this.form = new FormArray(this.buildForm(this.proyecciones));
             this.dataRetrieved = true;
             this.dataRetrieved = true;
           },
           },
@@ -250,6 +250,7 @@ export class VCNCostsComponent implements OnInit {
             title: "Exito"
             title: "Exito"
           });
           });
           this.proyecciones = result["result"]["proyecciones"];
           this.proyecciones = result["result"]["proyecciones"];
+          this.proyecciones.pop();
           this.form.clear();
           this.form.clear();
           this.form = new FormArray(this.buildForm(this.proyecciones));
           this.form = new FormArray(this.buildForm(this.proyecciones));
           Swal.close();
           Swal.close();

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

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

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

@@ -76,6 +76,7 @@ import { UploadLiquidationComponent } from "@app/components/investment-proposals
 import { SelectModule } from "ng-select";
 import { SelectModule } from "ng-select";
 import { OPC } from "@app/components/instruments/opciones/opciones.component";
 import { OPC } from "@app/components/instruments/opciones/opciones.component";
 import { FUTU } from "@app/components/instruments/futuros/futuros.component";
 import { FUTU } from "@app/components/instruments/futuros/futuros.component";
+import { FINVCostsComponent } from "@app/components/investments/costs/fondos/fondos.costs.component";
 
 
 // This array defines which "componentId" maps to which lazy-loaded module.
 // This array defines which "componentId" maps to which lazy-loaded module.
 
 
@@ -151,6 +152,7 @@ import { FUTU } from "@app/components/instruments/futuros/futuros.component";
     DAPCostsComponent,
     DAPCostsComponent,
     VCNCostsComponent,
     VCNCostsComponent,
     PBURCostsComponent,
     PBURCostsComponent,
+    FINVCostsComponent,
     IncomesComponent,
     IncomesComponent,
     GeneralIncomeFormComponent,
     GeneralIncomeFormComponent,
     PaymentApprovalComponent,
     PaymentApprovalComponent,

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

@@ -32,6 +32,7 @@ import { IncomesComponent } from "@app/components/incomes/incomes.component";
 import { GeneralIncomeFormComponent } from "@app/components/incomes/general-form/general-form.component";
 import { GeneralIncomeFormComponent } from "@app/components/incomes/general-form/general-form.component";
 import { PaymentApprovalComponent } from "@app/components/investment-proposals/payment-approval/payment-approval.component";
 import { PaymentApprovalComponent } from "@app/components/investment-proposals/payment-approval/payment-approval.component";
 import { UploadLiquidationComponent } from "@app/components/investment-proposals/upload-liquidation/upload-liquidation.component";
 import { UploadLiquidationComponent } from "@app/components/investment-proposals/upload-liquidation/upload-liquidation.component";
+import { FINVCostsComponent } from "@app/components/investments/costs/fondos/fondos.costs.component";
 
 
 export const AdminLayoutRoutes: Routes = [
 export const AdminLayoutRoutes: Routes = [
   {
   {
@@ -213,6 +214,10 @@ export const AdminLayoutRoutes: Routes = [
     path: "investment-costs/vcn/:id",
     path: "investment-costs/vcn/:id",
     component: VCNCostsComponent
     component: VCNCostsComponent
   },
   },
+  {
+    path: "investment-costs/finv/:id",
+    component: FINVCostsComponent
+  },
   {
   {
     path: "investment-costs/pbur/:id",
     path: "investment-costs/pbur/:id",
     component: PBURCostsComponent
     component: PBURCostsComponent