| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809 |
- 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-certificados",
- templateUrl: "./certificados.component.html"
- })
- export class CINV implements InstrumentComponent {
- title: string = "Certificados de inversión";
- @Input() data: any;
- @Input() summary: boolean;
- @Input() investmentID: string;
- displayedColumns: string[] = [
- "posicion",
- "plazo",
- "fecha_pago",
- "ingreso_bruto",
- "ingreso_neto",
- "renta"
- ];
- @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_ultima_cupon_compra: 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;
- bonosObject: {};
- dataSource = new MatTableDataSource(this.proyecciones);
- dataSource2 = new MatTableDataSource(this.proyecciones);
- hasProjections: boolean;
- fecha_vencimiento: any;
- comision_casa_compra: any;
- comision_bolsa_compra: any;
- fecha_siguiente_cupon_compra: any;
- dias_vencimiento_compra: any;
- dias_acumulados_compra: any;
- ytm_vencimiento_comision_porcentaje_compra: any;
- interes_acumulado_compra: any;
- interes_acumulado_porcentaje_compra: any;
- precio_sucio_porcentaje_compra: any;
- valor_transado_compra: any;
- monto_pagar: any;
- fecha_inicio_vigencia: any;
- comision_casa_venta: any;
- fecha_siguiente_cupon_venta: any;
- dias_vencimiento_venta: any;
- dias_acumulados_venta: any;
- ytm_vencimiento_comision_porcentaje_venta: any;
- interes_acumulado_venta: any;
- interes_acumulado_porcentaje_venta: any;
- precio_sucio_porcentaje_venta: any;
- valor_transado_venta: any;
- monto_recibir: any;
- dias_tenencia_total: any;
- ganancia_perdida_capital: any;
- ingresos_intereses: any;
- costos_totales: any;
- ganancia_perdida_total: any;
- ganancia_perdida_capital_porcentaje: any;
- intereses_porcentaje: any;
- neto_antes_impuesto_porcentaje: any;
- neto_despues_impuesto_porcentaje: any;
- total_ingresos_recibidos: any;
- operation_result: boolean = false;
- operation_results_work: any = [];
- instrument_work_summary: any = [];
- ytm_vencimiento_porcentaje_compra: any;
- ytm_vencimiento_porcentaje_venta: any;
- comision_bolsa_venta: any;
- consolidado_proyeccion: any;
- ejecuciones = [
- { codigo: 1, nombre: "Completa" },
- { codigo: 0, nombre: "Parcial" }
- ];
- tipoEjecucion: number = 0;
- constructor(
- private formBuilder: FormBuilder,
- 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 != ""
- ) {
- if (+this.instrument_work["valor_nominal_venta"] > 0) {
- this.tipoEjecucion = 1;
- }
- this.hasProjections = true;
- this.consolidado_proyeccion = this.instrument_work.proyecciones[
- this.instrument_work.proyecciones.length - 1
- ];
- 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.slice(0, -1);
- 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({
- ejecucion: [this.instrument_exists ? "" : this.tipoEjecucion],
- renta_porcentaje: [
- this.instrument_exists ? "" : this.instrument_work.renta_porcentaje,
- [
- Validators.required,
- Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
- ]
- ],
- costo_cedeval: [
- this.instrument_exists ? "" : this.instrument_work.costo_cedeval,
- [
- Validators.required,
- Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
- ]
- ],
- costo_transferencia: [
- this.instrument_exists ? "" : this.instrument_work.costo_transferencia,
- [
- Validators.required,
- Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
- ]
- ],
- precio_compra: [
- this.instrument_exists ? "" : this.instrument_work.precio_compra,
- [
- Validators.required,
- Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
- ]
- ],
- valor_nominal_compra: [
- this.instrument_exists ? "" : this.instrument_work.valor_nominal_compra,
- [
- Validators.required,
- Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
- ]
- ],
- precio_vencimiento_compra: [
- this.instrument_exists
- ? ""
- : this.instrument_work.precio_vencimiento_compra,
- [
- Validators.required,
- Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
- ]
- ],
- cupon_porcentaje_compra: [
- this.instrument_exists
- ? ""
- : this.instrument_work.cupon_porcentaje_compra,
- [
- Validators.required,
- Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
- ]
- ],
- comision_casa_porcentaje_compra: [
- this.instrument_exists
- ? ""
- : this.instrument_work.comision_casa_porcentaje_compra,
- [
- Validators.required,
- Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
- ]
- ],
- comision_bolsa_porcentaje_compra: [
- this.instrument_exists
- ? ""
- : this.instrument_work.comision_bolsa_porcentaje_compra,
- [
- Validators.required,
- Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
- ]
- ],
- precio_venta: [
- this.instrument_exists ? "" : this.instrument_work.precio_venta
- ],
- valor_nominal_venta: [
- this.instrument_exists ? "" : this.instrument_work.valor_nominal_venta
- ],
- precio_vencimiento_venta: [
- this.instrument_exists
- ? ""
- : this.instrument_work.precio_vencimiento_venta
- ],
- cupon_porcentaje_venta: [
- this.instrument_exists
- ? ""
- : this.instrument_work.cupon_porcentaje_venta
- ],
- comision_casa_porcentaje_venta: [
- this.instrument_exists
- ? ""
- : this.instrument_work.comision_casa_porcentaje_venta
- ],
- comision_bolsa_porcentaje_venta: [
- this.instrument_exists
- ? ""
- : this.instrument_work.comision_bolsa_porcentaje_venta
- ],
- fecha_ultima_cupon_compra: [
- this.instrument_exists
- ? ""
- : {
- isRange: false,
- singleDate: {
- jsDate: parse(
- this.instrument_work.fecha_ultima_cupon_compra,
- "dd/MM/yyyy",
- new Date()
- ),
- formatted: this.instrument_work.fecha_ultima_cupon_compra
- }
- },
- Validators.required
- ],
- fecha_liquidacion_compra: [
- this.instrument_exists
- ? ""
- : {
- isRange: false,
- singleDate: {
- jsDate: parse(
- this.instrument_work.fecha_liquidacion_compra,
- "dd/MM/yyyy",
- new Date()
- ),
- formatted: this.instrument_work.fecha_liquidacion_compra
- }
- },
- Validators.required
- ],
- fecha_vencimiento_compra: [
- this.instrument_exists
- ? ""
- : {
- isRange: false,
- singleDate: {
- jsDate: parse(
- this.instrument_work.fecha_vencimiento_compra,
- "dd/MM/yyyy",
- new Date()
- ),
- formatted: this.instrument_work.fecha_vencimiento_compra
- }
- },
- Validators.required
- ],
- fecha_ultima_cupon_venta: [
- this.instrument_exists
- ? ""
- : {
- isRange: false,
- singleDate: {
- jsDate: parse(
- this.instrument_work.fecha_ultima_cupon_venta,
- "dd/MM/yyyy",
- new Date()
- ),
- formatted: this.instrument_work.fecha_ultima_cupon_venta
- }
- }
- ],
- fecha_liquidacion_venta: [
- this.instrument_exists
- ? ""
- : {
- isRange: false,
- singleDate: {
- jsDate: parse(
- this.instrument_work.fecha_liquidacion_venta,
- "dd/MM/yyyy",
- new Date()
- ),
- formatted: this.instrument_work.fecha_liquidacion_venta
- }
- }
- ],
- fecha_vencimiento_venta: [
- this.instrument_exists
- ? ""
- : {
- isRange: false,
- singleDate: {
- jsDate: parse(
- this.instrument_work.fecha_vencimiento_venta,
- "dd/MM/yyyy",
- new Date()
- ),
- formatted: this.instrument_work.fecha_vencimiento_venta
- }
- }
- ]
- });
- }
- get f() {
- return this.investmentProposalForm.controls;
- }
- save(form: any): boolean {
- if (!form.valid) {
- return false;
- }
- this.formDataService.setWork(this.bonosObject);
- 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
- .bonosCalc(
- "CINV", // Codigo del instrumento
- {
- id_tipo_base: +this.general.base_anual,
- id_formato_ingreso: +this.general.formato_ingreso,
- id_periodicidad: +this.general.periodicidad
- },
- {
- completo: this.tipoEjecucion,
- renta_porcentaje: +this.f.renta_porcentaje.value,
- costo_cedeval: +this.f.costo_cedeval.value,
- costo_transferencia: +this.f.costo_transferencia.value,
- valor_nominal_compra: +this.f.valor_nominal_compra.value,
- precio_compra: +this.f.precio_compra.value,
- precio_vencimiento_compra: +this.f.precio_vencimiento_compra.value,
- cupon_porcentaje_compra: +this.f.cupon_porcentaje_compra.value,
- comision_casa_porcentaje_compra: this.f
- .comision_casa_porcentaje_compra.value,
- comision_bolsa_porcentaje_compra: this.f
- .comision_bolsa_porcentaje_compra.value,
- valor_nominal_venta: +this.f.valor_nominal_venta.value,
- precio_venta: +this.f.precio_venta.value,
- precio_vencimiento_venta: +this.f.precio_vencimiento_venta.value,
- cupon_porcentaje_venta: +this.f.cupon_porcentaje_venta.value,
- comision_casa_porcentaje_venta: this.f.comision_casa_porcentaje_venta
- .value,
- comision_bolsa_porcentaje_venta: this.f
- .comision_bolsa_porcentaje_venta.value,
- fecha_vencimiento_compra:
- this.f.fecha_vencimiento_compra.value == ""
- ? ""
- : this.f.fecha_vencimiento_compra.value.singleDate.formatted,
- fecha_ultima_cupon_compra:
- this.f.fecha_ultima_cupon_compra.value == ""
- ? ""
- : this.f.fecha_ultima_cupon_compra.value.singleDate.formatted,
- fecha_liquidacion_compra:
- this.f.fecha_liquidacion_compra.value == ""
- ? ""
- : this.f.fecha_liquidacion_compra.value.singleDate.formatted,
- fecha_vencimiento_venta:
- this.f.fecha_vencimiento_venta.value == ""
- ? ""
- : this.f.fecha_vencimiento_venta.value.singleDate.formatted,
- fecha_ultima_cupon_venta:
- this.f.fecha_ultima_cupon_venta.value == ""
- ? ""
- : this.f.fecha_ultima_cupon_venta.value.singleDate.formatted,
- fecha_liquidacion_venta:
- this.f.fecha_liquidacion_venta.value == ""
- ? ""
- : this.f.fecha_liquidacion_venta.value.singleDate.formatted
- }
- )
- .subscribe(
- ans => {
- // Instrumento de compra
- this.comision_casa_compra =
- ans["result"]["instrumento_compra"]["comision_casa_compra"];
- this.comision_bolsa_compra =
- ans["result"]["instrumento_compra"]["comision_bolsa_compra"];
- this.fecha_siguiente_cupon_compra =
- ans["result"]["instrumento_compra"]["fecha_siguiente_cupon_compra"];
- this.dias_vencimiento_compra =
- ans["result"]["instrumento_compra"]["dias_vencimiento_compra"];
- this.dias_acumulados_compra =
- ans["result"]["instrumento_compra"]["dias_acumulados_compra"];
- this.ytm_vencimiento_comision_porcentaje_compra =
- ans["result"]["instrumento_compra"][
- "ytm_vencimiento_comision_porcentaje_compra"
- ];
- this.ytm_vencimiento_porcentaje_compra =
- ans["result"]["instrumento_compra"][
- "ytm_vencimiento_porcentaje_compra"
- ];
- this.interes_acumulado_compra =
- ans["result"]["instrumento_compra"]["interes_acumulado_compra"];
- this.interes_acumulado_porcentaje_compra =
- ans["result"]["instrumento_compra"][
- "interes_acumulado_porcentaje_compra"
- ];
- this.precio_sucio_porcentaje_compra =
- ans["result"]["instrumento_compra"][
- "precio_sucio_porcentaje_compra"
- ];
- this.valor_transado_compra =
- ans["result"]["instrumento_compra"]["valor_transado_compra"];
- this.monto_pagar = ans["result"]["instrumento_compra"]["monto_pagar"];
- this.fecha_inicio_vigencia =
- ans["result"]["instrumento_compra"]["fecha_inicio_vigencia"];
- // Instrumento de venta
- if (this.tipoEjecucion == 1) {
- this.comision_casa_venta =
- ans["result"]["instrumento_venta"]["comision_casa_venta"];
- this.comision_bolsa_venta =
- ans["result"]["instrumento_venta"]["comision_bolsa_venta"];
- this.fecha_siguiente_cupon_venta =
- ans["result"]["instrumento_venta"]["fecha_siguiente_cupon_venta"];
- this.dias_vencimiento_venta =
- ans["result"]["instrumento_venta"]["dias_vencimiento_venta"];
- this.dias_acumulados_venta =
- ans["result"]["instrumento_venta"]["dias_acumulados_venta"];
- this.ytm_vencimiento_comision_porcentaje_venta =
- ans["result"]["instrumento_venta"][
- "ytm_vencimiento_comision_porcentaje_venta"
- ];
- this.ytm_vencimiento_porcentaje_venta =
- ans["result"]["instrumento_venta"][
- "ytm_vencimiento_porcentaje_venta"
- ];
- this.interes_acumulado_venta =
- ans["result"]["instrumento_venta"]["interes_acumulado_venta"];
- this.interes_acumulado_porcentaje_venta =
- ans["result"]["instrumento_venta"][
- "interes_acumulado_porcentaje_venta"
- ];
- this.precio_sucio_porcentaje_venta =
- ans["result"]["instrumento_venta"][
- "precio_sucio_porcentaje_venta"
- ];
- this.valor_transado_venta =
- ans["result"]["instrumento_venta"]["valor_transado_venta"];
- this.monto_recibir =
- ans["result"]["instrumento_venta"]["monto_recibir"];
- this.operation_results_work = ans["result"]["resultado_operacion"];
- this.operation_result = true;
- }
- // Proyecciones
- this.proyecciones = ans["result"]["proyecciones"];
- if (this.proyecciones != undefined && this.proyecciones.length > 0) {
- this.hasProjections = true;
- let proyecciones_temp = this.proyecciones;
- this.consolidado_proyeccion =
- proyecciones_temp[proyecciones_temp.length - 1];
- this.proyecciones = ans["result"]["proyecciones"];
- }
- this.dataSource.data = this.proyecciones.slice(0, -1);
- this.dataSource2.data = this.proyecciones.slice(0, -1);
- this.dataSource.paginator = this.paginator;
- this.dataSource.sort = this.sort;
- this.bonosObject = {
- completo: this.tipoEjecucion,
- cancelado: this.tipoEjecucion,
- renta_porcentaje: this.investmentProposalForm.value
- .renta_porcentaje,
- costo_cedeval: this.investmentProposalForm.value.costo_cedeval,
- costo_transferencia: this.investmentProposalForm.value
- .costo_transferencia,
- valor_nominal_compra: this.investmentProposalForm.value
- .valor_nominal_compra,
- precio_compra: this.investmentProposalForm.value.precio_compra,
- precio_vencimiento_compra: this.investmentProposalForm.value
- .precio_vencimiento_compra,
- cupon_porcentaje_compra: this.investmentProposalForm.value
- .cupon_porcentaje_compra,
- comision_casa_porcentaje_compra: this.investmentProposalForm.value
- .comision_casa_porcentaje_compra,
- comision_bolsa_porcentaje_compra: this.investmentProposalForm.value
- .comision_bolsa_porcentaje_compra,
- fecha_vencimiento_compra: this.f.fecha_vencimiento_compra.value
- .singleDate.formatted,
- fecha_ultima_cupon_compra: this.f.fecha_ultima_cupon_compra.value
- .singleDate.formatted,
- fecha_liquidacion_compra: this.f.fecha_liquidacion_compra.value
- .singleDate.formatted,
- // Instrumento de compra
- comision_casa_compra: this.comision_casa_compra,
- comision_bolsa_compra: this.comision_bolsa_compra,
- fecha_siguiente_cupon_compra: this.fecha_siguiente_cupon_compra,
- dias_vencimiento_compra: this.dias_vencimiento_compra,
- dias_acumulados_compra: this.dias_acumulados_compra,
- ytm_vencimiento_porcentaje_compra: this
- .ytm_vencimiento_porcentaje_compra,
- ytm_vencimiento_comision_porcentaje_compra: this
- .ytm_vencimiento_comision_porcentaje_compra,
- interes_acumulado_compra: this.interes_acumulado_compra,
- interes_acumulado_porcentaje_compra: this
- .interes_acumulado_porcentaje_compra,
- precio_sucio_porcentaje_compra: this.precio_sucio_porcentaje_compra,
- valor_transado_compra: this.valor_transado_compra,
- monto_pagar: this.monto_pagar,
- fecha_inicio_vigencia: this.fecha_inicio_vigencia,
- // Resultado de la operacion
- /*
- monto_recibir: this.monto_recibir,
- dias_tenencia_total: this.dias_tenencia_total,
- ganancia_perdida_capital: this.ganancia_perdida_capital,
- ingresos_intereses: this.ingresos_intereses,
- costos_totales: this.costos_totales,
- ganancia_perdida_total: this.ganancia_perdida_total,
- ganancia_perdida_capital_porcentaje: this
- .ganancia_perdida_capital_porcentaje,
- intereses_porcentaje: this.intereses_porcentaje,
- neto_antes_impuesto_porcentaje: this.neto_antes_impuesto_porcentaje,
- neto_despues_impuesto_porcentaje: this
- .neto_despues_impuesto_porcentaje,
- total_ingresos_recibidos: this.total_ingresos_recibidos,
- */
- // Proyecciones
- proyecciones: this.proyecciones
- };
- if (this.tipoEjecucion == 1) {
- this.bonosObject[
- "valor_nominal_venta"
- ] = this.investmentProposalForm.value.valor_nominal_venta;
- this.bonosObject[
- "precio_venta"
- ] = this.investmentProposalForm.value.precio_venta;
- this.bonosObject[
- "precio_vencimiento_venta"
- ] = this.investmentProposalForm.value.precio_vencimiento_venta;
- this.bonosObject[
- "comision_casa_porcentaje_venta"
- ] = this.investmentProposalForm.value.comision_casa_porcentaje_venta;
- this.bonosObject[
- "comision_bolsa_porcentaje_venta"
- ] = this.investmentProposalForm.value.comision_bolsa_porcentaje_venta;
- this.bonosObject[
- "fecha_vencimiento_venta"
- ] = this.f.fecha_vencimiento_venta.value.singleDate.formatted;
- this.bonosObject[
- "fecha_ultima_cupon_venta"
- ] = this.f.fecha_ultima_cupon_venta.value.singleDate.formatted;
- this.bonosObject[
- "fecha_liquidacion_venta"
- ] = this.f.fecha_liquidacion_venta.value.singleDate.formatted;
- this.bonosObject["comision_casa_venta"] = this.comision_casa_venta;
- this.bonosObject[
- "comision_bolsa_venta"
- ] = this.comision_bolsa_venta;
- this.bonosObject[
- "fecha_siguiente_cupon_venta"
- ] = this.fecha_siguiente_cupon_venta;
- this.bonosObject[
- "dias_vencimiento_venta"
- ] = this.dias_vencimiento_venta;
- this.bonosObject[
- "dias_acumulados_venta"
- ] = this.dias_acumulados_venta;
- this.bonosObject[
- "ytm_vencimiento_porcentaje_venta"
- ] = this.ytm_vencimiento_porcentaje_venta;
- this.bonosObject[
- "ytm_vencimiento_comision_porcentaje_venta"
- ] = this.ytm_vencimiento_comision_porcentaje_venta;
- this.bonosObject[
- "interes_acumulado_venta"
- ] = this.interes_acumulado_venta;
- this.bonosObject[
- "interes_acumulado_porcentaje_venta"
- ] = this.interes_acumulado_porcentaje_venta;
- this.bonosObject[
- "precio_sucio_porcentaje_venta"
- ] = this.precio_sucio_porcentaje_venta;
- this.bonosObject[
- "valor_transado_venta"
- ] = this.valor_transado_venta;
- }
- this.formDataService.setWork(this.bonosObject);
- Swal.close();
- 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);
- }
- toggle_ejecucion(input: any) {
- this.tipoEjecucion = +input;
- this.setValidators();
- }
- setValidators() {
- const precio_venta = this.investmentProposalForm.get("precio_venta");
- const valor_nominal_venta = this.investmentProposalForm.get(
- "valor_nominal_venta"
- );
- const precio_vencimiento_venta = this.investmentProposalForm.get(
- "precio_vencimiento_venta"
- );
- const cupon_porcentaje_venta = this.investmentProposalForm.get(
- "cupon_porcentaje_venta"
- );
- const comision_casa_porcentaje_venta = this.investmentProposalForm.get(
- "comision_casa_porcentaje_venta"
- );
- const comision_bolsa_porcentaje_venta = this.investmentProposalForm.get(
- "comision_bolsa_porcentaje_venta"
- );
- const fecha_ultima_cupon_venta = this.investmentProposalForm.get(
- "fecha_ultima_cupon_venta"
- );
- const fecha_liquidacion_venta = this.investmentProposalForm.get(
- "fecha_liquidacion_venta"
- );
- const fecha_vencimiento_venta = this.investmentProposalForm.get(
- "fecha_vencimiento_venta"
- );
- if (this.tipoEjecucion == 1) {
- precio_venta.setValidators([
- Validators.required,
- Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
- ]);
- valor_nominal_venta.setValidators([
- Validators.required,
- Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
- ]);
- precio_vencimiento_venta.setValidators([
- Validators.required,
- Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
- ]);
- cupon_porcentaje_venta.setValidators([
- Validators.required,
- Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
- ]);
- comision_casa_porcentaje_venta.setValidators([
- Validators.required,
- Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
- ]);
- comision_bolsa_porcentaje_venta.setValidators([
- Validators.required,
- Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
- ]);
- fecha_ultima_cupon_venta.setValidators([Validators.required]);
- fecha_liquidacion_venta.setValidators([Validators.required]);
- fecha_vencimiento_venta.setValidators([Validators.required]);
- } else {
- precio_venta.setValidators(null);
- valor_nominal_venta.setValidators(null);
- precio_vencimiento_venta.setValidators(null);
- cupon_porcentaje_venta.setValidators(null);
- comision_casa_porcentaje_venta.setValidators(null);
- comision_bolsa_porcentaje_venta.setValidators(null);
- fecha_ultima_cupon_venta.setValidators(null);
- fecha_liquidacion_venta.setValidators(null);
- fecha_vencimiento_venta.setValidators(null);
- }
- precio_venta.updateValueAndValidity();
- valor_nominal_venta.updateValueAndValidity();
- precio_vencimiento_venta.updateValueAndValidity();
- cupon_porcentaje_venta.updateValueAndValidity();
- comision_casa_porcentaje_venta.updateValueAndValidity();
- comision_bolsa_porcentaje_venta.updateValueAndValidity();
- fecha_ultima_cupon_venta.updateValueAndValidity();
- fecha_liquidacion_venta.updateValueAndValidity();
- fecha_vencimiento_venta.updateValueAndValidity();
- }
- }
|