certificados.component.ts 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  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-certificados",
  18. templateUrl: "./certificados.component.html"
  19. })
  20. export class CINV implements InstrumentComponent {
  21. title: string = "Certificados de inversión";
  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. instrument_work_summary: any = [];
  119. constructor(
  120. private formBuilder: FormBuilder,
  121. private router: Router,
  122. private formDataService: FormInvestmentProposalService,
  123. private catalogService: CatalogsService,
  124. private instrumentCalcService: InstrumentCalculations,
  125. public datepipe: DatePipe
  126. ) {
  127. this.instrument_work = this.formDataService.getWork();
  128. this.instrument_exists = this.instrument_work == undefined;
  129. this.general = this.formDataService.getGeneralInfo();
  130. if (
  131. this.instrument_work != undefined &&
  132. this.instrument_work.proyecciones != ""
  133. ) {
  134. this.hasProjections = true;
  135. this.operation_results_work = this.instrument_work["resultado_operacion"];
  136. if (this.instrument_work["instrumento"] != undefined) {
  137. this.instrument_work = this.instrument_work["instrumento"];
  138. }
  139. this.instrument_work_summary = this.instrument_work;
  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. }
  358. get f() {
  359. return this.investmentProposalForm.controls;
  360. }
  361. save(form: any): boolean {
  362. if (!form.valid) {
  363. return false;
  364. }
  365. this.formDataService.setWork(this.bonosObject);
  366. return true;
  367. }
  368. getCalculations(form: any, saveForm: boolean) {
  369. this.submitted = true;
  370. if (!form.valid) {
  371. return false;
  372. }
  373. Swal.fire({
  374. allowOutsideClick: false,
  375. icon: "info",
  376. text: "Espere por favor..."
  377. });
  378. Swal.showLoading();
  379. this.instrumentCalcService
  380. .bonosCalc(
  381. "CINV", // Codigo del instrumento
  382. {
  383. id_tipo_base: +this.general.base_anual,
  384. id_formato_ingreso: +this.general.formato_ingreso,
  385. id_periodicidad: +this.general.periodicidad
  386. },
  387. {
  388. costo_transferencia: +this.f.costo_transferencia.value,
  389. valor_nominal_compra: +this.f.valor_nominal_compra.value,
  390. precio_compra: +this.f.precio_compra.value,
  391. precio_vencimiento_compra: +this.f.precio_vencimiento_compra.value,
  392. cupon_porcentaje_compra: +this.f.cupon_porcentaje_compra.value,
  393. comision_casa_porcentaje_compra: this.f
  394. .comision_casa_porcentaje_compra.value,
  395. comision_bolsa_porcentaje_compra: this.f
  396. .comision_bolsa_porcentaje_compra.value,
  397. valor_nominal_venta: +this.f.valor_nominal_venta.value,
  398. precio_venta: +this.f.precio_venta.value,
  399. precio_vencimiento_venta: +this.f.precio_vencimiento_venta.value,
  400. cupon_porcentaje_venta: +this.f.cupon_porcentaje_venta.value,
  401. comision_casa_porcentaje_venta: this.f.comision_casa_porcentaje_venta
  402. .value,
  403. comision_bolsa_porcentaje_venta: this.f
  404. .comision_bolsa_porcentaje_venta.value,
  405. fecha_vencimiento_compra: this.f.fecha_vencimiento_compra.value
  406. .singleDate.formatted,
  407. fecha_ultima_cupon_compra: this.f.fecha_ultima_cupon_compra.value
  408. .singleDate.formatted,
  409. fecha_liquidacion_compra: this.f.fecha_liquidacion_compra.value
  410. .singleDate.formatted,
  411. fecha_vencimiento_venta: this.f.fecha_vencimiento_venta.value
  412. .singleDate.formatted,
  413. fecha_ultima_cupon_venta: this.f.fecha_ultima_cupon_venta.value
  414. .singleDate.formatted,
  415. fecha_liquidacion_venta: this.f.fecha_liquidacion_venta.value
  416. .singleDate.formatted
  417. }
  418. )
  419. .subscribe(
  420. ans => {
  421. // Instrumento de compra
  422. this.comision_casa_compra =
  423. ans["result"]["instrumento_compra"]["comision_casa_compra"];
  424. this.comision_bolsa_compra =
  425. ans["result"]["instrumento_compra"]["comision_bolsa_compra"];
  426. this.fecha_siguiente_cupon_compra =
  427. ans["result"]["instrumento_compra"]["fecha_siguiente_cupon_compra"];
  428. this.dias_vencimiento_compra =
  429. ans["result"]["instrumento_compra"]["dias_vencimiento_compra"];
  430. this.dias_acumulados_compra =
  431. ans["result"]["instrumento_compra"]["dias_acumulados_compra"];
  432. this.ytm_vencimiento_comision_porcentaje_compra =
  433. ans["result"]["instrumento_compra"][
  434. "ytm_vencimiento_comision_porcentaje_compra"
  435. ];
  436. this.interes_acumulado_compra =
  437. ans["result"]["instrumento_compra"]["interes_acumulado_compra"];
  438. this.interes_acumulado_porcentaje_compra =
  439. ans["result"]["instrumento_compra"][
  440. "interes_acumulado_porcentaje_compra"
  441. ];
  442. this.precio_sucio_porcentaje_compra =
  443. ans["result"]["instrumento_compra"][
  444. "precio_sucio_porcentaje_compra"
  445. ];
  446. this.valor_transado_compra =
  447. ans["result"]["instrumento_compra"]["valor_transado_compra"];
  448. this.monto_pagar = ans["result"]["instrumento_compra"]["monto_pagar"];
  449. this.fecha_inicio_vigencia =
  450. ans["result"]["instrumento_compra"]["fecha_inicio_vigencia"];
  451. // Instrumento de venta
  452. this.comision_casa_venta =
  453. ans["result"]["instrumento_venta"]["comision_casa_venta"];
  454. this.fecha_siguiente_cupon_venta =
  455. ans["result"]["instrumento_venta"]["fecha_siguiente_cupon_venta"];
  456. this.dias_vencimiento_venta =
  457. ans["result"]["instrumento_venta"]["dias_vencimiento_venta"];
  458. this.dias_acumulados_venta =
  459. ans["result"]["instrumento_venta"]["dias_acumulados_venta"];
  460. this.ytm_vencimiento_comision_porcentaje_venta =
  461. ans["result"]["instrumento_venta"][
  462. "ytm_vencimiento_comision_porcentaje_venta"
  463. ];
  464. this.interes_acumulado_venta =
  465. ans["result"]["instrumento_venta"]["interes_acumulado_venta"];
  466. this.interes_acumulado_porcentaje_venta =
  467. ans["result"]["instrumento_venta"][
  468. "interes_acumulado_porcentaje_venta"
  469. ];
  470. this.precio_sucio_porcentaje_venta =
  471. ans["result"]["instrumento_venta"]["precio_sucio_porcentaje_venta"];
  472. this.valor_transado_venta =
  473. ans["result"]["instrumento_venta"]["valor_transado_venta"];
  474. this.monto_recibir =
  475. ans["result"]["instrumento_venta"]["monto_recibir"];
  476. // Resultado de la operacion
  477. this.dias_tenencia_total =
  478. ans["result"]["resultado_operacion"]["dias_tenencia_total"];
  479. this.ganancia_perdida_capital =
  480. ans["result"]["resultado_operacion"]["ganancia_perdida_capital"];
  481. this.ingresos_intereses =
  482. ans["result"]["resultado_operacion"]["ingresos_intereses"];
  483. this.costos_totales =
  484. ans["result"]["resultado_operacion"]["costos_totales"];
  485. this.ganancia_perdida_total =
  486. ans["result"]["resultado_operacion"]["ganancia_perdida_total"];
  487. this.ganancia_perdida_capital_porcentaje =
  488. ans["result"]["resultado_operacion"][
  489. "ganancia_perdida_capital_porcentaje"
  490. ];
  491. this.intereses_porcentaje =
  492. ans["result"]["resultado_operacion"]["intereses_porcentaje"];
  493. this.neto_antes_impuesto_porcentaje =
  494. ans["result"]["resultado_operacion"][
  495. "neto_antes_impuesto_porcentaje"
  496. ];
  497. this.neto_despues_impuesto_porcentaje =
  498. ans["result"]["resultado_operacion"][
  499. "neto_despues_impuesto_porcentaje"
  500. ];
  501. this.total_ingresos_recibidos =
  502. ans["result"]["resultado_operacion"]["total_ingresos_recibidos"];
  503. // Proyecciones
  504. this.proyecciones = ans["result"]["proyecciones"];
  505. this.operation_result = true;
  506. this.dataSource.data = this.proyecciones;
  507. this.dataSource2.data = this.proyecciones;
  508. this.dataSource.paginator = this.paginator;
  509. this.dataSource.sort = this.sort;
  510. // Obj
  511. this.bonosObject = {
  512. costo_transferencia: this.investmentProposalForm.value
  513. .costo_transferencia,
  514. valor_nominal_compra: this.investmentProposalForm.value
  515. .valor_nominal_compra,
  516. precio_compra: this.investmentProposalForm.value.precio_compra,
  517. precio_vencimiento_compra: this.investmentProposalForm.value
  518. .precio_vencimiento_compra,
  519. cupon_porcentaje_compra: this.investmentProposalForm.value
  520. .cupon_porcentaje_compra,
  521. comision_casa_porcentaje_compra: this.investmentProposalForm.value
  522. .comision_casa_porcentaje_compra,
  523. comision_bolsa_porcentaje_compra: this.investmentProposalForm.value
  524. .comision_bolsa_porcentaje_compra,
  525. ytm_vencimiento_porcentaje_compra: this.investmentProposalForm.value
  526. .ytm_vencimiento_porcentaje_compra,
  527. valor_nominal_venta: this.investmentProposalForm.value
  528. .valor_nominal_venta,
  529. precio_venta: this.investmentProposalForm.value.precio_venta,
  530. precio_vencimiento_venta: this.investmentProposalForm.value
  531. .precio_vencimiento_venta,
  532. cupon_porcentaje_venta: this.investmentProposalForm.value
  533. .cupon_porcentaje_venta,
  534. comision_casa_porcentaje_venta: this.investmentProposalForm.value
  535. .comision_casa_porcentaje_venta,
  536. comision_bolsa_porcentaje_venta: this.investmentProposalForm.value
  537. .comision_bolsa_porcentaje_venta,
  538. ytm_vencimiento_porcentaje_venta: this.investmentProposalForm.value
  539. .ytm_vencimiento_porcentaje_venta,
  540. fecha_vencimiento_compra: this.f.fecha_vencimiento_compra.value
  541. .singleDate.formatted,
  542. fecha_ultima_cupon_compra: this.f.fecha_ultima_cupon_compra.value
  543. .singleDate.formatted,
  544. fecha_liquidacion_compra: this.f.fecha_liquidacion_compra.value
  545. .singleDate.formatted,
  546. fecha_vencimiento_venta: this.f.fecha_vencimiento_venta.value
  547. .singleDate.formatted,
  548. fecha_ultima_cupon_venta: this.f.fecha_ultima_cupon_venta.value
  549. .singleDate.formatted,
  550. fecha_liquidacion_venta: this.f.fecha_liquidacion_venta.value
  551. .singleDate.formatted,
  552. // Instrumento de compra
  553. comision_casa_compra: this.comision_casa_compra,
  554. comision_bolsa_compra: this.comision_bolsa_compra,
  555. fecha_siguiente_cupon_compra: this.fecha_siguiente_cupon_compra,
  556. dias_vencimiento_compra: this.dias_vencimiento_compra,
  557. dias_acumulados_compra: this.dias_acumulados_compra,
  558. ytm_vencimiento_comision_porcentaje_compra: this
  559. .ytm_vencimiento_comision_porcentaje_compra,
  560. interes_acumulado_compra: this.interes_acumulado_compra,
  561. interes_acumulado_porcentaje_compra: this
  562. .interes_acumulado_porcentaje_compra,
  563. precio_sucio_porcentaje_compra: this.precio_sucio_porcentaje_compra,
  564. valor_transado_compra: this.valor_transado_compra,
  565. monto_pagar: this.monto_pagar,
  566. fecha_inicio_vigencia: this.fecha_inicio_vigencia,
  567. // Instrumento de venta
  568. comision_casa_venta: this.comision_casa_venta,
  569. fecha_siguiente_cupon_venta: this.fecha_siguiente_cupon_venta,
  570. dias_vencimiento_venta: this.dias_vencimiento_venta,
  571. dias_acumulados_venta: this.dias_acumulados_venta,
  572. ytm_vencimiento_comision_porcentaje_venta: this
  573. .ytm_vencimiento_comision_porcentaje_venta,
  574. interes_acumulado_venta: this.interes_acumulado_venta,
  575. interes_acumulado_porcentaje_venta: this
  576. .interes_acumulado_porcentaje_venta,
  577. precio_sucio_porcentaje_venta: this.precio_sucio_porcentaje_venta,
  578. valor_transado_venta: this.valor_transado_venta,
  579. // Resultado de la operacion
  580. monto_recibir: this.monto_recibir,
  581. dias_tenencia_total: this.dias_tenencia_total,
  582. ganancia_perdida_capital: this.ganancia_perdida_capital,
  583. ingresos_intereses: this.ingresos_intereses,
  584. costos_totales: this.costos_totales,
  585. ganancia_perdida_total: this.ganancia_perdida_total,
  586. ganancia_perdida_capital_porcentaje: this
  587. .ganancia_perdida_capital_porcentaje,
  588. intereses_porcentaje: this.intereses_porcentaje,
  589. neto_antes_impuesto_porcentaje: this.neto_antes_impuesto_porcentaje,
  590. neto_despues_impuesto_porcentaje: this
  591. .neto_despues_impuesto_porcentaje,
  592. total_ingresos_recibidos: this.total_ingresos_recibidos,
  593. // Proyecciones
  594. proyecciones: this.proyecciones
  595. };
  596. this.formDataService.setWork(this.bonosObject);
  597. Swal.close();
  598. if (saveForm == true) {
  599. if (this.investmentID != undefined) {
  600. this.router.navigate(["/investment-proposal/complement-info"], {
  601. queryParams: { id: this.investmentID }
  602. });
  603. } else {
  604. this.router.navigate(["/investment-proposal/complement-info"]);
  605. }
  606. }
  607. },
  608. err => {
  609. Swal.fire({
  610. icon: "error",
  611. title: "Error en el servidor",
  612. text: "No su pudo obtener la informacion"
  613. });
  614. return false;
  615. }
  616. );
  617. }
  618. goToPrevious() {
  619. this.submitted = true;
  620. if (this.investmentID != undefined) {
  621. this.router.navigate(["/investment-proposal/general-info"], {
  622. queryParams: { id: this.investmentID }
  623. });
  624. } else {
  625. this.router.navigate(["/investment-proposal/general-info"]);
  626. }
  627. }
  628. goToNext(form: any) {
  629. this.getCalculations(form, true);
  630. }
  631. }