npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@cbm-common/report-financials-repository

v0.0.1

Published

Repositorio de utilidades para descargar y consultar reportes financieros desde el backend.

Readme

ReportFinancialsRepository

Repositorio de utilidades para descargar y consultar reportes financieros desde el backend.

Este paquete expone un módulo configurabled mediante forRoot y un servicio (CbmReportFinancialsService) con métodos para solicitar reportes en formatos generales o individuales (descarga de Excel/PDF como blobs) y peticiones que devuelven metadata.

Contenido del paquete

  • report-financials.module.ts — módulo que exporta el token de configuración REPORT_FINANCIALS_MODULE_CONFIG y la función estática CbmReportFinancialsModule.forRoot(config).
  • report-financials.service.ts — implementación principal con métodos para descargar reportes; utiliza HttpClient y la configuración inyectada.
  • report-financials.model.ts — tipos (params y respuestas) usados por los métodos del servicio.

Instalación

Si la librería está publicada en tu registry (npm o privado):

npm install @cbm-common/report-financials-repository

En un monorepo Angular puedes usar directamente la librería desde projects/ importando el módulo en tu app.

Configuración (recomendado)

Importa y configura el módulo en tu módulo raíz usando forRoot para proveer la baseUrl que se prefijará a todos los endpoints:

import { CbmReportFinancialsModule } from '@cbm-common/report-financials-repository';

@NgModule({
  imports: [
    // ...
    CbmReportFinancialsModule.forRoot({ baseUrl: 'https://api.example.com/reports' }),
  ],
})
export class AppModule {}

Alternativa: proveer el token manualmente en providers:

import { REPORT_FINANCIALS_MODULE_CONFIG } from '@cbm-common/report-financials-repository';

providers: [
  { provide: REPORT_FINANCIALS_MODULE_CONFIG, useValue: { baseUrl: 'https://api.example.com/reports' } }
]

Interfaz de configuración (resumida):

  • ICbmReportFinancialsModuleConfig
    • baseUrl: string — URL base que será concatenada a las rutas internas del servicio.

API principal (resumen)

El servicio CbmReportFinancialsService ofrece métodos para varias familias de reportes. Los nombres son descriptivos, p. ej:

  • Fixed assets: downloadExcelFixedAssetsReport, downloadPdfFixedAssetsReport, downloadIndividualExcelDepreciationFixedAssetsReport, etc.
  • Depreciation fixed assets, income/outgoing banking transaction reports, card settlement reports, seat reports.
  • Deposit (cash/cheque), protested checks, bank conciliation (descargas y plantillas + endpoints de upload), accounting upload, catalog-account-download.

Tipos de retorno comunes:

  • Observable<ConfirmResponse> — llamadas que devuelven metadata/confirmación.
  • Observable<HttpResponse<Blob>> — descargas de archivos (Excel/PDF) con responseType: 'blob'.

Ejemplo: descarga individual y forzar descarga en cliente

this.reportFinancialsService
  .downloadIndividualExcelSeatReport(id, params)
  .subscribe((res: HttpResponse<Blob>) => {
    const blob = res.body as Blob;
    const url = window.URL.createObjectURL(blob);
    const a = document.createElement('a');
    a.href = url;
    a.download = 'reporte.xlsx';
    a.click();
    window.URL.revokeObjectURL(url);
  });

Ejemplo: petición general que devuelve metadata

this.reportFinancialsService
  .downloadExcelSeatReport(params)
  .subscribe(resp => {
    // resp contiene ConfirmResponse con información sobre el proceso / archivo
  });

Tests

La librería incluye specs (unitarias). Para ejecutar los tests específicos de la librería desde la raíz del workspace:

g ng test report-financials-repository

O ejecutar todos los tests del workspace con:

ng test

(Dependiendo de la configuración del monorepo, ng test puede ejecutar varias suites en paralelo o secuencialmente.)

Build y publicación

Construir la librería:

ng build report-financials-repository

Al compilar se generará dist/report-financials-repository (según configuración del angular.json). Para publicar en npm/registry:

cd dist/report-financials-repository
npm publish

Si publicas en un registry privado, configura el fichero .npmrc con las credenciales y registry adecuados.

Notas y recomendaciones

  • El servicio ahora construye rutas usando la baseUrl inyectada. Asegúrate de pasar la baseUrl correcta (sin doble slash al concatenar) para evitar errores 404.
  • Si tu proyecto usa interceptores o wrappers HTTP personalizados, regístralos a nivel de aplicación. Si necesitas que la librería envuelva el HttpClient con un wrapper específico, puedo añadir ese proveedor en el módulo.
  • Para descargas de blobs recuerda manejar correctamente responseType: 'blob' y la conversión a HttpResponse<Blob>.

Troubleshooting rápido

  • 404 en endpoints: revisa baseUrl y las rutas definidas por el backend.
  • Problemas CORS en descargas: habilita Access-Control-Allow-Origin y Access-Control-Expose-Headers en el backend.
  • Errores de tipos TS: ejecuta npx tsc --noEmit desde la raíz para comprobar problemas de tipado.

Contribuir / desarrollo local

  • Para iterar en la librería dentro del monorepo: hacer cambios en projects/report-financials-repository/src/lib, ejecutar ng build report-financials-repository y usar la app de ejemplo del workspace para integrarlo localmente.
  • Añadir tests unitarios y ejecutarlos con ng test report-financials-repository.

Documento generado el 14 de agosto de 2025.