nexabase-report 0.2.5 → 0.2.8

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.
@@ -0,0 +1,537 @@
1
+ {
2
+ "metadata": {
3
+ "version": "1.0",
4
+ "name": "Factura de Venta",
5
+ "description": "Factura comercial con datos del cliente, detalle de productos y totales. Ejemplo de integración Blazor Razor + nexabase-report.",
6
+ "author": "NexaBase",
7
+ "createdAt": "2026-05-09T00:00:00.000Z"
8
+ },
9
+ "layout": {
10
+ "page": {
11
+ "format": "A4",
12
+ "orientation": "portrait",
13
+ "margins": {
14
+ "top": 1.5,
15
+ "right": 1,
16
+ "bottom": 1,
17
+ "left": 1
18
+ }
19
+ },
20
+ "bands": [
21
+ {
22
+ "id": "rh_factura",
23
+ "type": "ReportHeader",
24
+ "height": 250,
25
+ "elements": [
26
+ {
27
+ "id": "rect_header",
28
+ "type": "Rectangle",
29
+ "x": 0,
30
+ "y": 0,
31
+ "width": 680,
32
+ "height": 100,
33
+ "shapeType": "Rectangle",
34
+ "options": {
35
+ "lineColor": "#1e40af",
36
+ "strokeWidth": 2,
37
+ "fillColor": "#eff6ff"
38
+ }
39
+ },
40
+ {
41
+ "id": "t_empresa",
42
+ "type": "Text",
43
+ "x": 20,
44
+ "y": 10,
45
+ "width": 300,
46
+ "height": 24,
47
+ "content": "MI EMPRESA S.A.",
48
+ "style": {
49
+ "fontSize": "20px",
50
+ "fontWeight": "bold",
51
+ "color": "#1e3a8a"
52
+ }
53
+ },
54
+ {
55
+ "id": "t_empresa_nit",
56
+ "type": "Text",
57
+ "x": 20,
58
+ "y": 36,
59
+ "width": 200,
60
+ "height": 14,
61
+ "content": "NIT: 901.234.567-8",
62
+ "style": {
63
+ "fontSize": "11px",
64
+ "color": "#475569"
65
+ }
66
+ },
67
+ {
68
+ "id": "t_factura_derecha",
69
+ "type": "Text",
70
+ "x": 450,
71
+ "y": 10,
72
+ "width": 210,
73
+ "height": 24,
74
+ "content": "FACTURA DE VENTA",
75
+ "style": {
76
+ "fontSize": "18px",
77
+ "fontWeight": "bold",
78
+ "color": "#1e40af",
79
+ "textAlign": "right"
80
+ }
81
+ },
82
+ {
83
+ "id": "t_numero",
84
+ "type": "Text",
85
+ "x": 450,
86
+ "y": 38,
87
+ "width": 210,
88
+ "height": 16,
89
+ "content": "N° {{numeroFactura}}",
90
+ "style": {
91
+ "fontSize": "14px",
92
+ "fontWeight": "bold",
93
+ "color": "#374151",
94
+ "textAlign": "right"
95
+ }
96
+ },
97
+ {
98
+ "id": "t_fecha",
99
+ "type": "Text",
100
+ "x": 450,
101
+ "y": 58,
102
+ "width": 210,
103
+ "height": 14,
104
+ "content": "Fecha: {{fecha}}",
105
+ "style": {
106
+ "fontSize": "11px",
107
+ "color": "#64748b",
108
+ "textAlign": "right"
109
+ }
110
+ },
111
+ {
112
+ "id": "line_div",
113
+ "type": "Line",
114
+ "x": 0,
115
+ "y": 105,
116
+ "width": 680,
117
+ "height": 2,
118
+ "shapeType": "Line",
119
+ "options": {
120
+ "lineColor": "#1e40af",
121
+ "strokeWidth": 2
122
+ }
123
+ },
124
+ {
125
+ "id": "t_cliente_label",
126
+ "type": "Text",
127
+ "x": 20,
128
+ "y": 112,
129
+ "width": 80,
130
+ "height": 16,
131
+ "content": "Cliente:",
132
+ "style": {
133
+ "fontSize": "12px",
134
+ "fontWeight": "bold",
135
+ "color": "#374151"
136
+ }
137
+ },
138
+ {
139
+ "id": "t_cliente_nombre",
140
+ "type": "Text",
141
+ "x": 100,
142
+ "y": 112,
143
+ "width": 280,
144
+ "height": 16,
145
+ "content": "{{nombreCliente}}",
146
+ "style": {
147
+ "fontSize": "12px",
148
+ "color": "#1e293b"
149
+ }
150
+ },
151
+ {
152
+ "id": "t_cliente_nit",
153
+ "type": "Text",
154
+ "x": 20,
155
+ "y": 130,
156
+ "width": 200,
157
+ "height": 14,
158
+ "content": "NIT: {{nitCliente}}",
159
+ "style": {
160
+ "fontSize": "11px",
161
+ "color": "#64748b"
162
+ }
163
+ },
164
+ {
165
+ "id": "t_cliente_direccion",
166
+ "type": "Text",
167
+ "x": 20,
168
+ "y": 146,
169
+ "width": 350,
170
+ "height": 14,
171
+ "content": "{{direccionCliente}}",
172
+ "style": {
173
+ "fontSize": "11px",
174
+ "color": "#64748b"
175
+ }
176
+ },
177
+ {
178
+ "id": "t_forma_pago",
179
+ "type": "Text",
180
+ "x": 480,
181
+ "y": 112,
182
+ "width": 180,
183
+ "height": 14,
184
+ "content": "Forma de pago: {{formaPago}}",
185
+ "style": {
186
+ "fontSize": "11px",
187
+ "color": "#475569",
188
+ "textAlign": "right"
189
+ }
190
+ },
191
+ {
192
+ "id": "t_vendedor",
193
+ "type": "Text",
194
+ "x": 480,
195
+ "y": 130,
196
+ "width": 180,
197
+ "height": 14,
198
+ "content": "Vendedor: {{vendedor}}",
199
+ "style": {
200
+ "fontSize": "11px",
201
+ "color": "#475569",
202
+ "textAlign": "right"
203
+ }
204
+ }
205
+ ]
206
+ },
207
+ {
208
+ "id": "db_items",
209
+ "type": "DataBand",
210
+ "height": 280,
211
+ "dataSource": "items",
212
+ "elements": [
213
+ {
214
+ "id": "t_items_title",
215
+ "type": "Text",
216
+ "x": 0,
217
+ "y": 5,
218
+ "width": 250,
219
+ "height": 20,
220
+ "content": "Detalle de Productos",
221
+ "style": {
222
+ "fontSize": "13px",
223
+ "fontWeight": "bold",
224
+ "color": "#1e3a8a"
225
+ }
226
+ },
227
+ {
228
+ "id": "table_items",
229
+ "type": "Table",
230
+ "x": 0,
231
+ "y": 30,
232
+ "width": 680,
233
+ "height": 240,
234
+ "tableColumns": [
235
+ {
236
+ "id": "col_codigo",
237
+ "title": "Código",
238
+ "width": 80,
239
+ "binding": "codigo"
240
+ },
241
+ {
242
+ "id": "col_producto",
243
+ "title": "Producto",
244
+ "width": 260,
245
+ "binding": "descripcion"
246
+ },
247
+ {
248
+ "id": "col_cantidad",
249
+ "title": "Cant.",
250
+ "width": 70,
251
+ "binding": "cantidad"
252
+ },
253
+ {
254
+ "id": "col_precio",
255
+ "title": "Precio Unit.",
256
+ "width": 110,
257
+ "binding": "precioUnitario"
258
+ },
259
+ {
260
+ "id": "col_descuento",
261
+ "title": "Desc.",
262
+ "width": 60,
263
+ "binding": "descuentoPorcentaje"
264
+ },
265
+ {
266
+ "id": "col_subtotal",
267
+ "title": "Subtotal",
268
+ "width": 100,
269
+ "binding": "subtotal"
270
+ }
271
+ ],
272
+ "tableShowFooter": true,
273
+ "style": {
274
+ "fontSize": "11px"
275
+ }
276
+ }
277
+ ]
278
+ },
279
+ {
280
+ "id": "rf_totales",
281
+ "type": "ReportFooter",
282
+ "height": 120,
283
+ "elements": [
284
+ {
285
+ "id": "line_sep",
286
+ "type": "Line",
287
+ "x": 400,
288
+ "y": 0,
289
+ "width": 280,
290
+ "height": 1,
291
+ "shapeType": "Line",
292
+ "options": {
293
+ "lineColor": "#94a3b8",
294
+ "strokeWidth": 1
295
+ }
296
+ },
297
+ {
298
+ "id": "t_subtotal_label",
299
+ "type": "Text",
300
+ "x": 400,
301
+ "y": 8,
302
+ "width": 120,
303
+ "height": 18,
304
+ "content": "Subtotal:",
305
+ "style": {
306
+ "fontSize": "12px",
307
+ "fontWeight": "bold",
308
+ "color": "#374151",
309
+ "textAlign": "right"
310
+ }
311
+ },
312
+ {
313
+ "id": "t_subtotal_val",
314
+ "type": "Text",
315
+ "x": 530,
316
+ "y": 8,
317
+ "width": 150,
318
+ "height": 18,
319
+ "content": "${[sum(subtotal)]}",
320
+ "style": {
321
+ "fontSize": "12px",
322
+ "color": "#374151",
323
+ "textAlign": "right"
324
+ }
325
+ },
326
+ {
327
+ "id": "t_descuento_label",
328
+ "type": "Text",
329
+ "x": 400,
330
+ "y": 28,
331
+ "width": 120,
332
+ "height": 16,
333
+ "content": "Descuento total:",
334
+ "style": {
335
+ "fontSize": "11px",
336
+ "color": "#64748b",
337
+ "textAlign": "right"
338
+ }
339
+ },
340
+ {
341
+ "id": "t_descuento_val",
342
+ "type": "Text",
343
+ "x": 530,
344
+ "y": 28,
345
+ "width": 150,
346
+ "height": 16,
347
+ "content": "${[sum(descuentoPorcentaje)]}%",
348
+ "style": {
349
+ "fontSize": "11px",
350
+ "color": "#dc2626",
351
+ "textAlign": "right"
352
+ }
353
+ },
354
+ {
355
+ "id": "t_iva_label",
356
+ "type": "Text",
357
+ "x": 400,
358
+ "y": 48,
359
+ "width": 120,
360
+ "height": 16,
361
+ "content": "IVA (19%):",
362
+ "style": {
363
+ "fontSize": "11px",
364
+ "color": "#64748b",
365
+ "textAlign": "right"
366
+ }
367
+ },
368
+ {
369
+ "id": "t_iva_val",
370
+ "type": "Text",
371
+ "x": 530,
372
+ "y": 48,
373
+ "width": 150,
374
+ "height": 16,
375
+ "content": "${[sum(subtotal) * 0.19]}",
376
+ "style": {
377
+ "fontSize": "11px",
378
+ "color": "#64748b",
379
+ "textAlign": "right"
380
+ }
381
+ },
382
+ {
383
+ "id": "line_total",
384
+ "type": "Line",
385
+ "x": 400,
386
+ "y": 70,
387
+ "width": 280,
388
+ "height": 2,
389
+ "shapeType": "Line",
390
+ "options": {
391
+ "lineColor": "#1e40af",
392
+ "strokeWidth": 2
393
+ }
394
+ },
395
+ {
396
+ "id": "t_total_label",
397
+ "type": "Text",
398
+ "x": 400,
399
+ "y": 76,
400
+ "width": 120,
401
+ "height": 28,
402
+ "content": "TOTAL:",
403
+ "style": {
404
+ "fontSize": "16px",
405
+ "fontWeight": "bold",
406
+ "color": "#1e3a8a",
407
+ "textAlign": "right"
408
+ }
409
+ },
410
+ {
411
+ "id": "t_total_val",
412
+ "type": "Text",
413
+ "x": 530,
414
+ "y": 76,
415
+ "width": 150,
416
+ "height": 28,
417
+ "content": "${[sum(subtotal) * 1.19]}",
418
+ "style": {
419
+ "fontSize": "18px",
420
+ "fontWeight": "bold",
421
+ "color": "#1e3a8a",
422
+ "textAlign": "right"
423
+ }
424
+ }
425
+ ]
426
+ },
427
+ {
428
+ "id": "pf_pagina",
429
+ "type": "PageFooter",
430
+ "height": 30,
431
+ "elements": [
432
+ {
433
+ "id": "t_pagina",
434
+ "type": "Text",
435
+ "x": 0,
436
+ "y": 8,
437
+ "width": 680,
438
+ "height": 16,
439
+ "content": "Página {{Page}} de {{TotalPages}} — Generado: {{Now}}",
440
+ "style": {
441
+ "fontSize": "9px",
442
+ "color": "#94a3b8",
443
+ "textAlign": "center"
444
+ }
445
+ }
446
+ ]
447
+ }
448
+ ],
449
+ "watermark": {
450
+ "text": "",
451
+ "opacity": 0
452
+ },
453
+ "generateTOC": false
454
+ },
455
+ "dataSources": [
456
+ {
457
+ "id": "ds_factura",
458
+ "collection": "",
459
+ "alias": "factura",
460
+ "enabled": true,
461
+ "isManual": true,
462
+ "manualData": [
463
+ {
464
+ "numeroFactura": "FV-2026-00456",
465
+ "fecha": "2026-05-09",
466
+ "nombreCliente": "CLIENTE EJEMPLO S.A.S.",
467
+ "nitCliente": "900.987.654-3",
468
+ "direccionCliente": "Carrera 15 # 88-40, Bogotá D.C.",
469
+ "formaPago": "Crédito 30 días",
470
+ "vendedor": "Carlos Mendoza"
471
+ }
472
+ ]
473
+ },
474
+ {
475
+ "id": "ds_items",
476
+ "collection": "",
477
+ "alias": "items",
478
+ "enabled": true,
479
+ "isManual": true,
480
+ "manualData": [
481
+ {
482
+ "codigo": "P-001",
483
+ "descripcion": "Portátil HP ProBook 450 G10",
484
+ "cantidad": 2,
485
+ "precioUnitario": 3250000,
486
+ "descuentoPorcentaje": 5,
487
+ "subtotal": 6175000
488
+ },
489
+ {
490
+ "codigo": "P-002",
491
+ "descripcion": "Monitor Dell 27'' UltraSharp",
492
+ "cantidad": 2,
493
+ "precioUnitario": 1450000,
494
+ "descuentoPorcentaje": 0,
495
+ "subtotal": 2900000
496
+ },
497
+ {
498
+ "codigo": "P-003",
499
+ "descripcion": "Teclado mecánico Logitech MX",
500
+ "cantidad": 5,
501
+ "precioUnitario": 285000,
502
+ "descuentoPorcentaje": 10,
503
+ "subtotal": 1282500
504
+ },
505
+ {
506
+ "codigo": "P-004",
507
+ "descripcion": "Mouse wireless Logitech MX Master 3",
508
+ "cantidad": 5,
509
+ "precioUnitario": 380000,
510
+ "descuentoPorcentaje": 10,
511
+ "subtotal": 1710000
512
+ },
513
+ {
514
+ "codigo": "P-005",
515
+ "descripcion": "Webcam Logitech Brio 4K",
516
+ "cantidad": 3,
517
+ "precioUnitario": 650000,
518
+ "descuentoPorcentaje": 0,
519
+ "subtotal": 1950000
520
+ },
521
+ {
522
+ "codigo": "P-006",
523
+ "descripcion": "Docking station Dell WD19TBS",
524
+ "cantidad": 2,
525
+ "precioUnitario": 890000,
526
+ "descuentoPorcentaje": 5,
527
+ "subtotal": 1691000
528
+ }
529
+ ]
530
+ }
531
+ ],
532
+ "dictionary": {
533
+ "dataSources": [],
534
+ "manualFields": []
535
+ },
536
+ "documentType": "Report"
537
+ }
@@ -0,0 +1,52 @@
1
+ @page "/reports/view/{id:int}"
2
+ @model MyApp.Pages.Reports.ViewModel
3
+ @inject IReportService ReportService
4
+
5
+ @{
6
+ var reportDef = await ReportService.GetDefinitionAsync(Model.Id);
7
+ var reportData = await ReportService.GetDataAsync(Model.Id);
8
+ }
9
+
10
+ <link rel="stylesheet" href="~/lib/nexabase-report/style.css" />
11
+
12
+ <div class="report-viewer" style="height: 800px;">
13
+ <nexa-viewer id="viewer" minimal></nexa-viewer>
14
+ </div>
15
+
16
+ <div class="actions mt-3">
17
+ <button onclick="exportPdf()" class="btn btn-primary">PDF</button>
18
+ <button onclick="exportExcel()" class="btn btn-success">Excel</button>
19
+ </div>
20
+
21
+ @section Scripts {
22
+ <script src="~/lib/nexabase-report/nexabase-report.umd.js"></script>
23
+ <script>
24
+ let initialized = false;
25
+
26
+ document.addEventListener('DOMContentLoaded', function() {
27
+ if (!initialized) {
28
+ NexaReport.registerNexaReport();
29
+ initialized = true;
30
+ }
31
+
32
+ const viewer = document.getElementById('viewer');
33
+ viewer.definition = @Html.Raw(reportDef);
34
+ viewer.data = @Html.Raw(reportData);
35
+ });
36
+
37
+ function exportPdf() {
38
+ document.getElementById('viewer').exportPdf();
39
+ }
40
+
41
+ function exportExcel() {
42
+ document.getElementById('viewer').exportExcel();
43
+ }
44
+ </script>
45
+ }
46
+
47
+ <style>
48
+ .report-viewer { border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden; background: white; }
49
+ .btn { padding: 8px 16px; border: none; border-radius: 6px; cursor: pointer; margin-right: 8px; }
50
+ .btn-primary { background: #1e40af; color: white; }
51
+ .btn-success { background: #16a34a; color: white; }
52
+ </style>
@@ -0,0 +1,84 @@
1
+ @page "/reports/{id:int}"
2
+ @using System.Text.Json
3
+ @inject HttpClient Http
4
+ @inject IJSRuntime JS
5
+
6
+ <div class="report-container" style="height: @Height">
7
+ <nexa-viewer id="@ViewerId" minimal></nexa-viewer>
8
+ </div>
9
+
10
+ @code {
11
+ [Parameter] public int Id { get; set; }
12
+ [Parameter] public string Height { get; set; } = "800px";
13
+
14
+ private const string ViewerId = "nexa-report-viewer";
15
+ private bool _initialized = false;
16
+
17
+ protected override async Task OnAfterRenderAsync(bool firstRender)
18
+ {
19
+ if (firstRender && !_initialized)
20
+ {
21
+ _initialized = true;
22
+ await InitializeReport();
23
+ }
24
+ }
25
+
26
+ private async Task InitializeReport()
27
+ {
28
+ try
29
+ {
30
+ // Cargar definición del reporte
31
+ var definition = await Http.GetFromJsonAsync<JsonElement>($"/api/reports/{Id}/definition");
32
+
33
+ // Cargar datos (puede venir de una API diferente)
34
+ var data = await Http.GetFromJsonAsync<List<Dictionary<string, object>>>($"/api/reports/{Id}/data");
35
+
36
+ await JS.InvokeVoidAsync("nexaReportRender", ViewerId, definition, data);
37
+ }
38
+ catch (Exception ex)
39
+ {
40
+ Console.Error.WriteLine($"Error cargando reporte: {ex.Message}");
41
+ }
42
+ }
43
+
44
+ public async Task ExportPdf()
45
+ {
46
+ await JS.InvokeVoidAsync("nexaReportExportPdf", ViewerId);
47
+ }
48
+
49
+ public async Task ExportExcel()
50
+ {
51
+ await JS.InvokeVoidAsync("nexaReportExportExcel", ViewerId);
52
+ }
53
+ }
54
+
55
+ @section Scripts {
56
+ <script src="_content/nexabase-report/nexabase-report.umd.js"></script>
57
+ <script>
58
+ let nexaRegistered = false;
59
+
60
+ function nexaReportRender(viewerId, definition, data) {
61
+ if (!nexaRegistered) {
62
+ NexaReport.registerNexaReport();
63
+ nexaRegistered = true;
64
+ }
65
+
66
+ // pequeña demora para asegurar que el custom element está listo
67
+ setTimeout(() => {
68
+ const viewer = document.getElementById(viewerId);
69
+ if (viewer) {
70
+ viewer.definition = definition;
71
+ viewer.data = data;
72
+ }
73
+ }, 50);
74
+ }
75
+
76
+ function nexaReportExportPdf(viewerId) {
77
+ document.getElementById(viewerId)?.exportPdf();
78
+ }
79
+
80
+ function nexaReportExportExcel(viewerId) {
81
+ document.getElementById(viewerId)?.exportExcel();
82
+ }
83
+ </script>
84
+ }