@acontplus/ng-common 1.0.1 → 1.0.3
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 +260 -141
- package/fesm2022/acontplus-ng-common.mjs +361 -57
- package/fesm2022/acontplus-ng-common.mjs.map +1 -1
- package/package.json +1 -1
- package/types/acontplus-ng-common.d.ts +180 -24
|
@@ -21,6 +21,152 @@ import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar';
|
|
|
21
21
|
import * as i8 from '@angular/material/select';
|
|
22
22
|
import { MatSelectModule } from '@angular/material/select';
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Códigos de reportes de ventas
|
|
26
|
+
*/
|
|
27
|
+
var SALE_CODE_REPORT;
|
|
28
|
+
(function (SALE_CODE_REPORT) {
|
|
29
|
+
/**
|
|
30
|
+
* SALE REPORT RENTABILIDAD
|
|
31
|
+
*/
|
|
32
|
+
SALE_CODE_REPORT["SRR"] = "SRR";
|
|
33
|
+
/**
|
|
34
|
+
* SALE REPORT RENTABILIDAD CUSTOM
|
|
35
|
+
*/
|
|
36
|
+
SALE_CODE_REPORT["SRRC"] = "SRRC";
|
|
37
|
+
/**
|
|
38
|
+
* SALE REPORT INVOICE GENERAL
|
|
39
|
+
*/
|
|
40
|
+
SALE_CODE_REPORT["FG"] = "FG";
|
|
41
|
+
})(SALE_CODE_REPORT || (SALE_CODE_REPORT = {}));
|
|
42
|
+
/**
|
|
43
|
+
* Códigos de reportes de compras
|
|
44
|
+
*/
|
|
45
|
+
var PURCHASE_CODE_REPORT;
|
|
46
|
+
(function (PURCHASE_CODE_REPORT) {
|
|
47
|
+
/**
|
|
48
|
+
* REPORTE COMPRAS NOTA HIDDEN
|
|
49
|
+
*/
|
|
50
|
+
PURCHASE_CODE_REPORT["RCNH"] = "RCNH";
|
|
51
|
+
/**
|
|
52
|
+
* REPORTE LIQUIDACION COMPRA
|
|
53
|
+
*/
|
|
54
|
+
PURCHASE_CODE_REPORT["RLC"] = "RLC";
|
|
55
|
+
})(PURCHASE_CODE_REPORT || (PURCHASE_CODE_REPORT = {}));
|
|
56
|
+
/**
|
|
57
|
+
* Códigos de reportes de contabilidad
|
|
58
|
+
*/
|
|
59
|
+
var ACCOUNTING_CODE_REPORT;
|
|
60
|
+
(function (ACCOUNTING_CODE_REPORT) {
|
|
61
|
+
/**
|
|
62
|
+
* REPORTE CONTABLE ESTADO GENERAL RESULTADO
|
|
63
|
+
*/
|
|
64
|
+
ACCOUNTING_CODE_REPORT["RCEGR"] = "RCEGR";
|
|
65
|
+
/**
|
|
66
|
+
* ASIENTO CONTABLE ESTADO DE FLUJO DE PAGO
|
|
67
|
+
*/
|
|
68
|
+
ACCOUNTING_CODE_REPORT["ACEDFP"] = "ACEDFP";
|
|
69
|
+
/**
|
|
70
|
+
* ASIENTO CONTABLE ESTADO LIBRO CAJA
|
|
71
|
+
*/
|
|
72
|
+
ACCOUNTING_CODE_REPORT["ACELC"] = "ACELC";
|
|
73
|
+
})(ACCOUNTING_CODE_REPORT || (ACCOUNTING_CODE_REPORT = {}));
|
|
74
|
+
/**
|
|
75
|
+
* Códigos de reportes de clientes
|
|
76
|
+
*/
|
|
77
|
+
var CUSTOMER_CODE_REPORT;
|
|
78
|
+
(function (CUSTOMER_CODE_REPORT) {
|
|
79
|
+
/**
|
|
80
|
+
* REPORTE CLIENTE LISTADO
|
|
81
|
+
*/
|
|
82
|
+
CUSTOMER_CODE_REPORT["RCL"] = "RCL";
|
|
83
|
+
})(CUSTOMER_CODE_REPORT || (CUSTOMER_CODE_REPORT = {}));
|
|
84
|
+
/**
|
|
85
|
+
* Códigos de reportes de inventario
|
|
86
|
+
*/
|
|
87
|
+
var INVENTORY_CODE_REPORT;
|
|
88
|
+
(function (INVENTORY_CODE_REPORT) {
|
|
89
|
+
/**
|
|
90
|
+
* REPORTE KARDEX
|
|
91
|
+
*/
|
|
92
|
+
INVENTORY_CODE_REPORT["RK"] = "RK";
|
|
93
|
+
/**
|
|
94
|
+
* CONSOLIDADO DE ARTICULOS AGRUPADO
|
|
95
|
+
*/
|
|
96
|
+
INVENTORY_CODE_REPORT["CDAA"] = "CDAA";
|
|
97
|
+
/**
|
|
98
|
+
* CONSOLIDADO DE ARTICULOS
|
|
99
|
+
*/
|
|
100
|
+
INVENTORY_CODE_REPORT["CDA"] = "CDA";
|
|
101
|
+
/**
|
|
102
|
+
* INVENTARIO REPORTE VALORACION
|
|
103
|
+
*/
|
|
104
|
+
INVENTORY_CODE_REPORT["STOCK_VALORACION"] = "INVRV";
|
|
105
|
+
/**
|
|
106
|
+
* INVENTARIO ARTICULO TABLA
|
|
107
|
+
*/
|
|
108
|
+
INVENTORY_CODE_REPORT["ARTICULO_PVP"] = "INVAT";
|
|
109
|
+
/**
|
|
110
|
+
* REPORTE DE ARTICULOS FRACCIONADOS
|
|
111
|
+
*/
|
|
112
|
+
INVENTORY_CODE_REPORT["RAF"] = "RAF";
|
|
113
|
+
/**
|
|
114
|
+
* REPORTE DE CADUCIDAD DE ARTICULOS
|
|
115
|
+
*/
|
|
116
|
+
INVENTORY_CODE_REPORT["RCAA"] = "RCAA";
|
|
117
|
+
/**
|
|
118
|
+
* REPORTE DE ARTICULO STOCK VALORACION
|
|
119
|
+
*/
|
|
120
|
+
INVENTORY_CODE_REPORT["RASR"] = "RASR";
|
|
121
|
+
/**
|
|
122
|
+
* REPORTE CONSOLIDACION DETALLE
|
|
123
|
+
*/
|
|
124
|
+
INVENTORY_CODE_REPORT["RCD"] = "RCD";
|
|
125
|
+
/**
|
|
126
|
+
* REPORTE TRANSFERENCIA BODEGA
|
|
127
|
+
*/
|
|
128
|
+
INVENTORY_CODE_REPORT["RTB"] = "RTB";
|
|
129
|
+
})(INVENTORY_CODE_REPORT || (INVENTORY_CODE_REPORT = {}));
|
|
130
|
+
/**
|
|
131
|
+
* Códigos de documentos electrónicos
|
|
132
|
+
*/
|
|
133
|
+
var ELECTRONIC_DOCUMENT_CODE;
|
|
134
|
+
(function (ELECTRONIC_DOCUMENT_CODE) {
|
|
135
|
+
/**
|
|
136
|
+
* FACTURA
|
|
137
|
+
*/
|
|
138
|
+
ELECTRONIC_DOCUMENT_CODE["FV"] = "FV";
|
|
139
|
+
/**
|
|
140
|
+
* NOTA DE ENTREGA
|
|
141
|
+
*/
|
|
142
|
+
ELECTRONIC_DOCUMENT_CODE["NE"] = "NE";
|
|
143
|
+
/**
|
|
144
|
+
* NOTA DE CREDITO
|
|
145
|
+
*/
|
|
146
|
+
ELECTRONIC_DOCUMENT_CODE["NC"] = "NC";
|
|
147
|
+
/**
|
|
148
|
+
* NOTA DE DEBITO
|
|
149
|
+
*/
|
|
150
|
+
ELECTRONIC_DOCUMENT_CODE["ND"] = "ND";
|
|
151
|
+
/**
|
|
152
|
+
* GUIA DE REMISION
|
|
153
|
+
*/
|
|
154
|
+
ELECTRONIC_DOCUMENT_CODE["GR"] = "GR";
|
|
155
|
+
/**
|
|
156
|
+
* ORDEN DE PEDIDO
|
|
157
|
+
*/
|
|
158
|
+
ELECTRONIC_DOCUMENT_CODE["NORMAL"] = "NORMAL";
|
|
159
|
+
})(ELECTRONIC_DOCUMENT_CODE || (ELECTRONIC_DOCUMENT_CODE = {}));
|
|
160
|
+
/**
|
|
161
|
+
* Formatos de reporte disponibles
|
|
162
|
+
*/
|
|
163
|
+
var REPORT_FORMAT;
|
|
164
|
+
(function (REPORT_FORMAT) {
|
|
165
|
+
REPORT_FORMAT["PDF"] = "pdf";
|
|
166
|
+
REPORT_FORMAT["EXCEL"] = "excel";
|
|
167
|
+
REPORT_FORMAT["WORD"] = "word";
|
|
168
|
+
})(REPORT_FORMAT || (REPORT_FORMAT = {}));
|
|
169
|
+
|
|
24
170
|
const API_PATHS = {
|
|
25
171
|
WHATSAPP: '/api/common/whatsapp-cloud',
|
|
26
172
|
REPORTS: '/api/reports',
|
|
@@ -82,22 +228,26 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
82
228
|
args: [{ providedIn: 'root' }]
|
|
83
229
|
}] });
|
|
84
230
|
|
|
231
|
+
/**
|
|
232
|
+
* Builder para construir mensajes de WhatsApp
|
|
233
|
+
* Clase utilitaria con métodos estáticos
|
|
234
|
+
*/
|
|
85
235
|
class WhatsAppMessageBuilder {
|
|
86
|
-
buildDocumentDeliveryMessages(data) {
|
|
236
|
+
static buildDocumentDeliveryMessages(data) {
|
|
87
237
|
const main = this.buildMainMessage(data);
|
|
88
238
|
const promo = this.buildPromoMessage(data.establecimiento);
|
|
89
239
|
return { main, promo };
|
|
90
240
|
}
|
|
91
|
-
buildWelcomeMessage(customerName, establishmentName) {
|
|
241
|
+
static buildWelcomeMessage(customerName, establishmentName) {
|
|
92
242
|
return `¡Hola *${customerName}*! 👋\n\nBienvenido a *${establishmentName}*. Estamos aquí para ayudarte.`;
|
|
93
243
|
}
|
|
94
|
-
buildOrderConfirmationMessage(orderNumber, customerName) {
|
|
244
|
+
static buildOrderConfirmationMessage(orderNumber, customerName) {
|
|
95
245
|
return `Estimado(a) *${customerName}*,\n\n✅ Tu pedido #${orderNumber} ha sido confirmado.\n\nTe notificaremos cuando esté listo.`;
|
|
96
246
|
}
|
|
97
|
-
buildPaymentReminderMessage(customerName, amount, dueDate) {
|
|
98
|
-
return `Estimado(a) *${customerName}*,\n\n💰 Recordatorio de pago:\nMonto:
|
|
247
|
+
static buildPaymentReminderMessage(customerName, amount, dueDate) {
|
|
248
|
+
return `Estimado(a) *${customerName}*,\n\n💰 Recordatorio de pago:\nMonto: ${amount}\nVencimiento: ${dueDate}\n\nGracias por tu preferencia.`;
|
|
99
249
|
}
|
|
100
|
-
buildMainMessage(data) {
|
|
250
|
+
static buildMainMessage(data) {
|
|
101
251
|
const documentTypeDisplay = this.getDocumentTypeDisplay(data.tipo);
|
|
102
252
|
return (`Estimado(a) *${data.comprador}*,\n\n` +
|
|
103
253
|
`📄 Su ${documentTypeDisplay} ha sido generado exitosamente.\n\n` +
|
|
@@ -105,12 +255,12 @@ class WhatsAppMessageBuilder {
|
|
|
105
255
|
`📋 Serie: ${data.serie}\n\n` +
|
|
106
256
|
`Adjunto encontrará el documento solicitado.`);
|
|
107
257
|
}
|
|
108
|
-
buildPromoMessage(establishmentName) {
|
|
258
|
+
static buildPromoMessage(establishmentName) {
|
|
109
259
|
return (`📱 Documento enviado por *${establishmentName}*\n` +
|
|
110
260
|
`Powered by *Acontplus* 🚀\n\n` +
|
|
111
261
|
`¿Necesita ayuda? Contáctenos.`);
|
|
112
262
|
}
|
|
113
|
-
getDocumentTypeDisplay(tipo) {
|
|
263
|
+
static getDocumentTypeDisplay(tipo) {
|
|
114
264
|
const types = {
|
|
115
265
|
FACTURA: 'factura electrónica',
|
|
116
266
|
NOTA_ENTREGA: 'nota de entrega',
|
|
@@ -120,13 +270,7 @@ class WhatsAppMessageBuilder {
|
|
|
120
270
|
};
|
|
121
271
|
return types[tipo] || 'documento';
|
|
122
272
|
}
|
|
123
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: WhatsAppMessageBuilder, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
124
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: WhatsAppMessageBuilder, providedIn: 'root' });
|
|
125
273
|
}
|
|
126
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: WhatsAppMessageBuilder, decorators: [{
|
|
127
|
-
type: Injectable,
|
|
128
|
-
args: [{ providedIn: 'root' }]
|
|
129
|
-
}] });
|
|
130
274
|
|
|
131
275
|
/**
|
|
132
276
|
* Utilidades para formateo y validación de números telefónicos
|
|
@@ -257,7 +401,6 @@ class PhoneFormatterUtil {
|
|
|
257
401
|
|
|
258
402
|
class WhatsAppMessagingFacade {
|
|
259
403
|
messagingPort = inject(WHATSAPP_MESSAGING_PORT);
|
|
260
|
-
messageBuilder = inject(WhatsAppMessageBuilder);
|
|
261
404
|
// Métodos de alto nivel con lógica de negocio
|
|
262
405
|
sendSimpleText(to, message, previewUrl = true) {
|
|
263
406
|
const formattedPhone = PhoneFormatterUtil.formatForWhatsAppApi(to);
|
|
@@ -288,7 +431,7 @@ class WhatsAppMessagingFacade {
|
|
|
288
431
|
// Caso de uso específico: Entrega de documentos
|
|
289
432
|
deliverDocument(params) {
|
|
290
433
|
const formattedPhone = PhoneFormatterUtil.formatForWhatsAppApi(params.phone);
|
|
291
|
-
const messages =
|
|
434
|
+
const messages = WhatsAppMessageBuilder.buildDocumentDeliveryMessages({
|
|
292
435
|
comprador: params.customerName,
|
|
293
436
|
establecimiento: params.establishmentName,
|
|
294
437
|
serie: params.documentSeries,
|
|
@@ -689,55 +832,203 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
689
832
|
type: Injectable
|
|
690
833
|
}] });
|
|
691
834
|
|
|
835
|
+
/**
|
|
836
|
+
* Builder para construir parámetros de reportes
|
|
837
|
+
* Clase utilitaria con métodos estáticos
|
|
838
|
+
*/
|
|
692
839
|
class ReportParamsBuilder {
|
|
693
|
-
reportConfigs = {
|
|
694
|
-
|
|
695
|
-
|
|
840
|
+
static reportConfigs = {
|
|
841
|
+
// Documentos electrónicos
|
|
842
|
+
[ELECTRONIC_DOCUMENT_CODE.FV]: {
|
|
843
|
+
codigo: ELECTRONIC_DOCUMENT_CODE.FV,
|
|
696
844
|
hasService: true,
|
|
697
845
|
useV1Api: true,
|
|
698
846
|
idField: 'id',
|
|
699
847
|
includeEstabInData: true,
|
|
700
848
|
includeCodigoInData: true,
|
|
849
|
+
hasParams: true,
|
|
701
850
|
},
|
|
702
|
-
NE: {
|
|
703
|
-
codigo:
|
|
851
|
+
[ELECTRONIC_DOCUMENT_CODE.NE]: {
|
|
852
|
+
codigo: ELECTRONIC_DOCUMENT_CODE.NE,
|
|
704
853
|
hasService: true,
|
|
705
854
|
useV1Api: true,
|
|
706
855
|
idField: 'id',
|
|
707
856
|
extraDataParams: { tipo: 1 },
|
|
857
|
+
hasParams: true,
|
|
708
858
|
},
|
|
709
|
-
NORMAL: {
|
|
859
|
+
[ELECTRONIC_DOCUMENT_CODE.NORMAL]: {
|
|
710
860
|
codigo: 'OR',
|
|
711
861
|
hasService: false,
|
|
712
862
|
useV1Api: false,
|
|
713
863
|
idField: 'id',
|
|
864
|
+
hasParams: false,
|
|
714
865
|
},
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
codigo: 'NC',
|
|
866
|
+
[ELECTRONIC_DOCUMENT_CODE.NC]: {
|
|
867
|
+
codigo: ELECTRONIC_DOCUMENT_CODE.NC,
|
|
718
868
|
hasService: true,
|
|
719
869
|
useV1Api: true,
|
|
720
870
|
idField: 'id',
|
|
721
871
|
includeEstabInData: true,
|
|
872
|
+
hasParams: true,
|
|
722
873
|
},
|
|
723
|
-
ND: {
|
|
724
|
-
codigo:
|
|
874
|
+
[ELECTRONIC_DOCUMENT_CODE.ND]: {
|
|
875
|
+
codigo: ELECTRONIC_DOCUMENT_CODE.ND,
|
|
725
876
|
hasService: true,
|
|
726
877
|
useV1Api: true,
|
|
727
878
|
idField: 'id',
|
|
728
879
|
includeEstabInData: true,
|
|
880
|
+
hasParams: true,
|
|
729
881
|
},
|
|
730
|
-
GR: {
|
|
731
|
-
codigo:
|
|
882
|
+
[ELECTRONIC_DOCUMENT_CODE.GR]: {
|
|
883
|
+
codigo: ELECTRONIC_DOCUMENT_CODE.GR,
|
|
732
884
|
hasService: true,
|
|
733
885
|
useV1Api: false,
|
|
734
886
|
idField: 'id',
|
|
887
|
+
hasParams: true,
|
|
888
|
+
},
|
|
889
|
+
// Reportes de ventas
|
|
890
|
+
[SALE_CODE_REPORT.SRR]: {
|
|
891
|
+
codigo: SALE_CODE_REPORT.SRR,
|
|
892
|
+
hasService: true,
|
|
893
|
+
useV1Api: false,
|
|
894
|
+
idField: 'id',
|
|
895
|
+
hasParams: false,
|
|
896
|
+
},
|
|
897
|
+
[SALE_CODE_REPORT.SRRC]: {
|
|
898
|
+
codigo: SALE_CODE_REPORT.SRRC,
|
|
899
|
+
hasService: true,
|
|
900
|
+
useV1Api: false,
|
|
901
|
+
idField: 'id',
|
|
902
|
+
hasParams: false,
|
|
903
|
+
},
|
|
904
|
+
[SALE_CODE_REPORT.FG]: {
|
|
905
|
+
codigo: SALE_CODE_REPORT.FG,
|
|
906
|
+
hasService: true,
|
|
907
|
+
useV1Api: false,
|
|
908
|
+
idField: 'id',
|
|
909
|
+
hasParams: false,
|
|
910
|
+
},
|
|
911
|
+
// Reportes de compras
|
|
912
|
+
[PURCHASE_CODE_REPORT.RCNH]: {
|
|
913
|
+
codigo: PURCHASE_CODE_REPORT.RCNH,
|
|
914
|
+
hasService: true,
|
|
915
|
+
useV1Api: false,
|
|
916
|
+
idField: 'id',
|
|
917
|
+
hasParams: true,
|
|
918
|
+
},
|
|
919
|
+
[PURCHASE_CODE_REPORT.RLC]: {
|
|
920
|
+
codigo: PURCHASE_CODE_REPORT.RLC,
|
|
921
|
+
hasService: true,
|
|
922
|
+
useV1Api: false,
|
|
923
|
+
idField: 'id',
|
|
924
|
+
hasParams: false,
|
|
925
|
+
},
|
|
926
|
+
// Reportes de contabilidad
|
|
927
|
+
[ACCOUNTING_CODE_REPORT.RCEGR]: {
|
|
928
|
+
codigo: ACCOUNTING_CODE_REPORT.RCEGR,
|
|
929
|
+
hasService: true,
|
|
930
|
+
useV1Api: false,
|
|
931
|
+
idField: 'id',
|
|
932
|
+
hasParams: false,
|
|
933
|
+
},
|
|
934
|
+
[ACCOUNTING_CODE_REPORT.ACEDFP]: {
|
|
935
|
+
codigo: ACCOUNTING_CODE_REPORT.ACEDFP,
|
|
936
|
+
hasService: true,
|
|
937
|
+
useV1Api: false,
|
|
938
|
+
idField: 'id',
|
|
939
|
+
hasParams: false,
|
|
940
|
+
},
|
|
941
|
+
[ACCOUNTING_CODE_REPORT.ACELC]: {
|
|
942
|
+
codigo: ACCOUNTING_CODE_REPORT.ACELC,
|
|
943
|
+
hasService: true,
|
|
944
|
+
useV1Api: false,
|
|
945
|
+
idField: 'id',
|
|
946
|
+
hasParams: false,
|
|
947
|
+
},
|
|
948
|
+
// Reportes de clientes
|
|
949
|
+
[CUSTOMER_CODE_REPORT.RCL]: {
|
|
950
|
+
codigo: CUSTOMER_CODE_REPORT.RCL,
|
|
951
|
+
hasService: false,
|
|
952
|
+
useV1Api: false,
|
|
953
|
+
idField: 'id',
|
|
954
|
+
hasParams: false,
|
|
955
|
+
},
|
|
956
|
+
// Reportes de inventario
|
|
957
|
+
[INVENTORY_CODE_REPORT.RK]: {
|
|
958
|
+
codigo: INVENTORY_CODE_REPORT.RK,
|
|
959
|
+
hasService: true,
|
|
960
|
+
useV1Api: false,
|
|
961
|
+
idField: 'id',
|
|
962
|
+
hasParams: true,
|
|
963
|
+
},
|
|
964
|
+
[INVENTORY_CODE_REPORT.CDAA]: {
|
|
965
|
+
codigo: INVENTORY_CODE_REPORT.CDAA,
|
|
966
|
+
hasService: true,
|
|
967
|
+
useV1Api: false,
|
|
968
|
+
idField: 'id',
|
|
969
|
+
hasParams: false,
|
|
970
|
+
},
|
|
971
|
+
[INVENTORY_CODE_REPORT.CDA]: {
|
|
972
|
+
codigo: INVENTORY_CODE_REPORT.CDA,
|
|
973
|
+
hasService: true,
|
|
974
|
+
useV1Api: false,
|
|
975
|
+
idField: 'id',
|
|
976
|
+
hasParams: false,
|
|
977
|
+
},
|
|
978
|
+
[INVENTORY_CODE_REPORT.STOCK_VALORACION]: {
|
|
979
|
+
codigo: INVENTORY_CODE_REPORT.STOCK_VALORACION,
|
|
980
|
+
hasService: true,
|
|
981
|
+
useV1Api: false,
|
|
982
|
+
idField: 'id',
|
|
983
|
+
hasParams: false,
|
|
984
|
+
},
|
|
985
|
+
[INVENTORY_CODE_REPORT.ARTICULO_PVP]: {
|
|
986
|
+
codigo: INVENTORY_CODE_REPORT.ARTICULO_PVP,
|
|
987
|
+
hasService: true,
|
|
988
|
+
useV1Api: false,
|
|
989
|
+
idField: 'id',
|
|
990
|
+
hasParams: false,
|
|
991
|
+
},
|
|
992
|
+
[INVENTORY_CODE_REPORT.RAF]: {
|
|
993
|
+
codigo: INVENTORY_CODE_REPORT.RAF,
|
|
994
|
+
hasService: true,
|
|
995
|
+
useV1Api: false,
|
|
996
|
+
idField: 'id',
|
|
997
|
+
hasParams: false,
|
|
998
|
+
},
|
|
999
|
+
[INVENTORY_CODE_REPORT.RCAA]: {
|
|
1000
|
+
codigo: INVENTORY_CODE_REPORT.RCAA,
|
|
1001
|
+
hasService: true,
|
|
1002
|
+
useV1Api: false,
|
|
1003
|
+
idField: 'id',
|
|
1004
|
+
hasParams: false,
|
|
1005
|
+
},
|
|
1006
|
+
[INVENTORY_CODE_REPORT.RASR]: {
|
|
1007
|
+
codigo: INVENTORY_CODE_REPORT.RASR,
|
|
1008
|
+
hasService: true,
|
|
1009
|
+
useV1Api: false,
|
|
1010
|
+
idField: 'id',
|
|
1011
|
+
hasParams: false,
|
|
1012
|
+
},
|
|
1013
|
+
[INVENTORY_CODE_REPORT.RCD]: {
|
|
1014
|
+
codigo: INVENTORY_CODE_REPORT.RCD,
|
|
1015
|
+
hasService: false,
|
|
1016
|
+
useV1Api: false,
|
|
1017
|
+
idField: 'id',
|
|
1018
|
+
hasParams: true,
|
|
1019
|
+
},
|
|
1020
|
+
[INVENTORY_CODE_REPORT.RTB]: {
|
|
1021
|
+
codigo: INVENTORY_CODE_REPORT.RTB,
|
|
1022
|
+
hasService: true,
|
|
1023
|
+
useV1Api: false,
|
|
1024
|
+
idField: 'id',
|
|
1025
|
+
hasParams: true,
|
|
735
1026
|
},
|
|
736
1027
|
};
|
|
737
1028
|
/**
|
|
738
1029
|
* Construye los parámetros de reporte según el tipo de documento
|
|
739
1030
|
*/
|
|
740
|
-
buildParams(docData, format = 'pdf') {
|
|
1031
|
+
static buildParams(docData, format = 'pdf') {
|
|
741
1032
|
const config = this.getReportConfig(docData.codDoc);
|
|
742
1033
|
return {
|
|
743
1034
|
hasService: config.hasService,
|
|
@@ -748,14 +1039,14 @@ class ReportParamsBuilder {
|
|
|
748
1039
|
/**
|
|
749
1040
|
* Determina si debe usar la API v1 según el tipo de documento
|
|
750
1041
|
*/
|
|
751
|
-
shouldUseV1Api(codDoc) {
|
|
1042
|
+
static shouldUseV1Api(codDoc) {
|
|
752
1043
|
const config = this.getReportConfig(codDoc);
|
|
753
1044
|
return config.useV1Api;
|
|
754
1045
|
}
|
|
755
1046
|
/**
|
|
756
1047
|
* Obtiene la configuración para un tipo de documento
|
|
757
1048
|
*/
|
|
758
|
-
getReportConfig(codDoc) {
|
|
1049
|
+
static getReportConfig(codDoc) {
|
|
759
1050
|
const config = this.reportConfigs[codDoc];
|
|
760
1051
|
if (!config) {
|
|
761
1052
|
throw new Error(`Tipo de documento no soportado: ${codDoc}. Tipos disponibles: ${Object.keys(this.reportConfigs).join(', ')}`);
|
|
@@ -765,15 +1056,21 @@ class ReportParamsBuilder {
|
|
|
765
1056
|
/**
|
|
766
1057
|
* Construye los parámetros del reporte
|
|
767
1058
|
*/
|
|
768
|
-
buildReportParams(docData, config, format) {
|
|
1059
|
+
static buildReportParams(docData, config, format) {
|
|
769
1060
|
const params = {
|
|
770
1061
|
codigo: config.codigo,
|
|
771
|
-
codEstab: docData.codEstab,
|
|
772
1062
|
format,
|
|
773
1063
|
};
|
|
774
|
-
//
|
|
775
|
-
if (config.
|
|
776
|
-
params.hasParams =
|
|
1064
|
+
// Agregar hasParams según configuración
|
|
1065
|
+
if (config.hasParams !== undefined) {
|
|
1066
|
+
params.hasParams = config.hasParams;
|
|
1067
|
+
}
|
|
1068
|
+
// Agregar codEstab si existe
|
|
1069
|
+
if (docData.codEstab) {
|
|
1070
|
+
params.codEstab = docData.codEstab;
|
|
1071
|
+
}
|
|
1072
|
+
// Solo agregar aditionalParams si hasService es true y hasParams es true
|
|
1073
|
+
if (config.hasService && config.hasParams) {
|
|
777
1074
|
params.aditionalParams = [];
|
|
778
1075
|
}
|
|
779
1076
|
return JSON.stringify(params);
|
|
@@ -781,18 +1078,20 @@ class ReportParamsBuilder {
|
|
|
781
1078
|
/**
|
|
782
1079
|
* Construye los parámetros de datos
|
|
783
1080
|
*/
|
|
784
|
-
buildDataParams(docData, config, format) {
|
|
785
|
-
const params = {
|
|
786
|
-
|
|
787
|
-
|
|
1081
|
+
static buildDataParams(docData, config, format) {
|
|
1082
|
+
const params = {};
|
|
1083
|
+
// Agregar ID si existe el campo configurado
|
|
1084
|
+
if (config.idField && docData[config.idField]) {
|
|
1085
|
+
params.id = docData[config.idField];
|
|
1086
|
+
}
|
|
788
1087
|
// Agregar parámetros adicionales según configuración
|
|
789
|
-
if (config.includeEstabInData) {
|
|
1088
|
+
if (config.includeEstabInData && docData.codEstab) {
|
|
790
1089
|
params.codEstab = docData.codEstab;
|
|
791
1090
|
}
|
|
792
1091
|
if (config.includeCodigoInData) {
|
|
793
1092
|
params.codigo = config.codigo;
|
|
794
1093
|
}
|
|
795
|
-
if (config.hasService) {
|
|
1094
|
+
if (config.hasService && config.hasParams) {
|
|
796
1095
|
params.hasParams = true;
|
|
797
1096
|
if (config.includeCodigoInData) {
|
|
798
1097
|
params.format = format;
|
|
@@ -802,12 +1101,18 @@ class ReportParamsBuilder {
|
|
|
802
1101
|
if (config.extraDataParams) {
|
|
803
1102
|
Object.assign(params, config.extraDataParams);
|
|
804
1103
|
}
|
|
1104
|
+
// Agregar cualquier parámetro adicional del docData
|
|
1105
|
+
Object.keys(docData).forEach((key) => {
|
|
1106
|
+
if (!['codDoc', 'codEstab', 'id', 'serie'].includes(key) && docData[key] !== undefined) {
|
|
1107
|
+
params[key] = docData[key];
|
|
1108
|
+
}
|
|
1109
|
+
});
|
|
805
1110
|
return JSON.stringify(params);
|
|
806
1111
|
}
|
|
807
1112
|
/**
|
|
808
|
-
*
|
|
1113
|
+
* Construye las opciones completas para generar un reporte
|
|
809
1114
|
*/
|
|
810
|
-
|
|
1115
|
+
static build(docData, format = 'pdf', returnBlob = false) {
|
|
811
1116
|
return {
|
|
812
1117
|
data: this.buildParams(docData, format),
|
|
813
1118
|
format,
|
|
@@ -818,22 +1123,22 @@ class ReportParamsBuilder {
|
|
|
818
1123
|
/**
|
|
819
1124
|
* Obtiene la lista de tipos de documento soportados
|
|
820
1125
|
*/
|
|
821
|
-
getSupportedDocumentTypes() {
|
|
1126
|
+
static getSupportedDocumentTypes() {
|
|
822
1127
|
return Object.keys(this.reportConfigs);
|
|
823
1128
|
}
|
|
824
1129
|
/**
|
|
825
1130
|
* Verifica si un tipo de documento está soportado
|
|
826
1131
|
*/
|
|
827
|
-
isDocumentTypeSupported(codDoc) {
|
|
1132
|
+
static isDocumentTypeSupported(codDoc) {
|
|
828
1133
|
return codDoc in this.reportConfigs;
|
|
829
1134
|
}
|
|
830
|
-
|
|
831
|
-
|
|
1135
|
+
/**
|
|
1136
|
+
* Registra un nuevo tipo de reporte dinámicamente
|
|
1137
|
+
*/
|
|
1138
|
+
static registerReportType(codDoc, config) {
|
|
1139
|
+
this.reportConfigs[codDoc] = config;
|
|
1140
|
+
}
|
|
832
1141
|
}
|
|
833
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: ReportParamsBuilder, decorators: [{
|
|
834
|
-
type: Injectable,
|
|
835
|
-
args: [{ providedIn: 'root' }]
|
|
836
|
-
}] });
|
|
837
1142
|
|
|
838
1143
|
class WhatsAppSender {
|
|
839
1144
|
config;
|
|
@@ -841,7 +1146,6 @@ class WhatsAppSender {
|
|
|
841
1146
|
whatsappFacade = inject(WhatsAppMessagingFacade);
|
|
842
1147
|
reportFacade = inject(ReportFacade);
|
|
843
1148
|
snackBar = inject(MatSnackBar);
|
|
844
|
-
reportBuilder = inject(ReportParamsBuilder);
|
|
845
1149
|
whatsappForm;
|
|
846
1150
|
isLoading = signal(false, ...(ngDevMode ? [{ debugName: "isLoading" }] : []));
|
|
847
1151
|
messageLength = 0;
|
|
@@ -957,8 +1261,8 @@ class WhatsAppSender {
|
|
|
957
1261
|
}
|
|
958
1262
|
generateReport() {
|
|
959
1263
|
const docData = this.config.documentData;
|
|
960
|
-
//
|
|
961
|
-
const reportOptions =
|
|
1264
|
+
// Construir opciones de reporte
|
|
1265
|
+
const reportOptions = ReportParamsBuilder.build(docData, 'pdf', true);
|
|
962
1266
|
const reportResult = this.reportFacade.generate(reportOptions);
|
|
963
1267
|
// Manejar el caso donde generate puede retornar void
|
|
964
1268
|
return reportResult || throwError(() => new Error('No se pudo generar el reporte'));
|
|
@@ -1068,5 +1372,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
1068
1372
|
* Generated bundle index. Do not edit.
|
|
1069
1373
|
*/
|
|
1070
1374
|
|
|
1071
|
-
export { API_PATHS, DOCUMENT_TYPES, FileMapperUtil, GreenWhatsAppAdapter, MetaWhatsAppAdapter, PRINTER_PORT, PhoneFormatterUtil, PrinterAdapter, PrinterFacade, REPORT_PORT, ReportAdapter, ReportFacade, ReportParamsBuilder, WHATSAPP_MESSAGING_PORT, WhatsAppMessageBuilder, WhatsAppMessagingFacade, WhatsAppSender };
|
|
1375
|
+
export { ACCOUNTING_CODE_REPORT, API_PATHS, CUSTOMER_CODE_REPORT, DOCUMENT_TYPES, ELECTRONIC_DOCUMENT_CODE, FileMapperUtil, GreenWhatsAppAdapter, INVENTORY_CODE_REPORT, MetaWhatsAppAdapter, PRINTER_PORT, PURCHASE_CODE_REPORT, PhoneFormatterUtil, PrinterAdapter, PrinterFacade, REPORT_FORMAT, REPORT_PORT, ReportAdapter, ReportFacade, ReportParamsBuilder, SALE_CODE_REPORT, WHATSAPP_MESSAGING_PORT, WhatsAppMessageBuilder, WhatsAppMessagingFacade, WhatsAppSender };
|
|
1072
1376
|
//# sourceMappingURL=acontplus-ng-common.mjs.map
|