| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343 |
- 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`, {
- codigo_instrumento,
- info_inversion,
- info_instrumento
- })
- .pipe(
- map(response => {
- return response;
- }),
- catchError(this.errorHandl)
- );
- }
- ceteCalc(
- codigo_instrumento: string,
- info_inversion: {
- id_tipo_base: number;
- id_periodicidad: number;
- id_formato_ingreso: number;
- },
- 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`, {
- codigo_instrumento,
- info_inversion,
- info_instrumento
- })
- .pipe(
- map(response => {
- return response;
- }),
- catchError(this.errorHandl)
- );
- }
- // Para familia de bonos (bonos, eurobonos, certificados)
- bonosCalc(
- codigo_instrumento: string,
- info_inversion: {
- id_tipo_base: number;
- id_periodicidad: number;
- id_formato_ingreso: number;
- },
- info_instrumento: {
- costo_cedeval: number;
- comision_casa_porcentaje_compra: number;
- comision_bolsa_porcentaje_compra: number;
- cupon_porcentaje_compra: number;
- valor_nominal_compra: number;
- costo_transferencia: number;
- precio_vencimiento_compra: number;
- precio_compra: number;
- fecha_ultima_cupon_compra: string;
- fecha_liquidacion_compra: string;
- fecha_vencimiento_compra: string;
- comision_casa_porcentaje_venta: number;
- comision_bolsa_porcentaje_venta: number;
- cupon_porcentaje_venta: number;
- valor_nominal_venta: number;
- precio_vencimiento_venta: number;
- precio_venta: number;
- fecha_ultima_cupon_venta: string;
- fecha_liquidacion_venta: string;
- fecha_vencimiento_venta: string;
- }
- ): Observable<boolean> {
- return this.http
- .post<any>(`${environment.productionApiUrl}/autocomplete`, {
- codigo_instrumento,
- info_inversion,
- info_instrumento
- })
- .pipe(
- map(response => {
- return response;
- }),
- catchError(this.errorHandl)
- );
- }
- titularizacionCalc(
- codigo_instrumento: string,
- info_inversion: {
- id_tipo_base: number;
- id_periodicidad: number;
- id_formato_ingreso: number;
- },
- info_instrumento: {
- comision_casa_porcentaje_compra: number;
- comision_bolsa_porcentaje_compra: number;
- cupon_porcentaje_compra: number;
- valor_nominal_compra: number;
- costo_transferencia: number;
- precio_vencimiento_compra: number;
- precio_compra: number;
- fecha_ultima_cupon_compra: string;
- fecha_liquidacion_compra: string;
- fecha_vencimiento_compra: string;
- comision_casa_porcentaje_venta: number;
- comision_bolsa_porcentaje_venta: number;
- cupon_porcentaje_venta: number;
- valor_nominal_venta: number;
- precio_vencimiento_venta: number;
- precio_venta: number;
- fecha_ultima_cupon_venta: string;
- fecha_liquidacion_venta: string;
- fecha_vencimiento_venta: string;
- fecha_emision: string;
- costo_cedeval: number;
- amortizacion_porcentajes: any;
- }
- ): Observable<boolean> {
- return this.http
- .post<any>(`${environment.productionApiUrl}/autocomplete`, {
- codigo_instrumento,
- info_inversion,
- info_instrumento
- })
- .pipe(
- map(response => {
- return response;
- }),
- catchError(this.errorHandl)
- );
- }
- // Fondos de inversion
- fondosCalc(
- codigo_instrumento: string,
- info_inversion: {
- id_tipo_base: number;
- id_periodicidad: number;
- id_formato_ingreso: number;
- },
- info_instrumento: {
- cuota_participacion: number;
- valor_participacion: number;
- comision_bolsa_porcentaje: number;
- comision_casa_porcentaje: number;
- dividendo_porcentaje: number;
- rendimiento_porcentaje: number;
- dias_liquidacion: number;
- dias_vencimiento: number;
- fecha_operacion: string;
- }
- ): Observable<boolean> {
- return this.http
- .post<any>(`${environment.productionApiUrl}/autocomplete`, {
- codigo_instrumento,
- info_inversion,
- info_instrumento
- })
- .pipe(
- map(response => {
- return response;
- }),
- catchError(this.errorHandl)
- );
- }
- // Para vcn
- vcnCalc(
- codigo_instrumento: string,
- info_inversion: {
- id_tipo_base: number;
- id_periodicidad: number;
- id_formato_ingreso: number;
- },
- info_instrumento: {
- valor_par: boolean;
- valor_nominal: number;
- comision_casa_porcentaje: number;
- comision_bolsa_porcentaje: number;
- rendimiento_bruto: number;
- otros_costos: 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`, {
- codigo_instrumento,
- info_inversion,
- info_instrumento
- })
- .pipe(
- map(response => {
- return response;
- }),
- catchError(this.errorHandl)
- );
- }
- // Para pbur
- pburCalc(
- codigo_instrumento: string,
- info_inversion: {
- id_tipo_base: number;
- id_periodicidad: number;
- id_formato_ingreso: number;
- },
- 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;
- }
- ): Observable<boolean> {
- return this.http
- .post<any>(`${environment.productionApiUrl}/autocomplete`, {
- codigo_instrumento,
- info_inversion,
- info_instrumento
- })
- .pipe(
- map(response => {
- return response;
- }),
- catchError(this.errorHandl)
- );
- }
- dapCalc(
- codigo_instrumento: string,
- info_inversion: {
- id_tipo_base: number;
- id_periodicidad: number;
- id_formato_ingreso: number;
- },
- 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`, {
- codigo_instrumento,
- info_inversion,
- info_instrumento
- })
- .pipe(
- map(response => {
- return response;
- }),
- catchError(this.errorHandl)
- );
- }
- projectionCalc(id: string, proyecciones: any): Observable<boolean> {
- return this.http
- .put<any>(`${environment.productionApiUrl}/autocomplete/${id}`, {
- proyecciones
- })
- .pipe(
- map(response => {
- return response;
- }),
- catchError(this.errorHandl)
- );
- }
- projectionModification(id: string, proyecciones: any): Observable<boolean> {
- return this.http
- .put<any>(
- `${environment.productionApiUrl}/proyeccion/${id}`,
- proyecciones
- )
- .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);
- }
- }
|