| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755 |
- 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-futuros",
- templateUrl: "./futuros.component.html"
- })
- export class FUTU implements InstrumentComponent {
- title: string = "Futuros";
- @Input() data: any;
- @Input() summary: boolean;
- @Input() investmentID: string;
- form: any;
- general: GeneralInfo;
- // For daterange
- daysLabels: any = {
- su: "Dom",
- mo: "Lun",
- tu: "Mar",
- we: "Mie",
- th: "Jue",
- fr: "Vie",
- sa: "Sab"
- };
- monthsLabels: any = {
- 1: "Ene",
- 2: "Feb",
- 3: "Mar",
- 4: "Abr",
- 5: "May",
- 6: "Jun",
- 7: "Jul",
- 8: "Ago",
- 9: "Sep",
- 10: "Oct",
- 11: "Nov",
- 12: "Dic"
- };
- investmentProposalForm: FormGroup;
- myDpOptions: IAngularMyDpOptions = {
- dateRange: false,
- dateFormat: "dd/mm/yyyy",
- dayLabels: this.daysLabels,
- monthLabels: this.monthsLabels
- };
- myDateInit: boolean = true;
- m_fecha_vencimiento_compra: IMyDateModel;
- m_fecha_operacion: IMyDateModel;
- m_fecha_rendencion: IMyDateModel;
- m_fecha_liquidacion_compra: IMyDateModel;
- submitted: boolean = false;
- instrument_exists: boolean;
- instrument_work: any = [];
- financials: any;
- base_types: any;
- futurosObject: {};
- hasProjections: boolean;
- tipoOperacion: any;
- tipoEjecucion: any;
- fecha_vencimiento: any;
- operation_result: boolean = false;
- operation_results_work: any = [];
- instrument_work_summary: any = [];
- fecha_operacion_compra: any;
- fecha_liquidacion_compra: any;
- precio_unitario_compra: any;
- comision_broker_compra: any;
- cantidad_contratos_compra: any;
- unidades_contratos_compra: any;
- valor_transado_compra: any;
- valor_pagado: any;
- ganancia_perdida: any;
- rendimiento: any;
- corto: any;
- fecha_inicio_vigencia: any;
- fecha_vencimiento_compra: any;
- fecha_operacion_venta: any;
- fecha_liquidacion_venta: any;
- precio_unitario_venta: any;
- comision_broker_venta: any;
- cantidad_contratos_venta: any;
- unidades_contratos_venta: any;
- valor_transado_venta: any;
- valor_recibido: any;
- fecha_vencimiento_venta: any;
- valor_nominal: any;
- valor_transado: any;
- comision_casa: any;
- comision_bolsa: any;
- fecha_liquidacion: any;
- operacion: any;
- ejecucion: any;
- operaciones = [
- { codigo: 1, nombre: "Corto" },
- { codigo: 0, nombre: "Largo" }
- ];
- ejecuciones = [
- { codigo: 1, nombre: "Completa" },
- { codigo: 0, nombre: "Parcial" }
- ];
- 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();
- console.log("init");
- console.log(this.operaciones);
- console.log(this.instrument_work);
- if (
- this.instrument_work != undefined &&
- this.instrument_work.completo == undefined
- ) {
- if (
- this.instrument_work.valor_pagado > 0 &&
- this.instrument_work.valor_recibido > 0
- ) {
- this.ejecucion = 1;
- } else {
- this.ejecucion = +this.instrument_work_summary.completo;
- }
- }
- this.investmentProposalForm = this.formBuilder.group({
- operacion: [this.instrument_exists ? "" : this.instrument_work.corto],
- ejecucion: [this.instrument_exists ? "" : this.ejecucion],
- ticker: [this.instrument_exists ? "" : this.instrument_work.ticker],
- precio_unitario_compra: [
- this.instrument_exists
- ? ""
- : this.instrument_work.precio_unitario_compra
- ],
- comision_broker_compra: [
- this.instrument_exists
- ? ""
- : this.instrument_work.comision_broker_compra
- ],
- cantidad_contratos_compra: [
- this.instrument_exists
- ? ""
- : this.instrument_work.cantidad_contratos_compra
- ],
- unidades_contratos_compra: [
- this.instrument_exists
- ? ""
- : this.instrument_work.unidades_contratos_compra
- ],
- fecha_operacion_compra: [
- this.instrument_exists
- ? ""
- : this.instrument_exists
- ? ""
- : {
- isRange: false,
- singleDate: {
- jsDate: parse(
- this.instrument_work.fecha_operacion_compra,
- "dd/MM/yyyy",
- new Date()
- ),
- formatted: this.instrument_work.fecha_operacion_compra
- }
- }
- ],
- 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
- }
- }
- ],
- 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
- }
- }
- ],
- precio_unitario_venta: [
- this.instrument_exists ? "" : this.instrument_work.precio_unitario_venta
- ],
- comision_broker_venta: [
- this.instrument_exists ? "" : this.instrument_work.comision_broker_venta
- ],
- cantidad_contratos_venta: [
- this.instrument_exists
- ? ""
- : this.instrument_work.cantidad_contratos_venta
- ],
- unidades_contratos_venta: [
- this.instrument_exists
- ? ""
- : this.instrument_work.unidades_contratos_venta
- ],
- fecha_operacion_venta: [
- this.instrument_exists
- ? ""
- : {
- isRange: false,
- singleDate: {
- jsDate: parse(
- this.instrument_work.fecha_operacion_venta,
- "dd/MM/yyyy",
- new Date()
- ),
- formatted: this.instrument_work.fecha_operacion_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
- }
- }
- ]
- });
- if (this.instrument_work != undefined) {
- this.instrument_work_summary = this.instrument_work;
- this.operation_result = true;
- console.log("datos");
- console.log(this.instrument_work_summary);
- this.operacion = +this.instrument_work_summary.corto;
- if (this.instrument_work_summary.completo == undefined) {
- if (
- this.instrument_work_summary.valor_pagado > 0 &&
- this.instrument_work_summary.valor_recibido > 0
- ) {
- this.ejecucion = 1;
- }
- } else {
- this.ejecucion = +this.instrument_work_summary.completo;
- }
- this.toggle_operacion(this.operacion);
- this.toggle_ejecucion(this.ejecucion);
- }
- }
- toggle_operacion(input: any) {
- this.tipoOperacion = +input;
- this.setValidators();
- }
- toggle_ejecucion(input: any) {
- this.tipoEjecucion = +input;
- this.setValidators();
- }
- setValidators() {
- console.log("tipo de operacion");
- console.log(this.tipoOperacion);
- console.log("tipo de ejecucion");
- console.log(this.tipoEjecucion);
- const ticker = this.investmentProposalForm.get("ticker");
- const precio_unitario_compra = this.investmentProposalForm.get(
- "precio_unitario_compra"
- );
- const comision_broker_compra = this.investmentProposalForm.get(
- "comision_broker_compra"
- );
- const cantidad_contratos_compra = this.investmentProposalForm.get(
- "cantidad_contratos_compra"
- );
- const unidades_contratos_compra = this.investmentProposalForm.get(
- "unidades_contratos_compra"
- );
- const fecha_operacion_compra = this.investmentProposalForm.get(
- "fecha_operacion_compra"
- );
- const fecha_liquidacion_compra = this.investmentProposalForm.get(
- "fecha_liquidacion_compra"
- );
- const fecha_vencimiento_compra = this.investmentProposalForm.get(
- "fecha_vencimiento_compra"
- );
- const precio_unitario_venta = this.investmentProposalForm.get(
- "precio_unitario_venta"
- );
- const comision_broker_venta = this.investmentProposalForm.get(
- "comision_broker_venta"
- );
- const cantidad_contratos_venta = this.investmentProposalForm.get(
- "cantidad_contratos_venta"
- );
- const unidades_contratos_venta = this.investmentProposalForm.get(
- "unidades_contratos_venta"
- );
- const fecha_operacion_venta = this.investmentProposalForm.get(
- "fecha_operacion_venta"
- );
- const fecha_liquidacion_venta = this.investmentProposalForm.get(
- "fecha_liquidacion_venta"
- );
- const fecha_vencimiento_venta = this.investmentProposalForm.get(
- "fecha_vencimiento_venta"
- );
- ticker.setValidators([Validators.required]);
- if (this.tipoEjecucion == 1) {
- precio_unitario_compra.setValidators([
- Validators.required,
- Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
- ]);
- comision_broker_compra.setValidators([
- Validators.required,
- Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
- ]);
- cantidad_contratos_compra.setValidators([
- Validators.required,
- Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
- ]);
- unidades_contratos_compra.setValidators([
- Validators.required,
- Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
- ]);
- fecha_operacion_compra.setValidators([Validators.required]);
- fecha_liquidacion_compra.setValidators([Validators.required]);
- if (this.tipoOperacion == 0) {
- fecha_vencimiento_compra.setValidators([Validators.required]);
- fecha_vencimiento_venta.setValidators(null);
- }
- precio_unitario_venta.setValidators([
- Validators.required,
- Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
- ]);
- comision_broker_venta.setValidators([
- Validators.required,
- Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
- ]);
- cantidad_contratos_venta.setValidators([
- Validators.required,
- Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
- ]);
- unidades_contratos_venta.setValidators([
- Validators.required,
- Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
- ]);
- fecha_operacion_venta.setValidators([Validators.required]);
- fecha_liquidacion_venta.setValidators([Validators.required]);
- if (this.tipoOperacion == 1) {
- fecha_vencimiento_venta.setValidators([Validators.required]);
- fecha_vencimiento_compra.setValidators(null);
- }
- } else {
- if (this.tipoOperacion == 1) {
- precio_unitario_venta.setValidators([
- Validators.required,
- Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
- ]);
- comision_broker_venta.setValidators([
- Validators.required,
- Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
- ]);
- cantidad_contratos_venta.setValidators([
- Validators.required,
- Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
- ]);
- unidades_contratos_venta.setValidators([
- Validators.required,
- Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
- ]);
- fecha_operacion_venta.setValidators([Validators.required]);
- fecha_liquidacion_venta.setValidators([Validators.required]);
- fecha_vencimiento_venta.setValidators(null); //.setValidators([Validators.required]);
- precio_unitario_compra.setValidators(null);
- comision_broker_compra.setValidators(null);
- cantidad_contratos_compra.setValidators(null);
- unidades_contratos_compra.setValidators(null);
- fecha_operacion_compra.setValidators(null);
- fecha_liquidacion_compra.setValidators(null);
- fecha_vencimiento_compra.setValidators(null);
- }
- if (this.tipoOperacion == 0) {
- precio_unitario_compra.setValidators([
- Validators.required,
- Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
- ]);
- comision_broker_compra.setValidators([
- Validators.required,
- Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
- ]);
- cantidad_contratos_compra.setValidators([
- Validators.required,
- Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
- ]);
- unidades_contratos_compra.setValidators([
- Validators.required,
- Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
- ]);
- fecha_operacion_compra.setValidators([Validators.required]);
- fecha_liquidacion_compra.setValidators([Validators.required]);
- fecha_vencimiento_compra.setValidators(null); //.setValidators([Validators.required]);
- precio_unitario_venta.setValidators(null);
- comision_broker_venta.setValidators(null);
- cantidad_contratos_venta.setValidators(null);
- unidades_contratos_venta.setValidators(null);
- fecha_operacion_venta.setValidators(null);
- fecha_liquidacion_venta.setValidators(null);
- fecha_vencimiento_venta.setValidators(null);
- }
- }
- precio_unitario_compra.updateValueAndValidity();
- comision_broker_compra.updateValueAndValidity();
- cantidad_contratos_compra.updateValueAndValidity();
- unidades_contratos_compra.updateValueAndValidity();
- fecha_operacion_compra.updateValueAndValidity();
- fecha_liquidacion_compra.updateValueAndValidity();
- fecha_vencimiento_compra.updateValueAndValidity();
- precio_unitario_venta.updateValueAndValidity();
- comision_broker_venta.updateValueAndValidity();
- cantidad_contratos_venta.updateValueAndValidity();
- unidades_contratos_venta.updateValueAndValidity();
- fecha_operacion_venta.updateValueAndValidity();
- fecha_liquidacion_venta.updateValueAndValidity();
- fecha_vencimiento_venta.updateValueAndValidity();
- }
- save(form: any): boolean {
- if (!form.valid) {
- return false;
- }
- this.formDataService.setWork(this.futurosObject);
- return true;
- }
- get f() {
- return this.investmentProposalForm.controls;
- }
- getCalculations(form: any, saveForm: boolean) {
- this.submitted = true;
- console.log(this.investmentProposalForm);
- if (!form.valid) {
- return false;
- }
- Swal.fire({
- allowOutsideClick: false,
- icon: "info",
- text: "Espere por favor..."
- });
- Swal.showLoading();
- this.instrumentCalcService
- .opcionesFuturosCalc(
- "OPC", // 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,
- corto: this.tipoOperacion,
- precio_unitario_compra: this.f.precio_unitario_compra.value,
- comision_broker_compra: this.f.comision_broker_compra.value,
- cantidad_contratos_compra: this.f.cantidad_contratos_compra.value,
- unidades_contratos_compra: this.f.unidades_contratos_compra.value,
- fecha_operacion_compra:
- this.f.fecha_operacion_compra.value == ""
- ? ""
- : this.f.fecha_operacion_compra.value.singleDate.formatted,
- fecha_liquidacion_compra:
- this.f.fecha_liquidacion_compra.value == ""
- ? ""
- : this.f.fecha_liquidacion_compra.value.singleDate.formatted,
- fecha_vencimiento_compra:
- this.f.fecha_vencimiento_compra.value == ""
- ? ""
- : this.f.fecha_vencimiento_compra.value.singleDate.formatted,
- precio_unitario_venta: this.f.precio_unitario_venta.value,
- comision_broker_venta: this.f.comision_broker_venta.value,
- cantidad_contratos_venta: this.f.cantidad_contratos_venta.value,
- unidades_contratos_venta: this.f.unidades_contratos_venta.value,
- fecha_operacion_venta:
- this.f.fecha_operacion_venta.value == ""
- ? ""
- : this.f.fecha_operacion_venta.value.singleDate.formatted,
- fecha_liquidacion_venta:
- this.f.fecha_liquidacion_venta.value == ""
- ? ""
- : this.f.fecha_liquidacion_venta.value.singleDate.formatted,
- fecha_vencimiento_venta:
- this.f.fecha_vencimiento_venta.value == ""
- ? ""
- : this.f.fecha_vencimiento_venta.value.singleDate.formatted
- }
- )
- .subscribe(
- ans => {
- // Instrumento compra
- if (this.tipoOperacion == 0 || this.tipoEjecucion == 1) {
- this.fecha_operacion_compra =
- ans["result"]["instrumento_compra"]["fecha_operacion_compra"];
- this.fecha_liquidacion_compra =
- ans["result"]["instrumento_compra"]["fecha_liquidacion_compra"];
- this.precio_unitario_compra =
- ans["result"]["instrumento_compra"]["precio_unitario_compra"];
- this.comision_broker_compra =
- ans["result"]["instrumento_compra"]["comision_broker_compra"];
- this.cantidad_contratos_compra =
- ans["result"]["instrumento_compra"]["cantidad_contratos_compra"];
- this.unidades_contratos_compra =
- ans["result"]["instrumento_compra"]["unidades_contratos_compra"];
- this.valor_transado_compra =
- ans["result"]["instrumento_compra"]["valor_transado_compra"];
- this.valor_pagado =
- ans["result"]["instrumento_compra"]["valor_pagado"];
- this.ganancia_perdida =
- ans["result"]["instrumento_compra"]["ganancia_perdida"];
- this.rendimiento =
- ans["result"]["instrumento_compra"]["rendimiento"];
- }
- // Si es operacion largo y ejecucion completa
- if (this.tipoOperacion == 0) {
- this.corto = ans["result"]["instrumento_compra"]["corto"];
- this.fecha_inicio_vigencia =
- ans["result"]["instrumento_compra"]["fecha_inicio_vigencia"];
- this.fecha_vencimiento_compra =
- ans["result"]["instrumento_compra"]["fecha_vencimiento_compra"];
- }
- // Instrumento venta
- if (this.tipoOperacion == 1 || this.tipoEjecucion == 1) {
- this.fecha_operacion_venta =
- ans["result"]["instrumento_venta"]["fecha_operacion_venta"];
- this.fecha_liquidacion_venta =
- ans["result"]["instrumento_venta"]["fecha_liquidacion_venta"];
- this.precio_unitario_venta =
- ans["result"]["instrumento_venta"]["precio_unitario_venta"];
- this.comision_broker_venta =
- ans["result"]["instrumento_venta"]["comision_broker_venta"];
- this.cantidad_contratos_venta =
- ans["result"]["instrumento_venta"]["cantidad_contratos_venta"];
- this.unidades_contratos_venta =
- ans["result"]["instrumento_venta"]["unidades_contratos_venta"];
- this.valor_transado_venta =
- ans["result"]["instrumento_venta"]["valor_transado_venta"];
- this.valor_recibido =
- ans["result"]["instrumento_venta"]["valor_recibido "];
- }
- // Si es operacion corto
- if (this.tipoOperacion == 1) {
- this.corto = ans["result"]["instrumento_venta"]["corto"];
- this.fecha_inicio_vigencia =
- ans["result"]["instrumento_venta"]["fecha_inicio_vigencia"];
- this.fecha_vencimiento_venta =
- ans["result"]["instrumento_venta"]["fecha_vencimiento_venta"];
- }
- this.operation_result = true;
- this.futurosObject = {
- completo: this.tipoEjecucion,
- corto: this.tipoOperacion,
- ticker: this.investmentProposalForm.value.ticker,
- fecha_inicio_vigencia: this.fecha_inicio_vigencia
- };
- if (this.tipoOperacion == 0 || this.tipoEjecucion == 1) {
- (this.futurosObject[
- "precio_unitario_compra"
- ] = this.investmentProposalForm.value.precio_unitario_compra),
- (this.futurosObject[
- "comision_broker_compra"
- ] = this.investmentProposalForm.value.comision_broker_compra),
- (this.futurosObject[
- "cantidad_contratos_compra"
- ] = this.investmentProposalForm.value.cantidad_contratos_compra),
- (this.futurosObject[
- "unidades_contratos_compra"
- ] = this.investmentProposalForm.value.unidades_contratos_compra),
- (this.futurosObject["fecha_operacion_compra"] =
- this.investmentProposalForm.value.fecha_operacion_compra == ""
- ? ""
- : this.investmentProposalForm.value.fecha_operacion_compra
- .singleDate.formatted),
- (this.futurosObject["fecha_liquidacion_compra"] =
- this.investmentProposalForm.value.fecha_liquidacion_compra == ""
- ? ""
- : this.investmentProposalForm.value.fecha_liquidacion_compra
- .singleDate.formatted),
- (this.futurosObject[
- "valor_transado_compra"
- ] = this.valor_transado_compra),
- (this.futurosObject["valor_pagado"] = this.valor_pagado),
- (this.futurosObject["ganancia_perdida"] = this.ganancia_perdida),
- (this.futurosObject["rendimiento"] = this.rendimiento);
- }
- if (this.tipoOperacion == 1 || this.tipoEjecucion == 1) {
- (this.futurosObject[
- "precio_unitario_venta"
- ] = this.investmentProposalForm.value.precio_unitario_venta),
- (this.futurosObject[
- "comision_broker_venta"
- ] = this.investmentProposalForm.value.comision_broker_venta),
- (this.futurosObject[
- "cantidad_contratos_venta"
- ] = this.investmentProposalForm.value.cantidad_contratos_venta),
- (this.futurosObject[
- "unidades_contratos_venta"
- ] = this.investmentProposalForm.value.unidades_contratos_venta),
- (this.futurosObject["fecha_operacion_venta"] =
- this.investmentProposalForm.value.fecha_operacion_venta == ""
- ? ""
- : this.investmentProposalForm.value.fecha_operacion_venta
- .singleDate.formatted),
- (this.futurosObject["fecha_liquidacion_venta"] =
- this.investmentProposalForm.value.fecha_liquidacion_venta == ""
- ? ""
- : this.investmentProposalForm.value.fecha_liquidacion_venta
- .singleDate.formatted),
- (this.futurosObject[
- "valor_transado_venta"
- ] = this.valor_transado_venta),
- (this.futurosObject["valor_recibido"] = this.valor_recibido);
- }
- if (this.tipoOperacion == 0) {
- this.futurosObject[
- "fecha_vencimiento_compra"
- ] = this.fecha_vencimiento_compra;
- }
- if (this.tipoOperacion == 1) {
- this.futurosObject[
- "fecha_vencimiento_venta"
- ] = this.fecha_vencimiento_venta;
- }
- if (this.tipoEjecucion == 1) {
- this.futurosObject["fecha_cancelado"] = this.datepipe.transform(
- new Date(),
- "dd/MM/yyyy"
- ); //.toISOString().slice(0, 10);
- }
- this.formDataService.setWork(this.futurosObject);
- 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);
- }
- }
|