titulos.component.ts 27 KB

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