eurobonos.component.ts 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739
  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. constructor(
  117. private formBuilder: FormBuilder,
  118. private router: Router,
  119. private formDataService: FormInvestmentProposalService,
  120. private catalogService: CatalogsService,
  121. private instrumentCalcService: InstrumentCalculations,
  122. public datepipe: DatePipe
  123. ) {
  124. this.instrument_work = this.formDataService.getWork();
  125. this.instrument_exists = this.instrument_work == undefined;
  126. this.general = this.formDataService.getGeneralInfo();
  127. if (
  128. this.instrument_work != undefined &&
  129. (this.instrument_work.proyecciones != "" ||
  130. this.instrument_work != undefined)
  131. ) {
  132. this.hasProjections = true;
  133. this.dataSource2.data = this.instrument_work.proyecciones;
  134. this.dataSource2.paginator = this.paginator;
  135. this.dataSource2.sort = this.sort;
  136. } else {
  137. this.hasProjections = false;
  138. }
  139. this.investmentProposalForm = this.formBuilder.group({
  140. costo_transferencia: [
  141. this.instrument_exists ? "" : this.instrument_work.costo_transferencia,
  142. [
  143. Validators.required,
  144. Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
  145. ]
  146. ],
  147. precio_compra: [
  148. this.instrument_exists ? "" : this.instrument_work.precio_compra,
  149. [
  150. Validators.required,
  151. Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
  152. ]
  153. ],
  154. valor_nominal_compra: [
  155. this.instrument_exists ? "" : this.instrument_work.valor_nominal_compra,
  156. [
  157. Validators.required,
  158. Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
  159. ]
  160. ],
  161. precio_vencimiento_compra: [
  162. this.instrument_exists
  163. ? ""
  164. : this.instrument_work.precio_vencimiento_compra,
  165. [
  166. Validators.required,
  167. Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
  168. ]
  169. ],
  170. cupon_porcentaje_compra: [
  171. this.instrument_exists
  172. ? ""
  173. : this.instrument_work.cupon_porcentaje_compra,
  174. [
  175. Validators.required,
  176. Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
  177. ]
  178. ],
  179. comision_casa_porcentaje_compra: [
  180. this.instrument_exists
  181. ? ""
  182. : this.instrument_work.comision_casa_porcentaje_compra,
  183. [
  184. Validators.required,
  185. Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
  186. ]
  187. ],
  188. comision_bolsa_porcentaje_compra: [
  189. this.instrument_exists
  190. ? ""
  191. : this.instrument_work.comision_bolsa_porcentaje_compra,
  192. [
  193. Validators.required,
  194. Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
  195. ]
  196. ],
  197. ytm_vencimiento_porcentaje_compra: [
  198. this.instrument_exists
  199. ? ""
  200. : this.instrument_work.ytm_vencimiento_porcentaje_compra,
  201. [
  202. Validators.required,
  203. Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
  204. ]
  205. ],
  206. precio_venta: [
  207. this.instrument_exists ? "" : this.instrument_work.precio_venta,
  208. [
  209. Validators.required,
  210. Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
  211. ]
  212. ],
  213. valor_nominal_venta: [
  214. this.instrument_exists ? "" : this.instrument_work.valor_nominal_venta,
  215. [
  216. Validators.required,
  217. Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
  218. ]
  219. ],
  220. precio_vencimiento_venta: [
  221. this.instrument_exists
  222. ? ""
  223. : this.instrument_work.precio_vencimiento_venta,
  224. [
  225. Validators.required,
  226. Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
  227. ]
  228. ],
  229. cupon_porcentaje_venta: [
  230. this.instrument_exists
  231. ? ""
  232. : this.instrument_work.cupon_porcentaje_venta,
  233. [
  234. Validators.required,
  235. Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
  236. ]
  237. ],
  238. comision_casa_porcentaje_venta: [
  239. this.instrument_exists
  240. ? ""
  241. : this.instrument_work.comision_casa_porcentaje_venta,
  242. [
  243. Validators.required,
  244. Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
  245. ]
  246. ],
  247. comision_bolsa_porcentaje_venta: [
  248. this.instrument_exists
  249. ? ""
  250. : this.instrument_work.comision_bolsa_porcentaje_venta,
  251. [
  252. Validators.required,
  253. Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
  254. ]
  255. ],
  256. ytm_vencimiento_porcentaje_venta: [
  257. this.instrument_exists
  258. ? ""
  259. : this.instrument_work.ytm_vencimiento_porcentaje_venta,
  260. [
  261. Validators.required,
  262. Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
  263. ]
  264. ],
  265. fecha_ultima_cupon_compra: [
  266. this.instrument_exists
  267. ? ""
  268. : {
  269. isRange: false,
  270. singleDate: {
  271. jsDate: parse(
  272. this.instrument_work.fecha_ultima_cupon_compra,
  273. "dd/MM/yyyy",
  274. new Date()
  275. ),
  276. formatted: this.instrument_work.fecha_ultima_cupon_compra
  277. }
  278. },
  279. Validators.required
  280. ],
  281. fecha_liquidacion_compra: [
  282. this.instrument_exists
  283. ? ""
  284. : {
  285. isRange: false,
  286. singleDate: {
  287. jsDate: parse(
  288. this.instrument_work.fecha_liquidacion_compra,
  289. "dd/MM/yyyy",
  290. new Date()
  291. ),
  292. formatted: this.instrument_work.fecha_liquidacion_compra
  293. }
  294. },
  295. Validators.required
  296. ],
  297. fecha_vencimiento_compra: [
  298. this.instrument_exists
  299. ? ""
  300. : {
  301. isRange: false,
  302. singleDate: {
  303. jsDate: parse(
  304. this.instrument_work.fecha_vencimiento_compra,
  305. "dd/MM/yyyy",
  306. new Date()
  307. ),
  308. formatted: this.instrument_work.fecha_vencimiento_compra
  309. }
  310. },
  311. Validators.required
  312. ],
  313. fecha_ultima_cupon_venta: [
  314. this.instrument_exists
  315. ? ""
  316. : {
  317. isRange: false,
  318. singleDate: {
  319. jsDate: parse(
  320. this.instrument_work.fecha_ultima_cupon_venta,
  321. "dd/MM/yyyy",
  322. new Date()
  323. ),
  324. formatted: this.instrument_work.fecha_ultima_cupon_venta
  325. }
  326. },
  327. Validators.required
  328. ],
  329. fecha_liquidacion_venta: [
  330. this.instrument_exists
  331. ? ""
  332. : {
  333. isRange: false,
  334. singleDate: {
  335. jsDate: parse(
  336. this.instrument_work.fecha_liquidacion_venta,
  337. "dd/MM/yyyy",
  338. new Date()
  339. ),
  340. formatted: this.instrument_work.fecha_liquidacion_venta
  341. }
  342. },
  343. Validators.required
  344. ],
  345. fecha_vencimiento_venta: [
  346. this.instrument_exists
  347. ? ""
  348. : {
  349. isRange: false,
  350. singleDate: {
  351. jsDate: parse(
  352. this.instrument_work.fecha_vencimiento_venta,
  353. "dd/MM/yyyy",
  354. new Date()
  355. ),
  356. formatted: this.instrument_work.fecha_vencimiento_venta
  357. }
  358. },
  359. Validators.required
  360. ]
  361. });
  362. // Get calculations, always
  363. if (
  364. this.instrument_work != undefined &&
  365. this.instrument_work.proyecciones != ""
  366. ) {
  367. console.log("get calcs");
  368. this.getCalculations(this.investmentProposalForm, false);
  369. }
  370. }
  371. get f() {
  372. return this.investmentProposalForm.controls;
  373. }
  374. save(form: any): boolean {
  375. if (!form.valid) {
  376. return false;
  377. }
  378. this.formDataService.setWork(this.bonosObject);
  379. return true;
  380. }
  381. getCalculations(form: any, saveForm: boolean) {
  382. this.submitted = true;
  383. console.log(form);
  384. if (!form.valid) {
  385. return false;
  386. }
  387. Swal.fire({
  388. allowOutsideClick: false,
  389. icon: "info",
  390. text: "Espere por favor..."
  391. });
  392. Swal.showLoading();
  393. this.instrumentCalcService
  394. .bonosCalc(
  395. "EURB", // Codigo del instrumento
  396. {
  397. id_tipo_base: +this.general.base_anual,
  398. id_formato_ingreso: +this.general.formato_ingreso,
  399. id_periodicidad: +this.general.periodicidad
  400. },
  401. {
  402. costo_transferencia: +this.f.costo_transferencia.value,
  403. valor_nominal_compra: +this.f.valor_nominal_compra.value,
  404. precio_compra: +this.f.precio_compra.value,
  405. precio_vencimiento_compra: +this.f.precio_vencimiento_compra.value,
  406. cupon_porcentaje_compra: +this.f.cupon_porcentaje_compra.value,
  407. comision_casa_porcentaje_compra: this.f
  408. .comision_casa_porcentaje_compra.value,
  409. comision_bolsa_porcentaje_compra: this.f
  410. .comision_bolsa_porcentaje_compra.value,
  411. ytm_vencimiento_porcentaje_compra: this.f
  412. .ytm_vencimiento_porcentaje_compra.value,
  413. valor_nominal_venta: +this.f.valor_nominal_venta.value,
  414. precio_venta: +this.f.precio_venta.value,
  415. precio_vencimiento_venta: +this.f.precio_vencimiento_venta.value,
  416. cupon_porcentaje_venta: +this.f.cupon_porcentaje_venta.value,
  417. comision_casa_porcentaje_venta: this.f.comision_casa_porcentaje_venta
  418. .value,
  419. comision_bolsa_porcentaje_venta: this.f
  420. .comision_bolsa_porcentaje_venta.value,
  421. ytm_vencimiento_porcentaje_venta: this.f
  422. .ytm_vencimiento_porcentaje_venta.value,
  423. fecha_vencimiento_compra: this.f.fecha_vencimiento_compra.value
  424. .singleDate.formatted,
  425. fecha_ultima_cupon_compra: this.f.fecha_ultima_cupon_compra.value
  426. .singleDate.formatted,
  427. fecha_liquidacion_compra: this.f.fecha_liquidacion_compra.value
  428. .singleDate.formatted,
  429. fecha_vencimiento_venta: this.f.fecha_vencimiento_venta.value
  430. .singleDate.formatted,
  431. fecha_ultima_cupon_venta: this.f.fecha_ultima_cupon_venta.value
  432. .singleDate.formatted,
  433. fecha_liquidacion_venta: this.f.fecha_liquidacion_venta.value
  434. .singleDate.formatted
  435. }
  436. )
  437. .subscribe(
  438. ans => {
  439. console.log("---------");
  440. console.log(ans);
  441. // Instrumento de compra
  442. this.comision_casa_compra =
  443. ans["result"]["instrumento_compra"]["comision_casa_compra"];
  444. this.comision_bolsa_compra =
  445. ans["result"]["instrumento_compra"]["comision_bolsa_compra"];
  446. this.fecha_siguiente_cupon_compra =
  447. ans["result"]["instrumento_compra"]["fecha_siguiente_cupon_compra"];
  448. this.dias_vencimiento_compra =
  449. ans["result"]["instrumento_compra"]["dias_vencimiento_compra"];
  450. this.dias_acumulados_compra =
  451. ans["result"]["instrumento_compra"]["dias_acumulados_compra"];
  452. this.ytm_vencimiento_comision_porcentaje_compra =
  453. ans["result"]["instrumento_compra"][
  454. "ytm_vencimiento_comision_porcentaje_compra"
  455. ];
  456. this.interes_acumulado_compra =
  457. ans["result"]["instrumento_compra"]["interes_acumulado_compra"];
  458. this.interes_acumulado_porcentaje_compra =
  459. ans["result"]["instrumento_compra"][
  460. "interes_acumulado_porcentaje_compra"
  461. ];
  462. this.precio_sucio_porcentaje_compra =
  463. ans["result"]["instrumento_compra"][
  464. "precio_sucio_porcentaje_compra"
  465. ];
  466. this.valor_transado_compra =
  467. ans["result"]["instrumento_compra"]["valor_transado_compra"];
  468. this.monto_pagar = ans["result"]["instrumento_compra"]["monto_pagar"];
  469. this.fecha_inicio_vigencia =
  470. ans["result"]["instrumento_compra"]["fecha_inicio_vigencia"];
  471. // Instrumento de venta
  472. this.comision_casa_venta =
  473. ans["result"]["instrumento_venta"]["comision_casa_venta"];
  474. this.fecha_siguiente_cupon_venta =
  475. ans["result"]["instrumento_venta"]["fecha_siguiente_cupon_venta"];
  476. this.dias_vencimiento_venta =
  477. ans["result"]["instrumento_venta"]["dias_vencimiento_venta"];
  478. this.dias_acumulados_venta =
  479. ans["result"]["instrumento_venta"]["dias_acumulados_venta"];
  480. this.ytm_vencimiento_comision_porcentaje_venta =
  481. ans["result"]["instrumento_venta"][
  482. "ytm_vencimiento_comision_porcentaje_venta"
  483. ];
  484. this.interes_acumulado_venta =
  485. ans["result"]["instrumento_venta"]["interes_acumulado_venta"];
  486. this.interes_acumulado_porcentaje_venta =
  487. ans["result"]["instrumento_venta"][
  488. "interes_acumulado_porcentaje_venta"
  489. ];
  490. this.precio_sucio_porcentaje_venta =
  491. ans["result"]["instrumento_venta"]["precio_sucio_porcentaje_venta"];
  492. this.valor_transado_venta =
  493. ans["result"]["instrumento_venta"]["valor_transado_venta"];
  494. this.monto_recibir =
  495. ans["result"]["instrumento_venta"]["monto_recibir"];
  496. // Resultado de la operacion
  497. this.dias_tenencia_total =
  498. ans["result"]["resultado_operacion"]["dias_tenencia_total"];
  499. this.ganancia_perdida_capital =
  500. ans["result"]["resultado_operacion"]["ganancia_perdida_capital"];
  501. this.ingresos_intereses =
  502. ans["result"]["resultado_operacion"]["ingresos_intereses"];
  503. this.costos_totales =
  504. ans["result"]["resultado_operacion"]["costos_totales"];
  505. this.ganancia_perdida_total =
  506. ans["result"]["resultado_operacion"]["ganancia_perdida_total"];
  507. this.ganancia_perdida_capital_porcentaje =
  508. ans["result"]["resultado_operacion"][
  509. "ganancia_perdida_capital_porcentaje"
  510. ];
  511. this.intereses_porcentaje =
  512. ans["result"]["resultado_operacion"]["intereses_porcentaje"];
  513. this.neto_antes_impuesto_porcentaje =
  514. ans["result"]["resultado_operacion"][
  515. "neto_antes_impuesto_porcentaje"
  516. ];
  517. this.neto_despues_impuesto_porcentaje =
  518. ans["result"]["resultado_operacion"][
  519. "neto_despues_impuesto_porcentaje"
  520. ];
  521. this.total_ingresos_recibidos =
  522. ans["result"]["resultado_operacion"]["total_ingresos_recibidos"];
  523. // Proyecciones
  524. this.proyecciones = ans["result"]["proyecciones"];
  525. this.dataSource.data = this.proyecciones;
  526. this.dataSource.paginator = this.paginator;
  527. this.dataSource.sort = this.sort;
  528. /*
  529. "result": {
  530. "instrumento_compra": {
  531. "comision_casa_compra": 201.3,
  532. "comision_bolsa_compra": 30.194999999999997,
  533. "fecha_siguiente_cupon_compra": "28/04/2013",
  534. "dias_vencimiento_compra": 880,
  535. "dias_acumulados_compra": 32,
  536. "ytm_vencimiento_comision_porcentaje_compra": 6.565909090909091,
  537. "interes_acumulado_compra": 533.3333333333334,
  538. "interes_acumulado_porcentaje_compra": 6.000000000000001,
  539. "precio_sucio_porcentaje_compra": 106.65,
  540. "valor_transado_compra": 100650.0,
  541. "monto_pagar": 101419.82833333334,
  542. "fecha_inicio_vigencia": "30/4/2013"
  543. },
  544. "instrumento_venta": {
  545. "comision_casa_venta": 50.0,
  546. "fecha_siguiente_cupon_venta": "28/10/2022",
  547. "dias_vencimiento_venta": 179,
  548. "dias_acumulados_venta": 1,
  549. "ytm_vencimiento_comision_porcentaje_venta": -0.5229050279329608,
  550. "interes_acumulado_venta": 46.875,
  551. "interes_acumulado_porcentaje_venta": 6.75,
  552. "precio_sucio_porcentaje_venta": 106.74999999999999,
  553. "valor_transado_venta": 250000.0,
  554. "monto_recibir": 249396.875
  555. },
  556. "resultado_operacion": {
  557. "valor_nominal_compra": 100000.0,
  558. 1"dias_tenencia_total": 3389,
  559. "precio_compra": 100.64999999999999,
  560. "precio_venta": 100.0,
  561. 1"ganancia_perdida_capital": 149350.0,
  562. 1"ingresos_intereses": 13726.875,
  563. 1"costos_totales": -886.495,
  564. 1"ganancia_perdida_total": 162190.38,
  565. 1"ganancia_perdida_capital_porcentaje": 15.864856889938034,
  566. 1"intereses_porcentaje": 1.458151372086161,
  567. 1"neto_antes_impuesto_porcentaje": 17.22883942165831,
  568. 1"1neto_despues_impuesto_porcentaje": 17.067375863086458,
  569. 1"total_ingresos_recibidos": 13680.0
  570. },
  571. */
  572. this.bonosObject = {
  573. costo_transferencia: this.investmentProposalForm.value
  574. .costo_transferencia,
  575. valor_nominal_compra: this.investmentProposalForm.value
  576. .valor_nominal_compra,
  577. precio_compra: this.investmentProposalForm.value.precio_compra,
  578. precio_vencimiento_compra: this.investmentProposalForm.value
  579. .precio_vencimiento_compra,
  580. cupon_porcentaje_compra: this.investmentProposalForm.value
  581. .cupon_porcentaje_compra,
  582. comision_casa_porcentaje_compra: this.investmentProposalForm.value
  583. .comision_casa_porcentaje_compra,
  584. comision_bolsa_porcentaje_compra: this.investmentProposalForm.value
  585. .comision_bolsa_porcentaje_compra,
  586. ytm_vencimiento_porcentaje_compra: this.investmentProposalForm.value
  587. .ytm_vencimiento_porcentaje_compra,
  588. valor_nominal_venta: this.investmentProposalForm.value
  589. .valor_nominal_venta,
  590. precio_venta: this.investmentProposalForm.value.precio_venta,
  591. precio_vencimiento_venta: this.investmentProposalForm.value
  592. .precio_vencimiento_venta,
  593. cupon_porcentaje_venta: this.investmentProposalForm.value
  594. .cupon_porcentaje_venta,
  595. comision_casa_porcentaje_venta: this.investmentProposalForm.value
  596. .comision_casa_porcentaje_venta,
  597. comision_bolsa_porcentaje_venta: this.investmentProposalForm.value
  598. .comision_bolsa_porcentaje_venta,
  599. ytm_vencimiento_porcentaje_venta: this.investmentProposalForm.value
  600. .ytm_vencimiento_porcentaje_venta,
  601. fecha_vencimiento_compra: this.f.fecha_vencimiento_compra.value
  602. .singleDate.formatted,
  603. fecha_ultima_cupon_compra: this.f.fecha_ultima_cupon_compra.value
  604. .singleDate.formatted,
  605. fecha_liquidacion_compra: this.f.fecha_liquidacion_compra.value
  606. .singleDate.formatted,
  607. fecha_vencimiento_venta: this.f.fecha_vencimiento_venta.value
  608. .singleDate.formatted,
  609. fecha_ultima_cupon_venta: this.f.fecha_ultima_cupon_venta.value
  610. .singleDate.formatted,
  611. fecha_liquidacion_venta: this.f.fecha_liquidacion_venta.value
  612. .singleDate.formatted,
  613. // Instrumento de compra
  614. comision_casa_compra: this.comision_casa_compra,
  615. comision_bolsa_compra: this.comision_bolsa_compra,
  616. fecha_siguiente_cupon_compra: this.fecha_siguiente_cupon_compra,
  617. dias_vencimiento_compra: this.dias_vencimiento_compra,
  618. dias_acumulados_compra: this.dias_acumulados_compra,
  619. ytm_vencimiento_comision_porcentaje_compra: this
  620. .ytm_vencimiento_comision_porcentaje_compra,
  621. interes_acumulado_compra: this.interes_acumulado_compra,
  622. interes_acumulado_porcentaje_compra: this
  623. .interes_acumulado_porcentaje_compra,
  624. precio_sucio_porcentaje_compra: this.precio_sucio_porcentaje_compra,
  625. valor_transado_compra: this.valor_transado_compra,
  626. monto_pagar: this.monto_pagar,
  627. fecha_inicio_vigencia: this.fecha_inicio_vigencia,
  628. // Instrumento de venta
  629. comision_casa_venta: this.comision_casa_venta,
  630. fecha_siguiente_cupon_venta: this.fecha_siguiente_cupon_venta,
  631. dias_vencimiento_venta: this.dias_vencimiento_venta,
  632. dias_acumulados_venta: this.dias_acumulados_venta,
  633. ytm_vencimiento_comision_porcentaje_venta: this
  634. .ytm_vencimiento_comision_porcentaje_venta,
  635. interes_acumulado_venta: this.interes_acumulado_venta,
  636. interes_acumulado_porcentaje_venta: this
  637. .interes_acumulado_porcentaje_venta,
  638. precio_sucio_porcentaje_venta: this.precio_sucio_porcentaje_venta,
  639. valor_transado_venta: this.valor_transado_venta,
  640. // Resultado de la operacion
  641. monto_recibir: this.monto_recibir,
  642. dias_tenencia_total: this.dias_tenencia_total,
  643. ganancia_perdida_capital: this.ganancia_perdida_capital,
  644. ingresos_intereses: this.ingresos_intereses,
  645. costos_totales: this.costos_totales,
  646. ganancia_perdida_total: this.ganancia_perdida_total,
  647. ganancia_perdida_capital_porcentaje: this
  648. .ganancia_perdida_capital_porcentaje,
  649. intereses_porcentaje: this.intereses_porcentaje,
  650. neto_antes_impuesto_porcentaje: this.neto_antes_impuesto_porcentaje,
  651. neto_despues_impuesto_porcentaje: this
  652. .neto_despues_impuesto_porcentaje,
  653. total_ingresos_recibidos: this.total_ingresos_recibidos,
  654. // Proyecciones
  655. proyecciones: this.proyecciones
  656. };
  657. this.formDataService.setWork(this.bonosObject);
  658. Swal.close();
  659. if (saveForm == true) {
  660. if (this.investmentID != undefined) {
  661. this.router.navigate(["/investment-proposal/complement-info"], {
  662. queryParams: { id: this.investmentID }
  663. });
  664. } else {
  665. this.router.navigate(["/investment-proposal/complement-info"]);
  666. }
  667. }
  668. },
  669. err => {
  670. Swal.fire({
  671. icon: "error",
  672. title: "Error en el servidor",
  673. text: "No su pudo obtener la informacion"
  674. });
  675. return false;
  676. }
  677. );
  678. }
  679. goToPrevious() {
  680. this.submitted = true;
  681. if (this.investmentID != undefined) {
  682. this.router.navigate(["/investment-proposal/general-info"], {
  683. queryParams: { id: this.investmentID }
  684. });
  685. } else {
  686. this.router.navigate(["/investment-proposal/general-info"]);
  687. }
  688. }
  689. goToNext(form: any) {
  690. this.getCalculations(form, true);
  691. }
  692. }