eurobonos.component.ts 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  1. import { Component, OnInit, Input, ViewChild } from "@angular/core";
  2. import { InstrumentComponent } from "@app/components/investment-proposals/instrument/instrument.component";
  3. import { FormBuilder, FormGroup, Validators } from "@angular/forms";
  4. import { IAngularMyDpOptions, IMyDateModel } from "angular-mydatepicker";
  5. import { formatDate, DatePipe } from "@angular/common";
  6. import { Router } from "@angular/router";
  7. import { FormInvestmentProposalService } from "@app/services/form-investment-proposal.service";
  8. import { CatalogsService } from "@app/services/catalogs.service";
  9. import { InstrumentCalculations } from "@app/services/instrument-calculations.service";
  10. import Swal from "sweetalert2";
  11. import { GeneralInfo } from "@app/models/investment-proposal-form";
  12. import { parse } from "date-fns";
  13. import { MatPaginator } from "@angular/material/paginator";
  14. import { MatSort } from "@angular/material/sort";
  15. import { MatTableDataSource } from "@angular/material/table";
  16. @Component({
  17. selector: "app-eurobonos",
  18. templateUrl: "./eurobonos.component.html"
  19. })
  20. export class EURB implements InstrumentComponent {
  21. title: string = "Eurobonos";
  22. @Input() data: any;
  23. @Input() summary: boolean;
  24. @Input() investmentID: string;
  25. displayedColumns: string[] = [
  26. "posicion",
  27. "plazo",
  28. "fecha_pago",
  29. "ingreso_bruto",
  30. "ingreso_neto",
  31. "impuesto"
  32. ];
  33. @ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
  34. @ViewChild(MatSort, { static: true }) sort: MatSort;
  35. form: any;
  36. general: GeneralInfo;
  37. // For daterange
  38. daysLabels: any = {
  39. su: "Dom",
  40. mo: "Lun",
  41. tu: "Mar",
  42. we: "Mie",
  43. th: "Jue",
  44. fr: "Vie",
  45. sa: "Sab"
  46. };
  47. monthsLabels: any = {
  48. 1: "Ene",
  49. 2: "Feb",
  50. 3: "Mar",
  51. 4: "Abr",
  52. 5: "May",
  53. 6: "Jun",
  54. 7: "Jul",
  55. 8: "Ago",
  56. 9: "Sep",
  57. 10: "Oct",
  58. 11: "Nov",
  59. 12: "Dic"
  60. };
  61. investmentProposalForm: FormGroup;
  62. myDpOptions: IAngularMyDpOptions = {
  63. dateRange: false,
  64. dateFormat: "dd/mm/yyyy",
  65. dayLabels: this.daysLabels,
  66. monthLabels: this.monthsLabels
  67. };
  68. myDateInit: boolean = true;
  69. m_fecha_vencimiento_compra: IMyDateModel;
  70. m_fecha_ultima_cupon_compra: IMyDateModel;
  71. m_fecha_rendencion: IMyDateModel;
  72. m_fecha_liquidacion_compra: IMyDateModel;
  73. submitted: boolean = false;
  74. instrument_exists: boolean;
  75. instrument_work: any = [];
  76. financials: any;
  77. base_types: any;
  78. proyecciones: any;
  79. bonosObject: {};
  80. dataSource = new MatTableDataSource(this.proyecciones);
  81. dataSource2 = new MatTableDataSource(this.proyecciones);
  82. hasProjections: boolean;
  83. fecha_vencimiento: any;
  84. comision_casa_compra: any;
  85. comision_bolsa_compra: any;
  86. fecha_siguiente_cupon_compra: any;
  87. dias_vencimiento_compra: any;
  88. dias_acumulados_compra: any;
  89. ytm_vencimiento_comision_porcentaje_compra: any;
  90. interes_acumulado_compra: any;
  91. interes_acumulado_porcentaje_compra: any;
  92. precio_sucio_porcentaje_compra: any;
  93. valor_transado_compra: any;
  94. monto_pagar: any;
  95. fecha_inicio_vigencia: any;
  96. comision_casa_venta: any;
  97. fecha_siguiente_cupon_venta: any;
  98. dias_vencimiento_venta: any;
  99. dias_acumulados_venta: any;
  100. ytm_vencimiento_comision_porcentaje_venta: any;
  101. interes_acumulado_venta: any;
  102. interes_acumulado_porcentaje_venta: any;
  103. precio_sucio_porcentaje_venta: any;
  104. valor_transado_venta: any;
  105. monto_recibir: any;
  106. dias_tenencia_total: any;
  107. ganancia_perdida_capital: any;
  108. ingresos_intereses: any;
  109. costos_totales: any;
  110. ganancia_perdida_total: any;
  111. ganancia_perdida_capital_porcentaje: any;
  112. intereses_porcentaje: any;
  113. neto_antes_impuesto_porcentaje: any;
  114. neto_despues_impuesto_porcentaje: any;
  115. total_ingresos_recibidos: any;
  116. operation_result: boolean = false;
  117. operation_results_work: any = [];
  118. constructor(
  119. private formBuilder: FormBuilder,
  120. private router: Router,
  121. private formDataService: FormInvestmentProposalService,
  122. private catalogService: CatalogsService,
  123. private instrumentCalcService: InstrumentCalculations,
  124. public datepipe: DatePipe
  125. ) {
  126. this.instrument_work = this.formDataService.getWork();
  127. this.operation_results_work = this.formDataService.getWork();
  128. this.instrument_work = this.instrument_work["instrumento"];
  129. this.operation_results_work = this.operation_results_work[
  130. "resultado_operacion"
  131. ];
  132. this.instrument_exists = this.instrument_work == undefined;
  133. this.general = this.formDataService.getGeneralInfo();
  134. if (
  135. this.instrument_work != undefined &&
  136. (this.instrument_work.proyecciones != "" ||
  137. this.instrument_work != undefined)
  138. ) {
  139. this.hasProjections = true;
  140. this.dataSource2.data = this.instrument_work.proyecciones;
  141. this.dataSource2.paginator = this.paginator;
  142. this.dataSource2.sort = this.sort;
  143. } else {
  144. this.hasProjections = false;
  145. }
  146. if (
  147. this.operation_results_work != undefined ||
  148. this.operation_results_work != ""
  149. ) {
  150. this.operation_result = true;
  151. }
  152. this.investmentProposalForm = this.formBuilder.group({
  153. costo_transferencia: [
  154. this.instrument_exists ? "" : this.instrument_work.costo_transferencia,
  155. [
  156. Validators.required,
  157. Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
  158. ]
  159. ],
  160. precio_compra: [
  161. this.instrument_exists ? "" : this.instrument_work.precio_compra,
  162. [
  163. Validators.required,
  164. Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
  165. ]
  166. ],
  167. valor_nominal_compra: [
  168. this.instrument_exists ? "" : this.instrument_work.valor_nominal_compra,
  169. [
  170. Validators.required,
  171. Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
  172. ]
  173. ],
  174. precio_vencimiento_compra: [
  175. this.instrument_exists
  176. ? ""
  177. : this.instrument_work.precio_vencimiento_compra,
  178. [
  179. Validators.required,
  180. Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
  181. ]
  182. ],
  183. cupon_porcentaje_compra: [
  184. this.instrument_exists
  185. ? ""
  186. : this.instrument_work.cupon_porcentaje_compra,
  187. [
  188. Validators.required,
  189. Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
  190. ]
  191. ],
  192. comision_casa_porcentaje_compra: [
  193. this.instrument_exists
  194. ? ""
  195. : this.instrument_work.comision_casa_porcentaje_compra,
  196. [
  197. Validators.required,
  198. Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
  199. ]
  200. ],
  201. comision_bolsa_porcentaje_compra: [
  202. this.instrument_exists
  203. ? ""
  204. : this.instrument_work.comision_bolsa_porcentaje_compra,
  205. [
  206. Validators.required,
  207. Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
  208. ]
  209. ],
  210. precio_venta: [
  211. this.instrument_exists ? "" : this.instrument_work.precio_venta,
  212. [
  213. Validators.required,
  214. Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
  215. ]
  216. ],
  217. valor_nominal_venta: [
  218. this.instrument_exists ? "" : this.instrument_work.valor_nominal_venta,
  219. [
  220. Validators.required,
  221. Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
  222. ]
  223. ],
  224. precio_vencimiento_venta: [
  225. this.instrument_exists
  226. ? ""
  227. : this.instrument_work.precio_vencimiento_venta,
  228. [
  229. Validators.required,
  230. Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
  231. ]
  232. ],
  233. cupon_porcentaje_venta: [
  234. this.instrument_exists
  235. ? ""
  236. : this.instrument_work.cupon_porcentaje_venta,
  237. [
  238. Validators.required,
  239. Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
  240. ]
  241. ],
  242. comision_casa_porcentaje_venta: [
  243. this.instrument_exists
  244. ? ""
  245. : this.instrument_work.comision_casa_porcentaje_venta,
  246. [
  247. Validators.required,
  248. Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
  249. ]
  250. ],
  251. comision_bolsa_porcentaje_venta: [
  252. this.instrument_exists
  253. ? ""
  254. : this.instrument_work.comision_bolsa_porcentaje_venta,
  255. [
  256. Validators.required,
  257. Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
  258. ]
  259. ],
  260. fecha_ultima_cupon_compra: [
  261. this.instrument_exists
  262. ? ""
  263. : {
  264. isRange: false,
  265. singleDate: {
  266. jsDate: parse(
  267. this.instrument_work.fecha_ultima_cupon_compra,
  268. "dd/MM/yyyy",
  269. new Date()
  270. ),
  271. formatted: this.instrument_work.fecha_ultima_cupon_compra
  272. }
  273. },
  274. Validators.required
  275. ],
  276. fecha_liquidacion_compra: [
  277. this.instrument_exists
  278. ? ""
  279. : {
  280. isRange: false,
  281. singleDate: {
  282. jsDate: parse(
  283. this.instrument_work.fecha_liquidacion_compra,
  284. "dd/MM/yyyy",
  285. new Date()
  286. ),
  287. formatted: this.instrument_work.fecha_liquidacion_compra
  288. }
  289. },
  290. Validators.required
  291. ],
  292. fecha_vencimiento_compra: [
  293. this.instrument_exists
  294. ? ""
  295. : {
  296. isRange: false,
  297. singleDate: {
  298. jsDate: parse(
  299. this.instrument_work.fecha_vencimiento_compra,
  300. "dd/MM/yyyy",
  301. new Date()
  302. ),
  303. formatted: this.instrument_work.fecha_vencimiento_compra
  304. }
  305. },
  306. Validators.required
  307. ],
  308. fecha_ultima_cupon_venta: [
  309. this.instrument_exists
  310. ? ""
  311. : {
  312. isRange: false,
  313. singleDate: {
  314. jsDate: parse(
  315. this.instrument_work.fecha_ultima_cupon_venta,
  316. "dd/MM/yyyy",
  317. new Date()
  318. ),
  319. formatted: this.instrument_work.fecha_ultima_cupon_venta
  320. }
  321. },
  322. Validators.required
  323. ],
  324. fecha_liquidacion_venta: [
  325. this.instrument_exists
  326. ? ""
  327. : {
  328. isRange: false,
  329. singleDate: {
  330. jsDate: parse(
  331. this.instrument_work.fecha_liquidacion_venta,
  332. "dd/MM/yyyy",
  333. new Date()
  334. ),
  335. formatted: this.instrument_work.fecha_liquidacion_venta
  336. }
  337. },
  338. Validators.required
  339. ],
  340. fecha_vencimiento_venta: [
  341. this.instrument_exists
  342. ? ""
  343. : {
  344. isRange: false,
  345. singleDate: {
  346. jsDate: parse(
  347. this.instrument_work.fecha_vencimiento_venta,
  348. "dd/MM/yyyy",
  349. new Date()
  350. ),
  351. formatted: this.instrument_work.fecha_vencimiento_venta
  352. }
  353. },
  354. Validators.required
  355. ]
  356. });
  357. // Get calculations, always
  358. if (
  359. this.instrument_work != undefined &&
  360. this.instrument_work.proyecciones == ""
  361. ) {
  362. this.getCalculations(this.investmentProposalForm, false);
  363. }
  364. }
  365. get f() {
  366. return this.investmentProposalForm.controls;
  367. }
  368. save(form: any): boolean {
  369. if (!form.valid) {
  370. return false;
  371. }
  372. this.formDataService.setWork(this.bonosObject);
  373. return true;
  374. }
  375. getCalculations(form: any, saveForm: boolean) {
  376. this.submitted = true;
  377. if (!form.valid) {
  378. return false;
  379. }
  380. Swal.fire({
  381. allowOutsideClick: false,
  382. icon: "info",
  383. text: "Espere por favor..."
  384. });
  385. Swal.showLoading();
  386. this.instrumentCalcService
  387. .bonosCalc(
  388. "EURB", // Codigo del instrumento
  389. {
  390. id_tipo_base: +this.general.base_anual,
  391. id_formato_ingreso: +this.general.formato_ingreso,
  392. id_periodicidad: +this.general.periodicidad
  393. },
  394. {
  395. costo_transferencia: +this.f.costo_transferencia.value,
  396. valor_nominal_compra: +this.f.valor_nominal_compra.value,
  397. precio_compra: +this.f.precio_compra.value,
  398. precio_vencimiento_compra: +this.f.precio_vencimiento_compra.value,
  399. cupon_porcentaje_compra: +this.f.cupon_porcentaje_compra.value,
  400. comision_casa_porcentaje_compra: this.f
  401. .comision_casa_porcentaje_compra.value,
  402. comision_bolsa_porcentaje_compra: this.f
  403. .comision_bolsa_porcentaje_compra.value,
  404. valor_nominal_venta: +this.f.valor_nominal_venta.value,
  405. precio_venta: +this.f.precio_venta.value,
  406. precio_vencimiento_venta: +this.f.precio_vencimiento_venta.value,
  407. cupon_porcentaje_venta: +this.f.cupon_porcentaje_venta.value,
  408. comision_casa_porcentaje_venta: this.f.comision_casa_porcentaje_venta
  409. .value,
  410. comision_bolsa_porcentaje_venta: this.f
  411. .comision_bolsa_porcentaje_venta.value,
  412. fecha_vencimiento_compra: this.f.fecha_vencimiento_compra.value
  413. .singleDate.formatted,
  414. fecha_ultima_cupon_compra: this.f.fecha_ultima_cupon_compra.value
  415. .singleDate.formatted,
  416. fecha_liquidacion_compra: this.f.fecha_liquidacion_compra.value
  417. .singleDate.formatted,
  418. fecha_vencimiento_venta: this.f.fecha_vencimiento_venta.value
  419. .singleDate.formatted,
  420. fecha_ultima_cupon_venta: this.f.fecha_ultima_cupon_venta.value
  421. .singleDate.formatted,
  422. fecha_liquidacion_venta: this.f.fecha_liquidacion_venta.value
  423. .singleDate.formatted
  424. }
  425. )
  426. .subscribe(
  427. ans => {
  428. // Instrumento de compra
  429. this.comision_casa_compra =
  430. ans["result"]["instrumento_compra"]["comision_casa_compra"];
  431. this.comision_bolsa_compra =
  432. ans["result"]["instrumento_compra"]["comision_bolsa_compra"];
  433. this.fecha_siguiente_cupon_compra =
  434. ans["result"]["instrumento_compra"]["fecha_siguiente_cupon_compra"];
  435. this.dias_vencimiento_compra =
  436. ans["result"]["instrumento_compra"]["dias_vencimiento_compra"];
  437. this.dias_acumulados_compra =
  438. ans["result"]["instrumento_compra"]["dias_acumulados_compra"];
  439. this.ytm_vencimiento_comision_porcentaje_compra =
  440. ans["result"]["instrumento_compra"][
  441. "ytm_vencimiento_comision_porcentaje_compra"
  442. ];
  443. this.interes_acumulado_compra =
  444. ans["result"]["instrumento_compra"]["interes_acumulado_compra"];
  445. this.interes_acumulado_porcentaje_compra =
  446. ans["result"]["instrumento_compra"][
  447. "interes_acumulado_porcentaje_compra"
  448. ];
  449. this.precio_sucio_porcentaje_compra =
  450. ans["result"]["instrumento_compra"][
  451. "precio_sucio_porcentaje_compra"
  452. ];
  453. this.valor_transado_compra =
  454. ans["result"]["instrumento_compra"]["valor_transado_compra"];
  455. this.monto_pagar = ans["result"]["instrumento_compra"]["monto_pagar"];
  456. this.fecha_inicio_vigencia =
  457. ans["result"]["instrumento_compra"]["fecha_inicio_vigencia"];
  458. // Instrumento de venta
  459. this.comision_casa_venta =
  460. ans["result"]["instrumento_venta"]["comision_casa_venta"];
  461. this.fecha_siguiente_cupon_venta =
  462. ans["result"]["instrumento_venta"]["fecha_siguiente_cupon_venta"];
  463. this.dias_vencimiento_venta =
  464. ans["result"]["instrumento_venta"]["dias_vencimiento_venta"];
  465. this.dias_acumulados_venta =
  466. ans["result"]["instrumento_venta"]["dias_acumulados_venta"];
  467. this.ytm_vencimiento_comision_porcentaje_venta =
  468. ans["result"]["instrumento_venta"][
  469. "ytm_vencimiento_comision_porcentaje_venta"
  470. ];
  471. this.interes_acumulado_venta =
  472. ans["result"]["instrumento_venta"]["interes_acumulado_venta"];
  473. this.interes_acumulado_porcentaje_venta =
  474. ans["result"]["instrumento_venta"][
  475. "interes_acumulado_porcentaje_venta"
  476. ];
  477. this.precio_sucio_porcentaje_venta =
  478. ans["result"]["instrumento_venta"]["precio_sucio_porcentaje_venta"];
  479. this.valor_transado_venta =
  480. ans["result"]["instrumento_venta"]["valor_transado_venta"];
  481. this.monto_recibir =
  482. ans["result"]["instrumento_venta"]["monto_recibir"];
  483. // Resultado de la operacion
  484. this.dias_tenencia_total =
  485. ans["result"]["resultado_operacion"]["dias_tenencia_total"];
  486. this.ganancia_perdida_capital =
  487. ans["result"]["resultado_operacion"]["ganancia_perdida_capital"];
  488. this.ingresos_intereses =
  489. ans["result"]["resultado_operacion"]["ingresos_intereses"];
  490. this.costos_totales =
  491. ans["result"]["resultado_operacion"]["costos_totales"];
  492. this.ganancia_perdida_total =
  493. ans["result"]["resultado_operacion"]["ganancia_perdida_total"];
  494. this.ganancia_perdida_capital_porcentaje =
  495. ans["result"]["resultado_operacion"][
  496. "ganancia_perdida_capital_porcentaje"
  497. ];
  498. this.intereses_porcentaje =
  499. ans["result"]["resultado_operacion"]["intereses_porcentaje"];
  500. this.neto_antes_impuesto_porcentaje =
  501. ans["result"]["resultado_operacion"][
  502. "neto_antes_impuesto_porcentaje"
  503. ];
  504. this.neto_despues_impuesto_porcentaje =
  505. ans["result"]["resultado_operacion"][
  506. "neto_despues_impuesto_porcentaje"
  507. ];
  508. this.total_ingresos_recibidos =
  509. ans["result"]["resultado_operacion"]["total_ingresos_recibidos"];
  510. // Proyecciones
  511. this.proyecciones = ans["result"]["proyecciones"];
  512. this.operation_result = true;
  513. this.dataSource.data = this.proyecciones;
  514. this.dataSource2.data = this.proyecciones;
  515. this.dataSource.paginator = this.paginator;
  516. this.dataSource.sort = this.sort;
  517. this.bonosObject = {
  518. costo_transferencia: this.investmentProposalForm.value
  519. .costo_transferencia,
  520. valor_nominal_compra: this.investmentProposalForm.value
  521. .valor_nominal_compra,
  522. precio_compra: this.investmentProposalForm.value.precio_compra,
  523. precio_vencimiento_compra: this.investmentProposalForm.value
  524. .precio_vencimiento_compra,
  525. cupon_porcentaje_compra: this.investmentProposalForm.value
  526. .cupon_porcentaje_compra,
  527. comision_casa_porcentaje_compra: this.investmentProposalForm.value
  528. .comision_casa_porcentaje_compra,
  529. comision_bolsa_porcentaje_compra: this.investmentProposalForm.value
  530. .comision_bolsa_porcentaje_compra,
  531. ytm_vencimiento_porcentaje_compra: this.investmentProposalForm.value
  532. .ytm_vencimiento_porcentaje_compra,
  533. valor_nominal_venta: this.investmentProposalForm.value
  534. .valor_nominal_venta,
  535. precio_venta: this.investmentProposalForm.value.precio_venta,
  536. precio_vencimiento_venta: this.investmentProposalForm.value
  537. .precio_vencimiento_venta,
  538. cupon_porcentaje_venta: this.investmentProposalForm.value
  539. .cupon_porcentaje_venta,
  540. comision_casa_porcentaje_venta: this.investmentProposalForm.value
  541. .comision_casa_porcentaje_venta,
  542. comision_bolsa_porcentaje_venta: this.investmentProposalForm.value
  543. .comision_bolsa_porcentaje_venta,
  544. ytm_vencimiento_porcentaje_venta: this.investmentProposalForm.value
  545. .ytm_vencimiento_porcentaje_venta,
  546. fecha_vencimiento_compra: this.f.fecha_vencimiento_compra.value
  547. .singleDate.formatted,
  548. fecha_ultima_cupon_compra: this.f.fecha_ultima_cupon_compra.value
  549. .singleDate.formatted,
  550. fecha_liquidacion_compra: this.f.fecha_liquidacion_compra.value
  551. .singleDate.formatted,
  552. fecha_vencimiento_venta: this.f.fecha_vencimiento_venta.value
  553. .singleDate.formatted,
  554. fecha_ultima_cupon_venta: this.f.fecha_ultima_cupon_venta.value
  555. .singleDate.formatted,
  556. fecha_liquidacion_venta: this.f.fecha_liquidacion_venta.value
  557. .singleDate.formatted,
  558. // Instrumento de compra
  559. comision_casa_compra: this.comision_casa_compra,
  560. comision_bolsa_compra: this.comision_bolsa_compra,
  561. fecha_siguiente_cupon_compra: this.fecha_siguiente_cupon_compra,
  562. dias_vencimiento_compra: this.dias_vencimiento_compra,
  563. dias_acumulados_compra: this.dias_acumulados_compra,
  564. ytm_vencimiento_comision_porcentaje_compra: this
  565. .ytm_vencimiento_comision_porcentaje_compra,
  566. interes_acumulado_compra: this.interes_acumulado_compra,
  567. interes_acumulado_porcentaje_compra: this
  568. .interes_acumulado_porcentaje_compra,
  569. precio_sucio_porcentaje_compra: this.precio_sucio_porcentaje_compra,
  570. valor_transado_compra: this.valor_transado_compra,
  571. monto_pagar: this.monto_pagar,
  572. fecha_inicio_vigencia: this.fecha_inicio_vigencia,
  573. // Instrumento de venta
  574. comision_casa_venta: this.comision_casa_venta,
  575. fecha_siguiente_cupon_venta: this.fecha_siguiente_cupon_venta,
  576. dias_vencimiento_venta: this.dias_vencimiento_venta,
  577. dias_acumulados_venta: this.dias_acumulados_venta,
  578. ytm_vencimiento_comision_porcentaje_venta: this
  579. .ytm_vencimiento_comision_porcentaje_venta,
  580. interes_acumulado_venta: this.interes_acumulado_venta,
  581. interes_acumulado_porcentaje_venta: this
  582. .interes_acumulado_porcentaje_venta,
  583. precio_sucio_porcentaje_venta: this.precio_sucio_porcentaje_venta,
  584. valor_transado_venta: this.valor_transado_venta,
  585. // Resultado de la operacion
  586. monto_recibir: this.monto_recibir,
  587. dias_tenencia_total: this.dias_tenencia_total,
  588. ganancia_perdida_capital: this.ganancia_perdida_capital,
  589. ingresos_intereses: this.ingresos_intereses,
  590. costos_totales: this.costos_totales,
  591. ganancia_perdida_total: this.ganancia_perdida_total,
  592. ganancia_perdida_capital_porcentaje: this
  593. .ganancia_perdida_capital_porcentaje,
  594. intereses_porcentaje: this.intereses_porcentaje,
  595. neto_antes_impuesto_porcentaje: this.neto_antes_impuesto_porcentaje,
  596. neto_despues_impuesto_porcentaje: this
  597. .neto_despues_impuesto_porcentaje,
  598. total_ingresos_recibidos: this.total_ingresos_recibidos,
  599. // Proyecciones
  600. proyecciones: this.proyecciones
  601. };
  602. this.formDataService.setWork(this.bonosObject);
  603. Swal.close();
  604. if (saveForm == true) {
  605. if (this.investmentID != undefined) {
  606. this.router.navigate(["/investment-proposal/complement-info"], {
  607. queryParams: { id: this.investmentID }
  608. });
  609. } else {
  610. this.router.navigate(["/investment-proposal/complement-info"]);
  611. }
  612. }
  613. },
  614. err => {
  615. Swal.fire({
  616. icon: "error",
  617. title: "Error en el servidor",
  618. text: "No su pudo obtener la informacion"
  619. });
  620. return false;
  621. }
  622. );
  623. }
  624. goToPrevious() {
  625. this.submitted = true;
  626. if (this.investmentID != undefined) {
  627. this.router.navigate(["/investment-proposal/general-info"], {
  628. queryParams: { id: this.investmentID }
  629. });
  630. } else {
  631. this.router.navigate(["/investment-proposal/general-info"]);
  632. }
  633. }
  634. goToNext(form: any) {
  635. this.getCalculations(form, true);
  636. }
  637. }