| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- import { Injectable } from "@angular/core";
- import { of as observableOf, Observable, throwError } from "rxjs";
- import { HttpClient, HttpHeaders } from "@angular/common/http";
- import { retry, catchError, map, timeout } from "rxjs/operators";
- import { environment } from "@environments/environment";
- @Injectable({
- providedIn: "root"
- })
- export class InstrumentCalculations {
- time: number = 6000;
- constructor(private http: HttpClient) {}
- // Calculos para lete
- leteCalc(
- codigo_instrumento: string,
- info_inversion: { id_tipo_base: string },
- info_instrumento: {
- valor_nominal: number;
- plazo: number;
- comision_casa_porcentaje: number;
- comision_bolsa_porcentaje: number;
- rendimiento_bruto: number;
- fecha_operacion: string;
- fecha_liquidacion?: string;
- }
- ): Observable<boolean> {
- return this.http
- .post<any>(`${environment.productionApiUrl}/autocomplete/lete`, {
- codigo_instrumento,
- info_inversion,
- info_instrumento
- })
- .pipe(
- map(response => {
- return response;
- }),
- catchError(this.errorHandl)
- );
- }
- ceteCalc(
- codigo_instrumento: string,
- info_inversion: {
- id_tipo_base: string;
- id_periodicidad: string;
- id_formato_ingreso: string;
- },
- info_instrumento: {
- valor_nominal: number;
- comision_casa_porcentaje: number;
- comision_bolsa_porcentaje: number;
- plazo: number;
- rendimiento_bruto: number;
- otros_costos: number;
- fecha_operacion: string;
- fecha_liquidacion: string;
- fecha_ultima_cupon: string;
- fecha_vencimiento: string;
- }
- ): Observable<boolean> {
- return this.http
- .post<any>(`${environment.productionApiUrl}/autocomplete/cete`, {
- codigo_instrumento,
- info_inversion,
- info_instrumento
- })
- .pipe(
- map(response => {
- return response;
- }),
- catchError(this.errorHandl)
- );
- }
- // Para vcn y papel bursatil
- vcnCalc(
- codigo_instrumento: string,
- info_inversion: {
- id_tipo_base: string;
- id_periodicidad: string;
- id_formato_ingreso: string;
- },
- info_instrumento: {
- valor_par: boolean;
- valor_nominal: number;
- comision_casa_porcentaje: number;
- comision_bolsa_porcentaje: number;
- rendimiento_bruto: number;
- otros_costos: number;
- plazo: number;
- renta_porcentaje: number;
- fecha_operacion: string;
- fecha_liquidacion: string;
- fecha_ultima_cupon: string;
- fecha_vencimiento: string;
- }
- ): Observable<boolean> {
- return this.http
- .post<any>(`${environment.productionApiUrl}/autocomplete/vcn`, {
- codigo_instrumento,
- info_inversion,
- info_instrumento
- })
- .pipe(
- map(response => {
- return response;
- }),
- catchError(this.errorHandl)
- );
- }
- dapCalc(
- codigo_instrumento: string,
- info_inversion: {
- id_tipo_base: string;
- id_periodicidad: string;
- id_formato_ingreso: string;
- },
- info_instrumento: {
- monto_inversion: number;
- tasa_porcentaje: number;
- renta_porcentaje: number;
- plazo: number;
- fecha_operacion: string;
- fecha_vencimiento: string;
- }
- ): Observable<boolean> {
- return this.http
- .post<any>(`${environment.productionApiUrl}/autocomplete/dap`, {
- codigo_instrumento,
- info_inversion,
- info_instrumento
- })
- .pipe(
- map(response => {
- return response;
- }),
- catchError(this.errorHandl)
- );
- }
- errorHandl(error) {
- let errorMessage = "";
- if (error.error) {
- // Get client-side error
- errorMessage = error.error;
- } else {
- // Get server-side error
- errorMessage = `Error Code: ${error.status}\nMessage: ${error.message}`;
- }
- return throwError(errorMessage);
- }
- }
|