bonos.component.ts 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import { Component, OnInit, Input } 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. @Component({
  9. selector: "app-bonos",
  10. templateUrl: "./bonos.component.html"
  11. })
  12. export class BonosComponent implements InstrumentComponent {
  13. title: string = "Bonos";
  14. @Input() data: any;
  15. form: any;
  16. // For daterange
  17. daysLabels: any = {
  18. su: "Dom",
  19. mo: "Lun",
  20. tu: "Mar",
  21. we: "Mie",
  22. th: "Jue",
  23. fr: "Vie",
  24. sa: "Sab"
  25. };
  26. monthsLabels: any = {
  27. 1: "Ene",
  28. 2: "Feb",
  29. 3: "Mar",
  30. 4: "Abr",
  31. 5: "May",
  32. 6: "Jun",
  33. 7: "Jul",
  34. 8: "Ago",
  35. 9: "Sep",
  36. 10: "Oct",
  37. 11: "Nov",
  38. 12: "Dic"
  39. };
  40. investmentProposalForm: FormGroup;
  41. myDpOptions: IAngularMyDpOptions = {
  42. dateRange: false,
  43. dateFormat: "dd/mm/yyyy",
  44. dayLabels: this.daysLabels,
  45. monthLabels: this.monthsLabels
  46. };
  47. myDateInit: boolean = true;
  48. model: IMyDateModel = null;
  49. constructor(
  50. private formBuilder: FormBuilder,
  51. private router: Router,
  52. private formDataService: FormInvestmentProposalService
  53. ) {
  54. console.log("init");
  55. this.investmentProposalForm = this.formBuilder.group({
  56. valor_nominal: ["", Validators.required],
  57. ytm_vencimiento: ["", Validators.required],
  58. precio_c_v: ["", Validators.required],
  59. precio_vencimiento: ["", Validators.required],
  60. fecha_liquidacion: ["", Validators.required],
  61. fecha_cupon: ["", Validators.required],
  62. fecha_vencimiento: ["", Validators.required],
  63. comision_casa: ["", Validators.required],
  64. comision_bolsa: ["", Validators.required],
  65. cupon: ["", Validators.required],
  66. costos_transferencia: ["", Validators.required]
  67. });
  68. }
  69. save(form: any): boolean {
  70. /*if (!form.valid) {
  71. return false;
  72. }*/
  73. this.formDataService.setWork(this.investmentProposalForm.value);
  74. return true;
  75. }
  76. goToNext(form: any) {
  77. if (this.save(form)) {
  78. console.log("all good");
  79. // Navigate to the work page
  80. this.router.navigate(["/address"]);
  81. }
  82. }
  83. }