@acontplus/ng-common 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -134,7 +134,7 @@ import {
134
134
  export class ReportsComponent {
135
135
  constructor(private reportFacade: ReportFacade) {}
136
136
 
137
- // Ejemplo 1: Reporte simple de factura
137
+ // Ejemplo 1: Generar y abrir PDF automáticamente
138
138
  generateInvoiceReport(id: number, codEstab: string) {
139
139
  const reportOptions = ReportParamsBuilder.build(
140
140
  {
@@ -142,16 +142,18 @@ export class ReportsComponent {
142
142
  id,
143
143
  codEstab
144
144
  },
145
- REPORT_FORMAT.PDF,
146
- true // returnBlob
145
+ REPORT_FORMAT.PDF
147
146
  );
148
147
 
149
- this.reportFacade.generate(reportOptions).subscribe(response => {
150
- console.log('Reporte generado');
151
- });
148
+ // Se abre automáticamente en nueva ventana (o descarga en navegadores legacy)
149
+ this.reportFacade.openPDF(reportOptions.data, reportOptions.useV1Api)
150
+ .subscribe({
151
+ next: () => console.log('Reporte generado'),
152
+ error: (err) => console.error('Error:', err)
153
+ });
152
154
  }
153
155
 
154
- // Ejemplo 2: Reporte de ventas con parámetros personalizados
156
+ // Ejemplo 2: Generar Excel y descargar automáticamente
155
157
  generateSalesReport() {
156
158
  const reportOptions = ReportParamsBuilder.build(
157
159
  {
@@ -165,47 +167,54 @@ export class ReportsComponent {
165
167
  REPORT_FORMAT.EXCEL
166
168
  );
167
169
 
168
- this.reportFacade.generate(reportOptions);
170
+ this.reportFacade.downloadExcel(reportOptions.data, reportOptions.useV1Api)
171
+ .subscribe();
169
172
  }
170
173
 
171
- // Ejemplo 3: Reporte de inventario con múltiples parámetros
172
- generateInventoryReport() {
174
+ // Ejemplo 3: Control total sobre el blob
175
+ generateCustomReport() {
173
176
  const reportOptions = ReportParamsBuilder.build(
174
177
  {
175
178
  codDoc: INVENTORY_CODE_REPORT.ARTICULO_PVP,
176
179
  tipo: 2,
177
180
  stockStatusCode: 1,
178
- idTarifa: 3,
179
- idMarca: 10,
180
- fechaInicio: this.fromDate,
181
- fechaFin: this.toDate,
182
- // Cualquier parámetro adicional se incluye automáticamente
183
- customParam: 'valor'
181
+ idTarifa: 3
184
182
  },
185
183
  REPORT_FORMAT.PDF
186
184
  );
187
185
 
188
- this.reportFacade.generate(reportOptions);
186
+ this.reportFacade.generate(reportOptions)
187
+ .subscribe({
188
+ next: (response) => {
189
+ // Tienes control total del blob
190
+ const blob = response.body;
191
+ if (blob) {
192
+ // Hacer lo que quieras: enviar por WhatsApp, guardar, etc.
193
+ this.sendViaWhatsApp(blob);
194
+ }
195
+ }
196
+ });
189
197
  }
190
198
 
191
- // Ejemplo 4: Reporte condicional
192
- generateConditionalReport(useCustom: boolean) {
193
- const reportCode = useCustom
194
- ? SALE_CODE_REPORT.SRRC
195
- : SALE_CODE_REPORT.SRR;
196
-
199
+ // Ejemplo 4: Usar métodos genéricos
200
+ quickPDFReport() {
197
201
  const reportOptions = ReportParamsBuilder.build(
198
- {
199
- codDoc: reportCode,
200
- porcentajeRenta: 15,
201
- porcentajeComision: 5,
202
- fechaInicio: this.fromDate,
203
- fechaFin: this.toDate
204
- },
202
+ { codDoc: SALE_CODE_REPORT.SRR },
205
203
  REPORT_FORMAT.PDF
206
204
  );
207
205
 
208
- this.reportFacade.generate(reportOptions);
206
+ // Abre automáticamente
207
+ this.reportFacade.open(reportOptions).subscribe();
208
+ }
209
+
210
+ quickExcelDownload() {
211
+ const reportOptions = ReportParamsBuilder.build(
212
+ { codDoc: INVENTORY_CODE_REPORT.RCD },
213
+ REPORT_FORMAT.EXCEL
214
+ );
215
+
216
+ // Descarga automáticamente
217
+ this.reportFacade.download(reportOptions).subscribe();
209
218
  }
210
219
 
211
220
  // Verificar tipos soportados
@@ -213,11 +222,6 @@ export class ReportsComponent {
213
222
  const types = ReportParamsBuilder.getSupportedDocumentTypes();
214
223
  console.log('Tipos soportados:', types);
215
224
  }
216
-
217
- // Verificar si un tipo está soportado
218
- isSupported(code: string) {
219
- return ReportParamsBuilder.isDocumentTypeSupported(code);
220
- }
221
225
  }
222
226
  ```
223
227