titulos.component.ts 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752
  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. "impuesto",
  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. constructor(
  127. private formBuilder: FormBuilder,
  128. private router: Router,
  129. private formDataService: FormInvestmentProposalService,
  130. private catalogService: CatalogsService,
  131. private instrumentCalcService: InstrumentCalculations,
  132. public datepipe: DatePipe
  133. ) {
  134. this.instrument_work = this.formDataService.getWork();
  135. this.instrument_exists = this.instrument_work == undefined;
  136. this.general = this.formDataService.getGeneralInfo();
  137. if (
  138. this.instrument_work != undefined &&
  139. (this.instrument_work.proyecciones != "" ||
  140. this.instrument_work != undefined)
  141. ) {
  142. this.hasProjections = true;
  143. this.dataSource2.data = this.instrument_work.proyecciones;
  144. this.dataSource2.paginator = this.paginator;
  145. this.dataSource2.sort = this.sort;
  146. } else {
  147. this.hasProjections = false;
  148. }
  149. if (!this.instrument_exists) {
  150. this.amortizaciones = this.instrument_work.amortizacion_porcentajes;
  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. ytm_vencimiento_porcentaje_compra: [
  211. this.instrument_exists
  212. ? ""
  213. : this.instrument_work.ytm_vencimiento_porcentaje_compra,
  214. [
  215. Validators.required,
  216. Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
  217. ]
  218. ],
  219. precio_venta: [
  220. this.instrument_exists ? "" : this.instrument_work.precio_venta,
  221. [
  222. Validators.required,
  223. Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
  224. ]
  225. ],
  226. valor_nominal_venta: [
  227. this.instrument_exists ? "" : this.instrument_work.valor_nominal_venta,
  228. [
  229. Validators.required,
  230. Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
  231. ]
  232. ],
  233. precio_vencimiento_venta: [
  234. this.instrument_exists
  235. ? ""
  236. : this.instrument_work.precio_vencimiento_venta,
  237. [
  238. Validators.required,
  239. Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
  240. ]
  241. ],
  242. cupon_porcentaje_venta: [
  243. this.instrument_exists
  244. ? ""
  245. : this.instrument_work.cupon_porcentaje_venta,
  246. [
  247. Validators.required,
  248. Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
  249. ]
  250. ],
  251. comision_casa_porcentaje_venta: [
  252. this.instrument_exists
  253. ? ""
  254. : this.instrument_work.comision_casa_porcentaje_venta,
  255. [
  256. Validators.required,
  257. Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
  258. ]
  259. ],
  260. comision_bolsa_porcentaje_venta: [
  261. this.instrument_exists
  262. ? ""
  263. : this.instrument_work.comision_bolsa_porcentaje_venta,
  264. [
  265. Validators.required,
  266. Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
  267. ]
  268. ],
  269. ytm_vencimiento_porcentaje_venta: [
  270. this.instrument_exists
  271. ? ""
  272. : this.instrument_work.ytm_vencimiento_porcentaje_venta,
  273. [
  274. Validators.required,
  275. Validators.pattern(/^[+]?([0-9]+(?:[\.][0-9]*)?|\.[0-9]+)$/)
  276. ]
  277. ],
  278. fecha_ultima_cupon_compra: [
  279. this.instrument_exists
  280. ? ""
  281. : {
  282. isRange: false,
  283. singleDate: {
  284. jsDate: parse(
  285. this.instrument_work.fecha_ultima_cupon_compra,
  286. "dd/MM/yyyy",
  287. new Date()
  288. ),
  289. formatted: this.instrument_work.fecha_ultima_cupon_compra
  290. }
  291. },
  292. Validators.required
  293. ],
  294. fecha_liquidacion_compra: [
  295. this.instrument_exists
  296. ? ""
  297. : {
  298. isRange: false,
  299. singleDate: {
  300. jsDate: parse(
  301. this.instrument_work.fecha_liquidacion_compra,
  302. "dd/MM/yyyy",
  303. new Date()
  304. ),
  305. formatted: this.instrument_work.fecha_liquidacion_compra
  306. }
  307. },
  308. Validators.required
  309. ],
  310. fecha_vencimiento_compra: [
  311. this.instrument_exists
  312. ? ""
  313. : {
  314. isRange: false,
  315. singleDate: {
  316. jsDate: parse(
  317. this.instrument_work.fecha_vencimiento_compra,
  318. "dd/MM/yyyy",
  319. new Date()
  320. ),
  321. formatted: this.instrument_work.fecha_vencimiento_compra
  322. }
  323. },
  324. Validators.required
  325. ],
  326. fecha_ultima_cupon_venta: [
  327. this.instrument_exists
  328. ? ""
  329. : {
  330. isRange: false,
  331. singleDate: {
  332. jsDate: parse(
  333. this.instrument_work.fecha_ultima_cupon_venta,
  334. "dd/MM/yyyy",
  335. new Date()
  336. ),
  337. formatted: this.instrument_work.fecha_ultima_cupon_venta
  338. }
  339. },
  340. Validators.required
  341. ],
  342. fecha_liquidacion_venta: [
  343. this.instrument_exists
  344. ? ""
  345. : {
  346. isRange: false,
  347. singleDate: {
  348. jsDate: parse(
  349. this.instrument_work.fecha_liquidacion_venta,
  350. "dd/MM/yyyy",
  351. new Date()
  352. ),
  353. formatted: this.instrument_work.fecha_liquidacion_venta
  354. }
  355. },
  356. Validators.required
  357. ],
  358. fecha_vencimiento_venta: [
  359. this.instrument_exists
  360. ? ""
  361. : {
  362. isRange: false,
  363. singleDate: {
  364. jsDate: parse(
  365. this.instrument_work.fecha_vencimiento_venta,
  366. "dd/MM/yyyy",
  367. new Date()
  368. ),
  369. formatted: this.instrument_work.fecha_vencimiento_venta
  370. }
  371. },
  372. Validators.required
  373. ],
  374. fecha_emision: [
  375. this.instrument_exists
  376. ? ""
  377. : {
  378. isRange: false,
  379. singleDate: {
  380. jsDate: parse(
  381. this.instrument_work.fecha_emision,
  382. "dd/MM/yyyy",
  383. new Date()
  384. ),
  385. formatted: this.instrument_work.fecha_emision
  386. }
  387. },
  388. Validators.required
  389. ]
  390. });
  391. // Get calculations, always
  392. if (
  393. this.instrument_work != undefined &&
  394. this.instrument_work.proyecciones == ""
  395. ) {
  396. this.getCalculations(this.investmentProposalForm, false);
  397. }
  398. }
  399. public records: any[] = [];
  400. @ViewChild("csvReader", null) csvReader: any;
  401. uploadListener($event: any): void {
  402. /* wire up file reader */
  403. const target: DataTransfer = $event.target;
  404. if (target.files.length !== 1) {
  405. throw new Error("Cannot use multiple files");
  406. }
  407. const reader: FileReader = new FileReader();
  408. reader.readAsBinaryString(target.files[0]);
  409. reader.onload = (e: any) => {
  410. /* create workbook */
  411. const binarystr: string = e.target.result;
  412. const wb: XLSX.WorkBook = XLSX.read(binarystr, { type: "binary" });
  413. /* selected the first sheet */
  414. const wsname: string = wb.SheetNames[0];
  415. const ws: XLSX.WorkSheet = wb.Sheets[wsname];
  416. /* save data */
  417. const data = XLSX.utils.sheet_to_json(ws, { header: 1 }); // to get 2d array pass 2nd parameter as object {header: 1}
  418. const data2 = data.toString().split(",");
  419. data2.shift();
  420. this.amortizaciones = data2;
  421. };
  422. }
  423. get f() {
  424. return this.investmentProposalForm.controls;
  425. }
  426. save(form: any): boolean {
  427. if (!form.valid) {
  428. return false;
  429. }
  430. this.formDataService.setWork(this.titulosObject);
  431. return true;
  432. }
  433. getCalculations(form: any, saveForm: boolean) {
  434. this.submitted = true;
  435. if (!form.valid) {
  436. return false;
  437. }
  438. Swal.fire({
  439. allowOutsideClick: false,
  440. icon: "info",
  441. text: "Espere por favor..."
  442. });
  443. Swal.showLoading();
  444. this.instrumentCalcService
  445. .titularizacionCalc(
  446. "TIT", // Codigo del instrumento
  447. {
  448. id_tipo_base: +this.general.base_anual,
  449. id_formato_ingreso: +this.general.formato_ingreso,
  450. id_periodicidad: +this.general.periodicidad
  451. },
  452. {
  453. costo_transferencia: +this.f.costo_transferencia.value,
  454. valor_nominal_compra: +this.f.valor_nominal_compra.value,
  455. precio_compra: +this.f.precio_compra.value,
  456. precio_vencimiento_compra: +this.f.precio_vencimiento_compra.value,
  457. cupon_porcentaje_compra: +this.f.cupon_porcentaje_compra.value,
  458. comision_casa_porcentaje_compra: this.f
  459. .comision_casa_porcentaje_compra.value,
  460. comision_bolsa_porcentaje_compra: this.f
  461. .comision_bolsa_porcentaje_compra.value,
  462. ytm_vencimiento_porcentaje_compra: this.f
  463. .ytm_vencimiento_porcentaje_compra.value,
  464. valor_nominal_venta: +this.f.valor_nominal_venta.value,
  465. precio_venta: +this.f.precio_venta.value,
  466. precio_vencimiento_venta: +this.f.precio_vencimiento_venta.value,
  467. cupon_porcentaje_venta: +this.f.cupon_porcentaje_venta.value,
  468. comision_casa_porcentaje_venta: this.f.comision_casa_porcentaje_venta
  469. .value,
  470. comision_bolsa_porcentaje_venta: this.f
  471. .comision_bolsa_porcentaje_venta.value,
  472. ytm_vencimiento_porcentaje_venta: this.f
  473. .ytm_vencimiento_porcentaje_venta.value,
  474. fecha_vencimiento_compra: this.f.fecha_vencimiento_compra.value
  475. .singleDate.formatted,
  476. fecha_ultima_cupon_compra: this.f.fecha_ultima_cupon_compra.value
  477. .singleDate.formatted,
  478. fecha_liquidacion_compra: this.f.fecha_liquidacion_compra.value
  479. .singleDate.formatted,
  480. fecha_vencimiento_venta: this.f.fecha_vencimiento_venta.value
  481. .singleDate.formatted,
  482. fecha_ultima_cupon_venta: this.f.fecha_ultima_cupon_venta.value
  483. .singleDate.formatted,
  484. fecha_liquidacion_venta: this.f.fecha_liquidacion_venta.value
  485. .singleDate.formatted,
  486. fecha_emision: this.f.fecha_emision.value.singleDate.formatted,
  487. amortizacion_porcentajes: this.amortizaciones
  488. }
  489. )
  490. .subscribe(
  491. ans => {
  492. // Instrumento de compra
  493. this.comision_casa_compra =
  494. ans["result"]["instrumento_compra"]["comision_casa_compra"];
  495. this.comision_bolsa_compra =
  496. ans["result"]["instrumento_compra"]["comision_bolsa_compra"];
  497. this.fecha_siguiente_cupon_compra =
  498. ans["result"]["instrumento_compra"]["fecha_siguiente_cupon_compra"];
  499. this.dias_vencimiento_compra =
  500. ans["result"]["instrumento_compra"]["dias_vencimiento_compra"];
  501. this.dias_acumulados_compra =
  502. ans["result"]["instrumento_compra"]["dias_acumulados_compra"];
  503. this.ytm_vencimiento_comision_porcentaje_compra =
  504. ans["result"]["instrumento_compra"][
  505. "ytm_vencimiento_comision_porcentaje_compra"
  506. ];
  507. this.interes_acumulado_compra =
  508. ans["result"]["instrumento_compra"]["interes_acumulado_compra"];
  509. this.interes_acumulado_porcentaje_compra =
  510. ans["result"]["instrumento_compra"][
  511. "interes_acumulado_porcentaje_compra"
  512. ];
  513. this.precio_sucio_porcentaje_compra =
  514. ans["result"]["instrumento_compra"][
  515. "precio_sucio_porcentaje_compra"
  516. ];
  517. this.valor_transado_compra =
  518. ans["result"]["instrumento_compra"]["valor_transado_compra"];
  519. this.monto_pagar = ans["result"]["instrumento_compra"]["monto_pagar"];
  520. this.fecha_inicio_vigencia =
  521. ans["result"]["instrumento_compra"]["fecha_inicio_vigencia"];
  522. // Instrumento de venta
  523. this.comision_casa_venta =
  524. ans["result"]["instrumento_venta"]["comision_casa_venta"];
  525. this.fecha_siguiente_cupon_venta =
  526. ans["result"]["instrumento_venta"]["fecha_siguiente_cupon_venta"];
  527. this.dias_vencimiento_venta =
  528. ans["result"]["instrumento_venta"]["dias_vencimiento_venta"];
  529. this.dias_acumulados_venta =
  530. ans["result"]["instrumento_venta"]["dias_acumulados_venta"];
  531. this.ytm_vencimiento_comision_porcentaje_venta =
  532. ans["result"]["instrumento_venta"][
  533. "ytm_vencimiento_comision_porcentaje_venta"
  534. ];
  535. this.interes_acumulado_venta =
  536. ans["result"]["instrumento_venta"]["interes_acumulado_venta"];
  537. this.interes_acumulado_porcentaje_venta =
  538. ans["result"]["instrumento_venta"][
  539. "interes_acumulado_porcentaje_venta"
  540. ];
  541. this.precio_sucio_porcentaje_venta =
  542. ans["result"]["instrumento_venta"]["precio_sucio_porcentaje_venta"];
  543. this.valor_transado_venta =
  544. ans["result"]["instrumento_venta"]["valor_transado_venta"];
  545. this.monto_recibir =
  546. ans["result"]["instrumento_venta"]["monto_recibir"];
  547. // Resultado de la operacion
  548. this.operation_result = false;
  549. this.dias_tenencia_total =
  550. ans["result"]["resultado_operacion"]["dias_tenencia_total"];
  551. this.ganancia_perdida_capital =
  552. ans["result"]["resultado_operacion"]["ganancia_perdida_capital"];
  553. this.ingresos_intereses =
  554. ans["result"]["resultado_operacion"]["ingresos_intereses"];
  555. this.costos_totales =
  556. ans["result"]["resultado_operacion"]["costos_totales"];
  557. this.ganancia_perdida_total =
  558. ans["result"]["resultado_operacion"]["ganancia_perdida_total"];
  559. this.ganancia_perdida_capital_porcentaje =
  560. ans["result"]["resultado_operacion"][
  561. "ganancia_perdida_capital_porcentaje"
  562. ];
  563. this.intereses_porcentaje =
  564. ans["result"]["resultado_operacion"]["intereses_porcentaje"];
  565. this.neto_antes_impuesto_porcentaje =
  566. ans["result"]["resultado_operacion"][
  567. "neto_antes_impuesto_porcentaje"
  568. ];
  569. this.neto_despues_impuesto_porcentaje =
  570. ans["result"]["resultado_operacion"][
  571. "neto_despues_impuesto_porcentaje"
  572. ];
  573. this.total_ingresos_recibidos =
  574. ans["result"]["resultado_operacion"]["total_ingresos_recibidos"];
  575. // Proyecciones
  576. this.proyecciones = ans["result"]["proyecciones"];
  577. this.dataSource.data = this.proyecciones;
  578. this.dataSource2.data = this.proyecciones;
  579. this.dataSource.paginator = this.paginator;
  580. this.dataSource.sort = this.sort;
  581. this.titulosObject = {
  582. costo_transferencia: this.investmentProposalForm.value
  583. .costo_transferencia,
  584. valor_nominal_compra: this.investmentProposalForm.value
  585. .valor_nominal_compra,
  586. precio_compra: this.investmentProposalForm.value.precio_compra,
  587. precio_vencimiento_compra: this.investmentProposalForm.value
  588. .precio_vencimiento_compra,
  589. cupon_porcentaje_compra: this.investmentProposalForm.value
  590. .cupon_porcentaje_compra,
  591. comision_casa_porcentaje_compra: this.investmentProposalForm.value
  592. .comision_casa_porcentaje_compra,
  593. comision_bolsa_porcentaje_compra: this.investmentProposalForm.value
  594. .comision_bolsa_porcentaje_compra,
  595. ytm_vencimiento_porcentaje_compra: this.investmentProposalForm.value
  596. .ytm_vencimiento_porcentaje_compra,
  597. valor_nominal_venta: this.investmentProposalForm.value
  598. .valor_nominal_venta,
  599. precio_venta: this.investmentProposalForm.value.precio_venta,
  600. precio_vencimiento_venta: this.investmentProposalForm.value
  601. .precio_vencimiento_venta,
  602. cupon_porcentaje_venta: this.investmentProposalForm.value
  603. .cupon_porcentaje_venta,
  604. comision_casa_porcentaje_venta: this.investmentProposalForm.value
  605. .comision_casa_porcentaje_venta,
  606. comision_bolsa_porcentaje_venta: this.investmentProposalForm.value
  607. .comision_bolsa_porcentaje_venta,
  608. ytm_vencimiento_porcentaje_venta: this.investmentProposalForm.value
  609. .ytm_vencimiento_porcentaje_venta,
  610. fecha_vencimiento_compra: this.f.fecha_vencimiento_compra.value
  611. .singleDate.formatted,
  612. fecha_ultima_cupon_compra: this.f.fecha_ultima_cupon_compra.value
  613. .singleDate.formatted,
  614. fecha_liquidacion_compra: this.f.fecha_liquidacion_compra.value
  615. .singleDate.formatted,
  616. fecha_vencimiento_venta: this.f.fecha_vencimiento_venta.value
  617. .singleDate.formatted,
  618. fecha_ultima_cupon_venta: this.f.fecha_ultima_cupon_venta.value
  619. .singleDate.formatted,
  620. fecha_liquidacion_venta: this.f.fecha_liquidacion_venta.value
  621. .singleDate.formatted,
  622. fecha_emision: this.f.fecha_emision.value.singleDate.formatted,
  623. // Instrumento de compra
  624. comision_casa_compra: this.comision_casa_compra,
  625. comision_bolsa_compra: this.comision_bolsa_compra,
  626. fecha_siguiente_cupon_compra: this.fecha_siguiente_cupon_compra,
  627. dias_vencimiento_compra: this.dias_vencimiento_compra,
  628. dias_acumulados_compra: this.dias_acumulados_compra,
  629. ytm_vencimiento_comision_porcentaje_compra: this
  630. .ytm_vencimiento_comision_porcentaje_compra,
  631. interes_acumulado_compra: this.interes_acumulado_compra,
  632. interes_acumulado_porcentaje_compra: this
  633. .interes_acumulado_porcentaje_compra,
  634. precio_sucio_porcentaje_compra: this.precio_sucio_porcentaje_compra,
  635. valor_transado_compra: this.valor_transado_compra,
  636. monto_pagar: this.monto_pagar,
  637. fecha_inicio_vigencia: this.fecha_inicio_vigencia,
  638. // Instrumento de venta
  639. comision_casa_venta: this.comision_casa_venta,
  640. fecha_siguiente_cupon_venta: this.fecha_siguiente_cupon_venta,
  641. dias_vencimiento_venta: this.dias_vencimiento_venta,
  642. dias_acumulados_venta: this.dias_acumulados_venta,
  643. ytm_vencimiento_comision_porcentaje_venta: this
  644. .ytm_vencimiento_comision_porcentaje_venta,
  645. interes_acumulado_venta: this.interes_acumulado_venta,
  646. interes_acumulado_porcentaje_venta: this
  647. .interes_acumulado_porcentaje_venta,
  648. precio_sucio_porcentaje_venta: this.precio_sucio_porcentaje_venta,
  649. valor_transado_venta: this.valor_transado_venta,
  650. // Resultado de la operacion
  651. /*
  652. monto_recibir: this.monto_recibir,
  653. dias_tenencia_total: this.dias_tenencia_total,
  654. ganancia_perdida_capital: this.ganancia_perdida_capital,
  655. ingresos_intereses: this.ingresos_intereses,
  656. costos_totales: this.costos_totales,
  657. ganancia_perdida_total: this.ganancia_perdida_total,
  658. ganancia_perdida_capital_porcentaje: this
  659. .ganancia_perdida_capital_porcentaje,
  660. intereses_porcentaje: this.intereses_porcentaje,
  661. neto_antes_impuesto_porcentaje: this.neto_antes_impuesto_porcentaje,
  662. neto_despues_impuesto_porcentaje: this
  663. .neto_despues_impuesto_porcentaje,
  664. total_ingresos_recibidos: this.total_ingresos_recibidos,
  665. amortizacion_porcentajes: this.amortizaciones,-**/
  666. // Proyecciones
  667. proyecciones: this.proyecciones
  668. };
  669. this.formDataService.setWork(this.titulosObject);
  670. Swal.close();
  671. if (saveForm == true) {
  672. if (this.investmentID != undefined) {
  673. this.router.navigate(["/investment-proposal/complement-info"], {
  674. queryParams: { id: this.investmentID }
  675. });
  676. } else {
  677. this.router.navigate(["/investment-proposal/complement-info"]);
  678. }
  679. }
  680. },
  681. err => {
  682. Swal.fire({
  683. icon: "error",
  684. title: "Error en el servidor",
  685. text: "No su pudo obtener la informacion"
  686. });
  687. return false;
  688. }
  689. );
  690. }
  691. goToPrevious() {
  692. this.submitted = true;
  693. if (this.investmentID != undefined) {
  694. this.router.navigate(["/investment-proposal/general-info"], {
  695. queryParams: { id: this.investmentID }
  696. });
  697. } else {
  698. this.router.navigate(["/investment-proposal/general-info"]);
  699. }
  700. }
  701. goToNext(form: any) {
  702. this.getCalculations(form, true);
  703. }
  704. }