titulos.component.ts 27 KB

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